@miphamai/cli 0.2.4 → 0.3.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.
package/src/ui/input.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react'
1
+ import React, { useState, useEffect, useRef } from 'react'
2
2
  import { Box, Text } from 'ink'
3
3
  import TextInput from 'ink-text-input'
4
4
 
@@ -7,32 +7,37 @@ interface InputBarProps {
7
7
  isLoading: boolean
8
8
  }
9
9
 
10
- // ── Creative status messages (inspired by Claude Code's whimsical verbs) ──
10
+ // ── Status verbs English (Claude Code-aligned) + Chinese (Mipham originals) ──
11
11
 
12
- const STATUS_VERBS = [
13
- '思忖中', // Pondering
14
- '推演中', // Deducting
15
- '凝炼中', // Condensing
16
- '熬煮中', // Simmering
17
- '锻造中', // Forging
18
- '研磨中', // Grinding
19
- '解构中', // Deconstructing
20
- '冥思中', // Contemplating
21
- '编织中', // Weaving
22
- '萃取中', // Extracting
23
- '烹制中', // Cooking
24
- '淬火中', // Quenching
25
- '雕琢中', // Chiseling
26
- '融汇中', // Fusing
27
- '觉照中', // Illuminating
28
- '运转中', // Operating
29
- '参详中', // Studying
30
- '化合中', // Synthesizing
31
- '浸润中', // Infusing
32
- '焙烤中', // Baking
12
+ const STATUS_EN = [
13
+ 'Doodling', 'Forging', 'Germinating', 'Mosmosing', 'Cerebrating',
14
+ 'Boogieing', 'Finagling', 'Misting', 'Recombobulating', 'Slithering',
15
+ 'Effecting', 'Roosting', 'Crystallizing', 'Canoodling', 'Billowing',
16
+ 'Warping', 'Improvising', 'Metamorphing', 'Gusting', 'Whiring',
17
+ 'Topsy-turvying', 'Flibbertigibetting', 'Wibbling', 'Thundering',
18
+ 'Moseying', 'Julienning', 'Evaporating', 'Ruminating', 'Whisking',
19
+ 'Scampering', 'Meandering', 'Concoting', 'Gesticulating', 'Flamebeing',
20
+ 'Quantumizing', 'Waddling', 'Fluttering', 'Sprouting', 'Elucidating',
21
+ 'Embellishing', 'Razzmatizing', 'Pondering', 'Cogitating', 'Garnishing',
22
+ 'Actualizing', 'Zigzagging', 'Mustering', 'Frolicking', 'Hullaballooing',
23
+ 'Doing', 'Fermenting', 'Considering', 'Skedaddling', 'Actioning',
24
+ 'Orbiting', 'Perambulating', 'Drizzling', 'Schlepping', 'Ionizing',
25
+ 'Scurrying',
33
26
  ]
34
27
 
35
- const STATUS_EMOJI = ['🔮', '⚙️', '💎', '🔥', '🧪', '🌊', '⚡', '🌀', '🎯', '💡']
28
+ const STATUS_CN = [
29
+ '思忖中', '推演中', '凝炼中', '熬煮中', '锻造中',
30
+ '研磨中', '解构中', '冥思中', '编织中', '萃取中',
31
+ '烹制中', '淬火中', '雕琢中', '融汇中', '觉照中',
32
+ '运转中', '参详中', '化合中', '浸润中', '焙烤中',
33
+ ]
34
+
35
+ // Merge both — bilingual status verbs
36
+ const STATUS_GERUNDS = [...STATUS_EN, ...STATUS_CN]
37
+
38
+ const STATUS_PAST = [
39
+ 'Brewed', 'Churned', 'Cooked', 'Sautéed', 'Cogitated', 'Crunched',
40
+ ]
36
41
 
37
42
  function pick<T>(arr: T[]): T {
38
43
  return arr[Math.floor(Math.random() * arr.length)]!
@@ -40,25 +45,35 @@ function pick<T>(arr: T[]): T {
40
45
 
41
46
  export function InputBar({ onSubmit, isLoading }: InputBarProps) {
42
47
  const [value, setValue] = useState('')
43
- const [verb, setVerb] = useState(() => pick(STATUS_VERBS))
44
- const [emoji, setEmoji] = useState(() => pick(STATUS_EMOJI))
48
+ const [verb, setVerb] = useState(() => pick(STATUS_GERUNDS))
49
+ const [completionVerb, setCompletionVerb] = useState<string | null>(null)
50
+ const prevLoading = useRef(isLoading)
45
51
 
46
- // Rotate status messages while loading
52
+ // Rotate gerunds while loading
47
53
  useEffect(() => {
48
54
  if (!isLoading) return
49
55
  const interval = setInterval(() => {
50
- setVerb(pick(STATUS_VERBS))
51
- setEmoji(pick(STATUS_EMOJI))
52
- }, 2000)
56
+ setVerb(pick(STATUS_GERUNDS))
57
+ }, 1200)
53
58
  return () => clearInterval(interval)
54
59
  }, [isLoading])
55
60
 
56
- // Reset when loading starts
61
+ // Pick a fresh gerund when loading starts
57
62
  useEffect(() => {
58
63
  if (isLoading) {
59
- setVerb(pick(STATUS_VERBS))
60
- setEmoji(pick(STATUS_EMOJI))
64
+ setVerb(pick(STATUS_GERUNDS))
65
+ setCompletionVerb(null)
66
+ }
67
+ }, [isLoading])
68
+
69
+ // Flash a past participle when loading stops
70
+ useEffect(() => {
71
+ if (prevLoading.current === true && isLoading === false) {
72
+ setCompletionVerb(pick(STATUS_PAST))
73
+ const timer = setTimeout(() => setCompletionVerb(null), 1500)
74
+ return () => clearTimeout(timer)
61
75
  }
76
+ prevLoading.current = isLoading
62
77
  }, [isLoading])
63
78
 
64
79
  const handleSubmit = (val: string) => {
@@ -70,13 +85,19 @@ export function InputBar({ onSubmit, isLoading }: InputBarProps) {
70
85
  return (
71
86
  <Box marginTop={1}>
72
87
  <Box marginRight={1}>
73
- <Text color={isLoading ? 'yellow' : 'cyan'}>{isLoading ? `${emoji}` : ''}</Text>
88
+ <Text color={isLoading ? 'yellow' : 'cyan'}>{'>'}</Text>
74
89
  </Box>
75
90
  <TextInput
76
91
  value={value}
77
92
  onChange={setValue}
78
93
  onSubmit={handleSubmit}
79
- placeholder={isLoading ? `${verb}...` : 'Type a message (Esc to exit)...'}
94
+ placeholder={
95
+ isLoading
96
+ ? `${verb}...`
97
+ : completionVerb
98
+ ? completionVerb
99
+ : 'Type a message (Esc to cancel)...'
100
+ }
80
101
  />
81
102
  </Box>
82
103
  )