@make-u-free/migi 0.5.3 → 0.5.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.
- package/bin/migi.js +17 -0
- package/package.json +2 -1
- package/src/tools.js +40 -0
package/bin/migi.js
CHANGED
|
@@ -66,6 +66,23 @@ 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
|
+
{
|
|
71
|
+
const today = new Date().toISOString().split('T')[0]
|
|
72
|
+
console.log('\n' + chalk.bold.cyan(`─── ${agentName} `) + chalk.dim('─'.repeat(Math.max(0, (process.stdout.columns || 80) - agentName.length - 5))))
|
|
73
|
+
try {
|
|
74
|
+
await agent.chat(
|
|
75
|
+
`起動した。以下の手順で今日の状況を確認して、簡潔にダッシュボードを表示してから、今一番優先すべきことを1つだけ提案して:\n` +
|
|
76
|
+
`1. todos/${today}.md を read_file で読んで未完了タスクを確認\n` +
|
|
77
|
+
`2. .migi/memory/next-actions.md があれば読む\n` +
|
|
78
|
+
`3. ダッシュボード(完了済み・未完了の件数サマリー)をコンパクトに出して、一言で「今日はこれから」と提案する\n` +
|
|
79
|
+
`(詳細な説明はいらない。テンポよく)`
|
|
80
|
+
)
|
|
81
|
+
} catch (err) {
|
|
82
|
+
console.error(chalk.red(' 起動チェック失敗: ' + err.message))
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
69
86
|
function sep() {
|
|
70
87
|
const w = process.stdout.columns || 80
|
|
71
88
|
return chalk.dim('─'.repeat(w))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@make-u-free/migi",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Your AI right-hand agent. Works anywhere, with any LLM API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"adm-zip": "^0.5.16",
|
|
14
14
|
"chalk": "^5.3.0",
|
|
15
|
+
"diff": "^8.0.4",
|
|
15
16
|
"dotenv": "^16.4.0",
|
|
16
17
|
"glob": "^11.0.0",
|
|
17
18
|
"openai": "^4.0.0",
|
package/src/tools.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from 'fs'
|
|
2
2
|
import { execSync } from 'child_process'
|
|
3
3
|
import { dirname, extname } from 'path'
|
|
4
|
+
import { diffLines } from 'diff'
|
|
4
5
|
import { request } from 'https'
|
|
5
6
|
import { glob } from 'glob'
|
|
7
|
+
import chalk from 'chalk'
|
|
6
8
|
import xlsxPkg from 'xlsx'
|
|
7
9
|
import { createRequire } from 'module'
|
|
8
10
|
const require = createRequire(import.meta.url)
|
|
@@ -126,6 +128,40 @@ export const teamsToolSchema = {
|
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
// ---- diff 表示 ----
|
|
132
|
+
|
|
133
|
+
function showDiff(path, oldContent, newContent) {
|
|
134
|
+
const MAX_LINES = 50 // 長すぎる diff は省略
|
|
135
|
+
|
|
136
|
+
if (oldContent === null) {
|
|
137
|
+
console.log(chalk.green(` + ${path} (新規作成)`))
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (oldContent === newContent) {
|
|
142
|
+
console.log(chalk.dim(` = ${path} (変更なし)`))
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const parts = diffLines(oldContent, newContent)
|
|
147
|
+
let shown = 0
|
|
148
|
+
let truncated = false
|
|
149
|
+
|
|
150
|
+
for (const part of parts) {
|
|
151
|
+
if (!part.added && !part.removed) continue
|
|
152
|
+
const lines = part.value.replace(/\n$/, '').split('\n')
|
|
153
|
+
for (const line of lines) {
|
|
154
|
+
if (shown >= MAX_LINES) { truncated = true; break }
|
|
155
|
+
if (part.added) console.log(chalk.green(` + ${line}`))
|
|
156
|
+
if (part.removed) console.log(chalk.red(` - ${line}`))
|
|
157
|
+
shown++
|
|
158
|
+
}
|
|
159
|
+
if (truncated) break
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (truncated) console.log(chalk.dim(` … (省略)`))
|
|
163
|
+
}
|
|
164
|
+
|
|
129
165
|
// ---- ツール実行 ----
|
|
130
166
|
|
|
131
167
|
export async function executeTool(name, args, opts = {}) {
|
|
@@ -209,14 +245,18 @@ export async function executeTool(name, args, opts = {}) {
|
|
|
209
245
|
case 'write_file': {
|
|
210
246
|
const dir = dirname(args.path)
|
|
211
247
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
248
|
+
const oldContent = existsSync(args.path) ? readFileSync(args.path, 'utf-8') : null
|
|
212
249
|
writeFileSync(args.path, args.content, 'utf-8')
|
|
250
|
+
showDiff(args.path, oldContent, args.content)
|
|
213
251
|
return `完了: ${args.path} に書き込みました`
|
|
214
252
|
}
|
|
215
253
|
|
|
216
254
|
case 'append_file': {
|
|
217
255
|
const dir = dirname(args.path)
|
|
218
256
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
257
|
+
const base = existsSync(args.path) ? readFileSync(args.path, 'utf-8') : ''
|
|
219
258
|
appendFileSync(args.path, args.content, 'utf-8')
|
|
259
|
+
showDiff(args.path, base, base + args.content)
|
|
220
260
|
return `完了: ${args.path} に追記しました`
|
|
221
261
|
}
|
|
222
262
|
|