@make-u-free/migi 0.5.12 → 0.5.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@make-u-free/migi",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "description": "Your AI right-hand agent. Works anywhere, with any LLM API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,6 +17,7 @@
17
17
  "glob": "^11.0.0",
18
18
  "openai": "^4.0.0",
19
19
  "pdf-parse": "^2.4.5",
20
+ "pdfjs-dist": "^5.5.207",
20
21
  "xlsx": "^0.18.5"
21
22
  },
22
23
  "engines": {
package/src/agent.js CHANGED
@@ -68,6 +68,16 @@ ${userNameLine}
68
68
  - 過去の記録・決定事項が不明なときは search_content で能動的に探す
69
69
  - 「たぶんこうだろう」で進めるより、read_file で確認してから進める
70
70
 
71
+ ## リアルタイム記録(重要)
72
+
73
+ - 重要な情報・決定・要件・論点が出てきたら、セッション終了を待たず**その場で** write_file で書き込む
74
+ - 何を書くか:
75
+ - 要件の理解が固まった → 該当プロジェクトフォルダの requirements.md に追記
76
+ - 方針・判断が決まった → policy.md や decisions.md に追記
77
+ - 壁打ちで重要な論点が出た → notes.md にその場で追記
78
+ - 「あとでまとめる」はしない。気づいた瞬間に書く
79
+ - 書いたらユーザーに一言報告する(「〜を記録しました」)
80
+
71
81
  ## メモリと文脈の継続
72
82
  ワークスペースメモリは ${cwd}/.migi/memory/ に構造化して保存する:
73
83
  - projects.md ── 進行中の仕事・状況
package/src/tools.js CHANGED
@@ -11,6 +11,7 @@ const require = createRequire(import.meta.url)
11
11
  const _pdfParseModule = require('pdf-parse')
12
12
  const pdfParse = typeof _pdfParseModule === 'function' ? _pdfParseModule : _pdfParseModule.default
13
13
  import AdmZip from 'adm-zip'
14
+ import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs'
14
15
  import OpenAI from 'openai'
15
16
  import { httpsAgent } from './tls.js'
16
17
  const { readFile: xlsxReadFile, utils: xlsxUtils } = xlsxPkg
@@ -233,7 +234,20 @@ export async function executeTool(name, args, opts = {}) {
233
234
  if (ext === '.pdf') {
234
235
  const buf = readFileSync(args.path)
235
236
 
236
- // Step 1: テキストPDFとして抽出を試みる
237
+ // Step 1: pdfjs-dist でテキスト抽出(最も信頼性が高い)
238
+ try {
239
+ const doc = await pdfjsLib.getDocument({ data: new Uint8Array(buf) }).promise
240
+ const pages = []
241
+ for (let p = 1; p <= doc.numPages; p++) {
242
+ const page = await doc.getPage(p)
243
+ const content = await page.getTextContent()
244
+ pages.push(content.items.map(item => item.str).join(''))
245
+ }
246
+ const text = pages.join('\n').trim()
247
+ if (text) return text
248
+ } catch (_) {}
249
+
250
+ // Step 2: pdf-parse でも試みる(フォールバック)
237
251
  if (typeof pdfParse === 'function') {
238
252
  try {
239
253
  const data = await pdfParse(buf)
@@ -242,7 +256,7 @@ export async function executeTool(name, args, opts = {}) {
242
256
  } catch (_) {}
243
257
  }
244
258
 
245
- // Step 2: 画像PDFとしてVision APIでOCR(ネイティブ依存なし)
259
+ // Step 3: 画像PDFとしてVision APIでOCR(ネイティブ依存なし)
246
260
  if (!opts.apiKey) return '(テキストが抽出できませんでした)'
247
261
  const images = extractImagesFromPdf(buf)
248
262
  if (images.length === 0) return '(テキストも画像も抽出できませんでした)'