tribunal-kit 4.3.0 → 4.3.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/.agent/scripts/case_law_manager.js +684 -684
- package/.agent/scripts/graph_builder.js +199 -0
- package/.agent/scripts/graph_zoom.js +154 -0
- package/.agent/skills/agent-organizer/SKILL.md +9 -1
- package/.agent/skills/agentic-patterns/SKILL.md +9 -1
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +9 -1
- package/.agent/skills/api-patterns/SKILL.md +206 -198
- package/.agent/skills/api-security-auditor/SKILL.md +9 -1
- package/.agent/skills/app-builder/SKILL.md +9 -1
- package/.agent/skills/app-builder/templates/SKILL.md +77 -69
- package/.agent/skills/appflow-wireframe/SKILL.md +9 -1
- package/.agent/skills/architecture/SKILL.md +9 -1
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -1
- package/.agent/skills/bash-linux/SKILL.md +9 -1
- package/.agent/skills/behavioral-modes/SKILL.md +9 -1
- package/.agent/skills/brainstorming/SKILL.md +9 -1
- package/.agent/skills/building-native-ui/SKILL.md +9 -1
- package/.agent/skills/clean-code/SKILL.md +9 -1
- package/.agent/skills/code-review-checklist/SKILL.md +9 -1
- package/.agent/skills/config-validator/SKILL.md +9 -1
- package/.agent/skills/csharp-developer/SKILL.md +9 -1
- package/.agent/skills/data-validation-schemas/SKILL.md +287 -279
- package/.agent/skills/database-design/SKILL.md +199 -191
- package/.agent/skills/deployment-procedures/SKILL.md +9 -1
- package/.agent/skills/devops-engineer/SKILL.md +9 -1
- package/.agent/skills/devops-incident-responder/SKILL.md +9 -1
- package/.agent/skills/documentation-templates/SKILL.md +9 -1
- package/.agent/skills/edge-computing/SKILL.md +9 -1
- package/.agent/skills/error-resilience/SKILL.md +387 -379
- package/.agent/skills/extract-design-system/SKILL.md +9 -1
- package/.agent/skills/framer-motion-expert/SKILL.md +203 -195
- package/.agent/skills/frontend-design/SKILL.md +160 -152
- package/.agent/skills/game-design-expert/SKILL.md +9 -1
- package/.agent/skills/game-engineering-expert/SKILL.md +9 -1
- package/.agent/skills/geo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/github-operations/SKILL.md +9 -1
- package/.agent/skills/gsap-core/SKILL.md +54 -46
- package/.agent/skills/gsap-frameworks/SKILL.md +54 -46
- package/.agent/skills/gsap-performance/SKILL.md +54 -46
- package/.agent/skills/gsap-plugins/SKILL.md +54 -46
- package/.agent/skills/gsap-react/SKILL.md +54 -46
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -46
- package/.agent/skills/gsap-timeline/SKILL.md +54 -46
- package/.agent/skills/gsap-utils/SKILL.md +54 -46
- package/.agent/skills/i18n-localization/SKILL.md +9 -1
- package/.agent/skills/intelligent-routing/SKILL.md +38 -30
- package/.agent/skills/knowledge-graph/SKILL.md +36 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -1
- package/.agent/skills/llm-engineering/SKILL.md +9 -1
- package/.agent/skills/local-first/SKILL.md +9 -1
- package/.agent/skills/mcp-builder/SKILL.md +9 -1
- package/.agent/skills/mobile-design/SKILL.md +222 -214
- package/.agent/skills/monorepo-management/SKILL.md +293 -285
- package/.agent/skills/motion-engineering/SKILL.md +193 -185
- package/.agent/skills/nextjs-react-expert/SKILL.md +193 -185
- package/.agent/skills/nodejs-best-practices/SKILL.md +9 -1
- package/.agent/skills/observability/SKILL.md +9 -1
- package/.agent/skills/parallel-agents/SKILL.md +9 -1
- package/.agent/skills/performance-profiling/SKILL.md +9 -1
- package/.agent/skills/plan-writing/SKILL.md +9 -1
- package/.agent/skills/platform-engineer/SKILL.md +9 -1
- package/.agent/skills/playwright-best-practices/SKILL.md +9 -1
- package/.agent/skills/powershell-windows/SKILL.md +9 -1
- package/.agent/skills/project-idioms/SKILL.md +9 -1
- package/.agent/skills/python-patterns/SKILL.md +9 -1
- package/.agent/skills/python-pro/SKILL.md +282 -274
- package/.agent/skills/react-specialist/SKILL.md +236 -228
- package/.agent/skills/readme-builder/SKILL.md +9 -1
- package/.agent/skills/realtime-patterns/SKILL.md +9 -1
- package/.agent/skills/red-team-tactics/SKILL.md +9 -1
- package/.agent/skills/rust-pro/SKILL.md +9 -1
- package/.agent/skills/seo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/server-management/SKILL.md +9 -1
- package/.agent/skills/shadcn-ui-expert/SKILL.md +9 -1
- package/.agent/skills/skill-creator/SKILL.md +9 -1
- package/.agent/skills/sql-pro/SKILL.md +9 -1
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +9 -1
- package/.agent/skills/swiftui-expert/SKILL.md +9 -1
- package/.agent/skills/systematic-debugging/SKILL.md +9 -1
- package/.agent/skills/tailwind-patterns/SKILL.md +9 -1
- package/.agent/skills/tdd-workflow/SKILL.md +9 -1
- package/.agent/skills/test-result-analyzer/SKILL.md +9 -1
- package/.agent/skills/testing-patterns/SKILL.md +9 -1
- package/.agent/skills/trend-researcher/SKILL.md +9 -1
- package/.agent/skills/typescript-advanced/SKILL.md +294 -286
- package/.agent/skills/ui-ux-pro-max/SKILL.md +9 -1
- package/.agent/skills/ui-ux-researcher/SKILL.md +9 -1
- package/.agent/skills/vue-expert/SKILL.md +234 -226
- package/.agent/skills/vulnerability-scanner/SKILL.md +9 -1
- package/.agent/skills/web-accessibility-auditor/SKILL.md +9 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +9 -1
- package/.agent/skills/webapp-testing/SKILL.md +9 -1
- package/.agent/skills/whimsy-injector/SKILL.md +9 -1
- package/.agent/skills/workflow-optimizer/SKILL.md +9 -1
- package/README.md +242 -242
- package/bin/tribunal-kit.js +30 -22
- package/package.json +81 -80
- package/scripts/validate-payload.js +73 -0
|
@@ -164,35 +164,35 @@ This file contains all available skills and workflows as a condensed index for t
|
|
|
164
164
|
|`web-design-guidelines`|Review UI code for Next-Generation Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".|
|
|
165
165
|
|`webapp-testing`|Web application testing principles. E2E, Playwright, deep audit strategies.|
|
|
166
166
|
|`whimsy-injector`|Micro-delight generator for frontend interfaces. Suggests and implements subtle animations, playful transitions, and interaction polish across any frontend stack.|
|
|
167
|
-
|`workflow-optimizer`|Analyzes agent tool-calling patterns and task execution efficiency to suggest process improvements.|
|
|
168
|
-
|`api-architect`|API contract design agent. Builds robust REST/GraphQL/tRPC endpoints with RFC 9457 error formats, idempotency, pagination, and versioning. Use when designing new API routes or reviewing API contracts.|
|
|
169
|
-
|`resilience-reviewer`|Fault tolerance reviewer. Audits for swallowed errors, naked Promises, missing retries/timeouts, absent circuit breakers, and missing React error boundaries. Use when reviewing backend or full-stack code for reliability.|
|
|
170
|
-
|`schema-reviewer`|Input validation reviewer. Enforces strict Zod/Pydantic validation at all trust boundaries (API, env, query params). Catches `z.any()`, missing `.parse()`, and unvalidated external data. Use when reviewing data ingestion or API input handling.|
|
|
171
|
-
|`gsap-core`|GSAP core animation API — gsap.to(), from(), fromTo(), easing, stagger, defaults, matchMedia(). Use for JavaScript animation with GSAP.|
|
|
172
|
-
|`gsap-scrolltrigger`|GSAP ScrollTrigger plugin — scroll-driven animations, pinning, snapping. Use when building scroll-linked animation.|
|
|
173
|
-
|`gsap-timeline`|GSAP timeline sequencing — Timeline API, position parameters, labels, nesting. Use for multi-step animation choreography.|
|
|
174
|
-
|`gsap-react`|GSAP in React — useGSAP hook, ref-based targeting, cleanup, context scoping. Use when animating React components with GSAP.|
|
|
175
|
-
|`gsap-plugins`|GSAP plugins — Flip, Draggable, MorphSVG, SplitText, MotionPath, DrawSVG. Use for advanced GSAP effects.|
|
|
176
|
-
|`gsap-performance`|GSAP performance — will-change, GPU compositing, lazy MediaQuery, reduced motion. Use when optimizing GSAP animations.|
|
|
177
|
-
|`gsap-utils`|GSAP utility methods — toArray, clamp, mapRange, interpolate, distribute. Use for GSAP helper functions.|
|
|
178
|
-
|`gsap-frameworks`|GSAP framework integration — Vue, Svelte, Astro, Angular, Webflow. Use when integrating GSAP outside React.|
|
|
179
|
-
|`error-resilience`|Error resilience patterns. Retry strategies, circuit breakers, graceful degradation, timeout policies.|
|
|
180
|
-
|`data-validation-schemas`|Data validation with Zod, Pydantic, and JSON Schema. Use when building validation layers.|
|
|
181
|
-
|`monorepo-management`|Monorepo tooling and workspace management. Turborepo, Nx, pnpm workspaces.|
|
|
182
|
-
|`typescript-advanced`|Advanced TypeScript patterns. Generics, conditional types, template literals, discriminated unions.|
|
|
183
|
-
|`game-developer`|Game development orchestrator. Routes to platform-specific skills (Unity/C#, Godot/GDScript, WebGL). Use when building games or game engines.|
|
|
184
|
-
|`documentation-writer`|Technical documentation specialist. README files, API docs, code comments, architecture docs, and AI-friendly documentation. Use when writing or reviewing documentation.|
|
|
185
|
-
|`test-engineer`|Test generation and strategy specialist. Creates tests using the Testing Trophy (unit → integration → E2E). Use when generating tests or designing test architecture.|
|
|
186
|
-
|`qa-automation-engineer`|QA automation specialist. End-to-end testing pipelines, Playwright/Cypress configuration, CI test integration, visual regression. Use when building automated QA systems.|
|
|
187
|
-
|`code-archaeologist`|Legacy code exploration specialist. Navigates unfamiliar codebases, identifies patterns, maps dependencies, documents tribal knowledge. Use when exploring or understanding legacy code.|
|
|
188
|
-
|`project-planner`|Project planning specialist. 4-phase methodology (Analyze → Plan → Solution → Implement). Use when planning features, roadmaps, or multi-step implementations.|
|
|
189
|
-
|`product-manager`|Product strategy specialist. Feature prioritization, roadmap planning, stakeholder alignment, competitive analysis. Use when making product decisions or prioritizing features.|
|
|
190
|
-
|`product-owner`|User story and backlog management specialist. Writing acceptance criteria, sprint planning, backlog grooming. Use when defining user stories or managing backlogs.|
|
|
191
|
-
|`seo-specialist`|SEO optimization specialist. Technical SEO, meta tags, structured data (JSON-LD), Core Web Vitals impact on search ranking, sitemap/robots configuration. Use when optimizing search visibility.|
|
|
192
|
-
|`throughput-optimizer`|Throughput and latency optimization specialist. Load testing, connection pooling, queue management, batch processing, caching strategies. Use when optimizing system throughput or reducing latency.|
|
|
193
|
-
|`vitals-reviewer`|Core Web Vitals specialist. LCP, CLS, INP measurement and optimization, Lighthouse auditing, real user monitoring. Use when auditing or improving web performance metrics.|
|
|
194
|
-
|`penetration-tester`|Penetration testing and red team specialist. MITRE ATT&CK mapping, attack surface analysis, exploitation paths, vulnerability chaining. Use when pen testing applications or assessing attack surfaces.|
|
|
195
|
-
|`db-latency-auditor`|Database performance specialist. Slow query analysis, EXPLAIN ANALYZE, index optimization, N+1 detection, connection pool tuning. Use when debugging database performance issues.|
|
|
167
|
+
|`workflow-optimizer`|Analyzes agent tool-calling patterns and task execution efficiency to suggest process improvements.|
|
|
168
|
+
|`api-architect`|API contract design agent. Builds robust REST/GraphQL/tRPC endpoints with RFC 9457 error formats, idempotency, pagination, and versioning. Use when designing new API routes or reviewing API contracts.|
|
|
169
|
+
|`resilience-reviewer`|Fault tolerance reviewer. Audits for swallowed errors, naked Promises, missing retries/timeouts, absent circuit breakers, and missing React error boundaries. Use when reviewing backend or full-stack code for reliability.|
|
|
170
|
+
|`schema-reviewer`|Input validation reviewer. Enforces strict Zod/Pydantic validation at all trust boundaries (API, env, query params). Catches `z.any()`, missing `.parse()`, and unvalidated external data. Use when reviewing data ingestion or API input handling.|
|
|
171
|
+
|`gsap-core`|GSAP core animation API — gsap.to(), from(), fromTo(), easing, stagger, defaults, matchMedia(). Use for JavaScript animation with GSAP.|
|
|
172
|
+
|`gsap-scrolltrigger`|GSAP ScrollTrigger plugin — scroll-driven animations, pinning, snapping. Use when building scroll-linked animation.|
|
|
173
|
+
|`gsap-timeline`|GSAP timeline sequencing — Timeline API, position parameters, labels, nesting. Use for multi-step animation choreography.|
|
|
174
|
+
|`gsap-react`|GSAP in React — useGSAP hook, ref-based targeting, cleanup, context scoping. Use when animating React components with GSAP.|
|
|
175
|
+
|`gsap-plugins`|GSAP plugins — Flip, Draggable, MorphSVG, SplitText, MotionPath, DrawSVG. Use for advanced GSAP effects.|
|
|
176
|
+
|`gsap-performance`|GSAP performance — will-change, GPU compositing, lazy MediaQuery, reduced motion. Use when optimizing GSAP animations.|
|
|
177
|
+
|`gsap-utils`|GSAP utility methods — toArray, clamp, mapRange, interpolate, distribute. Use for GSAP helper functions.|
|
|
178
|
+
|`gsap-frameworks`|GSAP framework integration — Vue, Svelte, Astro, Angular, Webflow. Use when integrating GSAP outside React.|
|
|
179
|
+
|`error-resilience`|Error resilience patterns. Retry strategies, circuit breakers, graceful degradation, timeout policies.|
|
|
180
|
+
|`data-validation-schemas`|Data validation with Zod, Pydantic, and JSON Schema. Use when building validation layers.|
|
|
181
|
+
|`monorepo-management`|Monorepo tooling and workspace management. Turborepo, Nx, pnpm workspaces.|
|
|
182
|
+
|`typescript-advanced`|Advanced TypeScript patterns. Generics, conditional types, template literals, discriminated unions.|
|
|
183
|
+
|`game-developer`|Game development orchestrator. Routes to platform-specific skills (Unity/C#, Godot/GDScript, WebGL). Use when building games or game engines.|
|
|
184
|
+
|`documentation-writer`|Technical documentation specialist. README files, API docs, code comments, architecture docs, and AI-friendly documentation. Use when writing or reviewing documentation.|
|
|
185
|
+
|`test-engineer`|Test generation and strategy specialist. Creates tests using the Testing Trophy (unit → integration → E2E). Use when generating tests or designing test architecture.|
|
|
186
|
+
|`qa-automation-engineer`|QA automation specialist. End-to-end testing pipelines, Playwright/Cypress configuration, CI test integration, visual regression. Use when building automated QA systems.|
|
|
187
|
+
|`code-archaeologist`|Legacy code exploration specialist. Navigates unfamiliar codebases, identifies patterns, maps dependencies, documents tribal knowledge. Use when exploring or understanding legacy code.|
|
|
188
|
+
|`project-planner`|Project planning specialist. 4-phase methodology (Analyze → Plan → Solution → Implement). Use when planning features, roadmaps, or multi-step implementations.|
|
|
189
|
+
|`product-manager`|Product strategy specialist. Feature prioritization, roadmap planning, stakeholder alignment, competitive analysis. Use when making product decisions or prioritizing features.|
|
|
190
|
+
|`product-owner`|User story and backlog management specialist. Writing acceptance criteria, sprint planning, backlog grooming. Use when defining user stories or managing backlogs.|
|
|
191
|
+
|`seo-specialist`|SEO optimization specialist. Technical SEO, meta tags, structured data (JSON-LD), Core Web Vitals impact on search ranking, sitemap/robots configuration. Use when optimizing search visibility.|
|
|
192
|
+
|`throughput-optimizer`|Throughput and latency optimization specialist. Load testing, connection pooling, queue management, batch processing, caching strategies. Use when optimizing system throughput or reducing latency.|
|
|
193
|
+
|`vitals-reviewer`|Core Web Vitals specialist. LCP, CLS, INP measurement and optimization, Lighthouse auditing, real user monitoring. Use when auditing or improving web performance metrics.|
|
|
194
|
+
|`penetration-tester`|Penetration testing and red team specialist. MITRE ATT&CK mapping, attack surface analysis, exploitation paths, vulnerability chaining. Use when pen testing applications or assessing attack surfaces.|
|
|
195
|
+
|`db-latency-auditor`|Database performance specialist. Slow query analysis, EXPLAIN ANALYZE, index optimization, N+1 detection, connection pool tuning. Use when debugging database performance issues.|
|
|
196
196
|
|`ai-code-reviewer`|AI/LLM integration code reviewer. Hallucinated model names, invented API parameters, prompt injection vulnerabilities, missing rate limits, streaming error handling. Use when reviewing code that calls LLM APIs.|
|
|
197
197
|
|
|
198
198
|
|
|
@@ -235,4 +235,12 @@ Review these questions before confirming output:
|
|
|
235
235
|
|
|
236
236
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
237
237
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
238
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
238
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
## Pre-Flight Checklist
|
|
242
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
243
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
244
|
+
|
|
245
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
246
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Knowledge Graph Analyzer
|
|
3
|
+
description: Understands the architecture and dependencies of the codebase without token bloat.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /graph — Knowledge Graph Skill
|
|
8
|
+
|
|
9
|
+
Use this skill when the user types `/graph` or when you need to deeply understand the architecture of an unfamiliar codebase without suffering from context-window bloat.
|
|
10
|
+
|
|
11
|
+
## Pre-Flight Checklist
|
|
12
|
+
Before answering architectural questions or making broad code changes, you must understand the environment.
|
|
13
|
+
- [ ] Have I run the Macro Mapper to get the high-level architecture?
|
|
14
|
+
- [ ] Have I used the Micro Zoomer on the specific files related to the user's request to see their exact signatures?
|
|
15
|
+
|
|
16
|
+
## Execution Protocol
|
|
17
|
+
|
|
18
|
+
1. **Step 1: The Macro Map (World View)**
|
|
19
|
+
Execute the graph builder to map module boundaries. This runs incrementally and respects `.gitignore`.
|
|
20
|
+
```bash
|
|
21
|
+
node .agent/scripts/graph_builder.js
|
|
22
|
+
```
|
|
23
|
+
Read the output file at `.agent/history/architecture-graph.yaml`. **Do NOT try to read every file in the project.** Use this map to identify which files export the functions or components you need.
|
|
24
|
+
|
|
25
|
+
2. **Step 2: The Micro Zoom (Street View)**
|
|
26
|
+
Once you know which file to investigate, use the zoomer to get its structural skeleton. This strips out the internal logic and returns only imports, exports, class signatures, and function parameters.
|
|
27
|
+
```bash
|
|
28
|
+
node .agent/scripts/graph_zoom.js --focus <path_to_file>
|
|
29
|
+
```
|
|
30
|
+
*Example: `node .agent/scripts/graph_zoom.js --focus src/components/Button.tsx`*
|
|
31
|
+
|
|
32
|
+
3. **Step 3: Analyze and Advise**
|
|
33
|
+
Present the user with your findings. Highlight hidden dependencies, circular imports, or structural insights based on what you discovered in the graphs.
|
|
34
|
+
|
|
35
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
36
|
+
You are explicitly forbidden from guessing or "hallucinating" what functions, props, or variables exist inside a file. You MUST use the `graph_zoom.js` script to verify a component's exact signature before you attempt to call it, mock it, or rewrite it.
|
|
@@ -250,4 +250,12 @@ Review these questions before confirming output:
|
|
|
250
250
|
|
|
251
251
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
252
252
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
253
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
253
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
## Pre-Flight Checklist
|
|
257
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
258
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
259
|
+
|
|
260
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
261
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -383,4 +383,12 @@ Review these questions before confirming output:
|
|
|
383
383
|
|
|
384
384
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
385
385
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
386
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
386
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
## Pre-Flight Checklist
|
|
390
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
391
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
392
|
+
|
|
393
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
394
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -167,4 +167,12 @@ Review these questions before confirming output:
|
|
|
167
167
|
|
|
168
168
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
169
169
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
170
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
170
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
## Pre-Flight Checklist
|
|
174
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
175
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
176
|
+
|
|
177
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
178
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -131,4 +131,12 @@ Review these questions before confirming output:
|
|
|
131
131
|
|
|
132
132
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
133
133
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
134
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
134
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## Pre-Flight Checklist
|
|
138
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
139
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
140
|
+
|
|
141
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
142
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -1,216 +1,216 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: mobile-design
|
|
3
|
-
description: Mobile-first design for iOS, Android, Foldables, React Native, Flutter. Touch interaction, haptics, 120Hz performance, on-device AI, spatial UI, Reanimated 3. Use when building mobile UI, animations, or cross-platform apps.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version: 3.1.0
|
|
6
|
-
last-updated: 2026-04-06
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Mobile Design — Dense Reference
|
|
10
|
-
|
|
11
|
-
## Hallucination Traps (Read First)
|
|
12
|
-
- ❌ `Animated.View` for any animation → ✅ `Reanimated 3` worklets (Animated API is legacy, runs on JS thread)
|
|
13
|
-
- ❌ `ScrollView` for lists → ✅ `FlashList` (Shopify) — ScrollView renders ALL items at once
|
|
14
|
-
- ❌ `estimatedItemSize` optional in FlashList → ✅ **REQUIRED** or you get 0-height items
|
|
15
|
-
- ❌ White backgrounds (`#FFFFFF`) → ✅ OLED: `#000000` true black; off-white: `#FAFAFA`
|
|
16
|
-
- ❌ Linear animations (`easing: linear`) → ✅ Spring physics (`stiffness`, `damping`)
|
|
17
|
-
- ❌ Touch targets < 48px → ✅ Min 48px hitbox (visual size can be smaller via padding)
|
|
18
|
-
- ❌ `useAnimatedStyle` in worklet without `'worklet'` directive → crashes on native thread
|
|
19
|
-
- ❌ iOS: `useSafeAreaInsets()` optional → ✅ Required — screen content goes under dynamic island/home indicator
|
|
20
|
-
- ❌ Android: hardcoded status bar height (24dp) → ✅ `StatusBar.currentHeight` (varies per device)
|
|
21
|
-
- ❌ Platform-specific code with `if (platform === 'ios')` scattered everywhere → ✅ centralize in platform/ files
|
|
22
|
-
- ❌ `console.log` in production → ✅ blocks JS thread — remove before release
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## React Native Performance
|
|
27
|
-
|
|
28
|
-
### FlashList (Required for Lists)
|
|
29
|
-
```tsx
|
|
30
|
-
import { FlashList } from "@shopify/flash-list";
|
|
31
|
-
<FlashList
|
|
32
|
-
data={items}
|
|
33
|
-
renderItem={({ item }) => <ItemCard item={item} />}
|
|
34
|
-
estimatedItemSize={100} // REQUIRED — measure actual item height first
|
|
35
|
-
keyExtractor={(item) => item.id}
|
|
36
|
-
getItemType={(item) => item.type} // multi-type optimization
|
|
37
|
-
/>
|
|
38
|
-
// ❌ NEVER: <ScrollView>{items.map(...)}</ScrollView> for lists
|
|
39
|
-
// ❌ NEVER: <FlatList> for perf-critical lists — FlashList is 5-10x faster
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Reanimated 3 — Worklet Animations (Required for 120Hz)
|
|
43
|
-
```tsx
|
|
44
|
-
import { useSharedValue, useAnimatedStyle, withSpring, withTiming, runOnJS } from 'react-native-reanimated';
|
|
45
|
-
|
|
46
|
-
// Shared values run on the UI thread — never on JS thread
|
|
47
|
-
const scale = useSharedValue(1);
|
|
48
|
-
const opacity = useSharedValue(0);
|
|
49
|
-
|
|
50
|
-
// Animated style — computed on UI thread (no bridge crossing)
|
|
51
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
52
|
-
transform: [{ scale: scale.value }],
|
|
53
|
-
opacity: opacity.value,
|
|
54
|
-
}));
|
|
55
|
-
|
|
56
|
-
// Triggers
|
|
57
|
-
const onPress = () => {
|
|
58
|
-
scale.value = withSpring(0.95, { stiffness: 400, damping: 15 });
|
|
59
|
-
opacity.value = withTiming(1, { duration: 200 });
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// Call JS function from worklet
|
|
63
|
-
const onComplete = () => runOnJS(setVisible)(true);
|
|
64
|
-
scale.value = withSpring(1, {}, onComplete);
|
|
65
|
-
|
|
66
|
-
// ❌ TRAP: Accessing shared value with .value inside useAnimatedStyle is fine — but inside a gesture handler callback, you need runOnJS to call React setState
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### 120Hz Animation Rules
|
|
70
|
-
- ✅ Animate ONLY: `transform` (translateX/Y, scale, rotate), `opacity` — all GPU composited
|
|
71
|
-
- ❌ Never animate: `width`, `height`, `margin`, `padding`, `top/left/bottom/right` — causes layout recalc at 60 times per second → janky, battery draining
|
|
72
|
-
- ✅ Use `withSpring` for all UI interactions (feel alive) — `withTiming` only for intentional timed animations
|
|
73
|
-
- ✅ `Gesture.Pan()` / `Gesture.Tap()` from `react-native-gesture-handler` v2 (not `PanResponder`)
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Haptics
|
|
78
|
-
```tsx
|
|
79
|
-
import * as Haptics from 'expo-haptics';
|
|
80
|
-
// light → switch toggle, tap feedback
|
|
81
|
-
// medium → selection change, confirm
|
|
82
|
-
// heavy → destructive action, strong confirm
|
|
83
|
-
// notificationAsync('success' | 'warning' | 'error') → operation outcomes
|
|
84
|
-
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); // tap, toggle
|
|
85
|
-
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success); // save complete
|
|
86
|
-
// ❌ Never overuse — haptics must mean something
|
|
87
|
-
// ❌ Haptics not supported on Android emulators — test on device
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Safe Areas & Platform Layout
|
|
93
|
-
```tsx
|
|
94
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
95
|
-
import { Platform, StatusBar } from 'react-native';
|
|
96
|
-
|
|
97
|
-
function Screen() {
|
|
98
|
-
const insets = useSafeAreaInsets();
|
|
99
|
-
return (
|
|
100
|
-
<View style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
|
|
101
|
-
{/* Content safe from Dynamic Island, home indicator, status bar */}
|
|
102
|
-
</View>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
// Android status bar
|
|
106
|
-
const STATUS_BAR_HEIGHT = Platform.OS === 'android' ? StatusBar.currentHeight ?? 24 : 0;
|
|
107
|
-
|
|
108
|
-
// Foldable/tablet — dual pane
|
|
109
|
-
import { useWindowDimensions } from 'react-native';
|
|
110
|
-
function AdaptiveLayout() {
|
|
111
|
-
const { width } = useWindowDimensions();
|
|
112
|
-
const isTablet = width >= 600;
|
|
113
|
-
return isTablet ? <TwoPaneView /> : <SinglePaneView />;
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Touch Psychology & Thumb Zones
|
|
120
|
-
- **Thumb zone**: Bottom 40% of screen = primary actions, FABs, CTAs
|
|
121
|
-
- **Dead zone**: Top 25% = destructive/rare actions only
|
|
122
|
-
- **48px minimum hitbox**: Visual icon can be 24px, padding expands hitbox to 48px
|
|
123
|
-
```tsx
|
|
124
|
-
// Magnetic padding — visually small, touch-friendly
|
|
125
|
-
<TouchableOpacity style={{ padding: 12, margin: -4 }}>
|
|
126
|
-
<Icon size={24} />
|
|
127
|
-
</TouchableOpacity>
|
|
128
|
-
```
|
|
129
|
-
- **Coyote time**: Allow 100–150ms buffer after button intent registers before processing — prevents mis-taps
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Navigation (Expo Router / React Navigation)
|
|
134
|
-
```tsx
|
|
135
|
-
// Expo Router v3+ (file-based, recommended)
|
|
136
|
-
// app/(tabs)/_layout.tsx — tab navigator
|
|
137
|
-
// app/[id].tsx — dynamic segment
|
|
138
|
-
// app/(modal)/settings.tsx — modal group
|
|
139
|
-
|
|
140
|
-
// Stack navigation with gesture
|
|
141
|
-
import { Stack } from 'expo-router';
|
|
142
|
-
<Stack screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
|
|
143
|
-
<Stack.Screen name="(tabs)" />
|
|
144
|
-
<Stack.Screen name="[id]" options={{ presentation: 'modal' }} />
|
|
145
|
-
</Stack>
|
|
146
|
-
|
|
147
|
-
// Deep linking (Expo Router handles automatically via app.json scheme)
|
|
148
|
-
// ❌ TRAP: Don't use react-navigation Link for deep links in Expo Router — use expo-router Link
|
|
149
|
-
import { Link, useRouter } from 'expo-router';
|
|
150
|
-
const router = useRouter();
|
|
151
|
-
router.push('/user/42');
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## On-Device AI UX Patterns
|
|
157
|
-
- **Zero-wait illusion**: When model runs → immediately show contextual skeleton/partial tokens
|
|
158
|
-
- **Progressive disclosure**: Low confidence → softer UI, soft colors, require confirmation
|
|
159
|
-
- **Streaming UI**: `useEffect` + SSE or `StreamingText` component appending tokens
|
|
160
|
-
- **Local models** (MediaPipe, Core ML, ONNX): always wrap in try/catch — device capability varies
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## Color & Typography
|
|
165
|
-
```tsx
|
|
166
|
-
// OLED-safe dark mode
|
|
167
|
-
const colors = {
|
|
168
|
-
background: '#000000', // true black — OLED pixel off
|
|
169
|
-
surface: '#0A0A0A', // cards
|
|
170
|
-
surfaceAlt: '#121212', // elevated surfaces
|
|
171
|
-
border: '#1F1F1F',
|
|
172
|
-
text: '#FFFFFF',
|
|
173
|
-
textMuted: '#8E8E93', // iOS system gray
|
|
174
|
-
};
|
|
175
|
-
// Dynamic type (iOS) — always use system font with scalesWithContentSizeCategory
|
|
176
|
-
import { Text } from 'react-native';
|
|
177
|
-
<Text style={{ fontSize: 16, fontFamily: Platform.OS === 'ios' ? 'System' : 'Roboto' }}>
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## Performance Checklist
|
|
183
|
-
| Issue | Fix |
|
|
184
|
-
|-------|-----|
|
|
185
|
-
| JS thread jank | Move ALL animations to Reanimated worklets |
|
|
186
|
-
| Slow list | Replace ScrollView/FlatList with FlashList |
|
|
187
|
-
| Image flicker | `Image` from `expo-image` (faster cache, blurhash) |
|
|
188
|
-
| Re-render cascade | `React.memo` + stable callbacks + Zustand selectors |
|
|
189
|
-
| Large bundle | Dynamic imports + Metro tree shaking |
|
|
190
|
-
| Memory leak | `useEffect` cleanup + cancel animation on unmount |
|
|
191
|
-
|
|
192
|
-
```tsx
|
|
193
|
-
// Cancel animation on unmount
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
opacity.value = withTiming(1);
|
|
196
|
-
return () => cancelAnimation(opacity); // ← critical
|
|
197
|
-
}, []);
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
## iOS-Specific
|
|
203
|
-
- **BlurView**: Use `@react-native-community/blur` for frosted glass nav bars/modals
|
|
204
|
-
- **SF Symbols**: Use `@expo/vector-icons/Ionicons` for system-native icons
|
|
205
|
-
- **Haptics**: `expo-haptics` — rich feedback on iOS, limited on Android
|
|
206
|
-
- **Dynamic Island**: Check `insets.top > 50` for Dynamic Island devices
|
|
207
|
-
- **Sheet presentations**: `presentation: 'formSheet'` in Expo Router for iOS bottom sheet native feel
|
|
208
|
-
|
|
209
|
-
## Android-Specific
|
|
210
|
-
- **Material You**: Use `react-native-paper` for M3 dynamic color theming
|
|
211
|
-
- **Edge-to-edge**: Set `android:windowLayoutInDisplayCutoutMode="shortEdges"` in AndroidManifest
|
|
212
|
-
- **Back gesture prediction**: Wrap routes in `GestureHandlerRootView` at root
|
|
213
|
-
- **Splash**: Use `expo-splash-screen` — never hardcode a delay
|
|
1
|
+
---
|
|
2
|
+
name: mobile-design
|
|
3
|
+
description: Mobile-first design for iOS, Android, Foldables, React Native, Flutter. Touch interaction, haptics, 120Hz performance, on-device AI, spatial UI, Reanimated 3. Use when building mobile UI, animations, or cross-platform apps.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 3.1.0
|
|
6
|
+
last-updated: 2026-04-06
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Mobile Design — Dense Reference
|
|
10
|
+
|
|
11
|
+
## Hallucination Traps (Read First)
|
|
12
|
+
- ❌ `Animated.View` for any animation → ✅ `Reanimated 3` worklets (Animated API is legacy, runs on JS thread)
|
|
13
|
+
- ❌ `ScrollView` for lists → ✅ `FlashList` (Shopify) — ScrollView renders ALL items at once
|
|
14
|
+
- ❌ `estimatedItemSize` optional in FlashList → ✅ **REQUIRED** or you get 0-height items
|
|
15
|
+
- ❌ White backgrounds (`#FFFFFF`) → ✅ OLED: `#000000` true black; off-white: `#FAFAFA`
|
|
16
|
+
- ❌ Linear animations (`easing: linear`) → ✅ Spring physics (`stiffness`, `damping`)
|
|
17
|
+
- ❌ Touch targets < 48px → ✅ Min 48px hitbox (visual size can be smaller via padding)
|
|
18
|
+
- ❌ `useAnimatedStyle` in worklet without `'worklet'` directive → crashes on native thread
|
|
19
|
+
- ❌ iOS: `useSafeAreaInsets()` optional → ✅ Required — screen content goes under dynamic island/home indicator
|
|
20
|
+
- ❌ Android: hardcoded status bar height (24dp) → ✅ `StatusBar.currentHeight` (varies per device)
|
|
21
|
+
- ❌ Platform-specific code with `if (platform === 'ios')` scattered everywhere → ✅ centralize in platform/ files
|
|
22
|
+
- ❌ `console.log` in production → ✅ blocks JS thread — remove before release
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## React Native Performance
|
|
27
|
+
|
|
28
|
+
### FlashList (Required for Lists)
|
|
29
|
+
```tsx
|
|
30
|
+
import { FlashList } from "@shopify/flash-list";
|
|
31
|
+
<FlashList
|
|
32
|
+
data={items}
|
|
33
|
+
renderItem={({ item }) => <ItemCard item={item} />}
|
|
34
|
+
estimatedItemSize={100} // REQUIRED — measure actual item height first
|
|
35
|
+
keyExtractor={(item) => item.id}
|
|
36
|
+
getItemType={(item) => item.type} // multi-type optimization
|
|
37
|
+
/>
|
|
38
|
+
// ❌ NEVER: <ScrollView>{items.map(...)}</ScrollView> for lists
|
|
39
|
+
// ❌ NEVER: <FlatList> for perf-critical lists — FlashList is 5-10x faster
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Reanimated 3 — Worklet Animations (Required for 120Hz)
|
|
43
|
+
```tsx
|
|
44
|
+
import { useSharedValue, useAnimatedStyle, withSpring, withTiming, runOnJS } from 'react-native-reanimated';
|
|
45
|
+
|
|
46
|
+
// Shared values run on the UI thread — never on JS thread
|
|
47
|
+
const scale = useSharedValue(1);
|
|
48
|
+
const opacity = useSharedValue(0);
|
|
49
|
+
|
|
50
|
+
// Animated style — computed on UI thread (no bridge crossing)
|
|
51
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
52
|
+
transform: [{ scale: scale.value }],
|
|
53
|
+
opacity: opacity.value,
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
// Triggers
|
|
57
|
+
const onPress = () => {
|
|
58
|
+
scale.value = withSpring(0.95, { stiffness: 400, damping: 15 });
|
|
59
|
+
opacity.value = withTiming(1, { duration: 200 });
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Call JS function from worklet
|
|
63
|
+
const onComplete = () => runOnJS(setVisible)(true);
|
|
64
|
+
scale.value = withSpring(1, {}, onComplete);
|
|
65
|
+
|
|
66
|
+
// ❌ TRAP: Accessing shared value with .value inside useAnimatedStyle is fine — but inside a gesture handler callback, you need runOnJS to call React setState
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 120Hz Animation Rules
|
|
70
|
+
- ✅ Animate ONLY: `transform` (translateX/Y, scale, rotate), `opacity` — all GPU composited
|
|
71
|
+
- ❌ Never animate: `width`, `height`, `margin`, `padding`, `top/left/bottom/right` — causes layout recalc at 60 times per second → janky, battery draining
|
|
72
|
+
- ✅ Use `withSpring` for all UI interactions (feel alive) — `withTiming` only for intentional timed animations
|
|
73
|
+
- ✅ `Gesture.Pan()` / `Gesture.Tap()` from `react-native-gesture-handler` v2 (not `PanResponder`)
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Haptics
|
|
78
|
+
```tsx
|
|
79
|
+
import * as Haptics from 'expo-haptics';
|
|
80
|
+
// light → switch toggle, tap feedback
|
|
81
|
+
// medium → selection change, confirm
|
|
82
|
+
// heavy → destructive action, strong confirm
|
|
83
|
+
// notificationAsync('success' | 'warning' | 'error') → operation outcomes
|
|
84
|
+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); // tap, toggle
|
|
85
|
+
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success); // save complete
|
|
86
|
+
// ❌ Never overuse — haptics must mean something
|
|
87
|
+
// ❌ Haptics not supported on Android emulators — test on device
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Safe Areas & Platform Layout
|
|
93
|
+
```tsx
|
|
94
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
95
|
+
import { Platform, StatusBar } from 'react-native';
|
|
96
|
+
|
|
97
|
+
function Screen() {
|
|
98
|
+
const insets = useSafeAreaInsets();
|
|
99
|
+
return (
|
|
100
|
+
<View style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
|
|
101
|
+
{/* Content safe from Dynamic Island, home indicator, status bar */}
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
// Android status bar
|
|
106
|
+
const STATUS_BAR_HEIGHT = Platform.OS === 'android' ? StatusBar.currentHeight ?? 24 : 0;
|
|
107
|
+
|
|
108
|
+
// Foldable/tablet — dual pane
|
|
109
|
+
import { useWindowDimensions } from 'react-native';
|
|
110
|
+
function AdaptiveLayout() {
|
|
111
|
+
const { width } = useWindowDimensions();
|
|
112
|
+
const isTablet = width >= 600;
|
|
113
|
+
return isTablet ? <TwoPaneView /> : <SinglePaneView />;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Touch Psychology & Thumb Zones
|
|
120
|
+
- **Thumb zone**: Bottom 40% of screen = primary actions, FABs, CTAs
|
|
121
|
+
- **Dead zone**: Top 25% = destructive/rare actions only
|
|
122
|
+
- **48px minimum hitbox**: Visual icon can be 24px, padding expands hitbox to 48px
|
|
123
|
+
```tsx
|
|
124
|
+
// Magnetic padding — visually small, touch-friendly
|
|
125
|
+
<TouchableOpacity style={{ padding: 12, margin: -4 }}>
|
|
126
|
+
<Icon size={24} />
|
|
127
|
+
</TouchableOpacity>
|
|
128
|
+
```
|
|
129
|
+
- **Coyote time**: Allow 100–150ms buffer after button intent registers before processing — prevents mis-taps
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Navigation (Expo Router / React Navigation)
|
|
134
|
+
```tsx
|
|
135
|
+
// Expo Router v3+ (file-based, recommended)
|
|
136
|
+
// app/(tabs)/_layout.tsx — tab navigator
|
|
137
|
+
// app/[id].tsx — dynamic segment
|
|
138
|
+
// app/(modal)/settings.tsx — modal group
|
|
139
|
+
|
|
140
|
+
// Stack navigation with gesture
|
|
141
|
+
import { Stack } from 'expo-router';
|
|
142
|
+
<Stack screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
|
|
143
|
+
<Stack.Screen name="(tabs)" />
|
|
144
|
+
<Stack.Screen name="[id]" options={{ presentation: 'modal' }} />
|
|
145
|
+
</Stack>
|
|
146
|
+
|
|
147
|
+
// Deep linking (Expo Router handles automatically via app.json scheme)
|
|
148
|
+
// ❌ TRAP: Don't use react-navigation Link for deep links in Expo Router — use expo-router Link
|
|
149
|
+
import { Link, useRouter } from 'expo-router';
|
|
150
|
+
const router = useRouter();
|
|
151
|
+
router.push('/user/42');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## On-Device AI UX Patterns
|
|
157
|
+
- **Zero-wait illusion**: When model runs → immediately show contextual skeleton/partial tokens
|
|
158
|
+
- **Progressive disclosure**: Low confidence → softer UI, soft colors, require confirmation
|
|
159
|
+
- **Streaming UI**: `useEffect` + SSE or `StreamingText` component appending tokens
|
|
160
|
+
- **Local models** (MediaPipe, Core ML, ONNX): always wrap in try/catch — device capability varies
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Color & Typography
|
|
165
|
+
```tsx
|
|
166
|
+
// OLED-safe dark mode
|
|
167
|
+
const colors = {
|
|
168
|
+
background: '#000000', // true black — OLED pixel off
|
|
169
|
+
surface: '#0A0A0A', // cards
|
|
170
|
+
surfaceAlt: '#121212', // elevated surfaces
|
|
171
|
+
border: '#1F1F1F',
|
|
172
|
+
text: '#FFFFFF',
|
|
173
|
+
textMuted: '#8E8E93', // iOS system gray
|
|
174
|
+
};
|
|
175
|
+
// Dynamic type (iOS) — always use system font with scalesWithContentSizeCategory
|
|
176
|
+
import { Text } from 'react-native';
|
|
177
|
+
<Text style={{ fontSize: 16, fontFamily: Platform.OS === 'ios' ? 'System' : 'Roboto' }}>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Performance Checklist
|
|
183
|
+
| Issue | Fix |
|
|
184
|
+
|-------|-----|
|
|
185
|
+
| JS thread jank | Move ALL animations to Reanimated worklets |
|
|
186
|
+
| Slow list | Replace ScrollView/FlatList with FlashList |
|
|
187
|
+
| Image flicker | `Image` from `expo-image` (faster cache, blurhash) |
|
|
188
|
+
| Re-render cascade | `React.memo` + stable callbacks + Zustand selectors |
|
|
189
|
+
| Large bundle | Dynamic imports + Metro tree shaking |
|
|
190
|
+
| Memory leak | `useEffect` cleanup + cancel animation on unmount |
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
// Cancel animation on unmount
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
opacity.value = withTiming(1);
|
|
196
|
+
return () => cancelAnimation(opacity); // ← critical
|
|
197
|
+
}, []);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## iOS-Specific
|
|
203
|
+
- **BlurView**: Use `@react-native-community/blur` for frosted glass nav bars/modals
|
|
204
|
+
- **SF Symbols**: Use `@expo/vector-icons/Ionicons` for system-native icons
|
|
205
|
+
- **Haptics**: `expo-haptics` — rich feedback on iOS, limited on Android
|
|
206
|
+
- **Dynamic Island**: Check `insets.top > 50` for Dynamic Island devices
|
|
207
|
+
- **Sheet presentations**: `presentation: 'formSheet'` in Expo Router for iOS bottom sheet native feel
|
|
208
|
+
|
|
209
|
+
## Android-Specific
|
|
210
|
+
- **Material You**: Use `react-native-paper` for M3 dynamic color theming
|
|
211
|
+
- **Edge-to-edge**: Set `android:windowLayoutInDisplayCutoutMode="shortEdges"` in AndroidManifest
|
|
212
|
+
- **Back gesture prediction**: Wrap routes in `GestureHandlerRootView` at root
|
|
213
|
+
- **Splash**: Use `expo-splash-screen` — never hardcode a delay
|
|
214
214
|
|
|
215
215
|
|
|
216
216
|
---
|
|
@@ -252,4 +252,12 @@ Review these questions before confirming output:
|
|
|
252
252
|
|
|
253
253
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
254
254
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
255
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
255
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
## Pre-Flight Checklist
|
|
259
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
260
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
261
|
+
|
|
262
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
263
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|