@make-u-free/migi 0.3.4 → 0.3.6

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 (2) hide show
  1. package/bin/migi.js +92 -61
  2. package/package.json +1 -1
package/bin/migi.js CHANGED
@@ -66,78 +66,109 @@ console.log(chalk.dim(' /exit 終了\n'))
66
66
 
67
67
  const agent = new MigiAgent({ context, promptFn, apiKey, model, name: agentName, userName, teamsWebhookUrl })
68
68
 
69
- // ---- メインループ ----
70
- function prompt() {
71
- rl.question(chalk.cyan('> '), async (line) => {
72
- const input = line.trim()
73
- if (!input) return prompt()
74
-
75
- // --- ビルトインコマンド ---
76
- if (input === '/exit' || input === '/quit') {
77
- console.log(chalk.cyan(`\n お疲れ様でした!またね。\n`))
78
- process.exit(0)
69
+ function sep() { return chalk.dim('─'.repeat(process.stdout.columns || 80)) }
70
+
71
+ // ---- 複数行入力(空行で送信)----
72
+ async function readMultiLine() {
73
+ const lines = []
74
+ return new Promise((resolve) => {
75
+ const onLine = (line) => {
76
+ if (line === '' && lines.length > 0) {
77
+ rl.removeListener('line', onLine)
78
+ // 入力ボックス下辺 + 欄外ステータス
79
+ console.log(sep())
80
+ console.log(chalk.dim(` ✦ ${model} · Enterで改行 / 空行で送信`))
81
+ resolve(lines.join('\n'))
82
+ } else {
83
+ lines.push(line)
84
+ process.stdout.write(chalk.cyan(' '))
85
+ }
79
86
  }
87
+ process.stdout.write(chalk.cyan(' '))
88
+ rl.on('line', onLine)
89
+ })
90
+ }
80
91
 
81
- if (input === '/config') {
82
- const current = loadGlobalConfig()
83
- await runSetup(promptFn, current)
84
- console.log(chalk.yellow(' 再起動して設定を反映してください。\n'))
85
- return prompt()
92
+ // ---- メインループ ----
93
+ async function prompt() {
94
+ // 入力ボックス上辺
95
+ console.log('\n' + sep())
96
+ console.log(chalk.bold.cyan(` ${userName || 'あなた'}`))
97
+ console.log(sep())
98
+
99
+ const input = (await readMultiLine()).trim()
100
+ if (!input) return prompt()
101
+
102
+ // --- ビルトインコマンド ---
103
+ if (input === '/exit' || input === '/quit') {
104
+ console.log(chalk.cyan(`\n お疲れ様でした!またね。\n`))
105
+ process.exit(0)
106
+ }
107
+
108
+ if (input === '/config') {
109
+ const current = loadGlobalConfig()
110
+ await runSetup(promptFn, current)
111
+ console.log(chalk.yellow(' 再起動して設定を反映してください。\n'))
112
+ return prompt()
113
+ }
114
+
115
+ if (input === '/models') {
116
+ try {
117
+ console.log(chalk.dim('\n 利用可能なモデルを取得中...\n'))
118
+ const OpenAI = (await import('openai')).default
119
+ const client = new OpenAI({ apiKey })
120
+ const res = await client.models.list()
121
+ const models = res.data
122
+ .map(m => m.id)
123
+ .filter(id => id.includes('gpt') || id.includes('o1') || id.includes('o3') || id.includes('o4'))
124
+ .sort()
125
+ console.log(chalk.cyan(' 利用可能なモデル:'))
126
+ for (const m of models) {
127
+ const mark = m === model ? chalk.green(' ← 現在') : ''
128
+ console.log(chalk.dim(` • ${m}`) + mark)
129
+ }
130
+ console.log(chalk.dim('\n /config でモデルを変更できます。\n'))
131
+ } catch (err) {
132
+ console.error(chalk.red('\n 取得失敗: ' + err.message + '\n'))
86
133
  }
134
+ return prompt()
135
+ }
87
136
 
88
- if (input === '/models') {
137
+ // --- スキルルーティング ---
138
+ const parsed = parseSkillInput(input)
139
+ if (parsed) {
140
+ const skill = resolveSkill(parsed.name, process.cwd())
141
+ if (skill) {
142
+ console.log('\n' + sep())
143
+ console.log(chalk.bold.cyan(` ${agentName}`) + chalk.dim(` [スキル: ${parsed.name}]`))
144
+ console.log(sep())
145
+ const expanded = expandSkill(skill.content, parsed.args)
89
146
  try {
90
- console.log(chalk.dim('\n 利用可能なモデルを取得中...\n'))
91
- const OpenAI = (await import('openai')).default
92
- const client = new OpenAI({ apiKey })
93
- const res = await client.models.list()
94
- const models = res.data
95
- .map(m => m.id)
96
- .filter(id => id.includes('gpt') || id.includes('o1') || id.includes('o3') || id.includes('o4'))
97
- .sort()
98
- console.log(chalk.cyan(' 利用可能なモデル:'))
99
- for (const m of models) {
100
- const mark = m === model ? chalk.green(' ← 現在') : ''
101
- console.log(chalk.dim(` • ${m}`) + mark)
102
- }
103
- console.log(chalk.dim('\n /config でモデルを変更できます。\n'))
147
+ const reply = await agent.chat(expanded)
148
+ console.log('\n' + reply + '\n')
104
149
  } catch (err) {
105
- console.error(chalk.red('\n 取得失敗: ' + err.message + '\n'))
150
+ console.error(chalk.red('\n エラー: ' + err.message + '\n'))
106
151
  }
107
152
  return prompt()
153
+ } else {
154
+ console.log(chalk.yellow(`\n スキル「${parsed.name}」が見つかりません。`))
155
+ console.log(chalk.dim(` .migi/skills/${parsed.name}.md を作成してください。`))
156
+ return prompt()
108
157
  }
158
+ }
109
159
 
110
- // --- スキルルーティング ---
111
- const parsed = parseSkillInput(input)
112
- if (parsed) {
113
- const skill = resolveSkill(parsed.name, process.cwd())
114
- if (skill) {
115
- console.log(chalk.dim(` [スキル: ${parsed.name}]\n`))
116
- const expanded = expandSkill(skill.content, parsed.args)
117
- try {
118
- const reply = await agent.chat(expanded)
119
- console.log('\n' + reply + '\n')
120
- } catch (err) {
121
- console.error(chalk.red('\n エラー: ' + err.message + '\n'))
122
- }
123
- return prompt()
124
- } else {
125
- console.log(chalk.yellow(` スキル「${parsed.name}」が見つかりません。`))
126
- console.log(chalk.dim(` .migi/skills/${parsed.name}.md を作成してください。\n`))
127
- return prompt()
128
- }
129
- }
130
-
131
- // --- 通常チャット ---
132
- try {
133
- const reply = await agent.chat(input)
134
- console.log('\n' + reply + '\n')
135
- } catch (err) {
136
- console.error(chalk.red('\n エラー: ' + err.message + '\n'))
137
- }
160
+ // --- 通常チャット ---
161
+ console.log('\n' + sep())
162
+ console.log(chalk.bold.cyan(` ${agentName}`))
163
+ console.log(sep())
164
+ try {
165
+ const reply = await agent.chat(input)
166
+ console.log('\n' + reply + '\n')
167
+ } catch (err) {
168
+ console.error(chalk.red('\n エラー: ' + err.message + '\n'))
169
+ }
138
170
 
139
- prompt()
140
- })
171
+ prompt()
141
172
  }
142
173
 
143
174
  prompt()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@make-u-free/migi",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Your AI right-hand agent. Works anywhere, with any LLM API.",
5
5
  "type": "module",
6
6
  "bin": {