@make-u-free/migi 0.3.4 → 0.3.5

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