termi-kids 0.2.1 → 0.2.3

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.
@@ -54,7 +54,7 @@ async function pickProjectName(idea) {
54
54
  const suggested = defaultNameForIdea(idea);
55
55
  const typed = await p.text({
56
56
  message: 'Name your game.',
57
- placeholder: suggested,
57
+ initialValue: suggested,
58
58
  defaultValue: suggested,
59
59
  validate: (value) => {
60
60
  const trimmed = (value ?? '').trim() || suggested;
@@ -86,6 +86,14 @@ async function gatherHelpAnswers(idea) {
86
86
  }
87
87
  return answers;
88
88
  }
89
+ /**
90
+ * Merge typed input with an optional draft. Empty typing keeps the draft so
91
+ * kids can run a suggested prompt without retyping it.
92
+ */
93
+ export function resolvePromptInput(typed, draft) {
94
+ const resolved = typed.trim() || draft.trim();
95
+ return resolved.length > 0 ? resolved : null;
96
+ }
89
97
  async function obtainPrompt(idea) {
90
98
  const path = await p.select({
91
99
  message: 'How do you want to tell Termi what to build?',
@@ -110,18 +118,41 @@ async function obtainPrompt(idea) {
110
118
  return null;
111
119
  }
112
120
  draft = suggestPromptFromAnswers(idea, answers);
121
+ }
122
+ // When we already have a draft, do not force a long single-line text field.
123
+ // clack text() is unreliable for long initialValue (looks like a placeholder
124
+ // and Enter can fail validate). Offer a clear Run vs Edit choice first.
125
+ if (draft.length > 0) {
113
126
  p.note(draft, 'Suggested prompt');
127
+ const action = await p.select({
128
+ message: 'Use this prompt?',
129
+ options: [
130
+ { value: 'run', label: 'Run it' },
131
+ { value: 'edit', label: 'Edit it first' },
132
+ ],
133
+ initialValue: 'run',
134
+ });
135
+ if (p.isCancel(action)) {
136
+ return null;
137
+ }
138
+ if (action === 'run') {
139
+ return draft;
140
+ }
114
141
  }
115
142
  const text = await p.text({
116
- message: path === 'write' ? 'Type your prompt.' : 'Edit the prompt, or press Enter to run it.',
117
- defaultValue: draft,
118
- placeholder: draft || 'Make a fun browser game where...',
119
- validate: (value) => (value ?? '').trim().length > 0 ? undefined : 'Need a prompt to build.',
143
+ message: draft.length > 0 ? 'Edit your prompt.' : 'Type your prompt.',
144
+ initialValue: draft.length > 0 ? draft : undefined,
145
+ defaultValue: draft.length > 0 ? draft : undefined,
146
+ placeholder: draft.length > 0 ? undefined : 'Make a fun browser game where...',
147
+ validate: (value) => {
148
+ const resolved = resolvePromptInput(value ?? '', draft);
149
+ return resolved !== null ? undefined : 'Need a prompt to build.';
150
+ },
120
151
  });
121
152
  if (p.isCancel(text)) {
122
153
  return null;
123
154
  }
124
- return text.trim();
155
+ return resolvePromptInput(text, draft);
125
156
  }
126
157
  function listKidFileSummaries(project) {
127
158
  const out = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termi-kids",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Termi is a friendly coding buddy for kids. Build browser games with AI prompts, Learn AI lessons, and strong local safety rails.",
5
5
  "keywords": [
6
6
  "kids",