From 26c1e9484a72d757158cbc6ad108b4454e7d03bb Mon Sep 17 00:00:00 2001 From: GitHub Copilot CLI Date: Sun, 12 Apr 2026 23:44:51 +0900 Subject: [PATCH] Add MarkItDown skill for OpenChamber workflows Seed a markitdown converter skill, command, and instruction into ~/.opencode at startup, install uv/markitdown automatically, and support both explicit /to-markdown calls and natural-language routing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../opencode-seed/commands/to-markdown.md | 26 +++++++++ .../instructions/markitdown-converter.md | 6 ++ .../skills/markitdown-converter/SKILL.md | 27 +++++++++ .../markitdown-converter/scripts/convert.sh | 22 +++++++ .devcontainer/setup.sh | 13 +++++ .devcontainer/startup.sh | 58 +++++++++++++++++++ 6 files changed, 152 insertions(+) create mode 100644 .devcontainer/opencode-seed/commands/to-markdown.md create mode 100644 .devcontainer/opencode-seed/instructions/markitdown-converter.md create mode 100644 .devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md create mode 100644 .devcontainer/opencode-seed/skills/markitdown-converter/scripts/convert.sh diff --git a/.devcontainer/opencode-seed/commands/to-markdown.md b/.devcontainer/opencode-seed/commands/to-markdown.md new file mode 100644 index 0000000..0af9880 --- /dev/null +++ b/.devcontainer/opencode-seed/commands/to-markdown.md @@ -0,0 +1,26 @@ +--- +description: Convert files/URLs to Markdown via MarkItDown +agent: build +--- + +# to-markdown + +Convert source content into Markdown using MarkItDown. + +## Usage + +`/to-markdown [output.md]` + +## Execution + +1. Parse `$ARGUMENTS` as: + - first token: input path or URL + - optional second token: output file path +2. Run: + +```bash +bash /home/vscode/.opencode/skills/markitdown-converter/scripts/convert.sh [output] +``` + +3. If output path is provided, report the saved path. +4. If output path is omitted, return the generated Markdown in the response. diff --git a/.devcontainer/opencode-seed/instructions/markitdown-converter.md b/.devcontainer/opencode-seed/instructions/markitdown-converter.md new file mode 100644 index 0000000..e05c279 --- /dev/null +++ b/.devcontainer/opencode-seed/instructions/markitdown-converter.md @@ -0,0 +1,6 @@ +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`. + +Guidelines: +- Prefer `/to-markdown ` for large inputs. +- For small inputs, `/to-markdown ` and return inline Markdown is acceptable. +- After conversion, continue analysis using the Markdown output only. diff --git a/.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md b/.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md new file mode 100644 index 0000000..1fa65d9 --- /dev/null +++ b/.devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md @@ -0,0 +1,27 @@ +--- +name: markitdown-converter +description: Convert files and URLs into Markdown so AI agents can reliably read and reason over mixed-format content. +origin: opencode-ecc-devcontainer +--- + +# MarkItDown Converter + +Use this skill when you need to transform non-Markdown sources (PDF, Office docs, HTML, images with OCR-capable inputs, etc.) into Markdown before analysis. + +## When to Activate + +- User asks to summarize or extract data from files that are not already Markdown +- User provides URLs or documents that should be converted for downstream AI workflows +- You need a consistent Markdown representation before chunking, indexing, or prompt injection checks + +## OpenChamber Usage + +1. Explicit command: + - `/to-markdown [output.md]` +2. Natural language: + - Ask normally (e.g. "このPDFをMarkdown化して"), then route through `/to-markdown` + +## Notes + +- If output is large, prefer writing to a file and then summarizing key sections. +- Preserve the generated Markdown as an artifact when reproducibility is needed. diff --git a/.devcontainer/opencode-seed/skills/markitdown-converter/scripts/convert.sh b/.devcontainer/opencode-seed/skills/markitdown-converter/scripts/convert.sh new file mode 100644 index 0000000..d18d081 --- /dev/null +++ b/.devcontainer/opencode-seed/skills/markitdown-converter/scripts/convert.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -lt 1 ]; then + echo "Usage: convert.sh [output.md]" >&2 + exit 1 +fi + +INPUT="$1" +OUTPUT="${2:-}" + +if ! command -v markitdown >/dev/null 2>&1; then + echo "markitdown is not installed. Install with: uv tool install markitdown" >&2 + exit 2 +fi + +if [ -n "$OUTPUT" ]; then + markitdown "$INPUT" > "$OUTPUT" + echo "Saved Markdown: $OUTPUT" +else + markitdown "$INPUT" +fi diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index ce209e0..a2b89c8 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -91,6 +91,19 @@ if [ ${#INSTALL_PIDS[@]} -gt 0 ]; then done fi +# Pythonツール管理用 uv の準備 +if ! command -v uv &> /dev/null; then + echo "🐍 uv をインストール中..." + if curl -LsSf https://astral.sh/uv/install.sh | sh; then + export PATH="/home/vscode/.local/bin:$PATH" + echo " ✅ uv インストール完了" + else + echo " ⚠️ uv インストールに失敗しました(後で手動インストールしてください)" + fi +else + echo " ✅ uv 既にインストール済み: $(uv --version 2>/dev/null || echo 'version unknown')" +fi + # ECC の設定適用 echo " ECC設定を適用中..." diff --git a/.devcontainer/startup.sh b/.devcontainer/startup.sh index 91ffb4b..fa00abc 100755 --- a/.devcontainer/startup.sh +++ b/.devcontainer/startup.sh @@ -189,6 +189,64 @@ if [ -f "$PLANNER_AGENT_FILE" ]; then echo "✅ planner agent モデルを設定: $PLANNER_MODEL" fi +# MarkItDown skill/command をOpenChamberから使えるように同期 +MARKITDOWN_SEED_DIR="/workspace/.devcontainer/opencode-seed" +if [ -d "$MARKITDOWN_SEED_DIR" ]; then + mkdir -p \ + /home/vscode/.opencode/skills/markitdown-converter/scripts \ + /home/vscode/.opencode/commands \ + /home/vscode/.opencode/instructions + + install -m 755 \ + "$MARKITDOWN_SEED_DIR/skills/markitdown-converter/scripts/convert.sh" \ + /home/vscode/.opencode/skills/markitdown-converter/scripts/convert.sh + install -m 644 \ + "$MARKITDOWN_SEED_DIR/skills/markitdown-converter/SKILL.md" \ + /home/vscode/.opencode/skills/markitdown-converter/SKILL.md + install -m 644 \ + "$MARKITDOWN_SEED_DIR/commands/to-markdown.md" \ + /home/vscode/.opencode/commands/to-markdown.md + install -m 644 \ + "$MARKITDOWN_SEED_DIR/instructions/markitdown-converter.md" \ + /home/vscode/.opencode/instructions/markitdown-converter.md + echo "✅ MarkItDown skill/command を同期しました" +fi + +if ! command -v uv >/dev/null 2>&1; then + echo "📦 uv をインストール中..." + if curl -LsSf https://astral.sh/uv/install.sh | sh >/tmp/uv-install.log 2>&1; then + export PATH="/home/vscode/.local/bin:$PATH" + echo "✅ uv インストール完了" + else + echo "⚠️ uv インストール失敗 (ログ: /tmp/uv-install.log)" + fi +fi + +if command -v uv >/dev/null 2>&1 && ! command -v markitdown >/dev/null 2>&1; then + echo "📦 markitdown を uv でインストール中..." + if uv tool install markitdown >/tmp/markitdown-install.log 2>&1; then + echo "✅ markitdown インストール完了" + else + echo "⚠️ markitdown インストール失敗 (ログ: /tmp/markitdown-install.log)" + fi +fi + +if [ -f /home/vscode/.opencode/opencode.json ]; then + python3 - <<'PY' +import json +from pathlib import Path + +path = Path("/home/vscode/.opencode/opencode.json") +config = json.loads(path.read_text(encoding="utf-8")) +instructions = config.get("instructions", []) +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") +PY +fi + OPENCODE_LOG=/tmp/opencode-serve.log OPENCHAMBER_LOG=/tmp/openchamber.log