diff --git a/.devcontainer/opencode-seed/commands/to-markdown.md b/.devcontainer/opencode-seed/commands/to-markdown.md index 8ba74eb..85633fd 100644 --- a/.devcontainer/opencode-seed/commands/to-markdown.md +++ b/.devcontainer/opencode-seed/commands/to-markdown.md @@ -5,7 +5,7 @@ agent: build # to-markdown -Convert source content into Markdown using MarkItDown. +Convert source content into Markdown using MarkItDown CLI (fallback when MCP is unavailable). ## Usage diff --git a/.devcontainer/opencode-seed/instructions/markitdown-converter.md b/.devcontainer/opencode-seed/instructions/markitdown-converter.md index 4bc784a..6eaa4c6 100644 --- a/.devcontainer/opencode-seed/instructions/markitdown-converter.md +++ b/.devcontainer/opencode-seed/instructions/markitdown-converter.md @@ -1,6 +1,7 @@ -When users ask to read, summarize, or analyze non-Markdown sources (PDF, DOCX, PPTX, HTML, image-derived text, or URLs), first convert the source with `/to-markdown`. +When users ask to read, summarize, or analyze non-Markdown sources (PDF, DOCX, PPTX, HTML, image-derived text, or URLs), first convert the source with the `markitdown` MCP tool (`convert_to_markdown`). Guidelines: +- Prefer MCP conversion first; use `/to-markdown` only as a fallback when MCP is unavailable. - Prefer `/to-markdown ` for large inputs. - If `` is a directory, never use `Read File` on that directory path; run `/to-markdown ` instead. - For small inputs, `/to-markdown ` and return inline Markdown is acceptable. diff --git a/.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md b/.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md index 507e650..cc1673e 100644 --- a/.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md +++ b/.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md @@ -17,9 +17,10 @@ Use this skill when you need to transform non-Markdown sources (PDF, Office docs ## OpenChamber Usage 1. Explicit command: + - Use MCP tool `markitdown.convert_to_markdown(uri)` first - `/to-markdown [output.md]` 2. Natural language: - - Ask normally (e.g. "このPDFをMarkdown化して"), then route through `/to-markdown` + - Ask normally (e.g. "このPDFをMarkdown化して"), then route through MCP `convert_to_markdown` ## Notes diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index ac5975f..fea7b2b 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -124,6 +124,20 @@ if command -v uv &> /dev/null; then fi fi +MARKITDOWN_MCP_MARKER="/home/vscode/.local/share/uv/tools/markitdown-mcp/.ecc-installed" +if command -v uv &> /dev/null; then + if ! command -v markitdown-mcp &> /dev/null || [[ ! -f "$MARKITDOWN_MCP_MARKER" ]]; then + echo "🧩 markitdown-mcp をインストール中..." + if uv tool install --upgrade markitdown-mcp; then + mkdir -p "$(dirname "$MARKITDOWN_MCP_MARKER")" + touch "$MARKITDOWN_MCP_MARKER" + echo " ✅ markitdown-mcp インストール完了" + else + echo " ⚠️ markitdown-mcp インストールに失敗しました" + fi + fi +fi + # ECC の設定適用 echo " ECC設定を適用中..." @@ -161,6 +175,16 @@ cat > ~/.opencode/opencode.json << 'EOF' "model": "anthropic/claude-sonnet-4-5", "small_model": "anthropic/claude-haiku-4-5", "default_agent": "build", + "mcp": { + "markitdown": { + "type": "local", + "command": [ + "/home/vscode/.local/bin/markitdown-mcp" + ], + "enabled": true, + "timeout": 30000 + } + }, "plugin": [ "./plugins" ] diff --git a/.devcontainer/startup.sh b/.devcontainer/startup.sh index 6db2f9c..2da12ae 100755 --- a/.devcontainer/startup.sh +++ b/.devcontainer/startup.sh @@ -236,6 +236,20 @@ if command -v uv >/dev/null 2>&1; then fi fi +MARKITDOWN_MCP_MARKER="/home/vscode/.local/share/uv/tools/markitdown-mcp/.ecc-installed" +if command -v uv >/dev/null 2>&1; then + if ! command -v markitdown-mcp >/dev/null 2>&1 || [ ! -f "$MARKITDOWN_MCP_MARKER" ]; then + echo "📦 markitdown-mcp を uv でインストール中..." + if uv tool install --upgrade markitdown-mcp >/tmp/markitdown-mcp-install.log 2>&1; then + mkdir -p "$(dirname "$MARKITDOWN_MCP_MARKER")" + touch "$MARKITDOWN_MCP_MARKER" + echo "✅ markitdown-mcp インストール完了" + else + echo "⚠️ markitdown-mcp インストール失敗 (ログ: /tmp/markitdown-mcp-install.log)" + fi + fi +fi + if [ -f /home/vscode/.opencode/opencode.json ]; then python3 - <<'PY' import json @@ -248,7 +262,18 @@ entry = "instructions/markitdown-converter.md" if entry not in instructions: instructions.append(entry) config["instructions"] = instructions - path.write_text(json.dumps(config, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") + +mcp = config.get("mcp", {}) +if "markitdown" not in mcp: + mcp["markitdown"] = { + "type": "local", + "command": ["/home/vscode/.local/bin/markitdown-mcp"], + "enabled": True, + "timeout": 30000, + } + config["mcp"] = mcp + +path.write_text(json.dumps(config, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") PY fi