moai-adk 0.4.4__py3-none-any.whl → 0.4.7__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.

Files changed (191) hide show
  1. moai_adk/__init__.py +1 -1
  2. moai_adk/core/project/initializer.py +12 -5
  3. moai_adk/templates/.claude/agents/alfred/skill-factory.md +829 -0
  4. moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +78 -77
  5. moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/examples.md +29 -0
  6. moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/reference.md +28 -0
  7. moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +87 -77
  8. moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/examples.md +29 -0
  9. moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/reference.md +28 -0
  10. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +76 -66
  11. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +29 -0
  12. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +28 -0
  13. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +86 -59
  14. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +29 -0
  15. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +29 -0
  16. moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +87 -73
  17. moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +29 -0
  18. moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +28 -0
  19. moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +87 -79
  20. moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/examples.md +29 -0
  21. moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/reference.md +28 -0
  22. moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +87 -71
  23. moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/examples.md +29 -0
  24. moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/reference.md +28 -0
  25. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +78 -62
  26. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +29 -0
  27. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +28 -0
  28. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +78 -55
  29. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +29 -0
  30. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +28 -0
  31. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +78 -64
  32. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +29 -0
  33. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +28 -0
  34. moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +604 -56
  35. moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +974 -44
  36. moai_adk/templates/.claude/skills/moai-alfred-tui-survey/reference.md +801 -0
  37. moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +88 -61
  38. moai_adk/templates/.claude/skills/moai-claude-code/examples.md +16 -500
  39. moai_adk/templates/.claude/skills/moai-claude-code/reference.md +15 -420
  40. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +234 -43
  41. moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +1633 -0
  42. moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +660 -0
  43. moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +97 -69
  44. moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +29 -0
  45. moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +30 -0
  46. moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +97 -72
  47. moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +29 -0
  48. moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +30 -0
  49. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +97 -74
  50. moai_adk/templates/.claude/skills/moai-domain-database/examples.md +29 -0
  51. moai_adk/templates/.claude/skills/moai-domain-database/reference.md +30 -0
  52. moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +98 -74
  53. moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +29 -0
  54. moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +31 -0
  55. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +98 -73
  56. moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +29 -0
  57. moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +31 -0
  58. moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +97 -73
  59. moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +29 -0
  60. moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +30 -0
  61. moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +97 -67
  62. moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +29 -0
  63. moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +30 -0
  64. moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +97 -79
  65. moai_adk/templates/.claude/skills/moai-domain-security/examples.md +29 -0
  66. moai_adk/templates/.claude/skills/moai-domain-security/reference.md +30 -0
  67. moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +97 -71
  68. moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +29 -0
  69. moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +30 -0
  70. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +656 -60
  71. moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +1107 -0
  72. moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +1533 -0
  73. moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +87 -78
  74. moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +29 -0
  75. moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +28 -0
  76. moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +87 -70
  77. moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +29 -0
  78. moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +28 -0
  79. moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +87 -86
  80. moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +29 -0
  81. moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +28 -0
  82. moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +77 -62
  83. moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +29 -0
  84. moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +28 -0
  85. moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +88 -56
  86. moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +29 -0
  87. moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +29 -0
  88. moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +90 -71
  89. moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +29 -0
  90. moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +28 -0
  91. moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +78 -58
  92. moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +29 -0
  93. moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +28 -0
  94. moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +78 -51
  95. moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +29 -0
  96. moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +28 -0
  97. moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +253 -32
  98. moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
  99. moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +1099 -0
  100. moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +98 -74
  101. moai_adk/templates/.claude/skills/moai-lang-c/examples.md +29 -0
  102. moai_adk/templates/.claude/skills/moai-lang-c/reference.md +31 -0
  103. moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +97 -74
  104. moai_adk/templates/.claude/skills/moai-lang-clojure/examples.md +29 -0
  105. moai_adk/templates/.claude/skills/moai-lang-clojure/reference.md +30 -0
  106. moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +98 -76
  107. moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +29 -0
  108. moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +31 -0
  109. moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +97 -74
  110. moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +29 -0
  111. moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +30 -0
  112. moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +86 -61
  113. moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +29 -0
  114. moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +30 -0
  115. moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +98 -73
  116. moai_adk/templates/.claude/skills/moai-lang-elixir/examples.md +29 -0
  117. moai_adk/templates/.claude/skills/moai-lang-elixir/reference.md +31 -0
  118. moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +98 -74
  119. moai_adk/templates/.claude/skills/moai-lang-go/examples.md +29 -0
  120. moai_adk/templates/.claude/skills/moai-lang-go/reference.md +31 -0
  121. moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +98 -74
  122. moai_adk/templates/.claude/skills/moai-lang-haskell/examples.md +29 -0
  123. moai_adk/templates/.claude/skills/moai-lang-haskell/reference.md +31 -0
  124. moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +87 -61
  125. moai_adk/templates/.claude/skills/moai-lang-java/examples.md +29 -0
  126. moai_adk/templates/.claude/skills/moai-lang-java/reference.md +31 -0
  127. moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +88 -59
  128. moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +29 -0
  129. moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +32 -0
  130. moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +86 -61
  131. moai_adk/templates/.claude/skills/moai-lang-julia/examples.md +29 -0
  132. moai_adk/templates/.claude/skills/moai-lang-julia/reference.md +30 -0
  133. moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +98 -73
  134. moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +29 -0
  135. moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +31 -0
  136. moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +86 -61
  137. moai_adk/templates/.claude/skills/moai-lang-lua/examples.md +29 -0
  138. moai_adk/templates/.claude/skills/moai-lang-lua/reference.md +30 -0
  139. moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +86 -61
  140. moai_adk/templates/.claude/skills/moai-lang-php/examples.md +29 -0
  141. moai_adk/templates/.claude/skills/moai-lang-php/reference.md +30 -0
  142. moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +388 -53
  143. moai_adk/templates/.claude/skills/moai-lang-python/examples.md +624 -0
  144. moai_adk/templates/.claude/skills/moai-lang-python/reference.md +316 -0
  145. moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +97 -73
  146. moai_adk/templates/.claude/skills/moai-lang-r/examples.md +29 -0
  147. moai_adk/templates/.claude/skills/moai-lang-r/reference.md +30 -0
  148. moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +98 -73
  149. moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +29 -0
  150. moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +31 -0
  151. moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +98 -74
  152. moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +29 -0
  153. moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +31 -0
  154. moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +97 -74
  155. moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +29 -0
  156. moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +30 -0
  157. moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +97 -74
  158. moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +29 -0
  159. moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +30 -0
  160. moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +98 -74
  161. moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +29 -0
  162. moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +31 -0
  163. moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +97 -73
  164. moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +29 -0
  165. moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +30 -0
  166. moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +90 -59
  167. moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +29 -0
  168. moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +34 -0
  169. moai_adk/templates/.claude/skills/moai-skill-factory/CHECKLIST.md +482 -0
  170. moai_adk/templates/.claude/skills/moai-skill-factory/EXAMPLES.md +52 -0
  171. moai_adk/templates/.claude/skills/moai-skill-factory/INTERACTIVE-DISCOVERY.md +524 -0
  172. moai_adk/templates/.claude/skills/moai-skill-factory/METADATA.md +477 -0
  173. moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-UPDATE-ADVISOR.md +577 -0
  174. moai_adk/templates/.claude/skills/moai-skill-factory/SKILL.md +560 -0
  175. moai_adk/templates/.claude/skills/moai-skill-factory/STRUCTURE.md +583 -0
  176. moai_adk/templates/.claude/skills/moai-skill-factory/WEB-RESEARCH.md +526 -0
  177. moai_adk/templates/.claude/skills/moai-skill-factory/reference.md +69 -0
  178. moai_adk/templates/.claude/skills/moai-skill-factory/scripts/generate-structure.sh +328 -0
  179. moai_adk/templates/.claude/skills/moai-skill-factory/scripts/validate-skill.sh +312 -0
  180. moai_adk/templates/.claude/skills/moai-skill-factory/templates/SKILL_TEMPLATE.md +245 -0
  181. moai_adk/templates/.claude/skills/moai-skill-factory/templates/examples-template.md +285 -0
  182. moai_adk/templates/.claude/skills/moai-skill-factory/templates/reference-template.md +278 -0
  183. moai_adk/templates/.claude/skills/moai-skill-factory/templates/scripts-template.sh +303 -0
  184. moai_adk/templates/CLAUDE.md +43 -11
  185. moai_adk-0.4.7.dist-info/METADATA +1162 -0
  186. moai_adk-0.4.7.dist-info/RECORD +275 -0
  187. moai_adk-0.4.4.dist-info/METADATA +0 -369
  188. moai_adk-0.4.4.dist-info/RECORD +0 -152
  189. {moai_adk-0.4.4.dist-info → moai_adk-0.4.7.dist-info}/WHEEL +0 -0
  190. {moai_adk-0.4.4.dist-info → moai_adk-0.4.7.dist-info}/entry_points.txt +0 -0
  191. {moai_adk-0.4.4.dist-info → moai_adk-0.4.7.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,801 @@
1
+ # TUI Survey Reference - API & Integration Guide
2
+
3
+ Complete technical reference for the moai-alfred-tui-survey Skill.
4
+
5
+ _Last updated: 2025-10-22_
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ 1. [AskUserQuestion API](#askuserquestion-api)
12
+ 2. [Question Design Patterns](#question-design-patterns)
13
+ 3. [Response Handling](#response-handling)
14
+ 4. [Integration with Alfred Sub-agents](#integration-with-alfred-sub-agents)
15
+ 5. [Decision Trees](#decision-trees)
16
+ 6. [TUI Frameworks Comparison](#tui-frameworks-comparison)
17
+ 7. [Validation & Error Handling](#validation--error-handling)
18
+
19
+ ---
20
+
21
+ ## AskUserQuestion API
22
+
23
+ ### Complete API Specification
24
+
25
+ ```typescript
26
+ interface AskUserQuestionParams {
27
+ questions: Question[];
28
+ }
29
+
30
+ interface Question {
31
+ question: string; // Required: The question text
32
+ header: string; // Required: Short label (max 12 chars)
33
+ multiSelect: boolean; // Required: Allow multiple selections
34
+ options: Option[]; // Required: 2-4 options
35
+ }
36
+
37
+ interface Option {
38
+ label: string; // Required: Option display text
39
+ description: string; // Required: Explanation of option
40
+ }
41
+
42
+ interface AskUserQuestionResponse {
43
+ answers: {
44
+ [questionIndex: string]: string | string[];
45
+ };
46
+ }
47
+ ```
48
+
49
+ ### Field Constraints
50
+
51
+ | Field | Type | Required | Constraints | Notes |
52
+ |-------|------|----------|-------------|-------|
53
+ | `question` | string | Yes | 10-200 chars | Must end with `?` |
54
+ | `header` | string | Yes | Max 12 chars | Short label for UI |
55
+ | `multiSelect` | boolean | Yes | true/false | Checkbox vs radio |
56
+ | `options` | Option[] | Yes | 2-4 items | Too few = no choice, too many = fatigue |
57
+ | `label` | string | Yes | 3-50 chars | Concise option name |
58
+ | `description` | string | Yes | 20-200 chars | Explain implications |
59
+
60
+ ### Example: Minimal Survey
61
+
62
+ ```typescript
63
+ AskUserQuestion({
64
+ questions: [
65
+ {
66
+ question: "Which approach should be used?",
67
+ header: "Approach",
68
+ multiSelect: false,
69
+ options: [
70
+ {
71
+ label: "Option A",
72
+ description: "Description of option A with trade-offs."
73
+ },
74
+ {
75
+ label: "Option B",
76
+ description: "Description of option B with trade-offs."
77
+ }
78
+ ]
79
+ }
80
+ ]
81
+ })
82
+ ```
83
+
84
+ ### Example: Multi-Question Survey
85
+
86
+ ```typescript
87
+ AskUserQuestion({
88
+ questions: [
89
+ {
90
+ question: "What is the primary goal?",
91
+ header: "Goal",
92
+ multiSelect: false,
93
+ options: [
94
+ {
95
+ label: "Performance",
96
+ description: "Optimize for speed and efficiency."
97
+ },
98
+ {
99
+ label: "Simplicity",
100
+ description: "Optimize for ease of maintenance."
101
+ },
102
+ {
103
+ label: "Flexibility",
104
+ description: "Optimize for extensibility and customization."
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ question: "Which features should be included?",
110
+ header: "Features",
111
+ multiSelect: true,
112
+ options: [
113
+ {
114
+ label: "Feature A",
115
+ description: "Description of feature A."
116
+ },
117
+ {
118
+ label: "Feature B",
119
+ description: "Description of feature B."
120
+ },
121
+ {
122
+ label: "Feature C",
123
+ description: "Description of feature C."
124
+ }
125
+ ]
126
+ }
127
+ ]
128
+ })
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Question Design Patterns
134
+
135
+ ### Pattern 1: Binary Decision
136
+
137
+ **Use when**: Two mutually exclusive choices
138
+
139
+ ```typescript
140
+ {
141
+ question: "Should this feature be enabled?",
142
+ header: "Enable",
143
+ multiSelect: false,
144
+ options: [
145
+ {
146
+ label: "Yes, enable",
147
+ description: "Activate the feature immediately. PRO: Instant availability. CON: May need tuning."
148
+ },
149
+ {
150
+ label: "No, skip",
151
+ description: "Disable for now. PRO: No risk. CON: Feature unavailable."
152
+ }
153
+ ]
154
+ }
155
+ ```
156
+
157
+ ### Pattern 2: Multiple Choice (Exclusive)
158
+
159
+ **Use when**: 3-4 distinct options, pick one
160
+
161
+ ```typescript
162
+ {
163
+ question: "Which deployment strategy?",
164
+ header: "Deploy",
165
+ multiSelect: false,
166
+ options: [
167
+ {
168
+ label: "Rolling deployment",
169
+ description: "Gradual instance replacement. Zero downtime, 15 min duration."
170
+ },
171
+ {
172
+ label: "Blue-green deployment",
173
+ description: "Instant cutover to new environment. 5 min duration, easy rollback."
174
+ },
175
+ {
176
+ label: "Canary deployment",
177
+ description: "Gradual traffic shift (5% → 100%). Safest, 2 hour duration."
178
+ }
179
+ ]
180
+ }
181
+ ```
182
+
183
+ ### Pattern 3: Multiple Selection (Combinable)
184
+
185
+ **Use when**: Options are independent and can be combined
186
+
187
+ ```typescript
188
+ {
189
+ question: "Which security features should be enabled?",
190
+ header: "Security",
191
+ multiSelect: true,
192
+ options: [
193
+ {
194
+ label: "Rate limiting",
195
+ description: "Prevent abuse with request rate limits per user/IP."
196
+ },
197
+ {
198
+ label: "CSRF protection",
199
+ description: "Protect against cross-site request forgery attacks."
200
+ },
201
+ {
202
+ label: "XSS prevention",
203
+ description: "Set Content-Security-Policy and X-Frame-Options headers."
204
+ }
205
+ ]
206
+ }
207
+ ```
208
+
209
+ ### Pattern 4: Scope Definition
210
+
211
+ **Use when**: Need to define extent or depth of implementation
212
+
213
+ ```typescript
214
+ {
215
+ question: "What scope should this feature cover?",
216
+ header: "Scope",
217
+ multiSelect: false,
218
+ options: [
219
+ {
220
+ label: "Minimal (core only)",
221
+ description: "Essential functionality. Effort: 2-3 days."
222
+ },
223
+ {
224
+ label: "Standard (common use cases)",
225
+ description: "Core + frequent scenarios. Effort: 5-7 days."
226
+ },
227
+ {
228
+ label: "Comprehensive (full feature set)",
229
+ description: "All capabilities included. Effort: 10-14 days."
230
+ }
231
+ ]
232
+ }
233
+ ```
234
+
235
+ ### Pattern 5: Technical Choice
236
+
237
+ **Use when**: Selecting libraries, tools, or frameworks
238
+
239
+ ```typescript
240
+ {
241
+ question: "Which state management library?",
242
+ header: "Library",
243
+ multiSelect: false,
244
+ options: [
245
+ {
246
+ label: "Redux Toolkit (v2.x)",
247
+ description: "Industry standard. PRO: Battle-tested, DevTools. CON: More boilerplate."
248
+ },
249
+ {
250
+ label: "Zustand (v5.x)",
251
+ description: "Modern minimalist. PRO: Simple API. CON: Fewer resources."
252
+ },
253
+ {
254
+ label: "Jotai (v2.x)",
255
+ description: "Atomic state. PRO: Fine-grained reactivity. CON: Paradigm shift."
256
+ }
257
+ ]
258
+ }
259
+ ```
260
+
261
+ ### Pattern 6: Risk Assessment
262
+
263
+ **Use when**: Decision involves trade-offs between risk and speed
264
+
265
+ ```typescript
266
+ {
267
+ question: "What migration strategy?",
268
+ header: "Migration",
269
+ multiSelect: false,
270
+ options: [
271
+ {
272
+ label: "Big bang (high risk, fast)",
273
+ description: "Complete replacement. Timeline: 2-3 weeks. Risk: High downtime."
274
+ },
275
+ {
276
+ label: "Incremental (medium risk, medium speed)",
277
+ description: "Gradual rollout. Timeline: 4-6 weeks. Risk: Medium complexity."
278
+ },
279
+ {
280
+ label: "Parallel run (low risk, slow)",
281
+ description: "Support both systems. Timeline: 6-8 weeks. Risk: Low, safe rollback."
282
+ }
283
+ ]
284
+ }
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Response Handling
290
+
291
+ ### Single-Select Response
292
+
293
+ ```typescript
294
+ const response = await AskUserQuestion({
295
+ questions: [
296
+ {
297
+ question: "Which approach?",
298
+ header: "Approach",
299
+ multiSelect: false,
300
+ options: [
301
+ { label: "Option A", description: "..." },
302
+ { label: "Option B", description: "..." }
303
+ ]
304
+ }
305
+ ]
306
+ });
307
+
308
+ // Response format
309
+ {
310
+ answers: {
311
+ "0": "Option A" // String value
312
+ }
313
+ }
314
+
315
+ // Access the selected option
316
+ const selectedOption = response.answers["0"];
317
+ if (selectedOption === "Option A") {
318
+ // Execute Option A logic
319
+ }
320
+ ```
321
+
322
+ ### Multi-Select Response
323
+
324
+ ```typescript
325
+ const response = await AskUserQuestion({
326
+ questions: [
327
+ {
328
+ question: "Which features?",
329
+ header: "Features",
330
+ multiSelect: true,
331
+ options: [
332
+ { label: "Feature A", description: "..." },
333
+ { label: "Feature B", description: "..." },
334
+ { label: "Feature C", description: "..." }
335
+ ]
336
+ }
337
+ ]
338
+ });
339
+
340
+ // Response format
341
+ {
342
+ answers: {
343
+ "0": ["Feature A", "Feature C"] // Array of strings
344
+ }
345
+ }
346
+
347
+ // Access the selected options
348
+ const selectedFeatures = response.answers["0"];
349
+ if (selectedFeatures.includes("Feature A")) {
350
+ // Execute Feature A logic
351
+ }
352
+ if (selectedFeatures.includes("Feature C")) {
353
+ // Execute Feature C logic
354
+ }
355
+ ```
356
+
357
+ ### Multi-Question Response
358
+
359
+ ```typescript
360
+ const response = await AskUserQuestion({
361
+ questions: [
362
+ {
363
+ question: "Primary goal?",
364
+ header: "Goal",
365
+ multiSelect: false,
366
+ options: [/* ... */]
367
+ },
368
+ {
369
+ question: "Which features?",
370
+ header: "Features",
371
+ multiSelect: true,
372
+ options: [/* ... */]
373
+ }
374
+ ]
375
+ });
376
+
377
+ // Response format
378
+ {
379
+ answers: {
380
+ "0": "Performance", // Question 1 (single-select)
381
+ "1": ["Feature A", "Feature B"] // Question 2 (multi-select)
382
+ }
383
+ }
384
+
385
+ // Access responses
386
+ const goal = response.answers["0"];
387
+ const features = response.answers["1"];
388
+ ```
389
+
390
+ ### Handling "Other" Option
391
+
392
+ When user selects "Other" and provides custom input:
393
+
394
+ ```typescript
395
+ const selectedOption = response.answers["0"];
396
+ if (selectedOption === "Other") {
397
+ // Follow-up survey or prompt for details
398
+ const detailsResponse = await AskUserQuestion({
399
+ questions: [
400
+ {
401
+ question: "Please specify the custom approach:",
402
+ header: "Custom",
403
+ multiSelect: false,
404
+ options: [
405
+ { label: "Approach X", description: "..." },
406
+ { label: "Approach Y", description: "..." }
407
+ ]
408
+ }
409
+ ]
410
+ });
411
+ }
412
+ ```
413
+
414
+ ---
415
+
416
+ ## Integration with Alfred Sub-agents
417
+
418
+ ### spec-builder Integration
419
+
420
+ ```typescript
421
+ // In spec-builder sub-agent
422
+ class SpecBuilder {
423
+ async clarifyScope(featureName: string) {
424
+ const response = await AskUserQuestion({
425
+ questions: [
426
+ {
427
+ question: `What should the ${featureName} feature include?`,
428
+ header: "Scope",
429
+ multiSelect: true,
430
+ options: this.generateScopeOptions(featureName)
431
+ }
432
+ ]
433
+ });
434
+
435
+ return this.buildSpecFromAnswers(response.answers);
436
+ }
437
+
438
+ private generateScopeOptions(featureName: string): Option[] {
439
+ // Context-aware option generation based on codebase analysis
440
+ const analysis = this.analyzeExistingFeatures();
441
+ return [
442
+ {
443
+ label: "Core functionality",
444
+ description: `Essential ${featureName} capabilities. Effort: ${analysis.minimalEffort}`
445
+ },
446
+ {
447
+ label: "Extended features",
448
+ description: `Core + common use cases. Effort: ${analysis.standardEffort}`
449
+ },
450
+ {
451
+ label: "Full implementation",
452
+ description: `All capabilities. Effort: ${analysis.comprehensiveEffort}`
453
+ }
454
+ ];
455
+ }
456
+ }
457
+ ```
458
+
459
+ ### code-builder pipeline Integration
460
+
461
+ ```typescript
462
+ // In implementation-planner (Phase 1 of code-builder pipeline)
463
+ class ImplementationPlanner {
464
+ async selectLibrary(purpose: string, candidates: Library[]) {
465
+ const options = candidates.map(lib => ({
466
+ label: `${lib.name} (${lib.version})`,
467
+ description: `${lib.description} PRO: ${lib.pros}. CON: ${lib.cons}.`
468
+ }));
469
+
470
+ const response = await AskUserQuestion({
471
+ questions: [
472
+ {
473
+ question: `Which library should be used for ${purpose}?`,
474
+ header: "Library",
475
+ multiSelect: false,
476
+ options
477
+ }
478
+ ]
479
+ });
480
+
481
+ return candidates.find(lib =>
482
+ response.answers["0"].startsWith(lib.name)
483
+ );
484
+ }
485
+ }
486
+ ```
487
+
488
+ ### doc-syncer Integration
489
+
490
+ ```typescript
491
+ // In doc-syncer sub-agent
492
+ class DocSyncer {
493
+ async selectDocumentationFormat() {
494
+ const response = await AskUserQuestion({
495
+ questions: [
496
+ {
497
+ question: "Which documentation format should be used?",
498
+ header: "Format",
499
+ multiSelect: false,
500
+ options: [
501
+ {
502
+ label: "Markdown (standard)",
503
+ description: "GitHub-flavored Markdown. Best for most projects."
504
+ },
505
+ {
506
+ label: "MDX (interactive)",
507
+ description: "Markdown + JSX components. For interactive docs."
508
+ },
509
+ {
510
+ label: "AsciiDoc (technical)",
511
+ description: "Rich semantic markup. For complex technical docs."
512
+ }
513
+ ]
514
+ }
515
+ ]
516
+ });
517
+
518
+ return response.answers["0"];
519
+ }
520
+ }
521
+ ```
522
+
523
+ ---
524
+
525
+ ## Decision Trees
526
+
527
+ ### Tree 1: Feature Implementation Flow
528
+
529
+ ```
530
+ Start: User requests "Add feature X"
531
+
532
+ Context Analysis
533
+
534
+ Q1: "How should feature X be implemented?"
535
+ ├─ Option A → Q2a: "Which data store?"
536
+ ├─ Option B → Q2b: "Which UI framework?"
537
+ └─ Option C → Q2c: "Which API pattern?"
538
+
539
+ Review Summary
540
+
541
+ Confirmation
542
+
543
+ Execute
544
+ ```
545
+
546
+ ### Tree 2: Refactoring Decision Flow
547
+
548
+ ```
549
+ Start: User requests "Refactor component Y"
550
+
551
+ Risk Assessment
552
+
553
+ Q1: "What migration strategy?"
554
+ ├─ Big bang → Q2a: "Maintenance window timing?"
555
+ ├─ Incremental → Q2b: "Which parts first?"
556
+ └─ Parallel → Q2c: "Rollout percentage?"
557
+
558
+ Q3: "Rollback plan?"
559
+
560
+ Review Summary
561
+
562
+ Confirmation
563
+
564
+ Execute
565
+ ```
566
+
567
+ ### Tree 3: Library Selection Flow
568
+
569
+ ```
570
+ Start: User needs "State management"
571
+
572
+ Codebase Analysis (existing patterns, complexity)
573
+
574
+ Q1: "Which library?"
575
+ ├─ Redux → Q2a: "Store structure?"
576
+ ├─ Zustand → Q2b: "Domain stores?"
577
+ └─ Jotai → Q2c: "Atom organization?"
578
+
579
+ Q3: "Persistence strategy?"
580
+
581
+ Review Summary
582
+
583
+ Confirmation
584
+
585
+ Execute
586
+ ```
587
+
588
+ ---
589
+
590
+ ## TUI Frameworks Comparison
591
+
592
+ ### Popular TUI Frameworks (2025)
593
+
594
+ | Framework | Language | Strengths | Use Cases |
595
+ |-----------|----------|-----------|-----------|
596
+ | **Rich** | Python | Colors, tables, progress bars | Logs, reports, dashboards |
597
+ | **Textual** | Python | Reactive UI, CSS-like styling | Interactive applications |
598
+ | **BubbleTea** | Go | Model-view-update architecture | CLI tools, forms |
599
+ | **Ratatui** | Rust | Performance, complex layouts | System monitors, editors |
600
+ | **Ink** | JavaScript/Node | React-like components | CLI apps with React patterns |
601
+
602
+ ### Best Practices from TUI Frameworks
603
+
604
+ **Clarity (Rich, Textual)**:
605
+ - Use clear, concise text
606
+ - Provide obvious visual cues
607
+ - Avoid over-complication
608
+
609
+ **Simplicity (BubbleTea)**:
610
+ - Model-view-update separation
611
+ - Single source of truth for state
612
+ - Predictable state transitions
613
+
614
+ **Feedback (All frameworks)**:
615
+ - Immediate visual response to user input
616
+ - Loading indicators for async operations
617
+ - Clear error messages with suggestions
618
+
619
+ **Accessibility (Textual, Ink)**:
620
+ - Keyboard navigation support
621
+ - Screen reader compatibility
622
+ - High contrast color schemes
623
+
624
+ ### Applying TUI Best Practices to AskUserQuestion
625
+
626
+ ```typescript
627
+ // Clarity: Clear question + concise options
628
+ {
629
+ question: "Which deployment strategy should be used?", // Clear
630
+ header: "Deploy", // Concise label
631
+ options: [
632
+ {
633
+ label: "Rolling", // Short, clear
634
+ description: "Gradual instance replacement. Zero downtime." // Concise explanation
635
+ }
636
+ ]
637
+ }
638
+
639
+ // Simplicity: Limit to 2-4 options, avoid nested complexity
640
+ {
641
+ multiSelect: false, // Single choice simplifies decision
642
+ options: [/* 3 options */] // Not overwhelming
643
+ }
644
+
645
+ // Feedback: Review step provides confirmation
646
+ {
647
+ question: "Review your selections. Ready to proceed?",
648
+ options: [
649
+ { label: "Approve and execute", description: "..." },
650
+ { label: "Go back and modify", description: "..." }
651
+ ]
652
+ }
653
+ ```
654
+
655
+ ---
656
+
657
+ ## Validation & Error Handling
658
+
659
+ ### Input Validation
660
+
661
+ ```typescript
662
+ function validateSurvey(survey: AskUserQuestionParams): ValidationResult {
663
+ const errors: string[] = [];
664
+
665
+ // Validate questions array
666
+ if (!survey.questions || survey.questions.length === 0) {
667
+ errors.push("At least one question is required");
668
+ }
669
+
670
+ if (survey.questions.length > 4) {
671
+ errors.push("Maximum 4 questions allowed (avoid decision fatigue)");
672
+ }
673
+
674
+ // Validate each question
675
+ survey.questions.forEach((q, index) => {
676
+ // Question text
677
+ if (!q.question || q.question.length < 10) {
678
+ errors.push(`Question ${index + 1}: Text too short (min 10 chars)`);
679
+ }
680
+ if (!q.question.endsWith('?')) {
681
+ errors.push(`Question ${index + 1}: Must end with '?'`);
682
+ }
683
+
684
+ // Header
685
+ if (!q.header || q.header.length > 12) {
686
+ errors.push(`Question ${index + 1}: Header must be ≤12 chars`);
687
+ }
688
+
689
+ // Options
690
+ if (!q.options || q.options.length < 2) {
691
+ errors.push(`Question ${index + 1}: Minimum 2 options required`);
692
+ }
693
+ if (q.options.length > 4) {
694
+ errors.push(`Question ${index + 1}: Maximum 4 options allowed`);
695
+ }
696
+
697
+ // Validate each option
698
+ q.options.forEach((opt, optIndex) => {
699
+ if (!opt.label || opt.label.length < 3) {
700
+ errors.push(`Question ${index + 1}, Option ${optIndex + 1}: Label too short`);
701
+ }
702
+ if (!opt.description || opt.description.length < 20) {
703
+ errors.push(`Question ${index + 1}, Option ${optIndex + 1}: Description too short`);
704
+ }
705
+ });
706
+ });
707
+
708
+ return {
709
+ isValid: errors.length === 0,
710
+ errors
711
+ };
712
+ }
713
+ ```
714
+
715
+ ### Error Handling Patterns
716
+
717
+ ```typescript
718
+ // Pattern 1: Validation before survey
719
+ try {
720
+ const validation = validateSurvey(surveyParams);
721
+ if (!validation.isValid) {
722
+ console.error("Survey validation failed:", validation.errors);
723
+ // Fix issues and retry
724
+ return;
725
+ }
726
+
727
+ const response = await AskUserQuestion(surveyParams);
728
+ processResponse(response);
729
+ } catch (error) {
730
+ console.error("Survey execution failed:", error);
731
+ // Fallback to default behavior or manual input
732
+ }
733
+
734
+ // Pattern 2: Retry with clarification
735
+ async function surveyWithRetry(surveyParams, maxRetries = 2) {
736
+ for (let i = 0; i < maxRetries; i++) {
737
+ try {
738
+ const response = await AskUserQuestion(surveyParams);
739
+
740
+ if (response.answers["0"] === "Other") {
741
+ // User selected "Other", follow up for details
742
+ surveyParams = generateFollowUpSurvey(response);
743
+ continue;
744
+ }
745
+
746
+ return response;
747
+ } catch (error) {
748
+ if (i === maxRetries - 1) throw error;
749
+ console.warn(`Survey attempt ${i + 1} failed, retrying...`);
750
+ }
751
+ }
752
+ }
753
+
754
+ // Pattern 3: Graceful degradation
755
+ async function surveyOrFallback(surveyParams, fallback) {
756
+ try {
757
+ return await AskUserQuestion(surveyParams);
758
+ } catch (error) {
759
+ console.warn("Survey failed, using fallback:", fallback);
760
+ return { answers: { "0": fallback } };
761
+ }
762
+ }
763
+ ```
764
+
765
+ ---
766
+
767
+ ## Best Practices Checklist
768
+
769
+ ### Before Creating Survey
770
+
771
+ - [ ] Analyze codebase context (existing patterns, similar features)
772
+ - [ ] Identify specific ambiguity or decision point
773
+ - [ ] Verify decision requires user input (not deterministic)
774
+ - [ ] Check if similar decisions made before (consistency)
775
+ - [ ] Validate survey parameters (2-4 options, clear descriptions)
776
+
777
+ ### During Survey Design
778
+
779
+ - [ ] Question text is clear and specific
780
+ - [ ] Header is ≤12 characters
781
+ - [ ] 2-4 options per question (not more, not less)
782
+ - [ ] Each option has label + description
783
+ - [ ] Trade-offs (PRO/CON) visible when relevant
784
+ - [ ] "Other" option available for flexibility
785
+ - [ ] Multi-select only for independent choices
786
+
787
+ ### After Capturing Responses
788
+
789
+ - [ ] Show review summary of all selections
790
+ - [ ] Provide "Go back" option to revise
791
+ - [ ] Confirm understanding with echo: "You selected [X], which means [Y]"
792
+ - [ ] Log selections for future reference (SPEC, docs)
793
+ - [ ] Execute based on confirmed choices only
794
+
795
+ ---
796
+
797
+ **Version**: 2.0.0
798
+ **Last Updated**: 2025-10-22
799
+ **Total Lines**: 550+
800
+ **Coverage**: API spec, patterns, integration, decision trees, validation
801
+ **Status**: Production-ready