moai-adk 0.4.7__py3-none-any.whl → 0.4.8__py3-none-any.whl
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.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +188 -954
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +4 -5
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +2 -2
- moai_adk/templates/.claude/agents/alfred/git-manager.md +2 -2
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +3 -3
- moai_adk/templates/.claude/agents/alfred/project-manager.md +6 -6
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +4 -6
- moai_adk/templates/.claude/agents/alfred/skill-factory.md +36 -36
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +2 -2
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +2 -2
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +3 -3
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +5 -5
- moai_adk/templates/.claude/commands/alfred/0-project.md +98 -42
- moai_adk/templates/.claude/commands/alfred/1-plan.md +7 -7
- moai_adk/templates/.claude/commands/alfred/2-run.md +36 -36
- moai_adk/templates/.claude/commands/alfred/3-sync.md +10 -10
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +14 -1
- moai_adk/templates/.claude/hooks/alfred/core/__init__.py +115 -33
- moai_adk/templates/.claude/hooks/alfred/handlers/session.py +8 -9
- moai_adk/templates/.claude/hooks/alfred/handlers/tool.py +6 -6
- moai_adk/templates/.claude/hooks/alfred/handlers/user.py +5 -4
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +1 -1
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +1 -1
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +1 -1
- moai_adk/templates/.claude/settings.json +42 -2
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +480 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +257 -0
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +120 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +249 -0
- moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +32 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +278 -0
- moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +26 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +287 -0
- moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +21 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +232 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +19 -0
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +24 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +179 -0
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +39 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +296 -0
- moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +18 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +243 -0
- moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +30 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +271 -0
- moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +15 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/EXAMPLES.md +261 -35
- moai_adk/templates/.claude/skills/moai-skill-factory/INTERACTIVE-DISCOVERY.md +15 -15
- moai_adk/templates/.claude/skills/moai-skill-factory/PARALLEL-ANALYSIS-REPORT.md +429 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/PYTHON-VERSION-MATRIX.md +391 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-FACTORY-WORKFLOW.md +431 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL.md +33 -33
- moai_adk/templates/.claude/skills/moai-skill-factory/STEP-BY-STEP-GUIDE.md +466 -0
- moai_adk/templates/.claude/skills/moai-skill-factory/reference.md +438 -42
- moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +129 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +1300 -0
- moai_adk/templates/.claude/skills/moai-spec-authoring/examples/validate-spec.sh +161 -0
- moai_adk/templates/CLAUDE.md +101 -93
- {moai_adk-0.4.7.dist-info → moai_adk-0.4.8.dist-info}/METADATA +537 -146
- {moai_adk-0.4.7.dist-info → moai_adk-0.4.8.dist-info}/RECORD +63 -73
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +0 -635
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +0 -992
- moai_adk/templates/.claude/skills/moai-alfred-tui-survey/reference.md +0 -801
- moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +0 -121
- moai_adk/templates/.claude/skills/moai-claude-code/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-claude-code/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-claude-code/templates/agent-full.md +0 -332
- moai_adk/templates/.claude/skills/moai-claude-code/templates/command-full.md +0 -384
- moai_adk/templates/.claude/skills/moai-claude-code/templates/plugin-full.json +0 -363
- moai_adk/templates/.claude/skills/moai-claude-code/templates/settings-full.json +0 -595
- moai_adk/templates/.claude/skills/moai-claude-code/templates/skill-full.md +0 -496
- moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-clojure/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-clojure/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-elixir/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-elixir/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-haskell/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-haskell/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-julia/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-julia/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-lua/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-lua/reference.md +0 -30
- {moai_adk-0.4.7.dist-info → moai_adk-0.4.8.dist-info}/WHEEL +0 -0
- {moai_adk-0.4.7.dist-info → moai_adk-0.4.8.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.4.7.dist-info → moai_adk-0.4.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,992 +0,0 @@
|
|
|
1
|
-
# TUI Survey Examples - Real-World Scenarios
|
|
2
|
-
|
|
3
|
-
This document provides complete, production-ready examples of TUI surveys across common MoAI-ADK workflows.
|
|
4
|
-
|
|
5
|
-
_Last updated: 2025-10-22_
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Table of Contents
|
|
10
|
-
|
|
11
|
-
1. [Competition Completion Page](#example-1-competition-completion-page)
|
|
12
|
-
2. [State Management Library Selection](#example-2-state-management-library-selection)
|
|
13
|
-
3. [Auth System Refactor](#example-3-auth-system-refactor)
|
|
14
|
-
4. [Feature Approval Workflow](#example-4-feature-approval-workflow)
|
|
15
|
-
5. [API Design Decision](#example-5-api-design-decision)
|
|
16
|
-
6. [Database Migration Strategy](#example-6-database-migration-strategy)
|
|
17
|
-
7. [Testing Framework Selection](#example-7-testing-framework-selection)
|
|
18
|
-
8. [Performance Optimization](#example-8-performance-optimization)
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Example 1: Competition Completion Page
|
|
23
|
-
|
|
24
|
-
### Context
|
|
25
|
-
|
|
26
|
-
**User Request**: "Competition is over. Add a completion page."
|
|
27
|
-
|
|
28
|
-
**Current State**:
|
|
29
|
-
- Existing `/end` page (authentication required, shows results)
|
|
30
|
-
- No public completion page exists
|
|
31
|
-
- Need to communicate competition closure to all visitors
|
|
32
|
-
|
|
33
|
-
### Phase 1: Codebase Analysis
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
// Alfred analyzes existing code
|
|
37
|
-
const endPageAnalysis = await Read("/app/end/page.tsx");
|
|
38
|
-
|
|
39
|
-
// Analysis results:
|
|
40
|
-
// - Next.js App Router
|
|
41
|
-
// - Requires authentication
|
|
42
|
-
// - Shows competition results
|
|
43
|
-
// - No environment-based gating
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Phase 2: Interactive Survey
|
|
47
|
-
|
|
48
|
-
**Question 1: Implementation Approach**
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
AskUserQuestion({
|
|
52
|
-
questions: [
|
|
53
|
-
{
|
|
54
|
-
question: "How should the completion page be implemented?",
|
|
55
|
-
header: "Approach",
|
|
56
|
-
multiSelect: false,
|
|
57
|
-
options: [
|
|
58
|
-
{
|
|
59
|
-
label: "Create new public page (/competition-closed)",
|
|
60
|
-
description: "Unguarded route visible to all visitors, no authentication required. Clean separation from existing /end page."
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
label: "Modify existing /end page with conditional logic",
|
|
64
|
-
description: "Add competition status check, redirect to completion message if inactive. Reuses existing route structure."
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
label: "Use environment-based gating",
|
|
68
|
-
description: "Set NEXT_PUBLIC_COMPETITION_CLOSED=true, redirect all traffic. Runtime configuration."
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
})
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**User Selection**: "Create new public page (/competition-closed)"
|
|
77
|
-
|
|
78
|
-
**Question 2: User Behavior**
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
AskUserQuestion({
|
|
82
|
-
questions: [
|
|
83
|
-
{
|
|
84
|
-
question: "For logged-in participants accessing the new page, what should they see?",
|
|
85
|
-
header: "UX",
|
|
86
|
-
multiSelect: false,
|
|
87
|
-
options: [
|
|
88
|
-
{
|
|
89
|
-
label: "Show submission history",
|
|
90
|
-
description: "Redirect authenticated users to /end page, display full results and timeline."
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
label: "Show simple completion message only",
|
|
94
|
-
description: "Display 'Competition concluded' notice without historical data. Consistent experience for all users."
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
label: "Custom behavior based on user role",
|
|
98
|
-
description: "Different experience per role (admin/participants/visitors)."
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
})
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**User Selection**: "Show simple completion message only"
|
|
107
|
-
|
|
108
|
-
### Phase 3: Review & Confirmation
|
|
109
|
-
|
|
110
|
-
```
|
|
111
|
-
Summary:
|
|
112
|
-
✓ Implementation: New public page (/competition-closed)
|
|
113
|
-
✓ User experience: Simple completion message for all users
|
|
114
|
-
|
|
115
|
-
Ready to proceed?
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
**User Selection**: "Approve and execute"
|
|
119
|
-
|
|
120
|
-
### Phase 4: Execution
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
// /app/competition-closed/page.tsx
|
|
124
|
-
export const metadata = {
|
|
125
|
-
title: "Competition Closed",
|
|
126
|
-
description: "This competition has concluded"
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export default function CompetitionClosedPage() {
|
|
130
|
-
return (
|
|
131
|
-
<div className="flex min-h-screen items-center justify-center">
|
|
132
|
-
<div className="max-w-md text-center">
|
|
133
|
-
<h1 className="text-3xl font-bold">Competition Concluded</h1>
|
|
134
|
-
<p className="mt-4 text-muted-foreground">
|
|
135
|
-
Thank you for your interest. This competition has ended.
|
|
136
|
-
</p>
|
|
137
|
-
<p className="mt-2 text-sm">
|
|
138
|
-
Check back soon for future opportunities!
|
|
139
|
-
</p>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### Outcome
|
|
147
|
-
|
|
148
|
-
✅ Clean implementation matching user specifications
|
|
149
|
-
✅ No guessing or ambiguity
|
|
150
|
-
✅ Direct execution based on confirmed choices
|
|
151
|
-
✅ Simple public route with consistent UX
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## Example 2: State Management Library Selection
|
|
156
|
-
|
|
157
|
-
### Context
|
|
158
|
-
|
|
159
|
-
**User Request**: "Add state management to the application."
|
|
160
|
-
|
|
161
|
-
**Current State**:
|
|
162
|
-
- React 18.x application
|
|
163
|
-
- No existing state management library
|
|
164
|
-
- Component prop drilling in 12+ files
|
|
165
|
-
- Need centralized state for user auth, theme, settings
|
|
166
|
-
|
|
167
|
-
### Phase 1: Codebase Analysis
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
const analysis = {
|
|
171
|
-
framework: "React 18.3.1",
|
|
172
|
-
propDrillingDepth: 4,
|
|
173
|
-
stateComplexity: "Medium",
|
|
174
|
-
teamPreference: null
|
|
175
|
-
};
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Phase 2: Interactive Survey
|
|
179
|
-
|
|
180
|
-
**Question 1: Library Selection**
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
AskUserQuestion({
|
|
184
|
-
questions: [
|
|
185
|
-
{
|
|
186
|
-
question: "Which state management library should be used?",
|
|
187
|
-
header: "Library",
|
|
188
|
-
multiSelect: false,
|
|
189
|
-
options: [
|
|
190
|
-
{
|
|
191
|
-
label: "Redux Toolkit (v2.x)",
|
|
192
|
-
description: "Industry standard with extensive ecosystem. DevTools support, middleware. PRO: Battle-tested. CON: More boilerplate."
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
label: "Zustand (v5.x)",
|
|
196
|
-
description: "Modern, minimalist state management. Simple API with hooks. PRO: Minimal boilerplate. CON: Fewer resources."
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
label: "Jotai (v2.x)",
|
|
200
|
-
description: "Atomic state management. Fine-grained reactivity. PRO: Granular updates. CON: Paradigm shift."
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
label: "Context API + useReducer (built-in)",
|
|
204
|
-
description: "React's built-in solution. PRO: Zero dependencies. CON: Performance concerns."
|
|
205
|
-
}
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
]
|
|
209
|
-
})
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
**User Selection**: "Zustand (v5.x)"
|
|
213
|
-
|
|
214
|
-
**Question 2: Store Structure**
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
AskUserQuestion({
|
|
218
|
-
questions: [
|
|
219
|
-
{
|
|
220
|
-
question: "How should the Zustand store be structured?",
|
|
221
|
-
header: "Structure",
|
|
222
|
-
multiSelect: false,
|
|
223
|
-
options: [
|
|
224
|
-
{
|
|
225
|
-
label: "Single global store",
|
|
226
|
-
description: "All state in one store. Simple to reason about."
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
label: "Multiple domain stores",
|
|
230
|
-
description: "Separate stores per domain (useAuthStore, useThemeStore, useSettingsStore). Clear separation."
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
label: "Hybrid (global + domain-specific)",
|
|
234
|
-
description: "Core state in global store, specialized logic in domain stores."
|
|
235
|
-
}
|
|
236
|
-
]
|
|
237
|
-
}
|
|
238
|
-
]
|
|
239
|
-
})
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
**User Selection**: "Multiple domain stores"
|
|
243
|
-
|
|
244
|
-
**Question 3: Persistence**
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
AskUserQuestion({
|
|
248
|
-
questions: [
|
|
249
|
-
{
|
|
250
|
-
question: "Which state should be persisted to localStorage?",
|
|
251
|
-
header: "Persistence",
|
|
252
|
-
multiSelect: true,
|
|
253
|
-
options: [
|
|
254
|
-
{
|
|
255
|
-
label: "Authentication state",
|
|
256
|
-
description: "Persist user session, tokens. Resume logged-in state."
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
label: "Theme preferences",
|
|
260
|
-
description: "Persist dark/light mode selection."
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
label: "User settings",
|
|
264
|
-
description: "Persist app configuration (language, notifications)."
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
label: "None (session-only)",
|
|
268
|
-
description: "Don't persist any state."
|
|
269
|
-
}
|
|
270
|
-
]
|
|
271
|
-
}
|
|
272
|
-
]
|
|
273
|
-
})
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
**User Selections**: ["Theme preferences", "User settings"]
|
|
277
|
-
|
|
278
|
-
### Phase 3: Execution
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
// stores/theme.ts
|
|
282
|
-
import { create } from 'zustand';
|
|
283
|
-
import { persist } from 'zustand/middleware';
|
|
284
|
-
|
|
285
|
-
interface ThemeState {
|
|
286
|
-
theme: 'light' | 'dark';
|
|
287
|
-
setTheme: (theme: 'light' | 'dark') => void;
|
|
288
|
-
toggleTheme: () => void;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export const useThemeStore = create<ThemeState>()(
|
|
292
|
-
persist(
|
|
293
|
-
(set) => ({
|
|
294
|
-
theme: 'light',
|
|
295
|
-
setTheme: (theme) => set({ theme }),
|
|
296
|
-
toggleTheme: () => set((state) => ({
|
|
297
|
-
theme: state.theme === 'light' ? 'dark' : 'light'
|
|
298
|
-
}))
|
|
299
|
-
}),
|
|
300
|
-
{
|
|
301
|
-
name: 'theme-storage'
|
|
302
|
-
}
|
|
303
|
-
)
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
// stores/settings.ts
|
|
307
|
-
interface SettingsState {
|
|
308
|
-
language: string;
|
|
309
|
-
notifications: boolean;
|
|
310
|
-
setLanguage: (language: string) => void;
|
|
311
|
-
toggleNotifications: () => void;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export const useSettingsStore = create<SettingsState>()(
|
|
315
|
-
persist(
|
|
316
|
-
(set) => ({
|
|
317
|
-
language: 'en',
|
|
318
|
-
notifications: true,
|
|
319
|
-
setLanguage: (language) => set({ language }),
|
|
320
|
-
toggleNotifications: () => set((state) => ({
|
|
321
|
-
notifications: !state.notifications
|
|
322
|
-
}))
|
|
323
|
-
}),
|
|
324
|
-
{
|
|
325
|
-
name: 'settings-storage'
|
|
326
|
-
}
|
|
327
|
-
)
|
|
328
|
-
);
|
|
329
|
-
|
|
330
|
-
// stores/auth.ts (no persistence)
|
|
331
|
-
interface AuthState {
|
|
332
|
-
user: User | null;
|
|
333
|
-
isAuthenticated: boolean;
|
|
334
|
-
login: (user: User) => void;
|
|
335
|
-
logout: () => void;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export const useAuthStore = create<AuthState>((set) => ({
|
|
339
|
-
user: null,
|
|
340
|
-
isAuthenticated: false,
|
|
341
|
-
login: (user) => set({ user, isAuthenticated: true }),
|
|
342
|
-
logout: () => set({ user: null, isAuthenticated: false })
|
|
343
|
-
}));
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
### Outcome
|
|
347
|
-
|
|
348
|
-
✅ Zustand v5.x with minimal boilerplate
|
|
349
|
-
✅ Three domain-specific stores
|
|
350
|
-
✅ Selective persistence (theme + settings, not auth)
|
|
351
|
-
✅ Type-safe TypeScript implementation
|
|
352
|
-
✅ Exact match to user specifications
|
|
353
|
-
|
|
354
|
-
---
|
|
355
|
-
|
|
356
|
-
## Example 3: Auth System Refactor
|
|
357
|
-
|
|
358
|
-
### Context
|
|
359
|
-
|
|
360
|
-
**User Request**: "Refactor the auth system to use JWT instead of sessions."
|
|
361
|
-
|
|
362
|
-
**Current State**:
|
|
363
|
-
- Session-based authentication (Express + Redis)
|
|
364
|
-
- 20+ routes depend on session middleware
|
|
365
|
-
- ~500 active users in production
|
|
366
|
-
- No JWT infrastructure exists
|
|
367
|
-
|
|
368
|
-
### Risk Assessment
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
const riskAnalysis = {
|
|
372
|
-
activeUsers: 500,
|
|
373
|
-
dependentRoutes: 23,
|
|
374
|
-
currentUptime: "99.2%",
|
|
375
|
-
rollbackComplexity: "High",
|
|
376
|
-
estimatedDowntime: "2-4 hours (big bang) or 0 minutes (incremental)"
|
|
377
|
-
};
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
### Interactive Survey
|
|
381
|
-
|
|
382
|
-
**Question 1: Migration Strategy**
|
|
383
|
-
|
|
384
|
-
```typescript
|
|
385
|
-
AskUserQuestion({
|
|
386
|
-
questions: [
|
|
387
|
-
{
|
|
388
|
-
question: "What migration strategy should be used for the auth refactor?",
|
|
389
|
-
header: "Strategy",
|
|
390
|
-
multiSelect: false,
|
|
391
|
-
options: [
|
|
392
|
-
{
|
|
393
|
-
label: "Big bang migration (full rewrite)",
|
|
394
|
-
description: "Complete replacement in one deployment. Timeline: 2-3 weeks. Risk: High (downtime, all users logged out)."
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
label: "Incremental migration with feature flags",
|
|
398
|
-
description: "Gradual rollout per route. Timeline: 4-6 weeks. Risk: Medium (code duplication)."
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
label: "Parallel run with adapter pattern",
|
|
402
|
-
description: "Support both methods simultaneously. Timeline: 6-8 weeks. Risk: Low (safe rollback, zero downtime)."
|
|
403
|
-
}
|
|
404
|
-
]
|
|
405
|
-
}
|
|
406
|
-
]
|
|
407
|
-
})
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
**User Selection**: "Parallel run with adapter pattern"
|
|
411
|
-
|
|
412
|
-
**Question 2: JWT Configuration**
|
|
413
|
-
|
|
414
|
-
```typescript
|
|
415
|
-
AskUserQuestion({
|
|
416
|
-
questions: [
|
|
417
|
-
{
|
|
418
|
-
question: "How should JWT tokens be configured?",
|
|
419
|
-
header: "JWT Config",
|
|
420
|
-
multiSelect: false,
|
|
421
|
-
options: [
|
|
422
|
-
{
|
|
423
|
-
label: "Short-lived access tokens only (15 min)",
|
|
424
|
-
description: "Single token type. Simple but requires frequent logins."
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
label: "Access + refresh tokens (15 min + 7 days)",
|
|
428
|
-
description: "Access token for requests, refresh for renewal. Standard approach, better UX."
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
label: "Long-lived access tokens (24 hours)",
|
|
432
|
-
description: "Extended lifespan, no refresh tokens. Simplified but less secure."
|
|
433
|
-
}
|
|
434
|
-
]
|
|
435
|
-
}
|
|
436
|
-
]
|
|
437
|
-
})
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
**User Selection**: "Access + refresh tokens (15 min + 7 days)"
|
|
441
|
-
|
|
442
|
-
**Question 3: Rollout Plan**
|
|
443
|
-
|
|
444
|
-
```typescript
|
|
445
|
-
AskUserQuestion({
|
|
446
|
-
questions: [
|
|
447
|
-
{
|
|
448
|
-
question: "What rollout percentage should be used for JWT migration?",
|
|
449
|
-
header: "Rollout",
|
|
450
|
-
multiSelect: false,
|
|
451
|
-
options: [
|
|
452
|
-
{
|
|
453
|
-
label: "Canary (5% → 25% → 50% → 100%)",
|
|
454
|
-
description: "Gradual rollout over 4 weeks with monitoring. Safest approach."
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
label: "Blue-Green (0% → 100%)",
|
|
458
|
-
description: "Full cutover after parallel testing. Faster but higher risk."
|
|
459
|
-
},
|
|
460
|
-
{
|
|
461
|
-
label: "Opt-in beta (users choose)",
|
|
462
|
-
description: "Users voluntarily test JWT auth. Slowest but zero forced risk."
|
|
463
|
-
}
|
|
464
|
-
]
|
|
465
|
-
}
|
|
466
|
-
]
|
|
467
|
-
})
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
**User Selection**: "Canary (5% → 25% → 50% → 100%)"
|
|
471
|
-
|
|
472
|
-
### Execution
|
|
473
|
-
|
|
474
|
-
```typescript
|
|
475
|
-
// lib/auth/adapter.ts
|
|
476
|
-
export class AuthAdapter {
|
|
477
|
-
private sessionAuth: SessionAuthHandler;
|
|
478
|
-
private jwtAuth: JWTAuthHandler;
|
|
479
|
-
private rolloutPercentage: number;
|
|
480
|
-
|
|
481
|
-
async authenticate(req: Request): Promise<User | null> {
|
|
482
|
-
const useJWT = this.shouldUseJWT(req);
|
|
483
|
-
|
|
484
|
-
if (useJWT) {
|
|
485
|
-
return this.jwtAuth.authenticate(req);
|
|
486
|
-
} else {
|
|
487
|
-
return this.sessionAuth.authenticate(req);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
private shouldUseJWT(req: Request): boolean {
|
|
492
|
-
// Sticky session: once JWT, always JWT
|
|
493
|
-
if (req.cookies.auth_method === 'jwt') return true;
|
|
494
|
-
|
|
495
|
-
// Gradual rollout based on user ID hash
|
|
496
|
-
const userId = req.session?.userId;
|
|
497
|
-
if (!userId) return false;
|
|
498
|
-
|
|
499
|
-
const hash = hashUserId(userId);
|
|
500
|
-
return (hash % 100) < this.rolloutPercentage;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// Rollout schedule (via environment variable)
|
|
505
|
-
// Week 1-2: ROLLOUT_PERCENTAGE=5
|
|
506
|
-
// Week 3-4: ROLLOUT_PERCENTAGE=25
|
|
507
|
-
// Week 5-6: ROLLOUT_PERCENTAGE=50
|
|
508
|
-
// Week 7-8: ROLLOUT_PERCENTAGE=100
|
|
509
|
-
```
|
|
510
|
-
|
|
511
|
-
### Outcome
|
|
512
|
-
|
|
513
|
-
✅ Parallel auth system with adapter pattern
|
|
514
|
-
✅ Zero downtime migration over 6-8 weeks
|
|
515
|
-
✅ Safe rollback at any stage
|
|
516
|
-
✅ Canary deployment with monitoring
|
|
517
|
-
✅ Access (15 min) + refresh (7 days) tokens
|
|
518
|
-
✅ Matches confirmed risk tolerance
|
|
519
|
-
|
|
520
|
-
---
|
|
521
|
-
|
|
522
|
-
## Example 4: Feature Approval Workflow
|
|
523
|
-
|
|
524
|
-
### Context
|
|
525
|
-
|
|
526
|
-
**User Request**: "Clean up unused files from the last refactor."
|
|
527
|
-
|
|
528
|
-
**Current State**:
|
|
529
|
-
- 50 files not referenced in codebase (last modified >6 months ago)
|
|
530
|
-
- Files include: deprecated components, old test fixtures, legacy utils
|
|
531
|
-
- Risk: some files may be dynamically imported or used in scripts
|
|
532
|
-
|
|
533
|
-
### Phase 1: Analysis & Backup
|
|
534
|
-
|
|
535
|
-
```typescript
|
|
536
|
-
const unusedFiles = [
|
|
537
|
-
"/src/components/deprecated/OldButton.tsx",
|
|
538
|
-
"/src/utils/legacy/formatter.ts",
|
|
539
|
-
// ... 48 more files
|
|
540
|
-
];
|
|
541
|
-
|
|
542
|
-
// Create backup
|
|
543
|
-
await Bash("git checkout -b backup/pre-cleanup-2025-10-22");
|
|
544
|
-
await Bash("tar -czf .moai-backups/pre-cleanup-$(date +%Y%m%d).tar.gz src/");
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
### Phase 2: Approval Survey
|
|
548
|
-
|
|
549
|
-
```typescript
|
|
550
|
-
AskUserQuestion({
|
|
551
|
-
questions: [
|
|
552
|
-
{
|
|
553
|
-
question: "50 unused files identified. Review and approve deletion?",
|
|
554
|
-
header: "Cleanup",
|
|
555
|
-
multiSelect: false,
|
|
556
|
-
options: [
|
|
557
|
-
{
|
|
558
|
-
label: "Show file list first",
|
|
559
|
-
description: "Display all 50 files before deciding. Manual review of each path."
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
label: "Approve and execute cleanup",
|
|
563
|
-
description: "Delete all 50 files immediately. Backup created. Reversible via Git."
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
label: "Approve deletion for specific directories only",
|
|
567
|
-
description: "Select directories to clean. Partial cleanup with directory-level control."
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
label: "Cancel operation",
|
|
571
|
-
description: "Abort cleanup, keep all files."
|
|
572
|
-
}
|
|
573
|
-
]
|
|
574
|
-
}
|
|
575
|
-
]
|
|
576
|
-
})
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
**User Selection**: "Show file list first"
|
|
580
|
-
|
|
581
|
-
### Phase 3: Detailed Review
|
|
582
|
-
|
|
583
|
-
```typescript
|
|
584
|
-
const filesByCategory = {
|
|
585
|
-
"Deprecated Components (15 files)": [
|
|
586
|
-
"/src/components/deprecated/OldButton.tsx",
|
|
587
|
-
"/src/components/deprecated/LegacyModal.tsx",
|
|
588
|
-
// ... 13 more
|
|
589
|
-
],
|
|
590
|
-
"Legacy Utilities (20 files)": [
|
|
591
|
-
"/src/utils/legacy/formatter.ts",
|
|
592
|
-
"/src/utils/legacy/validator.ts",
|
|
593
|
-
// ... 18 more
|
|
594
|
-
],
|
|
595
|
-
"Old Test Fixtures (15 files)": [
|
|
596
|
-
"/tests/fixtures/old-data.json",
|
|
597
|
-
"/tests/fixtures/deprecated-mock.ts",
|
|
598
|
-
// ... 13 more
|
|
599
|
-
]
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
// Follow-up survey
|
|
603
|
-
AskUserQuestion({
|
|
604
|
-
questions: [
|
|
605
|
-
{
|
|
606
|
-
question: "Which categories should be cleaned up?",
|
|
607
|
-
header: "Categories",
|
|
608
|
-
multiSelect: true,
|
|
609
|
-
options: [
|
|
610
|
-
{
|
|
611
|
-
label: "Deprecated Components (15 files)",
|
|
612
|
-
description: "Remove old UI components no longer used."
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
label: "Legacy Utilities (20 files)",
|
|
616
|
-
description: "Remove utility functions replaced by modern alternatives."
|
|
617
|
-
},
|
|
618
|
-
{
|
|
619
|
-
label: "Old Test Fixtures (15 files)",
|
|
620
|
-
description: "Remove outdated test data and mocks."
|
|
621
|
-
}
|
|
622
|
-
]
|
|
623
|
-
}
|
|
624
|
-
]
|
|
625
|
-
})
|
|
626
|
-
```
|
|
627
|
-
|
|
628
|
-
**User Selections**: ["Deprecated Components (15 files)", "Old Test Fixtures (15 files)"]
|
|
629
|
-
|
|
630
|
-
### Phase 4: Execution
|
|
631
|
-
|
|
632
|
-
```typescript
|
|
633
|
-
const filesToDelete = [
|
|
634
|
-
...filesByCategory["Deprecated Components (15 files)"],
|
|
635
|
-
...filesByCategory["Old Test Fixtures (15 files)"]
|
|
636
|
-
];
|
|
637
|
-
|
|
638
|
-
for (const file of filesToDelete) {
|
|
639
|
-
await Bash(`rm ${file}`);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
await Bash(`git add -A && git commit -m "chore: remove deprecated components and test fixtures
|
|
643
|
-
|
|
644
|
-
- Deleted 15 deprecated component files
|
|
645
|
-
- Deleted 15 old test fixture files
|
|
646
|
-
- Preserved 20 legacy utility files for gradual migration
|
|
647
|
-
- Backup available at .moai-backups/pre-cleanup-2025-10-22.tar.gz
|
|
648
|
-
|
|
649
|
-
Refs: cleanup-2025-10-22"`);
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
### Outcome
|
|
653
|
-
|
|
654
|
-
✅ 30 files deleted (selective cleanup)
|
|
655
|
-
✅ 20 files preserved (user decision)
|
|
656
|
-
✅ Complete backup and Git branch for rollback
|
|
657
|
-
✅ User had full control and visibility
|
|
658
|
-
✅ Explicit approval before destructive operation
|
|
659
|
-
|
|
660
|
-
---
|
|
661
|
-
|
|
662
|
-
## Example 5: API Design Decision
|
|
663
|
-
|
|
664
|
-
### Context
|
|
665
|
-
|
|
666
|
-
**User Request**: "Add pagination to the /api/posts endpoint."
|
|
667
|
-
|
|
668
|
-
**Current State**:
|
|
669
|
-
- Endpoint returns all posts (currently 200, growing to 1000+)
|
|
670
|
-
- No pagination implemented
|
|
671
|
-
- Frontend expects array of posts
|
|
672
|
-
|
|
673
|
-
### Interactive Survey
|
|
674
|
-
|
|
675
|
-
```typescript
|
|
676
|
-
AskUserQuestion({
|
|
677
|
-
questions: [
|
|
678
|
-
{
|
|
679
|
-
question: "Which pagination strategy should be used?",
|
|
680
|
-
header: "Pagination",
|
|
681
|
-
multiSelect: false,
|
|
682
|
-
options: [
|
|
683
|
-
{
|
|
684
|
-
label: "Offset-based (?page=1&limit=20)",
|
|
685
|
-
description: "Traditional page numbers. Simple, familiar. CON: Performance degrades with large offsets."
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
label: "Cursor-based (?cursor=abc123&limit=20)",
|
|
689
|
-
description: "Use cursor (e.g., last post ID). Better performance, consistent results. CON: No random page access."
|
|
690
|
-
},
|
|
691
|
-
{
|
|
692
|
-
label: "Hybrid (offset + cursor fallback)",
|
|
693
|
-
description: "Offset for first 100 pages, cursor thereafter. Balances UX and performance. CON: Complex."
|
|
694
|
-
}
|
|
695
|
-
]
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
question: "Should the API return pagination metadata?",
|
|
699
|
-
header: "Metadata",
|
|
700
|
-
multiSelect: true,
|
|
701
|
-
options: [
|
|
702
|
-
{
|
|
703
|
-
label: "Total count",
|
|
704
|
-
description: "Include total number of posts. Allows 'Page X of Y'. Warning: COUNT(*) slow on large tables."
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
label: "Has next/previous flags",
|
|
708
|
-
description: "Boolean flags indicating more data. Efficient, no COUNT() needed."
|
|
709
|
-
},
|
|
710
|
-
{
|
|
711
|
-
label: "Next/previous page URLs",
|
|
712
|
-
description: "Full URLs (HATEOAS). Self-documenting but larger response."
|
|
713
|
-
}
|
|
714
|
-
]
|
|
715
|
-
}
|
|
716
|
-
]
|
|
717
|
-
})
|
|
718
|
-
```
|
|
719
|
-
|
|
720
|
-
**User Selections**:
|
|
721
|
-
- Pagination: "Cursor-based (?cursor=abc123&limit=20)"
|
|
722
|
-
- Metadata: ["Has next/previous flags", "Next/previous page URLs"]
|
|
723
|
-
|
|
724
|
-
### Execution
|
|
725
|
-
|
|
726
|
-
```typescript
|
|
727
|
-
// GET /api/posts?cursor=abc123&limit=20
|
|
728
|
-
{
|
|
729
|
-
"data": [...],
|
|
730
|
-
"pagination": {
|
|
731
|
-
"hasNext": true,
|
|
732
|
-
"hasPrevious": true,
|
|
733
|
-
"nextUrl": "/api/posts?cursor=def456&limit=20",
|
|
734
|
-
"previousUrl": "/api/posts?cursor=xyz789&limit=20"
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
```
|
|
738
|
-
|
|
739
|
-
---
|
|
740
|
-
|
|
741
|
-
## Example 6: Database Migration Strategy
|
|
742
|
-
|
|
743
|
-
### Context
|
|
744
|
-
|
|
745
|
-
**User Request**: "Add full-text search to the posts table."
|
|
746
|
-
|
|
747
|
-
**Current State**:
|
|
748
|
-
- PostgreSQL 15.x database
|
|
749
|
-
- 500k rows in posts table
|
|
750
|
-
- Production database (24/7 availability required)
|
|
751
|
-
|
|
752
|
-
### Interactive Survey
|
|
753
|
-
|
|
754
|
-
```typescript
|
|
755
|
-
AskUserQuestion({
|
|
756
|
-
questions: [
|
|
757
|
-
{
|
|
758
|
-
question: "Which full-text search implementation should be used?",
|
|
759
|
-
header: "Search",
|
|
760
|
-
multiSelect: false,
|
|
761
|
-
options: [
|
|
762
|
-
{
|
|
763
|
-
label: "PostgreSQL GIN index with tsvector",
|
|
764
|
-
description: "Native Postgres full-text search. PRO: No external dependencies. CON: Less flexible than dedicated engines."
|
|
765
|
-
},
|
|
766
|
-
{
|
|
767
|
-
label: "PostgreSQL pg_trgm (trigram) index",
|
|
768
|
-
description: "Fuzzy matching with trigrams. PRO: Typo-tolerant. CON: Higher storage overhead."
|
|
769
|
-
},
|
|
770
|
-
{
|
|
771
|
-
label: "External search engine (Elasticsearch/Meilisearch)",
|
|
772
|
-
description: "Dedicated search service. PRO: Advanced features. CON: Operational overhead, data sync."
|
|
773
|
-
}
|
|
774
|
-
]
|
|
775
|
-
},
|
|
776
|
-
{
|
|
777
|
-
question: "How should the index be created on production?",
|
|
778
|
-
header: "Migration",
|
|
779
|
-
multiSelect: false,
|
|
780
|
-
options: [
|
|
781
|
-
{
|
|
782
|
-
label: "Online with CONCURRENTLY (zero downtime)",
|
|
783
|
-
description: "CREATE INDEX CONCURRENTLY allows reads/writes during creation. Duration: ~2-4 hours. Risk: Low."
|
|
784
|
-
},
|
|
785
|
-
{
|
|
786
|
-
label: "Offline during maintenance window",
|
|
787
|
-
description: "Scheduled downtime. Duration: ~30-60 minutes. Risk: Medium (unavailable)."
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
label: "Blue-green deployment with replica",
|
|
791
|
-
description: "Create index on replica, promote to primary. Duration: ~1 hour prep + instant cutover. Risk: Low but complex."
|
|
792
|
-
}
|
|
793
|
-
]
|
|
794
|
-
}
|
|
795
|
-
]
|
|
796
|
-
})
|
|
797
|
-
```
|
|
798
|
-
|
|
799
|
-
**User Selections**:
|
|
800
|
-
- Implementation: "PostgreSQL GIN index with tsvector"
|
|
801
|
-
- Migration: "Online with CONCURRENTLY (zero downtime)"
|
|
802
|
-
|
|
803
|
-
### Execution
|
|
804
|
-
|
|
805
|
-
```sql
|
|
806
|
-
-- Migration: add_fulltext_search_to_posts.sql
|
|
807
|
-
|
|
808
|
-
-- Step 1: Add tsvector column
|
|
809
|
-
ALTER TABLE posts
|
|
810
|
-
ADD COLUMN search_vector tsvector;
|
|
811
|
-
|
|
812
|
-
-- Step 2: Populate search_vector (batched)
|
|
813
|
-
UPDATE posts
|
|
814
|
-
SET search_vector = to_tsvector('english', title || ' ' || content)
|
|
815
|
-
WHERE id BETWEEN 1 AND 100000;
|
|
816
|
-
|
|
817
|
-
-- Step 3: Create GIN index (CONCURRENTLY = zero downtime)
|
|
818
|
-
CREATE INDEX CONCURRENTLY idx_posts_search_vector
|
|
819
|
-
ON posts USING GIN(search_vector);
|
|
820
|
-
|
|
821
|
-
-- Step 4: Add trigger to keep search_vector updated
|
|
822
|
-
CREATE TRIGGER posts_search_vector_update
|
|
823
|
-
BEFORE INSERT OR UPDATE ON posts
|
|
824
|
-
FOR EACH ROW EXECUTE FUNCTION
|
|
825
|
-
tsvector_update_trigger(search_vector, 'pg_catalog.english', title, content);
|
|
826
|
-
```
|
|
827
|
-
|
|
828
|
-
---
|
|
829
|
-
|
|
830
|
-
## Example 7: Testing Framework Selection
|
|
831
|
-
|
|
832
|
-
### Context
|
|
833
|
-
|
|
834
|
-
**User Request**: "Set up testing for the React application."
|
|
835
|
-
|
|
836
|
-
**Current State**:
|
|
837
|
-
- React 18.x + TypeScript
|
|
838
|
-
- No tests exist yet
|
|
839
|
-
- Need unit tests, component tests, and E2E tests
|
|
840
|
-
|
|
841
|
-
### Interactive Survey
|
|
842
|
-
|
|
843
|
-
```typescript
|
|
844
|
-
AskUserQuestion({
|
|
845
|
-
questions: [
|
|
846
|
-
{
|
|
847
|
-
question: "Which unit/component testing framework should be used?",
|
|
848
|
-
header: "Test FW",
|
|
849
|
-
multiSelect: false,
|
|
850
|
-
options: [
|
|
851
|
-
{
|
|
852
|
-
label: "Vitest + React Testing Library",
|
|
853
|
-
description: "Modern, fast test runner with native ESM. PRO: Fastest execution. CON: Newer ecosystem."
|
|
854
|
-
},
|
|
855
|
-
{
|
|
856
|
-
label: "Jest + React Testing Library",
|
|
857
|
-
description: "Industry standard. PRO: Mature, many resources. CON: Slower, ESM issues."
|
|
858
|
-
},
|
|
859
|
-
{
|
|
860
|
-
label: "Vitest + Playwright component testing",
|
|
861
|
-
description: "Hybrid with real browser testing. PRO: True browser environment. CON: Slower, complex setup."
|
|
862
|
-
}
|
|
863
|
-
]
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
question: "Which E2E testing tool should be used?",
|
|
867
|
-
header: "E2E Tool",
|
|
868
|
-
multiSelect: false,
|
|
869
|
-
options: [
|
|
870
|
-
{
|
|
871
|
-
label: "Playwright",
|
|
872
|
-
description: "Modern E2E framework. PRO: Fast, reliable, trace viewer. CON: Node-only API."
|
|
873
|
-
},
|
|
874
|
-
{
|
|
875
|
-
label: "Cypress",
|
|
876
|
-
description: "Popular E2E tool. PRO: Great docs, visual testing. CON: Slower than Playwright."
|
|
877
|
-
},
|
|
878
|
-
{
|
|
879
|
-
label: "None (unit/component tests only)",
|
|
880
|
-
description: "Skip E2E initially. PRO: Faster setup. CON: No full user flow coverage."
|
|
881
|
-
}
|
|
882
|
-
]
|
|
883
|
-
}
|
|
884
|
-
]
|
|
885
|
-
})
|
|
886
|
-
```
|
|
887
|
-
|
|
888
|
-
**User Selections**:
|
|
889
|
-
- Unit/Component: "Vitest + React Testing Library"
|
|
890
|
-
- E2E: "Playwright"
|
|
891
|
-
|
|
892
|
-
---
|
|
893
|
-
|
|
894
|
-
## Example 8: Performance Optimization
|
|
895
|
-
|
|
896
|
-
### Context
|
|
897
|
-
|
|
898
|
-
**User Request**: "The dashboard is loading slowly."
|
|
899
|
-
|
|
900
|
-
**Current State**:
|
|
901
|
-
- Dashboard loads in 4-5 seconds
|
|
902
|
-
- Multiple data fetches on mount
|
|
903
|
-
- Large bundle size (500KB)
|
|
904
|
-
- No profiling data yet
|
|
905
|
-
|
|
906
|
-
### Interactive Survey
|
|
907
|
-
|
|
908
|
-
```typescript
|
|
909
|
-
AskUserQuestion({
|
|
910
|
-
questions: [
|
|
911
|
-
{
|
|
912
|
-
question: "What is the primary optimization goal?",
|
|
913
|
-
header: "Goal",
|
|
914
|
-
multiSelect: false,
|
|
915
|
-
options: [
|
|
916
|
-
{
|
|
917
|
-
label: "Reduce initial load time",
|
|
918
|
-
description: "Focus on bundle size, code splitting, lazy loading. Target: <2s to interactive."
|
|
919
|
-
},
|
|
920
|
-
{
|
|
921
|
-
label: "Reduce time to first data",
|
|
922
|
-
description: "Optimize API requests, implement caching, parallel fetches. Target: <1s to first content."
|
|
923
|
-
},
|
|
924
|
-
{
|
|
925
|
-
label: "Improve perceived performance",
|
|
926
|
-
description: "Add loading states, skeleton screens, progressive rendering. Target: instant visual feedback."
|
|
927
|
-
}
|
|
928
|
-
]
|
|
929
|
-
},
|
|
930
|
-
{
|
|
931
|
-
question: "Which optimization techniques should be applied?",
|
|
932
|
-
header: "Techniques",
|
|
933
|
-
multiSelect: true,
|
|
934
|
-
options: [
|
|
935
|
-
{
|
|
936
|
-
label: "Code splitting + lazy loading",
|
|
937
|
-
description: "Split dashboard into chunks, load on demand. Impact: -200KB initial bundle."
|
|
938
|
-
},
|
|
939
|
-
{
|
|
940
|
-
label: "Data fetching optimization",
|
|
941
|
-
description: "Parallel requests, caching, React Query. Impact: -2s load time."
|
|
942
|
-
},
|
|
943
|
-
{
|
|
944
|
-
label: "Image optimization",
|
|
945
|
-
description: "WebP format, responsive images, lazy loading. Impact: -100KB assets."
|
|
946
|
-
},
|
|
947
|
-
{
|
|
948
|
-
label: "Memo/useMemo for expensive renders",
|
|
949
|
-
description: "Prevent unnecessary re-renders. Impact: smoother interactions."
|
|
950
|
-
}
|
|
951
|
-
]
|
|
952
|
-
}
|
|
953
|
-
]
|
|
954
|
-
})
|
|
955
|
-
```
|
|
956
|
-
|
|
957
|
-
**User Selections**:
|
|
958
|
-
- Goal: "Reduce initial load time"
|
|
959
|
-
- Techniques: ["Code splitting + lazy loading", "Data fetching optimization"]
|
|
960
|
-
|
|
961
|
-
---
|
|
962
|
-
|
|
963
|
-
## Best Practices Summary
|
|
964
|
-
|
|
965
|
-
### Effective TUI Surveys:
|
|
966
|
-
|
|
967
|
-
1. **Analyze first**: Examine codebase context before presenting options
|
|
968
|
-
2. **Limit options**: 2-4 choices per question (avoid decision fatigue)
|
|
969
|
-
3. **Show trade-offs**: PRO/CON, effort, risk for each option
|
|
970
|
-
4. **Allow "Other"**: Provide escape hatch for custom input
|
|
971
|
-
5. **Review before execution**: Summary step with "Go back" option
|
|
972
|
-
6. **Context is key**: Include current state, constraints, implications
|
|
973
|
-
|
|
974
|
-
### Common Patterns:
|
|
975
|
-
|
|
976
|
-
- **Architectural decisions**: Present 3 approaches with trade-offs
|
|
977
|
-
- **Technical choices**: Show maturity, ecosystem, pros/cons
|
|
978
|
-
- **Migration strategies**: Include timeline, risk, rollback plan
|
|
979
|
-
- **Approval workflows**: Show impact, backup plan, reversibility
|
|
980
|
-
|
|
981
|
-
### Integration with MoAI Workflow:
|
|
982
|
-
|
|
983
|
-
- **Plan phase**: Scope clarification, EARS pattern selection
|
|
984
|
-
- **Run phase**: Library selection, implementation approach
|
|
985
|
-
- **Sync phase**: Documentation format, merge strategy
|
|
986
|
-
|
|
987
|
-
---
|
|
988
|
-
|
|
989
|
-
**Examples Count**: 8 complete scenarios
|
|
990
|
-
**Total Lines**: 850+
|
|
991
|
-
**Coverage**: Architecture, libraries, refactoring, approvals, API design, databases, testing, performance
|
|
992
|
-
**Last Updated**: 2025-10-22
|