@haposoft/cafekit 0.15.3 → 0.16.0-rc.2

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 (90) hide show
  1. package/README.md +4 -2
  2. package/bin/__tests__/codex-hooks.test.js +140 -0
  3. package/bin/__tests__/codex-native.test.js +2 -2
  4. package/bin/__tests__/develop-contract.test.js +1120 -0
  5. package/bin/__tests__/installer-safety.test.js +510 -2
  6. package/bin/__tests__/package-inventory.test.js +258 -0
  7. package/bin/__tests__/secret-scanner.test.js +157 -0
  8. package/bin/__tests__/validator-grounding.test.js +713 -0
  9. package/bin/install.js +5 -1
  10. package/bin/lib/codex-install.js +21 -6
  11. package/bin/lib/context.js +17 -6
  12. package/bin/lib/copy-utils.js +31 -0
  13. package/bin/lib/instruction-blocks.js +85 -0
  14. package/bin/lib/managed-writer.js +4 -1
  15. package/bin/lib/opencode-install.js +75 -30
  16. package/bin/phases/claude-runtime.js +103 -4
  17. package/bin/phases/codex-runtime.js +9 -5
  18. package/bin/phases/post-install.js +29 -22
  19. package/bin/phases/root-config.js +89 -10
  20. package/package.json +14 -4
  21. package/src/claude/CLAUDE.md +6 -122
  22. package/src/claude/agents/code-auditor.md +28 -22
  23. package/src/claude/agents/debugger.md +3 -3
  24. package/src/claude/agents/deployer.md +1 -1
  25. package/src/claude/agents/{god-developer.md → implementer.md} +2 -2
  26. package/src/claude/agents/project-manager.md +1 -1
  27. package/src/claude/agents/spec-maker.md +2 -2
  28. package/src/claude/hooks/__tests__/spec-gate.test.js +356 -5
  29. package/src/claude/hooks/agent.cjs +7 -14
  30. package/src/claude/hooks/rules.cjs +33 -53
  31. package/src/claude/hooks/spec-gate.cjs +66 -21
  32. package/src/claude/hooks/spec-state.cjs +5 -0
  33. package/src/claude/migration-manifest.json +9 -2
  34. package/src/claude/runtime.json +0 -3
  35. package/src/claude/scripts/generate-skill-catalog.cjs +1 -1
  36. package/src/claude/scripts/scan-staged-secrets.cjs +170 -0
  37. package/src/claude/scripts/spec-ground.cjs +189 -83
  38. package/src/claude/scripts/validate-spec-output.cjs +294 -30
  39. package/src/claude/scripts/workflow-policy.cjs +609 -0
  40. package/src/claude/skills/ai-multimodal/SKILL.md +2 -2
  41. package/src/claude/skills/ai-multimodal/references/audio-processing.md +6 -6
  42. package/src/claude/skills/ai-multimodal/references/video-analysis.md +1 -1
  43. package/src/claude/skills/backend-development/SKILL.md +4 -4
  44. package/src/claude/skills/backend-development/references/backend-architecture.md +1 -1
  45. package/src/claude/skills/backend-development/references/backend-devops.md +2 -2
  46. package/src/claude/skills/backend-development/references/backend-mindset.md +3 -3
  47. package/src/claude/skills/backend-development/references/backend-performance.md +5 -5
  48. package/src/claude/skills/backend-development/references/backend-security.md +55 -3
  49. package/src/claude/skills/backend-development/references/backend-technologies.md +5 -5
  50. package/src/claude/skills/backend-development/references/backend-testing.md +2 -2
  51. package/src/claude/skills/brainstorm/SKILL.md +2 -3
  52. package/src/claude/skills/code-review/SKILL.md +12 -8
  53. package/src/claude/skills/code-review/references/verification-gate.md +4 -4
  54. package/src/claude/skills/debug/SKILL.md +2 -0
  55. package/src/claude/skills/develop/SKILL.md +100 -52
  56. package/src/claude/skills/develop/references/parallel-waves.md +105 -26
  57. package/src/claude/skills/develop/references/quality-gate.md +78 -38
  58. package/src/claude/skills/develop/references/subagent-patterns.md +2 -2
  59. package/src/claude/skills/git/SKILL.md +44 -50
  60. package/src/claude/skills/hotfix/SKILL.md +10 -8
  61. package/src/claude/skills/hotfix/references/parallel-patterns.md +2 -2
  62. package/src/claude/skills/hotfix/references/review-cycle.md +26 -21
  63. package/src/claude/skills/inspect/SKILL.md +12 -30
  64. package/src/claude/skills/mobile-development/SKILL.md +12 -12
  65. package/src/claude/skills/mobile-development/references/mobile-android.md +7 -7
  66. package/src/claude/skills/mobile-development/references/mobile-best-practices.md +22 -23
  67. package/src/claude/skills/mobile-development/references/mobile-frameworks.md +13 -13
  68. package/src/claude/skills/mobile-development/references/mobile-ios.md +1 -1
  69. package/src/claude/skills/mobile-development/references/mobile-mindset.md +17 -19
  70. package/src/claude/skills/question/SKILL.md +13 -13
  71. package/src/claude/skills/research/SKILL.md +2 -2
  72. package/src/claude/skills/specs/SKILL.md +32 -15
  73. package/src/claude/skills/specs/references/review.md +3 -3
  74. package/src/claude/skills/specs/rules/tasks-generation.md +1 -1
  75. package/src/claude/skills/specs/templates/spec-state.json +7 -3
  76. package/src/claude/skills/sync/SKILL.md +26 -1
  77. package/src/claude/skills/sync/references/sync-protocols.md +3 -3
  78. package/src/claude/skills/test/SKILL.md +12 -4
  79. package/src/claude/skills/test/references/failure-triage.md +17 -17
  80. package/src/claude/skills/test/references/test-memory.md +2 -2
  81. package/src/codex/AGENTS.md +16 -24
  82. package/src/codex/hooks/lib/spec-receipt.cjs +57 -4
  83. package/src/codex/hooks/rules.cjs +27 -26
  84. package/src/codex/hooks/spec-gate.cjs +19 -8
  85. package/src/codex/hooks/spec-state.cjs +10 -1
  86. package/src/common/AGENTS.md +43 -0
  87. package/src/opencode/AGENTS.md +21 -121
  88. package/src/opencode/plugins/rules.ts +26 -34
  89. package/src/opencode/plugins/spec-gate.ts +283 -0
  90. package/src/claude/skills/inspect/references/external-gemini-inspection.md +0 -169
@@ -31,8 +31,8 @@ Production-ready mobile development with modern frameworks, best practices, and
31
31
  ## Technology Selection Guide
32
32
 
33
33
  **Cross-Platform Frameworks:**
34
- - **React Native**: JavaScript expertise, web code sharing, mature ecosystem (121K stars, 67% familiarity)
35
- - **Flutter**: Performance-critical apps, complex animations, fastest-growing (170K stars, 46% adoption)
34
+ - **React Native**: JavaScript expertise, web code sharing, mature ecosystem
35
+ - **Flutter**: Performance-critical apps, complex animations, fastest-growing
36
36
 
37
37
  **Native Development:**
38
38
  - **iOS (Swift/SwiftUI)**: Maximum iOS performance, latest features, Apple ecosystem integration
@@ -44,7 +44,7 @@ See: `references/mobile-frameworks.md` for detailed framework comparisons
44
44
 
45
45
  **The 10 Commandments of Mobile Development:**
46
46
 
47
- 1. **Performance is Foundation, Not Feature** - 70% abandon apps >3s load time
47
+ 1. **Performance is Foundation, Not Feature** - Slow load times can drive users away
48
48
  2. **Every Kilobyte, Every Millisecond Matters** - Mobile constraints are real
49
49
  3. **Offline-First by Default** - Network is unreliable, design for it
50
50
  4. **User Context > Developer Environment** - Think real-world usage scenarios
@@ -72,7 +72,7 @@ See: `references/mobile-mindset.md` for thinking patterns and decision framework
72
72
  ## Key Best Practices (2024-2025)
73
73
 
74
74
  **Performance Targets:**
75
- - App launch: <2 seconds (70% abandon if >3s)
75
+ - App launch: <2 seconds; slow launches risk abandonment
76
76
  - Memory usage: <100MB for typical screens
77
77
  - Network requests: Batch and cache aggressively
78
78
  - Battery impact: Respect Doze Mode and background restrictions
@@ -92,7 +92,7 @@ See: `references/mobile-mindset.md` for thinking patterns and decision framework
92
92
  - Implement proper session management
93
93
 
94
94
  **Testing Strategy:**
95
- - Unit tests: 70%+ coverage for business logic
95
+ - Unit tests: meaningful coverage for business logic
96
96
  - Integration tests: Critical user flows
97
97
  - E2E tests: Detox (React Native), Appium (cross-platform), XCUITest (iOS), Espresso (Android)
98
98
  - Real device testing mandatory before release
@@ -101,7 +101,7 @@ See: `references/mobile-mindset.md` for thinking patterns and decision framework
101
101
  - Fastlane for automation across platforms
102
102
  - Staged rollouts: Internal → Closed → Open → Production
103
103
  - Mandatory: iOS 17 SDK (2024), Android 15 API 35 (Aug 2025)
104
- - CI/CD saves 20% development time
104
+ - CI/CD saves development time
105
105
 
106
106
  ## Quick Decision Matrix
107
107
 
@@ -121,9 +121,9 @@ See: `references/mobile-mindset.md` for thinking patterns and decision framework
121
121
 
122
122
  | Criterion | React Native | Flutter | Swift/SwiftUI | Kotlin/Compose |
123
123
  |-----------|--------------|---------|---------------|----------------|
124
- | **Stars** | 121K | 170K | N/A | N/A |
125
- | **Adoption** | 35% | 46% | iOS only | Android only |
126
- | **Performance** | 80-90% native | 85-95% native | 100% native | 100% native |
124
+ | **Community footprint** | Large | Large | Apple ecosystem | Android ecosystem |
125
+ | **Adoption** | Established | Established | iOS only | Android only |
126
+ | **Performance** | Near-native when profiled | Near-native when profiled | Native baseline | Native baseline |
127
127
  | **Dev Speed** | Fast (hot reload) | Very fast (hot reload) | Fast (Xcode Previews) | Fast (Live Edit) |
128
128
  | **Learning Curve** | Easy (JavaScript) | Medium (Dart) | Medium (Swift) | Medium (Kotlin) |
129
129
  | **UI Paradigm** | Component-based | Widget-based | Declarative | Declarative |
@@ -148,7 +148,7 @@ See: `references/mobile-mindset.md` for thinking patterns and decision framework
148
148
  - Image optimization → Lazy loading → Memory profiling → Network optimization → Battery testing → Launch time optimization
149
149
 
150
150
  **Quality:**
151
- - Unit tests (70%+) → Integration tests → E2E tests → Accessibility testing → Performance testing → Security audit
151
+ - Unit tests → Integration tests → E2E tests → Accessibility testing → Performance testing → Security audit
152
152
 
153
153
  **Security:**
154
154
  - Secure storage → Authentication flow → Network security → Input validation → Session management → Encryption
@@ -179,7 +179,7 @@ See: `references/mobile-mindset.md` for thinking patterns and decision framework
179
179
  3. **No offline handling** - Network failures will happen
180
180
  4. **Poor memory management** - Leads to crashes and poor UX
181
181
  5. **Hardcoded credentials** - Security vulnerability
182
- 6. **No accessibility** - Excludes 15%+ of users
182
+ 6. **No accessibility** - Can exclude users
183
183
  7. **Premature optimization** - Optimize based on metrics, not assumptions
184
184
  8. **Over-engineering** - Start simple, scale as needed
185
185
  9. **Skipping real device testing** - Simulators don't show battery/network issues
@@ -193,7 +193,7 @@ See: `references/mobile-mindset.md` for thinking patterns and decision framework
193
193
  - **Screen load**: <1 second for cached data
194
194
  - **Network request**: <3 seconds for API calls
195
195
  - **Memory**: <100MB for typical screens, <200MB peak
196
- - **Battery**: <5% drain per hour of active use
196
+ - **Battery**: Minimize drain during active use
197
197
  - **Frame rate**: 60 FPS (16.67ms per frame)
198
198
 
199
199
  ## Resources
@@ -74,8 +74,8 @@ when (uiState) {
74
74
 
75
75
  ### Why Compose?
76
76
  - **Declarative**: Describe UI state, not imperative commands
77
- - **60% adoption**: In top 1,000 apps (2024)
78
- - **Less code**: 40% reduction vs Views
77
+ - **Adoption**: Used in many top 1,000 apps
78
+ - **Less code**: Reduction vs Views
79
79
  - **Modern**: Built for Kotlin and coroutines
80
80
  - **Material 3**: First-class support
81
81
 
@@ -310,7 +310,7 @@ class UserViewModel(
310
310
 
311
311
  **Hilt vs Koin:**
312
312
  - **Hilt**: Compile-time, type-safe, Google-backed, complex setup
313
- - **Koin**: Runtime, simple DSL, 50% faster setup, reflection-based
313
+ - **Koin**: Runtime, simple DSL, faster setup, reflection-based
314
314
 
315
315
  ## Performance Optimization
316
316
 
@@ -335,14 +335,14 @@ android {
335
335
  ```
336
336
 
337
337
  **Impact:**
338
- - 10-20% app size reduction
339
- - 20% faster startup
338
+ - Smaller app size
339
+ - Faster startup
340
340
  - Harder to reverse engineer
341
341
 
342
342
  ### Baseline Profiles
343
343
 
344
344
  **Performance boost:**
345
- - 10-20% faster startup
345
+ - Faster startup
346
346
  - Reduced jank in critical paths
347
347
  - AOT compilation of hot code
348
348
 
@@ -572,7 +572,7 @@ android {
572
572
  ```
573
573
 
574
574
  **Benefits:**
575
- - 15-30% smaller downloads
575
+ - Smaller downloads
576
576
  - Dynamic feature modules
577
577
  - Instant apps support
578
578
 
@@ -86,8 +86,8 @@ User opens screen
86
86
  - Background App Refresh (iOS)
87
87
 
88
88
  **Targets:**
89
- - Active use: <5% per hour
90
- - Background: <1% per hour
89
+ - Active use: minimize foreground energy use
90
+ - Background: minimize background energy use
91
91
 
92
92
  ## Offline-First Architecture
93
93
 
@@ -315,8 +315,8 @@ messaging().onNotificationOpenedApp(remoteMessage => {
315
315
  ```
316
316
 
317
317
  **Impact:**
318
- - 25% revenue increase with proper personalization
319
- - 88% opt-in rate with pre-permission modal (vs 40% without)
318
+ - Personalization can increase revenue
319
+ - Pre-permission modal can improve opt-in rate
320
320
 
321
321
  ## Authentication & Authorization
322
322
 
@@ -443,10 +443,10 @@ const token = credentials.password;
443
443
  - Expedited: 1-2 hours (emergencies only)
444
444
 
445
445
  **Rejection Reasons:**
446
- - Crashes (50%)
447
- - Privacy violations (25%)
448
- - Incomplete information (15%)
449
- - Guideline violations (10%)
446
+ - Crashes
447
+ - Privacy violations
448
+ - Incomplete information
449
+ - Guideline violations
450
450
 
451
451
  ### Google Play (Android)
452
452
 
@@ -460,7 +460,7 @@ const token = credentials.password;
460
460
  1. Build signed AAB (Android App Bundle)
461
461
  2. Upload to Play Console
462
462
  3. Submit to production track
463
- 4. Staged rollout (10% → 50% → 100%)
463
+ 4. Staged rollout (pilot → partial → full)
464
464
 
465
465
  **Review Time:**
466
466
  - Average: 1-3 days
@@ -468,22 +468,21 @@ const token = credentials.password;
468
468
 
469
469
  ### Staged Rollout Strategy
470
470
 
471
- **Week 1:**
472
- - 10% of users
471
+ **Pilot:**
472
+ - Release to a small audience
473
473
  - Monitor crash-free rate
474
474
  - Watch for critical bugs
475
475
 
476
- **Week 2:**
477
- - 50% of users
476
+ **Partial rollout:**
477
+ - Expand audience after pilot
478
478
  - Validate performance metrics
479
479
  - Check user feedback
480
480
 
481
- **Week 3:**
482
- - 100% of users
483
- - Full release if metrics healthy
481
+ **Full rollout:**
482
+ - Release to all users when metrics are healthy
484
483
 
485
484
  **Rollback Triggers:**
486
- - Crash-free rate drops >5%
485
+ - Crash-free rate shows a material drop
487
486
  - Critical bug discovered
488
487
  - Major user complaints
489
488
 
@@ -493,12 +492,12 @@ const token = credentials.password;
493
492
 
494
493
  | Metric | React Native | Flutter |
495
494
  |--------|--------------|---------|
496
- | **Adoption** | 35% | 46% |
497
- | **Performance** | 80-90% | 85-95% |
498
- | **App Size** | 40-50MB | 15-20MB |
499
- | **Dev Speed** | Fast | Very Fast |
500
- | **Commercial** | 12.57% | 5.24% |
501
- | **Developers** | 20:1 ratio | 1 ratio |
495
+ | **Adoption** | Established | Established |
496
+ | **Performance** | Near-native when profiled | Near-native when profiled |
497
+ | **App Size** | Moderate | Moderate |
498
+ | **Dev Speed** | Fast | Very fast |
499
+ | **Commercial footprint** | Established | Established |
500
+ | **Developers** | Broad ecosystem | Broad ecosystem |
502
501
  | **Best For** | JS teams | Performance |
503
502
 
504
503
  ### Architecture Comparison
@@ -7,8 +7,8 @@ Comprehensive guide to mobile development frameworks: React Native, Flutter, and
7
7
  ### React Native
8
8
  - **Language**: JavaScript/TypeScript
9
9
  - **Stars**: 121,000+ on GitHub
10
- - **Adoption**: 35% of mobile developers, 67% familiarity
11
- - **Performance**: 80-90% native performance
10
+ - **Adoption**: Broad adoption and familiarity among mobile developers
11
+ - **Performance**: Near-native performance
12
12
  - **Architecture**: Bridge-based (legacy) → New Architecture (JSI, Fabric, Codegen)
13
13
  - **Rendering**: Native components
14
14
  - **Hot Reload**: Yes
@@ -17,8 +17,8 @@ Comprehensive guide to mobile development frameworks: React Native, Flutter, and
17
17
  ### Flutter
18
18
  - **Language**: Dart
19
19
  - **Stars**: 170,000+ on GitHub (fastest-growing)
20
- - **Adoption**: 46% of mobile developers
21
- - **Performance**: 85-95% native performance
20
+ - **Adoption**: Broad adoption among mobile developers
21
+ - **Performance**: Near-native performance
22
22
  - **Architecture**: "Everything is a widget"
23
23
  - **Rendering**: Custom Impeller rendering engine (eliminates jank)
24
24
  - **Hot Reload**: Yes (fastest in industry)
@@ -26,7 +26,7 @@ Comprehensive guide to mobile development frameworks: React Native, Flutter, and
26
26
 
27
27
  ### Native iOS (Swift/SwiftUI)
28
28
  - **Language**: Swift
29
- - **Performance**: 100% native
29
+ - **Performance**: Native performance
30
30
  - **UI Framework**: SwiftUI (declarative) or UIKit (imperative)
31
31
  - **Latest**: Swift 6 with compile-time data race detection
32
32
  - **Tooling**: Xcode 16, Swift Package Manager
@@ -34,7 +34,7 @@ Comprehensive guide to mobile development frameworks: React Native, Flutter, and
34
34
 
35
35
  ### Native Android (Kotlin/Jetpack Compose)
36
36
  - **Language**: Kotlin
37
- - **Performance**: 100% native
37
+ - **Performance**: Native performance
38
38
  - **UI Framework**: Jetpack Compose (declarative) or Views (imperative)
39
39
  - **Latest**: Kotlin 2.1, Compose 1.7
40
40
  - **Tooling**: Android Studio Hedgehog+
@@ -51,7 +51,7 @@ Comprehensive guide to mobile development frameworks: React Native, Flutter, and
51
51
  - **Turbo Modules**: Lazy-loaded native modules
52
52
 
53
53
  **Performance Optimizations**
54
- - **Hermes Engine**: 30-40% faster startup, reduced memory
54
+ - **Hermes Engine**: Faster startup, reduced memory
55
55
  - **Native Driver Animations**: Offloaded to UI thread (60 FPS)
56
56
  - **FlatList Virtualization**: Renders only visible items
57
57
  - **Image Optimization**: FastImage library, progressive loading
@@ -81,14 +81,14 @@ src/
81
81
  4. **Context API**: Simple apps, avoid prop drilling
82
82
 
83
83
  **Navigation**
84
- - **React Navigation**: Industry standard, 80%+ adoption
84
+ - **React Navigation**: Industry standard
85
85
  - Type-safe navigation with TypeScript
86
86
  - Deep linking configuration
87
87
  - Tab, stack, drawer navigators
88
88
 
89
89
  **TypeScript Adoption**
90
- - 85%+ of new React Native projects use TypeScript
91
- - Type safety prevents 15% of runtime errors
90
+ - TypeScript is common in new React Native projects
91
+ - Type safety helps prevent runtime errors
92
92
  - Better IDE support and autocomplete
93
93
 
94
94
  ### Testing Strategy
@@ -130,7 +130,7 @@ test('login button should be enabled when form is valid', async () => {
130
130
  - Rapid prototyping and MVPs
131
131
  - Strong community support needed
132
132
  - npm ecosystem integration
133
- - Commercial apps (12.57% market share)
133
+ - Commercial apps
134
134
 
135
135
  **❌ Not Ideal For:**
136
136
  - Heavy graphics/gaming (use native or Unity)
@@ -254,7 +254,7 @@ testWidgets('Counter increments', (WidgetTester test-runner) async {
254
254
  - Move semantics for performance
255
255
 
256
256
  **SwiftUI vs UIKit**
257
- - **SwiftUI**: Declarative, 40% less code, iOS 13+, modern approach
257
+ - **SwiftUI**: Declarative, less code, iOS 13+, modern approach
258
258
  - **UIKit**: Imperative, fine-grained control, legacy support, complex customizations
259
259
  - Both work together in same project
260
260
 
@@ -318,7 +318,7 @@ struct LoginView: View {
318
318
 
319
319
  **Jetpack Compose**
320
320
  - Declarative UI (like SwiftUI/React)
321
- - 60% adoption in top 1,000 apps
321
+ - Widely adopted in top 1,000 apps
322
322
  - Material Design 3 integration
323
323
  - Compose compiler with Kotlin 2.0+
324
324
 
@@ -53,7 +53,7 @@ actor UserCache {
53
53
  ✅ Declarative UI preferred
54
54
  ✅ Fast iteration needed
55
55
  ✅ Cross-platform (macOS, watchOS, tvOS)
56
- ✅ 40% less code vs UIKit
56
+ ✅ Less code vs UIKit
57
57
 
58
58
  ### When to Use UIKit
59
59
  ✅ Legacy app maintenance
@@ -5,7 +5,7 @@ Essential thinking patterns and decision-making frameworks for successful mobile
5
5
  ## The 10 Commandments of Mobile Development
6
6
 
7
7
  ### 1. Performance is Foundation, Not Feature
8
- - **Reality**: 70% users abandon apps >3s load time
8
+ - **Reality**: Users may abandon apps when load time exceeds 3s
9
9
  - **Mindset**: Optimize from day one, not "later"
10
10
  - **Action**: Set performance budgets before writing code
11
11
 
@@ -50,7 +50,7 @@ Essential thinking patterns and decision-making frameworks for successful mobile
50
50
  - **Action**: MVVM for small apps, Clean Architecture when complexity demands
51
51
 
52
52
  ### 10. Continuous Learning is Survival
53
- - **Reality**: 85% developers use AI tools (2024), frameworks evolve constantly
53
+ - **Reality**: AI tools are widely used by developers (2024), frameworks evolve constantly
54
54
  - **Mindset**: Embrace change, allocate learning time
55
55
  - **Action**: 1+ hour weekly for new tech/patterns
56
56
 
@@ -131,7 +131,7 @@ Essential thinking patterns and decision-making frameworks for successful mobile
131
131
  - "It just works" expectation = zero tolerance for crashes
132
132
 
133
133
  **Fragmentation**: LOW
134
- - 90%+ on iOS 16+ (2024)
134
+ - Most users on iOS 16+ (2024)
135
135
  - Only ~50 device models to test
136
136
  - Predictable hardware specs
137
137
 
@@ -165,7 +165,7 @@ Essential thinking patterns and decision-making frameworks for successful mobile
165
165
  - Handle back button properly
166
166
 
167
167
  **When to Go Native Android:**
168
- - Global market focus (72% market share)
168
+ - Global market focus (Android dominates)
169
169
  - Emerging markets (Android dominates)
170
170
  - Enterprise/B2B (customization needs)
171
171
 
@@ -177,7 +177,7 @@ Essential thinking patterns and decision-making frameworks for successful mobile
177
177
  |--------|-----------|-----------------|
178
178
  | **Launch time** | <2s | Acceptable |
179
179
  | **Launch time** | 2-3s | Noticeable delay |
180
- | **Launch time** | >3s | 70% abandon |
180
+ | **Launch time** | >3s | Users may abandon |
181
181
  | **Screen load** | <1s | Instant (cached) |
182
182
  | **Screen load** | 1-3s | Acceptable (network) |
183
183
  | **Screen load** | >3s | Frustrating |
@@ -259,46 +259,44 @@ Week 2: Polish + Ship
259
259
  8. Merge to develop
260
260
 
261
261
  **CI/CD Impact:**
262
- - 20% reduction in development time
263
- - 50% fewer production bugs
264
- - 3x faster deployment
262
+ - Faster development and deployment with fewer production bugs
265
263
 
266
264
  ### Common Pitfalls & Avoidance
267
265
 
268
266
  #### 1. Testing Only on Simulators
269
267
  **Problem**: Simulators don't show real performance (battery, memory, network)
270
268
  **Solution**: Real device testing mandatory before every release
271
- **Impact**: 40% of bugs only appear on real devices
269
+ **Impact**: Some bugs only appear on real devices
272
270
 
273
271
  #### 2. Ignoring Platform Conventions
274
272
  **Problem**: Custom navigation confuses users
275
273
  **Solution**: Follow iOS HIG and Material Design
276
- **Impact**: 30% lower engagement with non-standard UIs
274
+ **Impact**: Non-standard UIs can lower engagement
277
275
 
278
276
  #### 3. No Offline Handling
279
277
  **Problem**: Network failures = blank screens, errors
280
278
  **Solution**: Offline-first architecture, cached data
281
- **Impact**: 50% of users experience network issues daily
279
+ **Impact**: Users can experience network issues daily
282
280
 
283
281
  #### 4. Poor Memory Management
284
282
  **Problem**: Memory leaks → crashes, poor performance
285
283
  **Solution**: ARC/GC understanding, profile regularly
286
- **Impact**: Memory issues = #1 crash cause (35%)
284
+ **Impact**: Memory issues are a leading crash cause
287
285
 
288
286
  #### 5. Hardcoded Credentials
289
287
  **Problem**: Security vulnerability, API key exposure
290
288
  **Solution**: Environment variables, secure storage
291
- **Impact**: 23% of apps leak sensitive data (OWASP)
289
+ **Impact**: Apps can leak sensitive data; follow OWASP guidance.
292
290
 
293
291
  #### 6. No Accessibility
294
- **Problem**: Excludes 15%+ of users (disability, situational)
292
+ **Problem**: Excludes users with disabilities or situational needs
295
293
  **Solution**: VoiceOver/TalkBack testing, semantic labels
296
294
  **Impact**: Accessibility = 1.3B global market
297
295
 
298
296
  #### 7. Premature Optimization
299
297
  **Problem**: Wasted time optimizing non-bottlenecks
300
298
  **Solution**: Measure first, optimize biggest impact
301
- **Impact**: 80% of performance issues = 20% of code
299
+ **Impact**: Many performance issues come from a small part of the code
302
300
 
303
301
  #### 8. Over-Engineering
304
302
  **Problem**: Complex architecture for simple apps
@@ -308,7 +306,7 @@ Week 2: Polish + Ship
308
306
  #### 9. Skipping Real Device Testing
309
307
  **Problem**: Missed battery drain, thermal issues
310
308
  **Solution**: Device farm in CI/CD, manual testing
311
- **Impact**: 25% of performance issues device-specific
309
+ **Impact**: Some performance issues are device-specific
312
310
 
313
311
  #### 10. Not Respecting Battery
314
312
  **Problem**: Background processing drains battery
@@ -460,12 +458,12 @@ if (isLowEndDevice) {
460
458
 
461
459
  **Example Architecture:**
462
460
  ```
463
- React Native / Flutter (90%)
461
+ React Native / Flutter
464
462
  ├─ UI and business logic
465
463
  ├─ Standard features
466
464
  └─ API integration
467
465
 
468
- Native Modules (10%)
466
+ Native Modules
469
467
  ├─ Performance-critical (video processing)
470
468
  ├─ Platform-specific (HealthKit, Android Auto)
471
469
  └─ Third-party SDKs (payment, analytics)
@@ -535,7 +533,7 @@ v4.0: Extract microservices if justified
535
533
  - Discord (React Native, Flutter official)
536
534
  - Twitter: Follow framework creators and contributors
537
535
 
538
- **AI Tools (85% adoption in 2024):**
536
+ **AI Tools (widely adopted in 2024):**
539
537
  - GitHub Copilot: Code completion, boilerplate
540
538
  - ChatGPT/Claude: Architecture questions, debugging
541
539
  - Tabnine: Context-aware suggestions
@@ -30,14 +30,14 @@ The output is an answer, evidence, confidence, and a follow-up only when needed.
30
30
  ## When To Use
31
31
 
32
32
  Use `hapo:question` when the user asks:
33
- - "Trong hệ thống này X làm gì?"
34
- - "Luồng này đang xử lý ở đâu?"
35
- - "Config/version/package hiện tại là gì?"
36
- - "Có dùng thư viện/công nghệ/cách làm nào không?"
37
- - "Requirement/spec này có khớp code không?"
38
- - "Tool/library/framework này nên dùng thế nào?"
39
- - "Theo best practice/current docs thì sao?"
40
- - "Tôi nên hiểu phần này như thế nào?"
33
+ - "What does X do in this system?"
34
+ - "Where is this flow handled?"
35
+ - "What is the current config/version/package?"
36
+ - "Does it use a particular library/technology/approach?"
37
+ - "Does this requirement/spec match the code?"
38
+ - "How should I use this tool/library/framework?"
39
+ - "What does best practice or the current docs say?"
40
+ - "How should I understand this part?"
41
41
 
42
42
  Do not use it when:
43
43
  - The user asks to implement, fix, debug, test, commit, or publish.
@@ -131,14 +131,14 @@ Use `templates/question.md` when the user asks to save or document the answer.
131
131
  - Separate "confirmed by source" from "inferred".
132
132
  - Keep the answer proportional: concise for simple questions, structured for complex ones.
133
133
  - If external sources were used, include source links or names.
134
- - If no evidence exists, say "không thấy bằng chứng trong source hiện tại" and explain what was checked.
134
+ - If no evidence exists, say "no evidence found in the current source" and explain what was checked.
135
135
 
136
136
  ## Examples
137
137
 
138
138
  ### Source Question
139
139
 
140
140
  ```text
141
- /hapo:question "Trong hệ thống này cafekit dùng file nào để bật/tắt skill routing?"
141
+ /hapo:question "In this system, which file does cafekit use to toggle skill routing?"
142
142
  ```
143
143
 
144
144
  Expected behavior:
@@ -149,7 +149,7 @@ Expected behavior:
149
149
  ### Mixed Source + Web Question
150
150
 
151
151
  ```text
152
- /hapo:question "Dự án này đang dùng React version nào, và version đó có còn phù hợp theo best practice hiện tại không?" --both
152
+ /hapo:question "Which React version does this project use, and does that version still match current best practice?" --both
153
153
  ```
154
154
 
155
155
  Expected behavior:
@@ -160,8 +160,8 @@ Expected behavior:
160
160
  ### Ask Back
161
161
 
162
162
  ```text
163
- /hapo:question "Hệ thống này có ổn không?"
163
+ /hapo:question "Is this system stable?"
164
164
  ```
165
165
 
166
166
  Expected behavior:
167
- - ask one narrowing question because "ổn" could mean architecture, security, performance, UX, tests, or deploy readiness.
167
+ - ask one narrowing question because "stable" could mean architecture, security, performance, UX, tests, or deploy readiness.
@@ -12,7 +12,7 @@ metadata:
12
12
  ---
13
13
  # Research (Delegation Facade)
14
14
 
15
- **Mantra:** YAGNI, KISS, DRY. Be brutal, straight to the point, and strictly authoritative.
15
+ **Mantra:** Return ranked recommendations with sources; never an unsorted list of options.
16
16
 
17
17
  This skill acts as a **Command Facade**. When invoked, the main Orchestrator MUST NOT attempt to run WebSearch itself. Instead, it must instantly delegate the operation to the Specialized Subagent.
18
18
 
@@ -40,7 +40,7 @@ Output Format: Must strictly follow the 'Standard Research Report' layout.
40
40
  The subagent MUST return the findings formatted EXACTLY according to the built-in specification template.
41
41
 
42
42
  Instruct the Researcher Subagent with this strict requirement:
43
- > "Sử dụng nguyên bản template tại `packages/spec/src/claude/skills/specs/templates/research.md`. Tuyệt đối không tự ý đẻ thêm các đề mục ngoài phạm vi file template này."
43
+ > "Use the template at .claude/skills/specs/templates/research.md verbatim. Do not add sections beyond it."
44
44
 
45
45
  ## Post-Execution
46
46
  Once the `researcher` completes the Task and returns the Markdown output, save it based on context:
@@ -88,6 +88,22 @@ Forbidden generated artifacts:
88
88
  - Concise, prefer bullet lists; no fluff
89
89
  - Unresolved questions → list at the end of each document
90
90
 
91
+ ## Lane selection before spec gate
92
+
93
+ Classify task risk at the runtime boundary before starting spec state or approval flow. Use the executable policy, not keyword count or prose alone:
94
+
95
+ ```bash
96
+ node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '<task JSON>' --json
97
+ # Downgrade from Critical requires explicit user authorization — model-supplied lane cannot bypass risk signals
98
+ node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '{"riskSignals":{"auth":true},"override":"Direct","userAuthorized":true}' --json
99
+ ```
100
+
101
+ - **Direct** — clear, isolated, reversible, low-risk work. May skip spec files, registry/state, and subagents. Still run targeted verification, diff self-check, and evidence proportional to blast radius. No spec/state/registry ceremony required.
102
+ - **Standard** — default lane. Create one bounded spec artifact (`requirements.md` + `design.md` in the current layout), keep one canonical receipt, and run exactly one combined `code-auditor` review at feature ship point (not per-task).
103
+ - **Critical** — destructive/irreversible, auth/payment/privacy/data, schema/migration, public contract, cross-runtime coupling, outcome-changing ambiguity, or difficult rollback. Require strict spec/state/evidence; delegation is risk-driven (inspector/test-runner/code-auditor enabled only when risk lens requires), not a fixed four-agent chain.
104
+
105
+ Explicit `override` is allowed in either direction but is enforced at the runtime boundary. A model-supplied lane or downgrade must not bypass risk signals. Downgrading from Critical requires explicit user-originated authorization (`userAuthorized:true` or `origin:user`) and must surface the trade-off (reduced review/evidence coverage). Agent validation or --auto never fabricates `user_approved`; `generated`, `agent_validated`, and `user_approved` are independent booleans per `schema_version: "2.0"`.
106
+
91
107
  ## Default Behavior
92
108
 
93
109
  > **This section is the entry/dispatch layer ONLY.** It decides *which part of the pipeline to run and where to stop*. It does NOT change any pipeline step, the validator, templates, or rules.
@@ -112,15 +128,15 @@ Forbidden generated artifacts:
112
128
 
113
129
  ### Creation Mode Gate
114
130
 
115
- Shown once on the no-flag create path. Selects the **stop point only**.
131
+ Shown once on the no-flag create path. Selects the **stop point only**. Approval schema is versioned (`schema_version: "2.0"`): each phase has `generated`, `agent_validated`, `user_approved` as independent booleans. `ready` requires all three true. Legacy `approved` field is rejected — `--auto` or agent validation never fabricates `user_approved`.
116
132
 
117
- | Option | Runs | Stops after | Approvals |
133
+ | Option | Runs | Stops after | Approvals (v2) |
118
134
  |---|---|---|---|
119
- | **Auto (→ Tasks)** | Step 1→10 end-to-end | full (ready gate) | each phase `generated=true` + `approved=true` |
120
- | **Stop after Design** | Step 1→6 | `design` (before Step 7) | requirements + design `approved=true`; `ready_for_implementation=false` |
121
- | **Step by step** | one phase at a time | after each phase | per phase `generated=true`, `approved=false` until user approves |
135
+ | **Auto (→ Tasks)** | Step 1→10 end-to-end | full (ready gate) | each phase `generated=true` + `agent_validated=true`; `user_approved` stays false until explicit user approval (`--auto` does NOT auto-set `user_approved`). Ready requires `generated && agent_validated && user_approved`. |
136
+ | **Stop after Design** | Step 1→6 | `design` (before Step 7) | requirements + design `generated=true` + `agent_validated=true`; `user_approved=true` only after explicit user approval; later phases ungenerated; `ready_for_implementation=false` |
137
+ | **Step by step** | one phase at a time | after each phase | per phase `generated=true`, `agent_validated` per agent check, `user_approved=false` until user explicitly approves |
122
138
 
123
- `--auto` = Auto without the gate. Early stops leave `ready_for_implementation=false` and emit Step 9b. Resume via `/hapo:specs` Interactive State Discovery.
139
+ `--auto` = Auto without the gate. Early stops leave `ready_for_implementation=false` and emit Step 9b. Resume via `/hapo:specs` Interactive State Discovery. If legacy `approved` field is present, fail closed with migration guidance: replace `approved` with `agent_validated` + `user_approved` per `spec-state.json` template.
124
140
 
125
141
  ### Translation Mirror (optional reference copy)
126
142
 
@@ -210,16 +226,16 @@ Load: `references/scope-inquiry.md` (+ `references/ask-user-question-gates.md` f
210
226
  - Smell: >8 files / >2 new classes / >12 tasks → challenge; **>15 tasks → sibling specs**
211
227
  - User: Expand / Hold / Reduce. Skip if trivial (< 20 words, 1 file, "just do it")
212
228
 
213
- #### Execution Tier (auto-scale — after 5-Dimension assessment)
214
- Record in `spec.json.design_context.execution_tier`.
229
+ #### Execution Tier (auto-scale — after 5-Dimension assessment) — legacy metadata
230
+ Record in `spec.json.design_context.execution_tier` for backward compatibility. Tier is metadata only; **lane controls ceremony and delegation** (Direct/Standard/Critical). Light/Standard/Deep mappings are preserved for compatibility but lane policy is authoritative.
215
231
 
216
- | Tier | Trigger | Research | Discovery | Red-Team | Always runs |
232
+ | Tier (legacy) | Trigger | Research | Discovery | Red-Team | Always runs |
217
233
  |---|---|---|---|---|---|
218
234
  | **Light** | Clear + Isolated + ≤2 tasks | skip (rationale) | minimal | Validate-only | scope_lock, EARS, **Layer 1+2** |
219
235
  | **Standard** | default / 3-4 tasks | targeted | light | per Step 8 | all of the above |
220
236
  | **Deep** | Complex/Critical / security-migration / 5+ tasks | full | full | Red-Team → Validate | all of the above |
221
237
 
222
- Grounding + validator + scope_lock never skip. Auth/payment/migration/schema/privacy force Deep. Tier never changes Hard Output Contract or DoCT.
238
+ Grounding + validator + scope_lock never skip. Auth/payment/migration/schema/privacy force Deep (legacy) and Critical (lane). Tier remains backward-compatible execution metadata; lane controls ceremony and delegation.
223
239
 
224
240
  ### Step 4: Init
225
241
  - Check duplicate slugs; create `specs/<feature-name>/`
@@ -355,17 +371,18 @@ Early stop (**Stop after Design** / **Step by step**): no completion block, no v
355
371
 
356
372
  | Field | Rule |
357
373
  |---|---|
374
+ | `schema_version` | Must be `"2.0"`; approvals use `generated` + `agent_validated` + `user_approved` per phase. Legacy `approved` field is rejected — fail closed with migration guidance. |
358
375
  | Status | `in_progress` / `blocked` / `done` / `archived` only (never emit `in-progress`) |
359
376
  | Timestamps | Each `timestamps.*_done` = actual ISO 8601 time at that phase; never reuse init |
360
- | Approvals (Auto / full pipeline) | `generated=true` + `approved=true` per completed phase |
361
- | Approvals (Stop after Design) | phases that ran: both true; later phases ungenerated; `ready_for_implementation=false` |
362
- | Approvals (Step by step) | `generated=true`, `approved=false` until user approves |
377
+ | Approvals (Auto / full pipeline) | `generated=true` + `agent_validated=true`; `user_approved` stays false until explicit user approval (`--auto` never fabricates `user_approved`). Ready requires all three true per phase. |
378
+ | Approvals (Stop after Design) | phases that ran: `generated=true` + `agent_validated=true`; `user_approved=true` only after explicit user approval; later phases ungenerated; `ready_for_implementation=false` |
379
+ | Approvals (Step by step) | `generated=true`, `agent_validated` per agent check, `user_approved=false` until user explicitly approves |
363
380
  | `task_files` / `task_registry` | Exact match to disk after Step 7; registry keys = relative paths with full registry fields |
364
381
  | `validation_recommended` | `true` for auth/privacy/delete/migration/schema/extension/provider or 5+ tasks |
365
382
  | `translation` | optional mirror metadata; never affects ready gate |
366
- | `ready_for_implementation` | `true` only when requirements+design+tasks approved, `progress.tasks=done`, inventories match disk, and validation completed when recommended |
383
+ | `ready_for_implementation` | `true` only when requirements+design+tasks each have `generated && agent_validated && user_approved`, `progress.tasks=done`, inventories match disk, and validation completed when recommended |
367
384
 
368
- If any approval is `false`, keep `ready_for_implementation = false`. Specs with 5+ tasks stay not-ready until `--validate` writes `validation.status = "completed"`.
385
+ If any approval (`generated`, `agent_validated`, or `user_approved`) is `false`, keep `ready_for_implementation = false`. Specs with 5+ tasks stay not-ready until `--validate` writes `validation.status = "completed"`. Legacy `approved` fails closed — do not infer `user_approved` from `generated` or `agent_validated`.
369
386
 
370
387
  ## Subcommands
371
388
 
@@ -99,7 +99,7 @@ These rules override any self-reasoning or optimization the system may attempt:
99
99
  Each reviewer receives:
100
100
  - Their specific lens and persona
101
101
  - Spec file paths to read directly
102
- - Instructions: find 5-10 flaws, findings only, NO praise
102
+ - Instructions: report findings only when backed by concrete citations
103
103
 
104
104
  **Reviewer instructions:**
105
105
  ```
@@ -111,8 +111,8 @@ Rules:
111
111
  - Be concrete: describe failure scenario, not just "could be a problem"
112
112
  - Rate severity: Critical (blocks success) | High (significant risk) | Medium (notable concern)
113
113
  - Skip trivial observations (style, naming, formatting)
114
- - No praise. No "overall looks good". Only findings.
115
- - 5-10 findings. Quality over quantity.
114
+ - No praise. No "overall looks good". Only evidence-backed findings.
115
+ - Quality over quantity; do not pad to a count.
116
116
  ```
117
117
 
118
118
  #### Step 5: Collect → Deduplicate → Cap