@make-u-free/migi 0.1.6 → 0.1.8

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 (3) hide show
  1. package/bin/migi.js +22 -0
  2. package/package.json +10 -3
  3. package/src/tools.js +14 -1
package/bin/migi.js CHANGED
@@ -79,6 +79,28 @@ function prompt() {
79
79
  return prompt()
80
80
  }
81
81
 
82
+ if (input === '/models') {
83
+ try {
84
+ console.log(chalk.dim('\n 利用可能なモデルを取得中...\n'))
85
+ const OpenAI = (await import('openai')).default
86
+ const client = new OpenAI({ apiKey })
87
+ const res = await client.models.list()
88
+ const models = res.data
89
+ .map(m => m.id)
90
+ .filter(id => id.includes('gpt') || id.includes('o1') || id.includes('o3') || id.includes('o4'))
91
+ .sort()
92
+ console.log(chalk.cyan(' 利用可能なモデル:'))
93
+ for (const m of models) {
94
+ const mark = m === model ? chalk.green(' ← 現在') : ''
95
+ console.log(chalk.dim(` • ${m}`) + mark)
96
+ }
97
+ console.log(chalk.dim('\n /config でモデルを変更できます。\n'))
98
+ } catch (err) {
99
+ console.error(chalk.red('\n 取得失敗: ' + err.message + '\n'))
100
+ }
101
+ return prompt()
102
+ }
103
+
82
104
  // --- スキルルーティング ---
83
105
  const parsed = parseSkillInput(input)
84
106
  if (parsed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@make-u-free/migi",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Your AI right-hand agent. Works anywhere, with any LLM API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,12 +13,19 @@
13
13
  "chalk": "^5.3.0",
14
14
  "dotenv": "^16.4.0",
15
15
  "glob": "^11.0.0",
16
- "openai": "^4.0.0"
16
+ "openai": "^4.0.0",
17
+ "xlsx": "^0.18.5"
17
18
  },
18
19
  "engines": {
19
20
  "node": ">=18.0.0"
20
21
  },
21
- "keywords": ["ai", "agent", "cli", "openai", "secretary"],
22
+ "keywords": [
23
+ "ai",
24
+ "agent",
25
+ "cli",
26
+ "openai",
27
+ "secretary"
28
+ ],
22
29
  "author": "MAKE U FREE",
23
30
  "license": "MIT"
24
31
  }
package/src/tools.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from 'fs'
2
2
  import { execSync } from 'child_process'
3
- import { dirname } from 'path'
3
+ import { dirname, extname } from 'path'
4
4
  import { glob } from 'glob'
5
+ import xlsxPkg from 'xlsx'
6
+ const { readFile: xlsxReadFile, utils: xlsxUtils } = xlsxPkg
5
7
 
6
8
  // ---- OpenAI ツールスキーマ定義 ----
7
9
 
@@ -102,6 +104,17 @@ export async function executeTool(name, args) {
102
104
  switch (name) {
103
105
  case 'read_file': {
104
106
  if (!existsSync(args.path)) return `エラー: ファイルが見つかりません: ${args.path}`
107
+ const ext = extname(args.path).toLowerCase()
108
+ if (ext === '.xlsx' || ext === '.xls') {
109
+ const workbook = xlsxReadFile(args.path)
110
+ const result = []
111
+ for (const sheetName of workbook.SheetNames) {
112
+ const sheet = workbook.Sheets[sheetName]
113
+ const csv = xlsxUtils.sheet_to_csv(sheet)
114
+ result.push(`## シート: ${sheetName}\n${csv}`)
115
+ }
116
+ return result.join('\n\n')
117
+ }
105
118
  return readFileSync(args.path, 'utf-8')
106
119
  }
107
120