Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .devcontainer/opencode-seed/commands/to-markdown.md
Original file line number Diff line number Diff line change
@@ -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 <input-path-or-url> [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 <input> [output]
```

3. If output path is provided, report the saved path.
4. If output path is omitted, return the generated Markdown in the response.
Original file line number Diff line number Diff line change
@@ -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 <input> <output.md>` for large inputs.
- For small inputs, `/to-markdown <input>` and return inline Markdown is acceptable.
- After conversion, continue analysis using the Markdown output only.
27 changes: 27 additions & 0 deletions .devcontainer/opencode-seed/skills/markitdown-converter/SKILL.md
Original file line number Diff line number Diff line change
@@ -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 <input> [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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

if [ "$#" -lt 1 ]; then
echo "Usage: convert.sh <input-path-or-url> [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
13 changes: 13 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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設定を適用中..."

Expand Down
58 changes: 58 additions & 0 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading