@qijenchen/design-system 0.1.0-beta.36 → 0.1.0-beta.37

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.
Files changed (56) hide show
  1. package/CLAUDE.md +3 -3
  2. package/ds-canonical/hooks/check_dim_count_drift.sh +3 -3
  3. package/ds-canonical/hooks/check_pattern_invariants.sh +3 -1
  4. package/ds-canonical/hooks/check_post_main_ssot_propagate.sh +1 -1
  5. package/ds-canonical/hooks/check_storybook_addon_preset_cjs.sh +7 -2
  6. package/ds-canonical/hooks/lib/_token_hygiene.sh +3 -2
  7. package/ds-canonical/hooks/session_start_governance_check.sh +32 -3
  8. package/ds-canonical/hooks/tests/test_check_token_hygiene.sh +1 -1
  9. package/ds-canonical/references/build-ui-canonicals.md +2 -2
  10. package/ds-canonical/references/item-anatomy-recipe.md +1 -1
  11. package/ds-canonical/references/ssot-consultation.md +1 -1
  12. package/ds-canonical/references/tailwind-gotchas.md +1 -1
  13. package/ds-canonical/rules/meta-patterns.md +2 -2
  14. package/ds-canonical/rules/story-rules.md +4 -4
  15. package/ds-canonical/skills/README.md +2 -2
  16. package/ds-canonical/skills/bug-fix-rhythm/SKILL.md +1 -1
  17. package/ds-canonical/skills/code-quality-audit/SKILL.md +2 -2
  18. package/ds-canonical/skills/codex-collab/SKILL.md +4 -4
  19. package/ds-canonical/skills/codify-corrections/SKILL.md +5 -5
  20. package/ds-canonical/skills/codify-principle/SKILL.md +2 -2
  21. package/ds-canonical/skills/component-quality-gate/SKILL.md +6 -6
  22. package/ds-canonical/skills/deep-audit-cross-codex/SKILL.md +5 -58
  23. package/ds-canonical/skills/deep-audit-cross-codex/references/phase-a-workflow.md +2 -2
  24. package/ds-canonical/skills/deep-audit-cross-codex/references/phase-b-codex-brief.md +23 -2
  25. package/ds-canonical/skills/deep-audit-cross-codex/references/skill-relationships-antipatterns-benchmarks.md +30 -0
  26. package/ds-canonical/skills/deep-audit-cross-codex/references/upstream-directives-r-mapping.md +33 -0
  27. package/ds-canonical/skills/design-system-audit/SKILL.md +24 -10
  28. package/ds-canonical/skills/design-system-audit/references/audit-prompts.md +16 -16
  29. package/ds-canonical/skills/design-system-audit/references/principle-audit-protocol.md +1 -1
  30. package/ds-canonical/skills/design-system-audit/references/rule-placement.md +10 -10
  31. package/ds-canonical/skills/ensure-canonical/SKILL.md +2 -2
  32. package/ds-canonical/skills/governance-health/SKILL.md +3 -2
  33. package/ds-canonical/skills/knowledge-prune/SKILL.md +10 -77
  34. package/ds-canonical/skills/knowledge-prune/references/phase-z-cross-repo-ssot-propagation.md +11 -0
  35. package/ds-canonical/skills/knowledge-prune/references/prune-dimensions-d5-d10.md +55 -0
  36. package/ds-canonical/skills/knowledge-prune/references/world-class-prune-alignment.md +7 -0
  37. package/ds-canonical/skills/new-component/SKILL.md +1 -1
  38. package/ds-canonical/skills/new-component/references/new-component-checklist.md +1 -1
  39. package/ds-canonical/skills/product-ui-audit/SKILL.md +9 -9
  40. package/ds-canonical/skills/product-ui-audit/references/audit-checks.md +3 -3
  41. package/ds-canonical/skills/product-ui-audit/references/report-template.md +1 -1
  42. package/ds-canonical/skills/propose-options/SKILL.md +18 -18
  43. package/ds-canonical/skills/prototype/SKILL.md +2 -2
  44. package/ds-canonical/skills/prototype/references/audit-checks.md +1 -1
  45. package/ds-canonical/skills/prototype/references/evaluation-matrix.md +1 -1
  46. package/ds-canonical/skills/prototype/references/proposal-template.md +1 -1
  47. package/ds-canonical/skills/scan-similar-bugs/SKILL.md +5 -5
  48. package/ds-canonical/skills/story-auto-compile-migrate/SKILL.md +2 -2
  49. package/ds-canonical/skills/story-writing/SKILL.md +3 -3
  50. package/ds-canonical/skills/story-writing/references/anatomy-standard.md +2 -2
  51. package/ds-canonical/skills/story-writing/references/category-templates.md +2 -2
  52. package/ds-canonical/skills/visual-audit/SKILL.md +3 -3
  53. package/ds-canonical/skills/visual-audit/references/visual-checklist.md +3 -3
  54. package/ds-canonical/skills/visual-audit/references/world-class-benchmarks.md +2 -2
  55. package/ds-story-manifest.json +1 -1
  56. package/package.json +1 -1
package/CLAUDE.md CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  ## 行數預算(Anthropic 對齊)
34
34
 
35
- CLAUDE.md target ≤ 200(Anthropic best-practice)/ transition ≤ 400 / hard cap 800。SKILL ≤ 250 / spec ≤ 300(foundational SSOT 例外 ≤ 800-1200)/ memory **per-file ≤ 100 lines** + **MEMORY.md index ≤ 20 entries**(soft 18 / hard 20,session-start hook 攔)。Hooks **26 soft / 60 hard**(SSOT = `session_start_governance_check.sh:186`,2026-05-27 升 50→55→60 per codex M31 P0 hooks + baseline + primitive-misuse 3 new hooks)。動態值見 `scripts/sync-governance-counters.mjs` 跑出為準(snapshot 2026-05-28:**31 M-rules / 82 audit dims / 59 hooks** — 數字僅供 sanity check,真值以 script 輸出為準避 drift)。
35
+ CLAUDE.md target ≤ 200(Anthropic best-practice)/ transition ≤ 400 / hard cap 800。SKILL ≤ 250 / spec ≤ 300(foundational SSOT 例外 ≤ 800-1200)/ memory **per-file ≤ 100 lines** + **MEMORY.md index ≤ 20 entries**(soft 18 / hard 20,session-start hook 攔)。Hooks **26 soft / 60 hard**(SSOT = `session_start_governance_check.sh` Check 7 threshold logic,2026-05-27 升 50→55→60 per codex M31 P0 hooks + baseline + primitive-misuse 3 new hooks)。動態值見 `scripts/sync-governance-counters.mjs` 跑出為準(snapshot 2026-05-30:**31 M-rules / 88 audit dims / 59 hooks** — 數字僅供 sanity check,真值以 script 輸出為準避 drift)。
36
36
 
37
37
  ## Anti-bloat L1-L3
38
38
 
@@ -107,7 +107,7 @@ CLAUDE.md target ≤ 200(Anthropic best-practice)/ transition ≤ 400 / hard cap
107
107
  | 3 告訴 user 主要 change(or preview URL)| 讓 user 知道看什麼 |
108
108
  | 4 等 user trigger | **「push / OK / 好 / 合 main」** → step 5;**「改 X / 不對 / 等等」** → 繼續 step 1 |
109
109
  | 5 Squash merge to main | 不開 PR(可 GitHub API squash-merge OR fast-forward)|
110
- | 5.5 **SSOT propagation gate**(2026-05-26 加 per user verbatim「push main 後所有 repo 都能獲得更新」)| Hook `check_post_main_ssot_propagate.sh` 偵測 `git push origin main` + diff HEAD~..HEAD 含 SSOT-affecting paths(`packages/{design-system,storybook-config}/src` / `.claude/{rules,hooks,skills,commands,references}` / `.claude-plugin/*.json` / `hooks/hooks.json` / `CLAUDE.md`)→ inject context 提議 bump npm `0.1.0-beta.<N+1>` + tag。AI 跑 bump + push tag → Release workflow auto-fire → npm publish → ds-product-template + fork repos Dependabot daily auto-PR(整鏈 1 trigger 涵蓋 /knowledge-prune / /deep-audit-cross-codex / 一般 dev / 任何 SSOT-affecting 來源,不需 skill-specific Phase Z)|
110
+ | 5.5 **SSOT propagation gate**(2026-05-26 加 per user verbatim「push main 後所有 repo 都能獲得更新」)| Hook `check_post_main_ssot_propagate.sh` 偵測 `git push origin main` + diff HEAD~..HEAD 含 SSOT-affecting paths(`packages/design-system/src` + `packages/storybook-config/{addons,addons-preset.ts,preview.tsx}`(無 src/ dir)/ `.claude/{rules,hooks,skills,commands,references}` / `.claude-plugin/*.json` / `hooks/hooks.json` / `CLAUDE.md`)→ inject context 提議 bump npm `0.1.0-beta.<N+1>` + tag。AI 跑 bump + push tag → Release workflow auto-fire → npm publish → ds-product-template + fork repos Dependabot daily auto-PR(整鏈 1 trigger 涵蓋 /knowledge-prune / /deep-audit-cross-codex / 一般 dev / 任何 SSOT-affecting 來源,不需 skill-specific Phase Z)|
111
111
  | 6 砍 remote branch | `git push origin --delete <branch>` ;sandbox HTTP 403 → 提醒 user GitHub UI 手動 |
112
112
  | 7 Local 對齊 | `git checkout main && git fetch && git reset --hard origin/main && git branch -d <branch>` |
113
113
 
@@ -155,7 +155,7 @@ CLAUDE.md target ≤ 200(Anthropic best-practice)/ transition ≤ 400 / hard cap
155
155
 
156
156
  **2026-05-23 永久 reinforcement(user verbatim,hook 機械強制)**:
157
157
  - **Triple-verify before propose**(M18 Q0 universal gate):propose / 列 option / 發現「問題」(含 codex / deep audit findings)前必 inline 跑 (1) grep DS-wide (2) Read spec.md / tsx (3) 對照 canonical exception。三題全過才 propose;任一 NO → 自動撤回不煩 user。Hook `check_propose_pre_grep_verify.sh`。Anchor:2026-05-18 Sheet/inline-action/SurfaceBody false positive、2026-05-23 Badge `text-[10px]` 誤判為 drift(spec L161-167 documented exception)
158
- - **SSOT auto-sync invariant**:M-rule count / hook count / dim count / npm scope / version / plugin name 等跨 file 數字禁 hardcode 多處;SSOT in `session_start_governance_check.sh:173` / `meta-patterns.md` / `design-system-audit/SKILL.md` / `package.json` / `.claude-plugin/plugin.json`;其他 file reference 或 `scripts/sync-governance-counters.mjs` 機械對齊,drift 偵測 auto fix
158
+ - **SSOT auto-sync invariant**:M-rule count / hook count / dim count / npm scope / version / plugin name 等跨 file 數字禁 hardcode 多處;SSOT in `session_start_governance_check.sh` Check 7 / `meta-patterns.md` / `design-system-audit/SKILL.md` / `package.json` / `.claude-plugin/plugin.json`;其他 file reference 或 `scripts/sync-governance-counters.mjs` 機械對齊,drift 偵測 auto fix
159
159
 
160
160
  # 遇不確定時的協議
161
161
 
@@ -49,14 +49,14 @@ NEW_CONTENT=$(echo "$INPUT" | jq -r '
49
49
  # Detect hardcoded numeric dim count
50
50
  # Patterns: "53 dim" / "53-dim" / "53 audit dim" / "53 audit dimensions" / "46 dim" / "46-dim"
51
51
  # Exclude legitimate uses: "N dim" / "全 dim" / "<N>" placeholder / "1 dim" thru "9 dim" (could be reasonable refs)
52
- HARDCODE_HITS=$(echo "$NEW_CONTENT" | grep -oE '\b[1-9][0-9]+[ -]?(dim|audit dim|audit dimension)' | sort -u || true)
52
+ HARDCODE_HITS=$(echo "$NEW_CONTENT" | grep -oE '\b[1-9][0-9]+[ -]?(dim|audit dim|audit dimension)|[0-9]+ ?維 ?(audit|sweep|dim)|[0-9]+ ?維度' | sort -u || true)
53
53
 
54
54
  # Allow if line contains "SSOT" / "禁" / "forbidden" / "example" / "anti-pattern" — these are invariant doc references
55
- ALLOWED_LINES=$(echo "$NEW_CONTENT" | grep -nE '\b[1-9][0-9]+[ -]?(dim|audit dim|audit dimension)' 2>/dev/null | grep -E '(SSOT|禁|forbidden|example|anti-pattern|invariant|hardcode)' || true)
55
+ ALLOWED_LINES=$(echo "$NEW_CONTENT" | grep -nE '\b[1-9][0-9]+[ -]?(dim|audit dim|audit dimension)|[0-9]+ ?維 ?(audit|sweep|dim)|[0-9]+ ?維度' 2>/dev/null | grep -E '(SSOT|禁|forbidden|example|anti-pattern|invariant|hardcode)' || true)
56
56
 
57
57
  if [ -n "$HARDCODE_HITS" ]; then
58
58
  # Filter out allowed lines (invariant doc context)
59
- VIOLATION_LINES=$(echo "$NEW_CONTENT" | grep -nE '\b[1-9][0-9]+[ -]?(dim|audit dim|audit dimension)' 2>/dev/null | grep -vE '(SSOT|禁|forbidden|example|anti-pattern|invariant|hardcode)' || true)
59
+ VIOLATION_LINES=$(echo "$NEW_CONTENT" | grep -nE '\b[1-9][0-9]+[ -]?(dim|audit dim|audit dimension)|[0-9]+ ?維 ?(audit|sweep|dim)|[0-9]+ ?維度' 2>/dev/null | grep -vE '(SSOT|禁|forbidden|example|anti-pattern|invariant|hardcode)' || true)
60
60
 
61
61
  if [ -n "$VIOLATION_LINES" ]; then
62
62
  printf '⚠️ AUDIT DIM COUNT DRIFT(P1 soft):\n' >&2
@@ -165,8 +165,10 @@ case "$FILE_PATH" in
165
165
  case "$FILE_PATH" in
166
166
  */item-anatomy.tsx|*/field-wrapper.tsx|*.stories.tsx|*.test.*|*.spec.tsx) ;; # SSOT/test skip
167
167
  *)
168
+ # 2026-05-30(dim 39 M7/M34 fix):order-INDEPENDENT — extract className attrs,require ALL 4 tokens
169
+ # present(natural Tailwind 序 `flex items-center gap-2 shrink-0 h-[1lh]` 之前漏抓)。BSD/GNU grep 通用。
168
170
  if ! echo "$NEW_CONTENT" | grep -q '@row-slot-handcraft-allow' \
169
- && echo "$NEW_CONTENT" | grep -E 'h-\[1lh\][^"]*shrink-0[^"]*flex[^"]*items-center|shrink-0[^"]*h-\[1lh\][^"]*flex[^"]*items-center|flex[^"]*items-center[^"]*h-\[1lh\][^"]*shrink-0' >/dev/null; then
171
+ && echo "$NEW_CONTENT" | grep -oE 'class(Name)?="[^"]*"' | grep -F 'h-[1lh]' | grep -F 'shrink-0' | grep -F 'flex' | grep -F 'items-center' >/dev/null 2>&1; then
170
172
  cat >&2 <<EOF
171
173
 
172
174
  ┄┄┄ C.4 check_pattern_invariants — row slot handcraft BLOCKER ┄┄┄
@@ -14,7 +14,7 @@
14
14
  #
15
15
  # SSOT-affecting paths(改這些 = consumer 需要 bump npm dep 才能拿到):
16
16
  # - packages/design-system/src/** (DS production code → npm package)
17
- # - packages/storybook-config/src/** (storybook addon config → npm package)
17
+ # - packages/storybook-config/{addons,addons-preset.ts,preview.tsx,package.json} (storybook addon config → npm;無 src/ dir,真 regex 見 L56)
18
18
  # - .claude/{rules,hooks,skills,commands,references}/** (governance plugin → ships via ds-canonical/)
19
19
  # - .claude-plugin/{plugin,marketplace}.json (plugin metadata)
20
20
  # - hooks/hooks.json (plugin hook registration)
@@ -38,11 +38,16 @@ CONTENT=$(echo "$INPUT" | jq -r '.tool_input.new_string // .tool_input.content /
38
38
  if echo "$CONTENT" | grep -qE '@preset-cjs-skip:'; then exit 0; fi
39
39
 
40
40
  # Detect ESM/CJS interop antipatterns
41
+ # 2026-05-30(dim 81 M7/M34 broad-vs-narrow fix + codex Phase B P3 inline-block edge):strip line-level 註解
42
+ # BEFORE keyword grep — 正確的 preset.ts 會在 comment 內「文件化」這些 anti-pattern(教學),raw-content
43
+ # grep 會假 BLOCK 合法 edit(ship 給 fork)。Strip 範圍:(1) 整行 //|/*|*/|* 開頭 (2) 同行 inline /* … */ block
44
+ # (3) 行尾 // 註解。多行 block 的中間行以 * 開頭已被 (1) 覆蓋。極罕見「同行開 /* + keyword 未閉合」→ @preset-cjs-skip: escape。
45
+ CONTENT_CODE=$(echo "$CONTENT" | grep -vE '^[[:space:]]*(//|\*|/\*|\*/)' | sed -E 's@/\*.*\*/@@g; s@//.*@@')
41
46
  ANTIPATTERN=""
42
- if echo "$CONTENT" | grep -qE 'createRequire|require\.resolve'; then
47
+ if echo "$CONTENT_CODE" | grep -qE 'createRequire|require\.resolve'; then
43
48
  ANTIPATTERN="${ANTIPATTERN} - createRequire / require.resolve(被 Node ESM scope 攔)\n"
44
49
  fi
45
- if echo "$CONTENT" | grep -qE 'fileURLToPath\s*\(\s*import\.meta\.url'; then
50
+ if echo "$CONTENT_CODE" | grep -qE 'fileURLToPath\s*\(\s*import\.meta\.url'; then
46
51
  ANTIPATTERN="${ANTIPATTERN} - fileURLToPath(import.meta.url)(同被 esbuild-register/ESM 衝突攔)\n"
47
52
  fi
48
53
 
@@ -1,5 +1,5 @@
1
1
  #!/bin/bash
2
- # PostToolUse hook: catch 4 classes of token hygiene / cross-OS violations on component/pattern tsx edits.
2
+ # PostToolUse hook: catch 5 classes of token hygiene / cross-OS violations on component/pattern tsx edits.
3
3
  #
4
4
  # Detects (ALL are silent-fail or cross-OS drift bug classes per CLAUDE.md):
5
5
  # 1. shadcn compat alias 回流 — bg-popover / text-muted-foreground / bg-accent / text-accent-foreground / text-popover-foreground / bg-destructive / bg-background / bg-card / border-input / text-primary-foreground
@@ -7,7 +7,8 @@
7
7
  # 2. Tailwind v4 `[--foo]` shorthand — must be `var(--foo)` wrapped; historical bug:
8
8
  # Sidebar's `w-[--sidebar-width]` broke 8 places (silent fail, no error)
9
9
  # 3. Hardcoded Tailwind shadow — `shadow-sm/md/lg/xl/2xl` is forbidden; must use `shadow-[var(--elevation-N)] N∈{100,200,300}`
10
- # 4. Native overflow-{auto,scroll} without ScrollAreacross-OS scrollbar drift
10
+ # 4. primitive color name used as Tailwind utility bg-neutral-3 / text-blue-6 silent-fail; use semantic utility or var()
11
+ # 5. Native overflow-{auto,scroll} without ScrollArea — cross-OS scrollbar drift
11
12
  # (macOS overlay 不吃寬 / Windows always-visible 吃 17px = 跨 OS 跑版)
12
13
  # 應改用 ScrollArea(Components/ScrollArea/)— overlay scrollbar 跨 OS 一致
13
14
  #
@@ -24,7 +24,10 @@ set -uo pipefail
24
24
  # Per-hook fire logging(enables /knowledge-prune D2 dead-hook detection)
25
25
  source "$(dirname "$0")/_log-fire.sh" 2>/dev/null && log_hook_fire
26
26
 
27
- set -euo pipefail
27
+ # 2026-05-30:移除 -e(對齊 L2 set -uo)。本 hook = 非阻塞 governance reminder,必永遠 exit 0;
28
+ # set -e 會讓任何未 guard 的 command(eg. L38 grep no-match pipeline 在 node-missing degraded env)
29
+ # 殺掉整個 session-start hook。fail-open > fail-closed。adversarial-verify 2026-05-30 抓出此真 bug。
30
+ set -uo pipefail
28
31
 
29
32
  PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(pwd)}"
30
33
  cd "$PROJECT_DIR" || exit 0
@@ -35,7 +38,7 @@ cd "$PROJECT_DIR" || exit 0
35
38
  # Memory sync = harness ↔ repo mirror auto-fix-up,not blocking,always exit 0。
36
39
  if [ -f scripts/sync-memory.mjs ]; then
37
40
  SYNC_OUT=$(node scripts/sync-memory.mjs 2>&1 || true)
38
- COPIED=$(echo "$SYNC_OUT" | grep -oE 'copied: [0-9]+' | grep -oE '[0-9]+' | head -1)
41
+ COPIED=$(echo "$SYNC_OUT" | grep -oE 'copied: [0-9]+' | grep -oE '[0-9]+' | head -1 || true)
39
42
  # COPIED > 0 → 加入 REMINDERS(下面 main flow inject)
40
43
  if [ -n "$COPIED" ] && [ "$COPIED" -gt 0 ]; then
41
44
  MEMSYNC_NOTE="\n- 🔄 auto sync-memory(SessionStart): harness → repo mirrored ${COPIED} memory file(s)。"
@@ -166,7 +169,7 @@ if [ -f "$FIRES_LOG" ] && [ -d "$TESTS_DIR" ]; then
166
169
  fi
167
170
  fi
168
171
 
169
- # Check 7: Hook count auto-trigger(soft 25 / hard 30 — Anthropic guideline ~15)
172
+ # Check 7: Hook count auto-trigger(soft 26 / hard 60 — Anthropic guideline ~15;真值見下方 -gt 判斷 + CLAUDE.md `# 治理 canonical`)
170
173
  # 2026-05-09 fix:tree-recursive count(含 lib/ helpers)。前身 -maxdepth 1 只 count root,
171
174
  # 漏 16 個 lib/ helpers → metric reports 19,reality 35 = system gaming own metric。
172
175
  # 2026-05-13 prune consolidation:`_*.sh` 約定 = internal helper(Unix convention)。
@@ -251,6 +254,30 @@ if command -v node >/dev/null 2>&1 && [ -f scripts/sync-governance-counters.mjs
251
254
  fi
252
255
  fi
253
256
 
257
+ # Check 11: Cross-repo env smoke(2026-05-30 — NON-BLOCKING:只進 PRUNE_TRIGGERS soft channel,
258
+ # 永不進 BLOCKER 路徑、永不非零退出。set -uo pipefail(無 -e)→ 探針非零返回不殺 script;
259
+ # 但 set -u 下 unset var 必 ${VAR:-} guard。每探針獨立、無 network、無 blocking subshell。
260
+ ENV_SMOKE=""
261
+ # (a) plugin-mode 完整性 — CLAUDE_PLUGIN_ROOT 在 ds-repo native mode 可能 UNSET → 先 guard 才用
262
+ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ ! -d "${CLAUDE_PLUGIN_ROOT:-}/hooks" ]; then
263
+ ENV_SMOKE="${ENV_SMOKE}\n - Plugin mode:\$CLAUDE_PLUGIN_ROOT 有設但 hooks/ 找不到 → plugin install 可能不完整(跑 /plugin marketplace update)。"
264
+ fi
265
+ # (b) node 在 PATH — audit scripts 依賴
266
+ if ! command -v node >/dev/null 2>&1; then
267
+ ENV_SMOKE="${ENV_SMOKE}\n - node 不在 PATH → audit scripts(dispatch-audit-dims / content-quality)在此環境跑不動。"
268
+ fi
269
+ # (c) codex transport(informational;缺 = fork repo 正常,Phase B 自動 fallback)
270
+ if [ ! -x node_modules/.bin/codex ] && ! command -v codex >/dev/null 2>&1; then
271
+ ENV_SMOKE="${ENV_SMOKE}\n - codex CLI 缺 → deep-audit Phase B dual-track 自動 fallback Phase-A-only(fork repo 屬正常;要雙軌跑 npm i -D @openai/codex)。"
272
+ fi
273
+ # (d) consumer-mode DS resolution — fork repo 引 npm DS 但未安裝
274
+ if [ -f package.json ] && grep -q '"@qijenchen/design-system"' package.json 2>/dev/null && [ ! -d node_modules/@qijenchen/design-system ]; then
275
+ ENV_SMOKE="${ENV_SMOKE}\n - Consumer repo 引用 @qijenchen/design-system 但 node_modules 沒裝(跑 npm install)。"
276
+ fi
277
+ if [ -n "$ENV_SMOKE" ]; then
278
+ PRUNE_TRIGGERS="${PRUNE_TRIGGERS}\n- 🩺 env-smoke(non-blocking,環境健檢):${ENV_SMOKE}"
279
+ fi
280
+
254
281
  # Inject if HARD BLOCKERS(must)or auto-prune-triggers or quarterly-prune-overdue
255
282
  QUARTERLY_DUE=""
256
283
  if [ -f .claude/logs/.last-prune ]; then
@@ -271,6 +298,8 @@ elif [ -n "$PRUNE_TRIGGERS" ]; then
271
298
  else
272
299
  MSG="🧭 Governance hygiene reminder (SessionStart):${QUARTERLY_DUE}\nNot blocking — address inline when convenient."
273
300
  fi
301
+ # fail-open:無 jq(eg. 殘缺 PATH / minimal cloud sandbox)→ 靜默 exit 0,不吐 malformed JSON(2026-05-30 硬化)
302
+ command -v jq >/dev/null 2>&1 || exit 0
274
303
  ESCAPED=$(printf '%b' "$MSG" | jq -Rs .)
275
304
  printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":%s}}\n' "$ESCAPED"
276
305
  exit 0
@@ -1,5 +1,5 @@
1
1
  #!/bin/bash
2
- # Smoke test for check_token_hygiene.sh
2
+ # Smoke test for lib/_token_hygiene.sh (HOOK= resolves to ../lib/_token_hygiene.sh; check_token_hygiene.sh was never a standalone file)
3
3
  set -u
4
4
  HOOK="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../lib/_token_hygiene.sh"
5
5
  [ -x "$HOOK" ] || { echo "FATAL"; exit 1; }
@@ -28,7 +28,7 @@
28
28
 
29
29
  **Story 特別提醒**:**stories 也是 code**。如果 story 在 label / comment 說「DataTable cell 用法」「Table 配額」「Menu 選單」等,**要 render 真的該元件 demo,不可用 raw `<table>` / raw `<button>` 假裝**。否則 story 教壞 consumer、自己也在破壞 DS 訓練資料。
30
30
 
31
- `check_story_anatomy.sh` hook 會在 Write/Edit 階段攔下這類手刻;allowlist `// @anatomy-exempt: <reason>`(檔首)/ `// @anatomy-exempt-next`(下一行)可豁免教學用 raw primitive。
31
+ `check_story_invariants.sh` hook(R1 anatomy,原 `check_story_anatomy.sh` folded 折入)會在 Write/Edit 階段攔下這類手刻;allowlist `// @anatomy-exempt: <reason>`(檔首)/ `// @anatomy-exempt-next`(下一行)可豁免教學用 raw primitive。
32
32
 
33
33
  ---
34
34
 
@@ -63,7 +63,7 @@
63
63
 
64
64
  ## overflow 使用三規則(避免跨 OS 跑版)
65
65
 
66
- 1. Design-system 元件 `.tsx` 內**禁止** raw `overflow-auto / overflow-scroll / overflow-{x,y}-{auto,scroll}`(hook `check_token_hygiene.sh` check #4 守衛)
66
+ 1. Design-system 元件 `.tsx` 內**禁止** raw `overflow-auto / overflow-scroll / overflow-{x,y}-{auto,scroll}`(hook `lib/_token_hygiene.sh` Check 5 守衛)
67
67
  2. 需捲軸且跨 OS 一致 → 用 `ScrollArea`
68
68
  3. 刻意隱藏捲軸 + fade-mask → 用 `horizontal-overflow` pattern
69
69
  4. 例外:`overlay-surface` spec 明文允許 Dialog body `flex-1 overflow-y-auto`(viewport-fill 特殊 context);若未來此場景需跨 OS 一致,遷移 ScrollArea 再更新 spec
@@ -194,7 +194,7 @@ const isActive = variant === "meta" ? false : (... 同上)
194
194
  - 看 `item-layout.tsx` 的 export → 找到 `ICON_SIZE` / `AVATAR_SIZE` / `ItemPrefix` / `ItemLabel` / `ItemIcon` / `ItemAvatar` / `ItemInlineAction` / `ItemInlineActionButton` / `ItemSuffix` / `RowSizeProvider` / `useRowSize` / `getUniformPrefixSlotStyle` / `INLINE_ACTION_HOVER_BG_SIZE` ✓
195
195
  - 看本 spec 的 Recipe → 7 步 copy-paste ✓
196
196
  - 看 `MenuItem` / `SidebarMenuButton` / `TreeItem` 三個現成 row primitive → canonical 實作參考 ✓
197
- - 跨檔案 grep 規則 → CLAUDE.mdRow primitives 共用 item-layout 公式」節列出禁止事項 ✓
197
+ - 跨檔案 grep 規則 → `patterns/element-anatomy/item-anatomy.spec.md`「Row primitives item-layout 公式」節列出禁止事項 ✓
198
198
 
199
199
  如果以上四條任何一條斷掉,就是 spec / code drift,該補。
200
200
 
@@ -50,7 +50,7 @@ CLAUDE.md `# SSOT 消費 canonical` 的詳表 + 反例。主章留核心 + point
50
50
  */
51
51
  ```
52
52
 
53
- Hook `check_ssot_consultation.sh`(Write 新 tsx 到 `packages/design-system/src/components/` 或 `src/explorations/`)→ 若檔內無上述註解區 → warn 要求補齊。
53
+ Hook `check_ssot_consultation.sh`(retired;改靠 mindset #2 + `check_canonical_propagation.sh`)(原 Write 新 tsx 到 `packages/design-system/src/components/` 或 `src/explorations/` → 若檔內無上述註解區 → warn 要求補齊)。
54
54
 
55
55
  ## 禁止:隱性自創
56
56
 
@@ -84,4 +84,4 @@
84
84
 
85
85
  **為什麼**:shadcn alias 是「臨時橋」讓 shadcn add 不炸;我們有自己 design opinion 後直接用 own token,保持 DS 單一真實來源。允許 shadcn alias 進我們的 code = 慢慢讓 shadcn 命名污染回流,DS 自主性退化。
86
86
 
87
- **曾經發生的 bug**:Popover.tsx / Command.tsx 保留 shadcn template 的 `bg-popover`, `text-popover-foreground`, `text-muted-foreground`, `bg-accent`, `text-accent-foreground` 多處,2026-04-18 session 時 audit 發現統一遷移為 direct token(`bg-surface-raised` / `text-foreground` / `text-fg-muted` / `bg-neutral-hover`)。hook `check_token_hygiene.sh` 現已自動攔截此類回流。
87
+ **曾經發生的 bug**:Popover.tsx / Command.tsx 保留 shadcn template 的 `bg-popover`, `text-popover-foreground`, `text-muted-foreground`, `bg-accent`, `text-accent-foreground` 多處,2026-04-18 session 時 audit 發現統一遷移為 direct token(`bg-surface-raised` / `text-foreground` / `text-fg-muted` / `bg-neutral-hover`)。hook `lib/_token_hygiene.sh`(由 `post_edit_dispatcher.sh` source)現已自動攔截此類回流(Check 1 shadcn alias)。
@@ -61,8 +61,8 @@
61
61
  | **M21** | **新元件 / 新 sub-component 抽象前必過 prop variant test**。當新元件名 = `<Existing>+suffix`(Time / Range / Color / Light / Dark / Filled / Outline / Compact / Rich)→ 強烈 signal 應為 prop variant on `<Existing>`。3-test 通過才能分(全失敗 → prop):(1) `<Existing>` 加 prop 無法達成同 DOM/behavior?(2) ≥3 家 world-class DS 用分離元件而非 prop(必 cite source)?(3) value 結構或 contract 真的不同(如 Range = [start, end])?Hook check_premature_abstraction(retired/未實作;mindset enforcement)。 | DateTimePicker 從 DatePicker 拆 → 撤回合併 `<DatePicker showTime>`(2026-05-02);DataTableFilterPanel 5-file → 撤回 sub-file pattern |
62
62
  | **M22** | **Benchmark claim 必附 inline source citation**(不可憑印象)。寫 spec / tsx 含「Ant / Material / Polaris / Atlassian / Carbon / shadcn / Radix」等 world-class DS claim,必同段附:(a) inline URL(domain 對應 DS 官網 / GitHub source);(b) GitHub source path + line ref `#L42`;(c) screenshot reference `snapshots/...`;(d) 顯式撤回 `@benchmark-unverified`。Hook `check_benchmark_citation.sh` 機械化警告(P1 soft)。每次 implement 前跑 WebFetch 取真 source,不憑印象解碼。 | claim「Ant showTime range = 2 calendars」憑印象,實證 source code `multiplePanel = false` = 1 calendar(2026-05-02 鬼話事件)|
63
63
  | **M23** | **DS 內既有 canonical 優先於外部 benchmark**。寫 visual decision(color / size / spacing / typography / state)/ prop name namespace 前必先 grep DS 既有 codified token / variant / pattern / prop;命中 → 必對齊;沒命中 → 才引 world-class + 同步補 canonical。**禁止**:外部 benchmark(M22 cite OK)直接覆蓋 DS 內已有 canonical。Mindset #2「優先消費既有」的 visual layer。判斷流程:(a) grep 該屬性 / prop 既有 token/variant/usage;(b) 命中 canonical?有 → 用,沒 → 走 M22 cite 然後 codify;(c) **prop name conflict 子規則**(former M27,2026-05-15 collapsed):外部 framework prop name(TanStack `size` / Radix `disabled` / dnd-kit attrs 等)跟 DS 既有 prop 同字不同義 → wrap-and-rename(DS-internal naming + pre-process map);(d) **nearest same-purpose canonical wins 子規則**(former M35,2026-05-22 folded):寫 stories / UI composition wrap 既有 primitive 前必先 grep + Read primitive 的「完整佈局」production canonical story(eg. `sidebar.stories.tsx#IconCollapse`)抄 archetype 結構 / helper / variant — 不准憑記憶寫 simplified mock。**Cite 存在 ≠ consume 落實**(codex 2026-05-20 verdict)。最相近同目的 canonical 用法 > 泛用 component spec / 寬鬆 pattern wording。Registry SSOT `.claude/references/story-baseline-registry.json` + hook `check_story_invariants.sh R8 story_archetype_registry`。 | 2026-05-03 chevron color:DS `text-foreground` (icon-only Button neutral-9 85%) vs 我憑「Ant 5 家 muted」覆蓋 → 自開新 tier 違反一致設計語言。2026-05-06 column width:DS 49+ 處 `size: 'sm'\|'md'\|'lg'` density vs TanStack `size: 280` px = 同 prop 不同義 → `meta.width` wrap。2026-05-20 AppShell-vs-Sidebar drift:simplified mock + jargon + wrong variant + 不消費 primitive props。Hook `check_data_table_size_num_to_meta_width.sh` + `check_story_invariants.sh R8` |
64
- | **M24** | **State 顯著性 precedence:disabled > muted > emphasis**。元件在 disabled state 時,內部所有文字載體(label / value / placeholder / icon)統一切 disabled token(`text-fg-disabled` neutral-6),**不**繼續 muted token(`text-fg-muted` neutral-7)。muted 是裝飾,disabled 是語意 state — state 勝 emphasis。同理:error / warning state 內 placeholder 應對應 state token。Hook check_disabled_placeholder_color(retired/未實作;mindset enforcement)。 | 2026-05-04 5+ violation:`bareInputStyles` 永遠 muted / `select.tsx` 3 處 plain&tag empty 不分 mode / `textarea.tsx` 同;Input.tsx 唯一做對。User 5+ 次糾正才 codify |
65
- | **M25** | **Layered chain invariant 必整鏈 forward(viewport-aware overlay scroll 範例)**。Overlay surface(Popover / HoverCard / Dialog / Sheet)的 viewport-aware scroll 機制要求 root → SurfaceBody 之間**所有中間 wrapper 都 forward `flex flex-col h-full`**;任何中間 div 沒 forward → SurfaceBody flex-1 失效 → body 不 scroll。同類 chain pattern:density 透傳 / fieldCtx 鏈 / theme subtree(M3 portal 逃逸對偶)。Hook check_overlay_panel_scroll_chain(retired/未實作;mindset enforcement)。 | 2026-05-04:Filter / Sort panel root `<div w-[640px]>` 無 flex-col → user 縮 viewport 時 body 不 scroll。NameCard 因自設 max-h flex-col 才繞過(無中間 wrapper) |
64
+ | **M24** | **State 顯著性 precedence:disabled > muted > emphasis**。元件在 disabled state 時,內部所有文字載體(label / value / placeholder / icon)統一切 disabled token(`text-fg-disabled` neutral-6),**不**繼續 muted token(`text-fg-muted` neutral-7)。muted 是裝飾,disabled 是語意 state — state 勝 emphasis。同理:error / warning state 內 placeholder 應對應 state token。Hook `check_field_family_invariants.sh` A.4( check_disabled_placeholder_color folded,live P1 stderr)。 | 2026-05-04 5+ violation:`bareInputStyles` 永遠 muted / `select.tsx` 3 處 plain&tag empty 不分 mode / `textarea.tsx` 同;Input.tsx 唯一做對。User 5+ 次糾正才 codify |
65
+ | **M25** | **Layered chain invariant 必整鏈 forward(viewport-aware overlay scroll 範例)**。Overlay surface(Popover / HoverCard / Dialog / Sheet)的 viewport-aware scroll 機制要求 root → SurfaceBody 之間**所有中間 wrapper 都 forward `flex flex-col h-full`**;任何中間 div 沒 forward → SurfaceBody flex-1 失效 → body 不 scroll。同類 chain pattern:density 透傳 / fieldCtx 鏈 / theme subtree(M3 portal 逃逸對偶)。Hook `check_pattern_invariants.sh` C.1( check_overlay_panel_scroll_chain folded,live P1 WARN)。 | 2026-05-04:Filter / Sort panel root `<div w-[640px]>` 無 flex-col → user 縮 viewport 時 body 不 scroll。NameCard 因自設 max-h flex-col 才繞過(無中間 wrapper) |
66
66
  | **M26** | **Behavior / visual canonical decision 前必跑 WebFetch + WebSearch 取 ≥ 3 source,不可憑印象 propose**。M22 升級版 — M22 管「寫 spec / tsx 含 claim 必附 cite」(實作後),M26 管「propose / 決策前必先 fetch」(實作前)。Pipeline:(1) WebFetch 3 家世界級 source(Atlassian / Material / Polaris / Ant / Carbon / Apple HIG / shadcn / Radix);(2) 全 403 → WebSearch fallback 用 snippet,**明示「search-only confidence」**;(3) WebFetch + WebSearch 都失敗 → STOP propose,告知 user「無法 verify,要看 screenshot/實機」。Hook `check_propose_without_benchmark.sh`(2026-05-26 backfill — 前期 doc claim 但 file missing;UserPromptSubmit 偵測 user prompt 含 propose / visual / behavior decision keyword + 近 20 turn WebFetch/WebSearch < 2 → soft inject 提醒)。 | 2026-05-05:user 反覆糾「為什麼每次都沒 webfetch 只憑印象」— Jira drag handle / cell display 兩題我憑印象 propose 多輪;升級成硬規範 |
67
67
  <!-- M27 retired 2026-05-15(per /knowledge-prune D3 audit):self-flagged「M23 子規則」 → collapsed into M23 sub-bullet (c) "framework prop name namespace conflict"。Original case (TanStack size vs DS density) + hook `check_data_table_size_num_to_meta_width.sh` retained 在 M23 children。 -->
68
68
 
@@ -12,9 +12,9 @@ paths:
12
12
 
13
13
  | 層 | 檔案 | Canonical | Hook | Audit Dim |
14
14
  |---|------|-----------|------|-----------|
15
- | 1 展示 | `*.stories.tsx` | trait-based v2 | `check_story_category.sh` | 29 |
16
- | 2 設計規格 | `*.anatomy.stories.tsx` | 6-canonical(Overview / Inspector / ColorMatrix / SizeMatrix / StateBehavior / Accessibility)| `check_story_anatomy.sh` | 13 |
17
- | 3 設計原則 | `*.principles.stories.tsx` | Polaris-aligned ≥ 2 of {WhenToUse / WhenNotToUse / Vs*Rule / ContentGuidelines};v3 預設整合 `UsageGuidance` 單一 export(Polaris/Material/Ant 共識) | `check_principles_canonical.sh` | 30 |
15
+ | 1 展示 | `*.stories.tsx` | trait-based v2 | `check_story_invariants.sh` R3 category | 29 |
16
+ | 2 設計規格 | `*.anatomy.stories.tsx` | 6-canonical(Overview / Inspector / ColorMatrix / SizeMatrix / StateBehavior / Accessibility)| `check_story_invariants.sh` R1 anatomy | 13 |
17
+ | 3 設計原則 | `*.principles.stories.tsx` | Polaris-aligned ≥ 2 of {WhenToUse / WhenNotToUse / Vs*Rule / ContentGuidelines};v3 預設整合 `UsageGuidance` 單一 export(Polaris/Material/Ant 共識) | `check_canonical_propagation.sh` E.1 principles | 30 |
18
18
 
19
19
  ## Title 命名
20
20
 
@@ -56,7 +56,7 @@ paths:
56
56
  - 同 affordance 內 prop variations 用 Controls 不另開(❌ `WithStartIcon`+`WithEndIcon` → ✓ `WithIcon` grid)
57
57
  - Compound 有 new constraint 才分
58
58
 
59
- **展示 v2 trait-based**:spec.md frontmatter `traits:` array → required core stories 衍生 + hook `check_story_category.sh` 攔。
59
+ **展示 v2 trait-based**:spec.md frontmatter `traits:` array → required core stories 衍生 + hook `check_story_invariants.sh` R3 category 攔。
60
60
 
61
61
  **Principles canonical**(Polaris-aligned):universal core ≥ 2 of `WhenToUse`/`WhenNotToUse`/`Vs*Rule`/`ContentGuidelines` + hook 攔。SSOT → `/story-writing` skill `references/category-templates.md`。
62
62
 
@@ -13,8 +13,8 @@
13
13
  **Audit / Quality(5)**:
14
14
  | Skill | Invoke 時機 | Scope |
15
15
  |-------|-----------|-------|
16
- | `design-system-audit/` | user 要求 audit DS 本身 | DS 內部 spec/cva/SSOT 33 維度(Phase 0 自建 baseline)|
17
- | `product-ui-audit/` | 「audit 這個 UI / 檢查 DS 用對嗎」| consumer UI 6 維檢核 |
16
+ | `design-system-audit/` | user 要求 audit DS 本身 | DS 內部 spec/cva/SSOT full-dim(Phase 0 自建 baseline)|
17
+ | `product-ui-audit/` | 「audit 這個 UI / 檢查 DS 用對嗎」| consumer UI 7 維檢核 |
18
18
  | `component-quality-gate/` | 元件 merge / ready / check | 45+ 項 checklist + Phase 4 Ship 6 項 |
19
19
  | `visual-audit/` | 視覺對齊 / 排版問題 / gap 錯 | pixel-level Layer A + B |
20
20
  | `code-quality-audit/` | 量化 clean code(any / dead export / file-size / long fn / circular dep / magic number)| chained by /design-system-audit Dim 27 |
@@ -28,7 +28,7 @@ description: Batch-end-verify rhythm + parallel tool batch + user-listed N-rule
28
28
 
29
29
  ## Non-goals
30
30
 
31
- - 不擴展到「audit 7 維」(那是 `/design-system-audit`)
31
+ - 不擴展到「audit full-dim」(那是 `/design-system-audit`)
32
32
  - 不取代 `/scan-similar-bugs`(那是 fix 後 root-pattern scan;本 skill 是 fix-過程 rhythm)
33
33
  - 不動 canonical 語意(走 audit-vs-execute STOP 提議)
34
34
 
@@ -20,7 +20,7 @@ Scope:**tsx / ts code hygiene**,跟 design canonical 正交。
20
20
  | 3 | Long function | P1 > 80 行 | naive:`function`/`const` 宣告到 matching `}` indent 行距 |
21
21
  | 4 | Dead export | P1 | `export` 名稱在其他 src/ 檔無出現;exempt `*Props/Options/Config/Args/Context/Variants/Value` 型別 API 慣例 |
22
22
  | 5 | Circular dep | P0 | DFS import graph,找 cycle |
23
- | 6 | Magic number | P1 | 覆蓋不完整 → 由 `check_token_hygiene.sh` hook 層負責(primitive color / shadow / Tailwind v4 `[--foo]`);本 skill 不重複 |
23
+ | 6 | Magic number | P1 | 覆蓋不完整 → 由 token 防線(`lib/_token_hygiene.sh` + `check_opacity_token_usage.sh`)層負責(primitive color / shadow / Tailwind v4 `[--foo]`);本 skill 不重複 |
24
24
 
25
25
  ## When to run
26
26
 
@@ -60,4 +60,4 @@ Scope:**tsx / ts code hygiene**,跟 design canonical 正交。
60
60
 
61
61
  - `scripts/code-quality-audit.mjs` — 實作
62
62
  - `.claude/hooks/check_code_quality.sh` — per-edit lite check
63
- - 相關:`check_token_hygiene.sh`(正交 — token 紀律 vs code 紀律)
63
+ - 相關:token 防線 `lib/_token_hygiene.sh` + `check_opacity_token_usage.sh`(正交 — token 紀律 vs code 紀律)
@@ -51,7 +51,7 @@ ls -la ~/.codex/auth.json # 3 Auth(
51
51
 
52
52
  **User 原話 SSOT**(2026-05-15):「也要告訴他我的原話,讓他也能有機會解讀我的原話 ... 說不定codex在解讀別人的問題比你還有慧根 ... 請你在infra上避免你下次又在局限codex發現問題的能力」
53
53
 
54
- **Why**:Paraphrase 過濾 user 細節 / 加 Claude 偏見 / frame 問題 → codex 只能在 Claude 框架答 surgical fix → root cause 沒抓到。錨例 2026-05-15:I1 placeholder ellipsis + I3 overflow 兩 bug user 提 2-3 次,每次送 paraphrase → 冰山修。Hook TBD `check_codex_brief_verbatim.sh`(grep `## User 原話` heading missing warn)。
54
+ **Why**:Paraphrase 過濾 user 細節 / 加 Claude 偏見 / frame 問題 → codex 只能在 Claude 框架答 surgical fix → root cause 沒抓到。錨例 2026-05-15:I1 placeholder ellipsis + I3 overflow 兩 bug user 提 2-3 次,每次送 paraphrase → 冰山修。Hook `check_codex_brief_verbatim.sh`(未實作;verbatim-relay `## User 原話` heading 檢查無 write-time hook — live `check_codex_brief_invariants.sh` 只 cover 全盤閱讀/triple-verify/禁抽樣/禁列檔 audit-flow invariants,不涵蓋此 verbatim-relay,改靠本 Step 0.05 mindset enforcement)。
55
55
 
56
56
  ## ⚠️ M31 Universal 5-step canonical(2026-05-10 user directive)
57
57
 
@@ -62,7 +62,7 @@ ls -la ~/.codex/auth.json # 3 Auth(
62
62
  | Step | Claude | Codex | 共通 invariant |
63
63
  |---|---|---|---|
64
64
  | **1 各自熟讀** | grep / read spec.md / canonical / source 真讀 | `exec -s read-only` grep / git show / read source | 憑印象 propose = M31 違反 |
65
- | **2 各自驗證** | `npx tsc -b` + invariant + audit script | `exec` grep / git show 證據 | 任一方未跑真 verify 撤回 propose |
65
+ | **2 各自驗證** | `npx tsc -b` + invariant + audit script | **audit-verify**:`exec --dangerously-bypass-approvals-and-sandbox -C $PWD`(user-authorize)跑**同樣** tsc / invariant / .mjs / Playwright + 貼 stdout(per `references/phase-b-codex-brief.md` B.0.1);**純讀**:`exec -s read-only` grep / git show | 任一方未跑真 verify 撤回;**禁** codex 只目測機械維度(verify 不對稱違 M31 Step 2)|
66
66
  | **3 各自視覺稽核** | playwright screenshot + DOM + pixel audit | code-read + diff + grep visual path | 只 code 跳 visual 違反 user directive |
67
67
  | **4 各自 cite-based propose** | 3-column:`spec.md path:line / 引文 / reasoning` | 同上獨立出 | hand-wave 無 cite 撤回 |
68
68
  | **5 整合完美版本**(NOT pass-through)| Agree → synthesize 補對方缺漏;Disagree → cite battle verify 對方 cite + counter-cite | 同上雙向 | **絕禁** Claude pass-through codex / 只一方驗證跳整合 |
@@ -207,7 +207,7 @@ target PR:當前 working branch 的 PR(`mcp__github__list_pull_requests` 找到
207
207
 
208
208
  ### Step 6:User approve → Claude 實作
209
209
 
210
- 由我(非 codex)實作,跑完整 stop hook (`stop_meta_self_audit.sh`)+ M14 5-layer pipeline。
210
+ 由我(非 codex)實作,跑完整 stop hook (`stop_self_audit.sh`)+ M14 5-layer pipeline。
211
211
 
212
212
  **Joint test case planning(D-class architectural change 必走,2026-05-07 user 拍板)**:
213
213
 
@@ -242,7 +242,7 @@ PR comment:`@codex 結論已 land at <commit>. 感謝 review.`
242
242
 
243
243
  ## Guardrails
244
244
 
245
- 沿用既有 hook(`check_benchmark_citation.sh` / `stop_meta_self_audit.sh`),codex reply 不入 commit,hook 對 final commit 強制。**禁止**:codex commit 直接 push / 跳過 Step 4 送 user 原文 / 把 codex reply 當 ground truth。**M20 self-improvement**:codex 抓的 M-rule violation → 加 `.claude/memory/codex-caught-violations.md`。**Auto-codify(2026-05-07)**:任何 collab 新發現 → 立刻 5-layer(SKILL + memory + CLAUDE.md + planning),trigger「確保記錄起來」「不需要再對你耳提面命」「自然就知道」。
245
+ 沿用既有 hook(`check_benchmark_citation.sh` / `stop_self_audit.sh`),codex reply 不入 commit,hook 對 final commit 強制。**禁止**:codex commit 直接 push / 跳過 Step 4 送 user 原文 / 把 codex reply 當 ground truth。**M20 self-improvement**:codex 抓的 M-rule violation → 加 `.claude/memory/codex-caught-violations.md`。**Auto-codify(2026-05-07)**:任何 collab 新發現 → 立刻 5-layer(SKILL + memory + CLAUDE.md + planning),trigger「確保記錄起來」「不需要再對你耳提面命」「自然就知道」。
246
246
 
247
247
  ## Deep Audit 整合 + Cross-session persistence
248
248
 
@@ -5,10 +5,10 @@ description: Process .claude/logs/user-corrections.jsonl — the Stop-hook-harve
5
5
 
6
6
  # Codify Corrections — 把 user 糾正 log 落到 governance 文件
7
7
 
8
- **目的**:`.claude/logs/user-corrections.jsonl` 是 `stop_harvest_corrections.sh` 從每 session transcript 抓到的「不是 / 不對 / 應該 / 糾正」訊號。骨架存在,但從 log 到實際 CLAUDE.md / memory / spec edit 原本全靠人工讀 + 決定寫哪,實務上堆積 = 骨架失靈。本 skill 把這條 loop 合上。
8
+ **目的**:`.claude/logs/user-corrections.jsonl` 是 `stop_passive_logging.sh` R2 `rule_harvest_corrections()`(原 lib/stop_harvest_corrections.sh,已 folded 進統一 Stop hook)從每 session transcript 抓到的「不是 / 不對 / 應該 / 糾正」訊號。骨架存在,但從 log 到實際 CLAUDE.md / memory / spec edit 原本全靠人工讀 + 決定寫哪,實務上堆積 = 骨架失靈。本 skill 把這條 loop 合上。
9
9
 
10
10
  **對齊 CLAUDE.md**:
11
- - 資訊治理 canonical L2(per-commit)下游
11
+ - 治理 canonical L2(per-commit)下游
12
12
  - mindset #6「user tell me once,我不該要 tell me twice」執行面
13
13
  - M14 AUTO integrate pipeline 第 7 層(memory / CLAUDE.md 落地)
14
14
  - 稽核 vs 執行 分權:動 canonical substantive → STOP Checkpoint(本 skill 內建)
@@ -25,7 +25,7 @@ description: Process .claude/logs/user-corrections.jsonl — the Stop-hook-harve
25
25
  - 不改 code(`.tsx` / `.css`)— 只動 governance 文件
26
26
  - 不自動 write 任何 M-row(新 Meta-Pattern 必 Checkpoint 3 — 動 canonical substantive)
27
27
  - 不刪 jsonl 歷史 — 處理後 append 到 `.processed.jsonl`,raw log 保留 grep evidence
28
- - 不重跑 harvest — harvest 是 stop_harvest_corrections.sh 的責任
28
+ - 不重跑 harvest — harvest 是 stop_passive_logging.sh R2 rule_harvest_corrections()(原 stop_harvest_corrections.sh,已 folded)的責任
29
29
 
30
30
  ---
31
31
 
@@ -147,7 +147,7 @@ Update `.claude/logs/metric-snapshots.jsonl`:
147
147
  ```markdown
148
148
  ## Self-improvement capture
149
149
  - 新發現 pattern:{某 topic 反覆出現 → 該抽 meta}OR "無"
150
- - Harvest miss:{stop_harvest_corrections.sh 沒抓到但該抓的 keyword}OR "無"
150
+ - Harvest miss:{stop_passive_logging.sh R2 rule_harvest_corrections()(原 stop_harvest_corrections.sh,已 folded)沒抓到但該抓的 keyword}OR "無"
151
151
  - Codify-to-home 公式漂移:{有 topic 判斷多次走錯 home → 更新 Phase 1 判斷表}OR "無"
152
152
  ```
153
153
 
@@ -157,7 +157,7 @@ Update `.claude/logs/metric-snapshots.jsonl`:
157
157
 
158
158
  | Skill | Scope |
159
159
  |-------|-------|
160
- | `stop_harvest_corrections.sh`(hook)| 抓 log — 不 codify |
160
+ | `stop_passive_logging.sh` R2 rule_harvest_corrections()(原 stop_harvest_corrections.sh,已 folded)| 抓 log — 不 codify |
161
161
  | **本 skill**(`/codify-corrections`) | log → governance 文件 edit |
162
162
  | `/knowledge-prune` | governance 文件 prune — 不處理新 correction |
163
163
  | `/design-system-audit --deep` Phase 4.5 | chain `/knowledge-prune`;未來可 chain 本 skill |
@@ -129,7 +129,7 @@ User 親自確認 scope / type / affected homes 是否正確,禁 AI 單方面決
129
129
 
130
130
  - `~/.../memory/MEMORY.md` — index of codified principles
131
131
  - `.claude/logs/codified-principles.jsonl` — execution log
132
- - CLAUDE.md `# 資訊治理 canonical` 8-home — home 識別 rules
132
+ - CLAUDE.md `# 治理 canonical` 8-home — home 識別 rules
133
133
  - CLAUDE.md `# Meta-Pattern 預警` M14 / M19 — 上游 pipeline rules
134
134
 
135
135
  ## 範例呼叫
@@ -141,7 +141,7 @@ Skill 自動:
141
141
  2. M8:Polaris/Material/Atlassian React form lib 都支援 dual-mode ✓ (3/3 ≥3)
142
142
  3. Draft layer:
143
143
  - SSOT:`.claude/rules/ui-development.md`「元件 Props 命名」 + form spec
144
- - Hook:`.claude/hooks/check_form_dual_mode.sh` 偵測 missing pair
144
+ - Hook:`.claude/hooks/check_form_dual_mode.sh`(未實作;此為 5-layer 產物範例 — audit-only via dim,無 write-time hook)偵測 missing pair
145
145
  - Audit dim:Dim 31「Dual-mode coherence」(已存在 Dim 26 — STOP 提議擴充而非新增)
146
146
  - Scaffold:`/new-component` Phase 4 加 dual-mode template
147
147
  - Memory:`project_form_dual_mode_2026_04_26.md`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: component-quality-gate
3
- description: Pre-merge quality gate for new or significantly refactored design-system components. Walks through Spec / Code / Stories / Ship checklist (45+ items) to ensure world-class discipline before a component enters `packages/design-system/src/components/`. Invoke when user says「元件做完了」「這元件可以收工了嗎」「元件 ready 嗎」「check 這個 element」「要 merge 進 DS 了」or before closing a component PR.
3
+ description: Pre-merge quality gate for new or significantly refactored design-system components. Walks through Spec / Code / Stories / Ship checklist (35 items) to ensure world-class discipline before a component enters `packages/design-system/src/components/`. Invoke when user says「元件做完了」「這元件可以收工了嗎」「元件 ready 嗎」「check 這個 element」「要 merge 進 DS 了」or before closing a component PR.
4
4
  ---
5
5
 
6
6
  # Component Quality Gate
@@ -75,7 +75,7 @@ cva `defaultVariants` 異動 → 強制 grep 該元件所有檔案確認三方
75
75
  5. Chain `/ux-audit --scope=component:{Name}`(D4)
76
76
  6. **D6 真 scan**:讀 `.claude/skills/design-system-audit/references/principle-audit-protocol.md` 對該元件 + 其 spec 跨指的 kin specs 跑 4 子維(合理 / 一致 / 無矛盾 / 完整);先讀「常見 FP 記憶」節避免誤報
77
77
  7. 彙整 6 維 findings:**依 protocol 判斷公式 — 動 canonical substantive → STOP;對齊 canonical → AUTO**
78
- 8. **Self-improvement capture**(強制):Phase 結束寫「新 FP / 新 pattern / user 糾正」—見 CLAUDE.md `# 資訊治理 canonical` → Audit skill Phase F 節
78
+ 8. **Self-improvement capture**(強制):Phase 結束寫「新 FP / 新 pattern / user 糾正」—見 CLAUDE.md `# 治理 canonical` → Audit skill Phase F 節
79
79
 
80
80
  **為什麼 mandatory**:code / spec 對不夠;效能 / UX / 視覺三維各有歷史 bug(DatePicker 四邊不對稱、DropdownMenu 鍵盤不通、Badge 位置離譜、Rating 邊框、Carousel 箭頭壓文字、inline 物件 prop 造成 render 爆)。merge 前沒過 6 維 = 把 bug 帶進 DS。
81
81
 
@@ -84,7 +84,7 @@ cva `defaultVariants` 異動 → 強制 grep 該元件所有檔案確認三方
84
84
  ### Phase 5 — 簽結(Checkpoint — STOP 點)
85
85
 
86
86
  全部打勾後,回報 user:
87
- - 「元件 {Name} 已過 quality gate,46 項全綠(含 Layer A visual)+ Layer B AI 視覺判斷通過」
87
+ - 「元件 {Name} 已過 quality gate,35 項全綠(含 Layer A visual)+ Layer B AI 視覺判斷通過」
88
88
  - 列出 Phase 1-4.5 各 section 打勾結果
89
89
  - 列出 `snapshots/report.json` 摘要(contrast / geometry violation 數 = 0)
90
90
  - 若任一 phase 有合理例外(documented 在 spec),列出例外清單
@@ -93,10 +93,10 @@ cva `defaultVariants` 異動 → 強制 grep 該元件所有檔案確認三方
93
93
 
94
94
  ## References
95
95
 
96
- - `references/checklist.md` — 完整 45 項 checklist(Spec 12 / Code 13 / Stories 6 / Ship 4 + 各項的 CLAUDE.md pointer)
96
+ - `references/checklist.md` — 完整 35 項 checklist(Spec 12 / Code 13 / Stories 6 / Ship 4 + 各項的 CLAUDE.md pointer)
97
97
 
98
98
  ## 相關
99
99
 
100
- - `.claude/skills/design-system-audit/` — 本 skill focus 在單元件進 DS 的 gate;design-system-audit 是系統級 20 sweep,兩者互補
100
+ - `.claude/skills/design-system-audit/` — 本 skill focus 在單元件進 DS 的 gate;design-system-audit 是系統級 full-dim sweep(per design-system-audit SSOT),兩者互補
101
101
  - `.claude/skills/story-writing/` — Phase 3 story 深審可 chain 進去
102
- - `.claude/hooks/pre_edit_spec_check.sh` — 編輯 tsx 前提醒讀 spec(session 級)
102
+ - `.claude/hooks/pre_edit_spec_check.sh`(retired;改靠 M3 mindset #3「改一處看三處」)— 編輯 tsx 前提醒讀 spec(session 級)
@@ -6,33 +6,7 @@ arguments: scope?=full|changed focus?=「ssot|visual|behavior|all」
6
6
 
7
7
  # Deep Audit Cross-Codex — 雙 model adversarial 完整 DS 稽核
8
8
 
9
- > **SSOT integrity invariant**(2026-05-18 user-mandated):本 skill audit dim list **完全 chain `/design-system-audit --deep` SSOT**(`.claude/skills/design-system-audit/SKILL.md` `## The N audit dimensions` 段)。
10
- >
11
- > **禁** hardcode dim count(`46 dim` / `53 dim` 等具體數字)— 用「全 dim」/「Group A-P」/「per design-system-audit SSOT」表達。新增 / 刪除 / 修改稽核項目 → **只動 design-system-audit/SKILL.md**,本 skill 自動繼承。
12
- >
13
- > Mechanical 強制:hook `check_dim_count_drift.sh` 攔 Edit 寫死數字。
14
-
15
- **生態位**:`/design-system-audit --deep` 是 Claude solo 全 dim 稽核 SSOT;本 skill 是**雙 model 完整 sweep**(Claude solo → codex parallel → 比稿辯論共識 → 落地),chain 既有 audit dim 不 fork。
16
-
17
- **上游 canonical 全繼承(2026-05-29 加明示,per user「避免膨脹但別漏」directive)**:本 skill 繼承 CLAUDE.md 6 mindset 全(對標世界級 / 優先消費 / 改一處看三處 / 範例真實 / 猶豫就問 / 大原則吸收瑣碎) + meta-patterns 31 active M-rules 全(M1-M32,M27/M33/M34/M35 retired)+ 治理 8-home canonical + 自主執行 7 軸 canonical + 命名 SSOT 3-test。**Skill 不重述上游內容(避 R19 膨脹),全靠 chain reference**。
18
-
19
- 對齊 mindset #1「不取巧省工」+ M31 dual-track + 用戶 2026-05-18 directive(verbatim):
20
-
21
- > 「完整深度進階稽核整個 design system」+「codex 跑相同的完整深度進階稽核」+「跟 codex 討論辯論出共識」+「SSOT-UI/UX 增刪改需要用中文具體人話言簡意賅地講給我聽讓我判斷決策,其他的決策基本上就是不以省工為前提...自主自動自發地做到完整、完美」
22
-
23
- **+ 用戶 2026-05-29 directive(verbatim,permanent codify)**:
24
-
25
- > 「你應該要確保任何 infra 包括各種 Claude.md, skills, hooks 等在 ds repo, template repo, fork template 的 repo, 都能正常順利如預期的運作達到預期的效果, 且流程都正確無誤,且該維持 SSOT 的部分又能完全維持」+「我們的工作流程就是用 claude code 直接連去 repo 進行各種增刪改, 然後要可以部署出來讓人驗證, 驗證完成之後再推去 main」+「確保環境建置是能夠全雲端的, 且該自動化的就自動化, 真的無法自動化的要有具體的言簡意賅的中文明確引導」+「確保所有原則都是足夠泛化可以用來舉一反三的原則, 避免原則無限膨脹, 沒有多餘重複的且是 SSOT, 並確保所有 infra 都是最佳有效率的 claude code 實務, 並確保 infra 能夠產出世界級的設計並符合我們一致的設計語言和確保 ssot, 然後所有程式碼都是乾淨簡潔易懂好維護好管理的, 且是會有大腦地自動優化不斷改善, 確保自己永遠符合上述原則」
26
-
27
- **機械強制 R18-R26 對齊**:
28
- - R18 泛化 / 舉一反三 → 上游 mindset #6 + meta-patterns velocity ≤ 3/quarter(`/knowledge-prune`)
29
- - R19 避免膨脹 → 上游治理 canonical 行數預算 + `/knowledge-prune` 季度
30
- - R20 無多餘重複 SSOT → 上游 Rule-of-3(`/knowledge-prune` D1 + ensure-canonical Phase 3)
31
- - R21 最佳 Claude Code 實務 → 上游「世界級對照」section
32
- - R22 世界級 + 一致設計 → 上游 mindset #1 + A.3 7 目標 simultaneous
33
- - R24 code clean → chain `/code-quality-audit`(Phase A.4 verify chain)
34
- - R25 大腦自動 self-improve → chain `/ensure-canonical` Phase F + M14
35
- - R26 永遠符合 → M19 trigger phrase auto-pipeline(`stop_self_audit.sh` 機械強制)
9
+ 上游 context / 框架(SSOT integrity invariant + 生態位 + canonical 全繼承)+ user-verbatim directives(2026-05-18 + 2026-05-29)+ 機械強制 R18-R26 對齊清單 references/upstream-directives-r-mapping.md
36
10
 
37
11
  ## When to invoke
38
12
 
@@ -66,7 +40,7 @@ detect_mode() {
66
40
 
67
41
  | Mode | A.0 全盤閱讀 scope | A.1 audit dim scope | Phase B codex scope |
68
42
  |---|---|---|---|
69
- | **ds-repo**(DS owner workflow,含 template SSOT 編輯)| full DS canonical + spec + token + pattern + memory + `template/ds-product-template/` scaffold | 全 dim per `/design-system-audit --deep` SSOT(含 dim 83 cross-3-repo runtime audit)| 全 dim parallel verify |
43
+ | **ds-repo**(DS owner workflow,含 template SSOT 編輯)| full DS canonical + spec + token + pattern + memory + `template/ds-product-template/` scaffold | 全 dim per `/design-system-audit --deep` SSOT(含 dim 83 cross-3-repo runtime audit)**+ chain `/product-ui-audit` 對 `apps/template`**(DS owner dogfood 自家消費端 surface,用 fork user 同等產品標準把關)| 全 dim parallel verify |
70
44
  | **fork-user-repo**(published template repo / fork user product repo)| `node_modules/@qijenchen/design-system/CLAUDE.md` + `ds-canonical/rules/meta-patterns.md` + `apps/**` + 本 repo `CLAUDE.md` | dim 83 fork-side runtime checks(hook fire / cross-load / setup-netlify smoke / deploy URL hook live) + dim 62-67 consumer subset | 同 dim,fork-side verify;**禁** propose DS source change |
71
45
 
72
46
  ### Fork-mode safety invariants(2026-05-29 加)
@@ -88,7 +62,7 @@ detect_mode() {
88
62
  1. `CLAUDE.md` 全文
89
63
  2. `.claude/rules/{meta-patterns,spec-rules,ui-development,story-rules,self-verify}.md` 全文
90
64
  3. `.claude/references/{ssot-index,ssot-consultation,build-ui-canonicals,naming-conventions}.md`
91
- 4. `packages/design-system/src/**/*.spec.md` 全部(60+ file,通過 Glob 列舉 + Read)
65
+ 4. `packages/design-system/src/**/*.spec.md` 全部(83 file,通過 Glob 列舉 + Read)
92
66
  5. `packages/design-system/src/tokens/**/*.spec.md` + `packages/design-system/src/patterns/**/*.spec.md` 全部
93
67
  6. 本 session 對話脈絡 + memory `~/.claude/.../memory/MEMORY.md` index + active project memory files
94
68
 
@@ -271,32 +245,5 @@ Send via `codex exec`(local CLI per M31 Step 0.4)或 cloud `@codex` 後序。
271
245
  - `references/phase-a-workflow.md` — A.0 全盤閱讀 file list canonical + A.1 全 dim sub-agent dispatch template
272
246
  - `references/phase-b-codex-brief.md` — codex brief template(B.1)+ Step 4.5 verify checklist + Step 5 比稿 matrix template
273
247
  - `references/triage-rubric.md` — Scope classifier(SSOT-UI/UX vs non-SSOT)+ 中文人話 propose format + 7 autonomous 目標 expansion
274
-
275
- ## 與其他 skill 分工
276
-
277
- | Skill | Scope | 不重疊 |
278
- |---|---|---|
279
- | `/design-system-audit --deep` | 全 dim Claude solo audit | 本 skill chain 為 Phase A.1,額外 Phase B + 全盤閱讀 preflight + 比稿辯論 |
280
- | `/codex-collab` | M31 5-step dual-track for **任意題目** | 本 skill chain 為 Phase B,額外 Phase A 前置 + 全 dim 完整覆蓋(per design-system-audit SSOT) + Phase C 共識 commit |
281
- | `/propose-options` | M18 4-Q gate single propose | 本 skill A.2 / B.5 chain 用它格式化 propose |
282
- | `/ensure-canonical` | M19 5-layer auto-pipeline | 本 skill A.3 / B.5 chain 用它落地 canonical |
283
- | `/knowledge-prune` | 治理文件冗贅清 | **Transitively chained**:Phase A.1 chain `/design-system-audit --deep` → Phase 4.5 auto-chain `/knowledge-prune`(per `design-system-audit/SKILL.md:334-340` 9-trigger 條件)。SSOT 透過 `Skill` tool 直接 invoke,**不**重寫 prune logic / **不**複製 phase。Mechanical signal:`check_audit_post_report_validator.sh:81` emit `prune-chain-trigger` → `inject_pending_self_audit.sh` parse `.claude/logs/audit-post-report-validator.jsonl` → next-turn inject directive |
284
- | `/bug-fix-rhythm` | surgical visual bug 修 | 正交,本 skill 是 broad sweep;surgical bug 不該觸發本 skill |
285
-
286
- ## Anti-pattern(永久 ban)
287
-
288
- - ❌ Skip A.0 全盤閱讀(憑記憶判斷哪些 spec 該讀)
289
- - ❌ A.1 sub-agent prompt 含「sample top N」/「heavy agent skip」escape
290
- - ❌ A.2 propose 用 jargon(L1-L7 / SSOT / canonical 在 propose 內裸用)
291
- - ❌ 跳 Phase B 只跑 Phase A(除非 codex transport 全失敗 + user 同意)
292
- - ❌ B.2 收 codex reply 直接 paste 給 user(pass-through,M31 Step 4.5 verify 跳)
293
- - ❌ B.4 disagreement 用直覺 vote / 「兩邊都對」打太極(cite battle invariant)
294
- - ❌ C.2 AI 自決 merge main(M28 violation)
295
- - ❌ Phase A 完成沒等 user 拍板 SSOT-UI/UX 就進 Phase B(scope 跑掉)
296
-
297
- ## 世界級對照
298
-
299
- - **RFC 學術同儕審查**:作者 v1 + reviewer v2(獨立)+ public cite battle 收斂共識
300
- - **Linux kernel patch review**:Maintainer first-pass + lkml mailing list 二 review + cite source 比稿
301
- - **Google ML eng-design-review**:proposer + adversarial reviewer + structured disagreement protocol
302
- - **Anthropic constitutional AI critic + revise**:同 model 不同 prompt 互審 → 本 skill 升級成跨 model
248
+ - `references/upstream-directives-r-mapping.md` — 上游 context / 框架(SSOT integrity invariant + 生態位 + canonical 全繼承)+ user-verbatim directives(2026-05-18 + 2026-05-29)+ 機械強制 R18-R26 對齊清單
249
+ - `references/skill-relationships-antipatterns-benchmarks.md` — 與其他 skill 分工 + Anti-pattern(永久 ban)+ 世界級對照
@@ -23,8 +23,8 @@
23
23
  ### DS spec.md(全部)
24
24
  ```bash
25
25
  # 列舉所有 spec.md
26
- find src/design-system -name "*.spec.md" -type f
27
- # 預期 ~60 file:components/* + patterns/* + tokens/*
26
+ find packages/design-system/src -name "*.spec.md" -type f
27
+ # 預期 ~83 file:components/* + patterns/* + tokens/*
28
28
  ```
29
29
 
30
30
  每個必 Read 全文(spec ≤ 300 lines budget,foundational SSOT ≤ 800-1200)。