Skip to content

Commit 7853973

Browse files
authored
Merge pull request #7 from fjmrytfjsn/feat/markitdown-skill
Add MarkItDown skill for OpenChamber conversion workflows
2 parents 57bde00 + 26c1e94 commit 7853973

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
@@ -189,6 +189,64 @@ if [ -f "$PLANNER_AGENT_FILE" ]; then
189189
echo "✅ planner agent モデルを設定: $PLANNER_MODEL"
190190
fi
191191

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

0 commit comments

Comments
 (0)