Skip to content

Commit 4ce37c8

Browse files
GitHub Copilot CLICopilot
andcommitted
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>
1 parent a885c6e commit 4ce37c8

6 files changed

Lines changed: 152 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
description: Convert files/URLs to Markdown via MarkItDown
3+
agent: build
4+
---
5+
6+
# to-markdown
7+
8+
Convert source content into Markdown using MarkItDown.
9+
10+
## Usage
11+
12+
`/to-markdown <input-path-or-url> [output.md]`
13+
14+
## Execution
15+
16+
1. Parse `$ARGUMENTS` as:
17+
- first token: input path or URL
18+
- optional second token: output file path
19+
2. Run:
20+
21+
```bash
22+
bash /home/vscode/.opencode/skills/markitdown-converter/scripts/convert.sh <input> [output]
23+
```
24+
25+
3. If output path is provided, report the saved path.
26+
4. If output path is omitted, return the generated Markdown in the response.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
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`.
2+
3+
Guidelines:
4+
- Prefer `/to-markdown <input> <output.md>` for large inputs.
5+
- For small inputs, `/to-markdown <input>` and return inline Markdown is acceptable.
6+
- After conversion, continue analysis using the Markdown output only.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: markitdown-converter
3+
description: Convert files and URLs into Markdown so AI agents can reliably read and reason over mixed-format content.
4+
origin: opencode-ecc-devcontainer
5+
---
6+
7+
# MarkItDown Converter
8+
9+
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.
10+
11+
## When to Activate
12+
13+
- User asks to summarize or extract data from files that are not already Markdown
14+
- User provides URLs or documents that should be converted for downstream AI workflows
15+
- You need a consistent Markdown representation before chunking, indexing, or prompt injection checks
16+
17+
## OpenChamber Usage
18+
19+
1. Explicit command:
20+
- `/to-markdown <input> [output.md]`
21+
2. Natural language:
22+
- Ask normally (e.g. "このPDFをMarkdown化して"), then route through `/to-markdown`
23+
24+
## Notes
25+
26+
- If output is large, prefer writing to a file and then summarizing key sections.
27+
- Preserve the generated Markdown as an artifact when reproducibility is needed.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ "$#" -lt 1 ]; then
5+
echo "Usage: convert.sh <input-path-or-url> [output.md]" >&2
6+
exit 1
7+
fi
8+
9+
INPUT="$1"
10+
OUTPUT="${2:-}"
11+
12+
if ! command -v markitdown >/dev/null 2>&1; then
13+
echo "markitdown is not installed. Install with: uv tool install markitdown" >&2
14+
exit 2
15+
fi
16+
17+
if [ -n "$OUTPUT" ]; then
18+
markitdown "$INPUT" > "$OUTPUT"
19+
echo "Saved Markdown: $OUTPUT"
20+
else
21+
markitdown "$INPUT"
22+
fi

.devcontainer/setup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ if [ ${#INSTALL_PIDS[@]} -gt 0 ]; then
9191
done
9292
fi
9393

94+
# Pythonツール管理用 uv の準備
95+
if ! command -v uv &> /dev/null; then
96+
echo "🐍 uv をインストール中..."
97+
if curl -LsSf https://astral.sh/uv/install.sh | sh; then
98+
export PATH="/home/vscode/.local/bin:$PATH"
99+
echo " ✅ uv インストール完了"
100+
else
101+
echo " ⚠️ uv インストールに失敗しました(後で手動インストールしてください)"
102+
fi
103+
else
104+
echo " ✅ uv 既にインストール済み: $(uv --version 2>/dev/null || echo 'version unknown')"
105+
fi
106+
94107
# ECC の設定適用
95108
echo " ECC設定を適用中..."
96109

.devcontainer/startup.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,64 @@ else
177177
echo "⚠️ OpenCode ECC設定修正スクリプトまたはagentsディレクトリが見つかりません"
178178
fi
179179

180+
# MarkItDown skill/command をOpenChamberから使えるように同期
181+
MARKITDOWN_SEED_DIR="/workspace/.devcontainer/opencode-seed"
182+
if [ -d "$MARKITDOWN_SEED_DIR" ]; then
183+
mkdir -p \
184+
/home/vscode/.opencode/skills/markitdown-converter/scripts \
185+
/home/vscode/.opencode/commands \
186+
/home/vscode/.opencode/instructions
187+
188+
install -m 755 \
189+
"$MARKITDOWN_SEED_DIR/skills/markitdown-converter/scripts/convert.sh" \
190+
/home/vscode/.opencode/skills/markitdown-converter/scripts/convert.sh
191+
install -m 644 \
192+
"$MARKITDOWN_SEED_DIR/skills/markitdown-converter/SKILL.md" \
193+
/home/vscode/.opencode/skills/markitdown-converter/SKILL.md
194+
install -m 644 \
195+
"$MARKITDOWN_SEED_DIR/commands/to-markdown.md" \
196+
/home/vscode/.opencode/commands/to-markdown.md
197+
install -m 644 \
198+
"$MARKITDOWN_SEED_DIR/instructions/markitdown-converter.md" \
199+
/home/vscode/.opencode/instructions/markitdown-converter.md
200+
echo "✅ MarkItDown skill/command を同期しました"
201+
fi
202+
203+
if ! command -v uv >/dev/null 2>&1; then
204+
echo "📦 uv をインストール中..."
205+
if curl -LsSf https://astral.sh/uv/install.sh | sh >/tmp/uv-install.log 2>&1; then
206+
export PATH="/home/vscode/.local/bin:$PATH"
207+
echo "✅ uv インストール完了"
208+
else
209+
echo "⚠️ uv インストール失敗 (ログ: /tmp/uv-install.log)"
210+
fi
211+
fi
212+
213+
if command -v uv >/dev/null 2>&1 && ! command -v markitdown >/dev/null 2>&1; then
214+
echo "📦 markitdown を uv でインストール中..."
215+
if uv tool install markitdown >/tmp/markitdown-install.log 2>&1; then
216+
echo "✅ markitdown インストール完了"
217+
else
218+
echo "⚠️ markitdown インストール失敗 (ログ: /tmp/markitdown-install.log)"
219+
fi
220+
fi
221+
222+
if [ -f /home/vscode/.opencode/opencode.json ]; then
223+
python3 - <<'PY'
224+
import json
225+
from pathlib import Path
226+
227+
path = Path("/home/vscode/.opencode/opencode.json")
228+
config = json.loads(path.read_text(encoding="utf-8"))
229+
instructions = config.get("instructions", [])
230+
entry = "instructions/markitdown-converter.md"
231+
if entry not in instructions:
232+
instructions.append(entry)
233+
config["instructions"] = instructions
234+
path.write_text(json.dumps(config, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
235+
PY
236+
fi
237+
180238
OPENCODE_LOG=/tmp/opencode-serve.log
181239
OPENCHAMBER_LOG=/tmp/openchamber.log
182240

0 commit comments

Comments
 (0)