gencode-ai 0.1.2 → 0.2.0

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 (180) hide show
  1. package/README.md +15 -17
  2. package/dist/agent/agent.d.ts +43 -0
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/agent.js +107 -4
  5. package/dist/agent/agent.js.map +1 -1
  6. package/dist/agent/index.d.ts +1 -0
  7. package/dist/agent/index.d.ts.map +1 -1
  8. package/dist/agent/types.d.ts +20 -1
  9. package/dist/agent/types.d.ts.map +1 -1
  10. package/dist/checkpointing/checkpoint-manager.d.ts +87 -0
  11. package/dist/checkpointing/checkpoint-manager.d.ts.map +1 -0
  12. package/dist/checkpointing/checkpoint-manager.js +281 -0
  13. package/dist/checkpointing/checkpoint-manager.js.map +1 -0
  14. package/dist/checkpointing/index.d.ts +29 -0
  15. package/dist/checkpointing/index.d.ts.map +1 -0
  16. package/dist/checkpointing/index.js +29 -0
  17. package/dist/checkpointing/index.js.map +1 -0
  18. package/dist/checkpointing/types.d.ts +98 -0
  19. package/dist/checkpointing/types.d.ts.map +1 -0
  20. package/dist/checkpointing/types.js +7 -0
  21. package/dist/checkpointing/types.js.map +1 -0
  22. package/dist/cli/components/App.d.ts.map +1 -1
  23. package/dist/cli/components/App.js +193 -7
  24. package/dist/cli/components/App.js.map +1 -1
  25. package/dist/cli/components/CommandSuggestions.d.ts.map +1 -1
  26. package/dist/cli/components/CommandSuggestions.js +5 -0
  27. package/dist/cli/components/CommandSuggestions.js.map +1 -1
  28. package/dist/cli/components/Messages.d.ts +7 -1
  29. package/dist/cli/components/Messages.d.ts.map +1 -1
  30. package/dist/cli/components/Messages.js +28 -2
  31. package/dist/cli/components/Messages.js.map +1 -1
  32. package/dist/cli/components/ModeIndicator.d.ts +42 -0
  33. package/dist/cli/components/ModeIndicator.d.ts.map +1 -0
  34. package/dist/cli/components/ModeIndicator.js +52 -0
  35. package/dist/cli/components/ModeIndicator.js.map +1 -0
  36. package/dist/cli/components/PlanApproval.d.ts +36 -0
  37. package/dist/cli/components/PlanApproval.d.ts.map +1 -0
  38. package/dist/cli/components/PlanApproval.js +154 -0
  39. package/dist/cli/components/PlanApproval.js.map +1 -0
  40. package/dist/cli/components/QuestionPrompt.d.ts +23 -0
  41. package/dist/cli/components/QuestionPrompt.d.ts.map +1 -0
  42. package/dist/cli/components/QuestionPrompt.js +231 -0
  43. package/dist/cli/components/QuestionPrompt.js.map +1 -0
  44. package/dist/cli/components/index.d.ts +1 -0
  45. package/dist/cli/components/index.d.ts.map +1 -1
  46. package/dist/cli/components/index.js +1 -0
  47. package/dist/cli/components/index.js.map +1 -1
  48. package/dist/cli/components/theme.d.ts +9 -0
  49. package/dist/cli/components/theme.d.ts.map +1 -1
  50. package/dist/cli/components/theme.js +14 -1
  51. package/dist/cli/components/theme.js.map +1 -1
  52. package/dist/index.d.ts +1 -0
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +2 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/permissions/types.d.ts.map +1 -1
  57. package/dist/permissions/types.js +2 -0
  58. package/dist/permissions/types.js.map +1 -1
  59. package/dist/planning/index.d.ts +13 -0
  60. package/dist/planning/index.d.ts.map +1 -0
  61. package/dist/planning/index.js +15 -0
  62. package/dist/planning/index.js.map +1 -0
  63. package/dist/planning/plan-file.d.ts +59 -0
  64. package/dist/planning/plan-file.d.ts.map +1 -0
  65. package/dist/planning/plan-file.js +278 -0
  66. package/dist/planning/plan-file.js.map +1 -0
  67. package/dist/planning/state.d.ts +127 -0
  68. package/dist/planning/state.d.ts.map +1 -0
  69. package/dist/planning/state.js +261 -0
  70. package/dist/planning/state.js.map +1 -0
  71. package/dist/planning/tools/enter-plan-mode.d.ts +25 -0
  72. package/dist/planning/tools/enter-plan-mode.d.ts.map +1 -0
  73. package/dist/planning/tools/enter-plan-mode.js +98 -0
  74. package/dist/planning/tools/enter-plan-mode.js.map +1 -0
  75. package/dist/planning/tools/exit-plan-mode.d.ts +24 -0
  76. package/dist/planning/tools/exit-plan-mode.d.ts.map +1 -0
  77. package/dist/planning/tools/exit-plan-mode.js +149 -0
  78. package/dist/planning/tools/exit-plan-mode.js.map +1 -0
  79. package/dist/planning/types.d.ts +100 -0
  80. package/dist/planning/types.d.ts.map +1 -0
  81. package/dist/planning/types.js +28 -0
  82. package/dist/planning/types.js.map +1 -0
  83. package/dist/pricing/calculator.d.ts +21 -0
  84. package/dist/pricing/calculator.d.ts.map +1 -0
  85. package/dist/pricing/calculator.js +59 -0
  86. package/dist/pricing/calculator.js.map +1 -0
  87. package/dist/pricing/index.d.ts +7 -0
  88. package/dist/pricing/index.d.ts.map +1 -0
  89. package/dist/pricing/index.js +7 -0
  90. package/dist/pricing/index.js.map +1 -0
  91. package/dist/pricing/models.d.ts +20 -0
  92. package/dist/pricing/models.d.ts.map +1 -0
  93. package/dist/pricing/models.js +322 -0
  94. package/dist/pricing/models.js.map +1 -0
  95. package/dist/pricing/types.d.ts +30 -0
  96. package/dist/pricing/types.d.ts.map +1 -0
  97. package/dist/pricing/types.js +5 -0
  98. package/dist/pricing/types.js.map +1 -0
  99. package/dist/providers/anthropic.d.ts.map +1 -1
  100. package/dist/providers/anthropic.js +17 -10
  101. package/dist/providers/anthropic.js.map +1 -1
  102. package/dist/providers/gemini.d.ts.map +1 -1
  103. package/dist/providers/gemini.js +21 -14
  104. package/dist/providers/gemini.js.map +1 -1
  105. package/dist/providers/openai.d.ts.map +1 -1
  106. package/dist/providers/openai.js +12 -8
  107. package/dist/providers/openai.js.map +1 -1
  108. package/dist/providers/types.d.ts +2 -0
  109. package/dist/providers/types.d.ts.map +1 -1
  110. package/dist/providers/vertex-ai.d.ts.map +1 -1
  111. package/dist/providers/vertex-ai.js +17 -10
  112. package/dist/providers/vertex-ai.js.map +1 -1
  113. package/dist/session/manager.d.ts +4 -0
  114. package/dist/session/manager.d.ts.map +1 -1
  115. package/dist/session/manager.js +8 -0
  116. package/dist/session/manager.js.map +1 -1
  117. package/dist/tools/builtin/ask-user.d.ts +64 -0
  118. package/dist/tools/builtin/ask-user.d.ts.map +1 -0
  119. package/dist/tools/builtin/ask-user.js +148 -0
  120. package/dist/tools/builtin/ask-user.js.map +1 -0
  121. package/dist/tools/index.d.ts +19 -1
  122. package/dist/tools/index.d.ts.map +1 -1
  123. package/dist/tools/index.js +11 -0
  124. package/dist/tools/index.js.map +1 -1
  125. package/dist/tools/registry.d.ts +13 -0
  126. package/dist/tools/registry.d.ts.map +1 -1
  127. package/dist/tools/registry.js +79 -2
  128. package/dist/tools/registry.js.map +1 -1
  129. package/dist/tools/types.d.ts +17 -0
  130. package/dist/tools/types.d.ts.map +1 -1
  131. package/dist/tools/types.js.map +1 -1
  132. package/docs/cost-tracking-comparison.md +904 -0
  133. package/docs/operating-modes.md +96 -0
  134. package/docs/proposals/0012-ask-user-question.md +66 -1
  135. package/docs/proposals/0025-cost-tracking.md +60 -2
  136. package/docs/proposals/README.md +2 -2
  137. package/examples/test-ask-user.ts +167 -0
  138. package/examples/test-checkpointing.ts +121 -0
  139. package/examples/test-cost-tracking.ts +77 -0
  140. package/examples/test-interrupt-cleanup.ts +94 -0
  141. package/package.json +1 -1
  142. package/src/agent/agent.ts +130 -4
  143. package/src/agent/index.ts +1 -0
  144. package/src/agent/types.ts +19 -1
  145. package/src/checkpointing/checkpoint-manager.ts +327 -0
  146. package/src/checkpointing/index.ts +45 -0
  147. package/src/checkpointing/types.ts +104 -0
  148. package/src/cli/components/App.tsx +259 -8
  149. package/src/cli/components/CommandSuggestions.tsx +5 -0
  150. package/src/cli/components/Messages.tsx +66 -4
  151. package/src/cli/components/ModeIndicator.tsx +174 -0
  152. package/src/cli/components/PlanApproval.tsx +327 -0
  153. package/src/cli/components/QuestionPrompt.tsx +462 -0
  154. package/src/cli/components/index.ts +1 -0
  155. package/src/cli/components/theme.ts +14 -1
  156. package/src/index.ts +15 -0
  157. package/src/permissions/types.ts +2 -0
  158. package/src/planning/index.ts +53 -0
  159. package/src/planning/plan-file.ts +326 -0
  160. package/src/planning/state.ts +305 -0
  161. package/src/planning/tools/enter-plan-mode.ts +111 -0
  162. package/src/planning/tools/exit-plan-mode.ts +170 -0
  163. package/src/planning/types.ts +150 -0
  164. package/src/pricing/calculator.ts +71 -0
  165. package/src/pricing/index.ts +7 -0
  166. package/src/pricing/models.ts +334 -0
  167. package/src/pricing/types.ts +32 -0
  168. package/src/prompts/system/base.txt +42 -0
  169. package/src/prompts/tools/ask-user.txt +110 -0
  170. package/src/providers/anthropic.ts +21 -10
  171. package/src/providers/gemini.ts +25 -14
  172. package/src/providers/openai.ts +17 -8
  173. package/src/providers/types.ts +3 -0
  174. package/src/providers/vertex-ai.ts +21 -10
  175. package/src/session/manager.ts +9 -0
  176. package/src/tools/builtin/ask-user.ts +185 -0
  177. package/src/tools/index.ts +23 -0
  178. package/src/tools/registry.ts +95 -2
  179. package/src/tools/types.ts +18 -0
  180. package/.gencode/settings.local.json +0 -7
@@ -0,0 +1,462 @@
1
+ /**
2
+ * QuestionPrompt Component - Claude Code style structured questioning UI
3
+ *
4
+ * Matches Claude Code's AskUserQuestion UI pattern:
5
+ * - Progress bar with step indicators (← □ Step1 □ Step2 ✓ Submit →)
6
+ * - Numbered options with cursor indicator
7
+ * - Description on separate line
8
+ * - Keyboard hints at bottom
9
+ */
10
+
11
+ import { useState, useCallback } from 'react';
12
+ import { Box, Text, useInput } from 'ink';
13
+ import { colors } from './theme.js';
14
+ import type { Question, QuestionAnswer } from '../../tools/types.js';
15
+
16
+ // ============================================================================
17
+ // Types
18
+ // ============================================================================
19
+
20
+ interface QuestionPromptProps {
21
+ questions: Question[];
22
+ onComplete: (answers: QuestionAnswer[]) => void;
23
+ onCancel?: () => void;
24
+ }
25
+
26
+ interface OptionWithOther {
27
+ label: string;
28
+ description: string;
29
+ isOther?: boolean;
30
+ }
31
+
32
+ // ============================================================================
33
+ // Progress Bar Component
34
+ // ============================================================================
35
+
36
+ interface ProgressBarProps {
37
+ questions: Question[];
38
+ currentIndex: number;
39
+ answers: QuestionAnswer[];
40
+ showSubmit?: boolean;
41
+ }
42
+
43
+ function ProgressBar({ questions, currentIndex, answers, showSubmit = true }: ProgressBarProps) {
44
+ const isReviewMode = currentIndex >= questions.length;
45
+
46
+ return (
47
+ <Box>
48
+ <Text color={colors.textMuted}>← </Text>
49
+ {questions.map((q, idx) => {
50
+ const isCompleted = idx < answers.length;
51
+ const isCurrent = idx === currentIndex;
52
+ const checkmark = isCompleted ? '☒' : '☐';
53
+
54
+ return (
55
+ <Box key={idx}>
56
+ {isCurrent ? (
57
+ <Text backgroundColor="#6366F1" color="#FFFFFF" bold>
58
+ {` □ ${q.header} `}
59
+ </Text>
60
+ ) : (
61
+ <Text color={isCompleted ? colors.textSecondary : colors.textMuted}>
62
+ {checkmark} {q.header}
63
+ </Text>
64
+ )}
65
+ <Text color={colors.textMuted}> </Text>
66
+ </Box>
67
+ );
68
+ })}
69
+ {showSubmit && (
70
+ <>
71
+ {isReviewMode ? (
72
+ <Text backgroundColor="#22C55E" color="#FFFFFF" bold>
73
+ {` ✓ Submit `}
74
+ </Text>
75
+ ) : (
76
+ <Text color={colors.textMuted}>✓ Submit</Text>
77
+ )}
78
+ </>
79
+ )}
80
+ <Text color={colors.textMuted}> →</Text>
81
+ </Box>
82
+ );
83
+ }
84
+
85
+ // ============================================================================
86
+ // QuestionPrompt Component
87
+ // ============================================================================
88
+
89
+ export function QuestionPrompt({ questions, onComplete, onCancel }: QuestionPromptProps) {
90
+ const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
91
+ const [answers, setAnswers] = useState<QuestionAnswer[]>([]);
92
+ const [selectedOptions, setSelectedOptions] = useState<Set<string>>(new Set());
93
+ const [optionIndex, setOptionIndex] = useState(0);
94
+ const [showOtherInput, setShowOtherInput] = useState(false);
95
+ const [otherInput, setOtherInput] = useState('');
96
+ const [isReviewMode, setIsReviewMode] = useState(false);
97
+ const [reviewOptionIndex, setReviewOptionIndex] = useState(0);
98
+
99
+ const currentQuestion = questions[currentQuestionIndex];
100
+ const showProgressBar = questions.length > 1;
101
+
102
+ // Add "Type something." option to the list
103
+ const optionsWithOther: OptionWithOther[] = currentQuestion
104
+ ? [
105
+ ...currentQuestion.options,
106
+ { label: 'Type something.', description: '', isOther: true },
107
+ ]
108
+ : [];
109
+
110
+ // Toggle option selection (for multi-select)
111
+ const toggleOption = useCallback(() => {
112
+ const option = optionsWithOther[optionIndex];
113
+ setSelectedOptions((prev) => {
114
+ const next = new Set(prev);
115
+ if (next.has(option.label)) {
116
+ next.delete(option.label);
117
+ } else {
118
+ next.add(option.label);
119
+ }
120
+ return next;
121
+ });
122
+ }, [optionIndex, optionsWithOther]);
123
+
124
+ // Finish current question and move to next or review
125
+ const finishQuestion = useCallback(
126
+ (selected: string[], customInput?: string) => {
127
+ const answer: QuestionAnswer = {
128
+ question: currentQuestion.question,
129
+ header: currentQuestion.header,
130
+ selectedOptions: selected.filter((s) => s !== 'Type something.'),
131
+ customInput,
132
+ };
133
+
134
+ const newAnswers = [...answers, answer];
135
+
136
+ if (currentQuestionIndex < questions.length - 1) {
137
+ // Move to next question
138
+ setAnswers(newAnswers);
139
+ setCurrentQuestionIndex((i) => i + 1);
140
+ setSelectedOptions(new Set());
141
+ setOptionIndex(0);
142
+ setShowOtherInput(false);
143
+ setOtherInput('');
144
+ } else {
145
+ // All questions answered, go to review mode (for multi-question)
146
+ setAnswers(newAnswers);
147
+ if (questions.length > 1) {
148
+ setIsReviewMode(true);
149
+ setReviewOptionIndex(0);
150
+ } else {
151
+ // Single question, complete immediately
152
+ onComplete(newAnswers);
153
+ }
154
+ }
155
+ },
156
+ [currentQuestion, currentQuestionIndex, questions.length, answers, onComplete]
157
+ );
158
+
159
+ // Handle selection (Enter key)
160
+ const handleSelect = useCallback(() => {
161
+ const option = optionsWithOther[optionIndex];
162
+
163
+ if (currentQuestion.multiSelect) {
164
+ if (selectedOptions.size === 0) {
165
+ toggleOption();
166
+ return;
167
+ }
168
+ if (selectedOptions.has('Type something.')) {
169
+ setShowOtherInput(true);
170
+ } else {
171
+ finishQuestion([...selectedOptions]);
172
+ }
173
+ } else {
174
+ if (option.isOther) {
175
+ setShowOtherInput(true);
176
+ } else {
177
+ finishQuestion([option.label]);
178
+ }
179
+ }
180
+ }, [
181
+ optionIndex,
182
+ optionsWithOther,
183
+ currentQuestion?.multiSelect,
184
+ selectedOptions,
185
+ toggleOption,
186
+ finishQuestion,
187
+ ]);
188
+
189
+ // Handle keyboard input
190
+ useInput((input, key) => {
191
+ // Review mode navigation
192
+ if (isReviewMode) {
193
+ if (key.upArrow) {
194
+ setReviewOptionIndex((i) => Math.max(0, i - 1));
195
+ } else if (key.downArrow) {
196
+ setReviewOptionIndex((i) => Math.min(1, i + 1));
197
+ } else if (key.return) {
198
+ if (reviewOptionIndex === 0) {
199
+ // Submit
200
+ onComplete(answers);
201
+ } else {
202
+ // Cancel
203
+ onCancel?.();
204
+ }
205
+ } else if (key.escape) {
206
+ onCancel?.();
207
+ }
208
+ return;
209
+ }
210
+
211
+ if (showOtherInput) {
212
+ if (key.return) {
213
+ if (otherInput.trim()) {
214
+ if (currentQuestion.multiSelect) {
215
+ const selected = [...selectedOptions].filter((s) => s !== 'Type something.');
216
+ finishQuestion(selected, otherInput.trim());
217
+ } else {
218
+ finishQuestion([], otherInput.trim());
219
+ }
220
+ }
221
+ } else if (key.escape) {
222
+ setShowOtherInput(false);
223
+ setOtherInput('');
224
+ } else if (key.backspace || key.delete) {
225
+ setOtherInput((prev) => prev.slice(0, -1));
226
+ } else if (input && !key.ctrl && !key.meta) {
227
+ setOtherInput((prev) => prev + input);
228
+ }
229
+ return;
230
+ }
231
+
232
+ // Navigation
233
+ if (key.upArrow) {
234
+ setOptionIndex((i) => Math.max(0, i - 1));
235
+ } else if (key.downArrow) {
236
+ setOptionIndex((i) => Math.min(optionsWithOther.length - 1, i + 1));
237
+ } else if (key.tab) {
238
+ // Tab cycles through options
239
+ setOptionIndex((i) => (i + 1) % optionsWithOther.length);
240
+ }
241
+
242
+ // Selection
243
+ if (key.return) {
244
+ handleSelect();
245
+ }
246
+
247
+ // Toggle (multi-select only)
248
+ if (input === ' ' && currentQuestion.multiSelect) {
249
+ toggleOption();
250
+ }
251
+
252
+ // Number shortcuts (1-5)
253
+ const num = parseInt(input, 10);
254
+ if (num >= 1 && num <= optionsWithOther.length) {
255
+ setOptionIndex(num - 1);
256
+ if (!currentQuestion.multiSelect) {
257
+ const option = optionsWithOther[num - 1];
258
+ if (option.isOther) {
259
+ setShowOtherInput(true);
260
+ } else {
261
+ finishQuestion([option.label]);
262
+ }
263
+ }
264
+ }
265
+
266
+ // Escape to cancel
267
+ if (key.escape && onCancel) {
268
+ onCancel();
269
+ }
270
+ });
271
+
272
+ // Review mode UI
273
+ if (isReviewMode) {
274
+ return (
275
+ <Box flexDirection="column" marginTop={1}>
276
+ {/* Progress bar */}
277
+ {showProgressBar && (
278
+ <Box marginBottom={1}>
279
+ <ProgressBar
280
+ questions={questions}
281
+ currentIndex={questions.length}
282
+ answers={answers}
283
+ />
284
+ </Box>
285
+ )}
286
+
287
+ {/* Review title */}
288
+ <Box marginBottom={1}>
289
+ <Text bold>Review your answers</Text>
290
+ </Box>
291
+
292
+ {/* Answered questions summary */}
293
+ <Box flexDirection="column" marginBottom={1} paddingLeft={1}>
294
+ {answers.map((answer, idx) => {
295
+ const selections = answer.customInput
296
+ ? [...answer.selectedOptions, answer.customInput].join(', ')
297
+ : answer.selectedOptions.join(', ');
298
+
299
+ return (
300
+ <Box key={idx} flexDirection="column" marginBottom={1}>
301
+ <Box>
302
+ <Text color={colors.textSecondary}>● </Text>
303
+ <Text bold>{answer.question}</Text>
304
+ </Box>
305
+ <Box paddingLeft={2}>
306
+ <Text color={colors.primary}>→ {selections}</Text>
307
+ </Box>
308
+ </Box>
309
+ );
310
+ })}
311
+ </Box>
312
+
313
+ {/* Ready to submit */}
314
+ <Box marginBottom={1}>
315
+ <Text>Ready to submit your answers?</Text>
316
+ </Box>
317
+
318
+ {/* Submit/Cancel options */}
319
+ <Box flexDirection="column" paddingLeft={1}>
320
+ <Box>
321
+ <Text color={reviewOptionIndex === 0 ? colors.text : colors.textMuted}>
322
+ {reviewOptionIndex === 0 ? '❯ ' : ' '}
323
+ </Text>
324
+ <Text color={colors.primary} bold={reviewOptionIndex === 0}>
325
+ 1. Submit answers
326
+ </Text>
327
+ </Box>
328
+ <Box>
329
+ <Text color={reviewOptionIndex === 1 ? colors.text : colors.textMuted}>
330
+ {reviewOptionIndex === 1 ? '❯ ' : ' '}
331
+ </Text>
332
+ <Text bold={reviewOptionIndex === 1}>2. Cancel</Text>
333
+ </Box>
334
+ </Box>
335
+
336
+ {/* Separator */}
337
+ <Box marginTop={1} marginBottom={1}>
338
+ <Text color={colors.textMuted}>{'─'.repeat(60)}</Text>
339
+ </Box>
340
+
341
+ {/* Keyboard hints */}
342
+ <Box>
343
+ <Text color={colors.textMuted}>
344
+ Enter to select · Tab/Arrow keys to navigate · Esc to cancel
345
+ </Text>
346
+ </Box>
347
+ </Box>
348
+ );
349
+ }
350
+
351
+ // Normal question mode UI
352
+ return (
353
+ <Box flexDirection="column" marginTop={1}>
354
+ {/* Progress bar */}
355
+ {showProgressBar && (
356
+ <Box marginBottom={1}>
357
+ <ProgressBar
358
+ questions={questions}
359
+ currentIndex={currentQuestionIndex}
360
+ answers={answers}
361
+ />
362
+ </Box>
363
+ )}
364
+
365
+ {/* Question text */}
366
+ <Box marginBottom={1}>
367
+ <Text bold>{currentQuestion.question}</Text>
368
+ </Box>
369
+
370
+ {/* Options list */}
371
+ <Box flexDirection="column" paddingLeft={1}>
372
+ {optionsWithOther.map((option, index) => {
373
+ const isSelected = index === optionIndex;
374
+ const isChecked = selectedOptions.has(option.label);
375
+
376
+ return (
377
+ <Box key={option.label} flexDirection="column" marginBottom={option.description ? 1 : 0}>
378
+ {/* Option row */}
379
+ <Box>
380
+ <Text color={isSelected ? colors.text : colors.textMuted}>
381
+ {isSelected ? '❯ ' : ' '}
382
+ </Text>
383
+ <Text color={colors.textMuted}>{index + 1}. </Text>
384
+ {currentQuestion.multiSelect && (
385
+ <Text color={colors.primary}>{isChecked ? '☒ ' : '☐ '}</Text>
386
+ )}
387
+ <Text color={colors.primary} bold>
388
+ {option.label}
389
+ </Text>
390
+ </Box>
391
+
392
+ {/* Description (if exists) */}
393
+ {option.description && (
394
+ <Box paddingLeft={4}>
395
+ <Text color={colors.textMuted}>{option.description}</Text>
396
+ </Box>
397
+ )}
398
+ </Box>
399
+ );
400
+ })}
401
+ </Box>
402
+
403
+ {/* Other input field */}
404
+ {showOtherInput && (
405
+ <Box marginTop={1} paddingLeft={1}>
406
+ <Text color={colors.textMuted}>Type your answer: </Text>
407
+ <Text>{otherInput}</Text>
408
+ <Text color={colors.primary}>▋</Text>
409
+ </Box>
410
+ )}
411
+
412
+ {/* Separator */}
413
+ <Box marginTop={1} marginBottom={1}>
414
+ <Text color={colors.textMuted}>{'─'.repeat(60)}</Text>
415
+ </Box>
416
+
417
+ {/* Chat about this (placeholder) */}
418
+ <Box marginBottom={1}>
419
+ <Text color={colors.textMuted}> Chat about this</Text>
420
+ </Box>
421
+
422
+ {/* Keyboard hints */}
423
+ <Box>
424
+ <Text color={colors.textMuted}>
425
+ Enter to select · Tab/Arrow keys to navigate
426
+ {currentQuestion.multiSelect && ' · Space to toggle'}
427
+ {onCancel && ' · Esc to cancel'}
428
+ </Text>
429
+ </Box>
430
+ </Box>
431
+ );
432
+ }
433
+
434
+ // ============================================================================
435
+ // Answer Display Component (shown after completion)
436
+ // ============================================================================
437
+
438
+ interface AnswerDisplayProps {
439
+ answers: QuestionAnswer[];
440
+ compact?: boolean;
441
+ }
442
+
443
+ export function AnswerDisplay({ answers, compact = true }: AnswerDisplayProps) {
444
+ return (
445
+ <Box flexDirection="column">
446
+ {answers.map((answer, index) => {
447
+ const selections = answer.customInput
448
+ ? [...answer.selectedOptions, answer.customInput].join(', ')
449
+ : answer.selectedOptions.join(', ');
450
+
451
+ return (
452
+ <Box key={index}>
453
+ <Text color={colors.textSecondary}>● </Text>
454
+ <Text>{answer.question}</Text>
455
+ <Text color={colors.textMuted}> → </Text>
456
+ <Text color={colors.primary}>{selections || '(none)'}</Text>
457
+ </Box>
458
+ );
459
+ })}
460
+ </Box>
461
+ );
462
+ }
@@ -25,3 +25,4 @@ export {
25
25
  PermissionRulesDisplay,
26
26
  PermissionAuditDisplay,
27
27
  } from './PermissionPrompt.js';
28
+ export { QuestionPrompt, AnswerDisplay } from './QuestionPrompt.js';
@@ -35,9 +35,22 @@ export const icons = {
35
35
  // UI
36
36
  thinking: '✱', // Star for thinking state
37
37
  cursor: '▋',
38
- // Selection
38
+ // Selection (single-select)
39
39
  radio: '●', // Filled radio for selected
40
40
  radioEmpty: '○', // Empty radio for unselected
41
+ // Selection (multi-select)
42
+ checkbox: '☑', // Checked checkbox
43
+ checkboxEmpty: '☐', // Empty checkbox
44
+ // Chip/tag borders (Claude Code style headers)
45
+ chipLeft: '╭─',
46
+ chipRight: '─╮',
47
+ // Box drawing
48
+ boxTop: '╭',
49
+ boxBottom: '╰',
50
+ boxVertical: '│',
41
51
  // Tree connectors
42
52
  treeEnd: '└', // Tree end connector for tool results
53
+ // Mode indicators
54
+ modePlan: '⏸', // Pause for plan mode
55
+ modeAccept: '⏵⏵', // Double play for accept mode
43
56
  };
package/src/index.ts CHANGED
@@ -84,3 +84,18 @@ export {
84
84
  SessionManager,
85
85
  DEFAULT_SESSION_CONFIG,
86
86
  } from './session/index.js';
87
+
88
+ // Checkpointing
89
+ export {
90
+ type ChangeType,
91
+ type FileCheckpoint,
92
+ type CheckpointSession,
93
+ type RewindOptions,
94
+ type RewindResult,
95
+ type CheckpointSummary,
96
+ type RecordChangeInput,
97
+ CheckpointManager,
98
+ getCheckpointManager,
99
+ initCheckpointManager,
100
+ resetCheckpointManager,
101
+ } from './checkpointing/index.js';
@@ -227,6 +227,8 @@ export const DEFAULT_PERMISSION_CONFIG: PermissionConfig = {
227
227
  { tool: 'LSP', mode: 'auto', description: 'Language server' },
228
228
  // Internal state management - auto-approve (no side effects)
229
229
  { tool: 'TodoWrite', mode: 'auto', description: 'Task tracking' },
230
+ // User interaction - auto-approve (asking user questions, not dangerous)
231
+ { tool: 'AskUserQuestion', mode: 'auto', description: 'User questioning' },
230
232
  ],
231
233
  allowedPrompts: [],
232
234
  };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Planning Module
3
+ *
4
+ * Plan Mode for GenCode - allows the LLM to design implementation
5
+ * approaches before writing code, with read-only exploration tools.
6
+ */
7
+
8
+ // Types
9
+ export type {
10
+ PlanPhase,
11
+ PlanApprovalOption,
12
+ AllowedPrompt,
13
+ PlanModeState,
14
+ PlanFile,
15
+ PlanModeAllowedTool,
16
+ PlanModeBlockedTool,
17
+ ModeType,
18
+ PlanApprovalState,
19
+ PlanModeEvent,
20
+ } from './types.js';
21
+
22
+ export { PLAN_MODE_ALLOWED_TOOLS, PLAN_MODE_BLOCKED_TOOLS } from './types.js';
23
+
24
+ // State Management
25
+ export {
26
+ PlanModeManager,
27
+ getPlanModeManager,
28
+ resetPlanModeManager,
29
+ isPlanModeActive,
30
+ getCurrentMode,
31
+ enterPlanMode,
32
+ exitPlanMode,
33
+ togglePlanMode,
34
+ } from './state.js';
35
+
36
+ // Plan File Utilities
37
+ export {
38
+ generatePlanFileName,
39
+ getPlansDir,
40
+ ensurePlansDir,
41
+ createPlanFile,
42
+ readPlanFile,
43
+ writePlanFile,
44
+ listPlanFiles,
45
+ deletePlanFile,
46
+ parseFilesToChange,
47
+ parsePreApprovedPermissions,
48
+ getDisplayPath,
49
+ } from './plan-file.js';
50
+
51
+ // Tools
52
+ export { enterPlanModeTool } from './tools/enter-plan-mode.js';
53
+ export { exitPlanModeTool } from './tools/exit-plan-mode.js';