Skip to content

ローカル画像添付機能をjson-to-pptxに追加#40

Merged
mido-app merged 2 commits into
developfrom
feature/json-to-pptx-form
Feb 9, 2026
Merged

ローカル画像添付機能をjson-to-pptxに追加#40
mido-app merged 2 commits into
developfrom
feature/json-to-pptx-form

Conversation

@mido-app
Copy link
Copy Markdown
Contributor

@mido-app mido-app commented Feb 6, 2026

Summary by CodeRabbit

  • New Features

    • JSON→PPTX変換でローカル画像ファイルを利用可能に。CLIで複数画像を指定できる--images(-i)オプションを追加。
  • Documentation

    • ローカル画像を使ったJSON→PPTX変換の実例を追加し、利用方法を明記。
  • Tests

    • 画像付き変換フローを含むCLI/クライアント/統合テストを追加し、動作を検証。
  • Chores

    • パッケージバージョンを v0.3.2 に更新し、変更履歴を追記。

@mido-app mido-app self-assigned this Feb 6, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 6, 2026

Walkthrough

JSON→PPTX 変換にローカル画像ファイルサポートを追加。CLI、クライアント、MCP サーバーで image_paths を受け渡し、クライアントは multipart/form-data(/execute/form)で画像を送信するよう変更。関連テストとバージョン更新を追加。

Changes

Cohort / File(s) Summary
バージョン・ドキュメント
CHANGELOG.md, pyproject.toml
v0.3.2 へのバージョン bump とローカル画像を使った PPTX 生成の追記。
CLI コマンド更新
src/middleman_ai/cli/main.py
json_to_pptx_execute--images/-i オプション追加、引数 images: tuple[str, ...] を受け image_paths をクライアント呼び出しへ渡す。
クライアント実装
src/middleman_ai/client.py
`json_to_pptx_execute_v2(..., image_paths: List[str]
MCP サーバー実装
src/middleman_ai/mcp/server.py
`json_to_pptx_execute(..., image_paths: List[str]
例(examples)
examples/client_usage/main.py
ローカル画像を渡す JSON→PPTX 実行の使用例を追加(image_paths=["test_image.png"])。
テストフィクスチャ(VCR)
tests/cassettes/test_json_to_pptx_execute_v2_vcr.yaml, tests/cassettes/test_json_to_pptx_execute_v2_with_images_vcr.yaml
既存カセットを form ベースへ更新し、画像を含む multipart リクエストのカセットを追加。
テストコード
tests/cli/test_cli.py, tests/test_client.py, tests/test_client_vcr.py, tests/test_mcp.py
CLI/クライアント/MCP の画像パス処理をテスト追加。Presentation/Slide/Placeholder のエクスポートと multipart リクエストの検証テストを追加。

Sequence Diagram(s)

sequenceDiagram
    participant User as User/CLI
    participant FS as Filesystem
    participant CLI as CLI Handler
    participant Client as Client
    participant Server as Middleman API

    User->>CLI: json-to-pptx-execute --images image.png
    CLI->>FS: (optional) validate file exists/readable
    CLI->>Client: json_to_pptx_execute_v2(template_id, presentation, image_paths)
    Client->>FS: open/read image.png
    Client->>Client: infer MIME type, build multipart/form-data
    Client->>Server: POST /api/v2/tools/json-to-pptx/execute/form (presentation_json, pptx_template_id, files)
    Server-->>Client: 200 { result_data: { pptx_url, ... } }
    Client->>CLI: return pptx_url
    CLI->>User: print pptx_url
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰📦 画像をつめて送るよ、ぴょんと一跳び、
multipart の道を行けば PPTX が舞う。
CLI 呼んで、ファイル開いて、MIME を読む、
サーバー戻せば URL が輝く、
おめでとう v0.3.2、にんまり!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、ローカル画像ファイルをJSON→PPTX変換に追加する主な変更を正確に説明しています。
Docstring Coverage ✅ Passed Docstring coverage is 92.31% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/json-to-pptx-form

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/test_client_vcr.py (1)

164-165: ⚠️ Potential issue | 🔴 Critical

パイプライン失敗の原因: match_on パラメータの欠落

エンドポイントが /execute から /execute/form に変更され、リクエスト形式がJSONからフォームエンコードに変わったため、このテストにも match_on パラメータが必要です。CIの失敗はこれが原因です。

🐛 修正案
-@pytest.mark.vcr()
+@pytest.mark.vcr(match_on=["method", "scheme", "port", "path", "query"])
 def test_json_to_pptx_execute_v2_vcr(client: ToolsClient) -> None:

As per coding guidelines, ファイルアップロードを伴うマルチパートリクエストのテストでは、match_on パラメータを使用してマッチング条件を調整する必要があります。

🤖 Fix all issues with AI agents
In `@tests/cassettes/test_json_to_pptx_execute_v2_vcr.yaml`:
- Around line 1-46:
テストデコレータのVCRマッチ設定が古いままなのでボディ形式(JSON→form)が一致せずCIが失敗しています。tests 内の
test_json_to_pptx_execute_v2_vcr の `@pytest.mark.vcr`()
デコレータを、test_json_to_pptx_execute_v2_with_images_vcr と同じ match_on 設定(ボディ比較を適切に扱う
match_on を含む)に変更して、フォームエンコードされたリクエストボディでのマッチングを許可してください(テスト名:
test_json_to_pptx_execute_v2_vcr、参照テスト:
test_json_to_pptx_execute_v2_with_images_vcr、デコレータ: `@pytest.mark.vcr`)。
🧹 Nitpick comments (3)
tests/test_mcp.py (1)

3-3: Line 287 の from pathlib import Path がモジュールレベルのインポートと重複しています。

Line 3 で Path がモジュールレベルでインポートされたため、test_mermaid_file_to_image_tool_mcp 内(Line 287)のローカルインポートは不要になっています。

♻️ 修正案

Line 287 のローカルインポートを削除:

 def test_mermaid_file_to_image_tool_mcp(mocker: "MockerFixture") -> None:
     """mermaid_file_to_imageツールのテスト。"""
-    from pathlib import Path
-
     mock_client = mocker.patch("middleman_ai.mcp.server.client")
src/middleman_ai/mcp/server.py (1)

215-223: 画像パスバリデーションロジックの重複。

Lines 68-76 の md_file_to_pdf 内の画像バリデーションと完全に同一のコードです。ヘルパー関数への抽出を検討してください。

♻️ 例: ヘルパー関数の抽出
+def _validate_image_paths(image_paths: List[str]) -> None:
+    """画像パスの存在・ファイル・読み取り権限を検証します。"""
+    for img_path in image_paths:
+        img_file = Path(img_path)
+        if not img_file.exists():
+            raise ValueError(f"Image file not found: {img_path}")
+        if not img_file.is_file():
+            raise ValueError(f"Image path is not a file: {img_path}")
+        if not os.access(img_file, os.R_OK):
+            raise ValueError(f"Image file not readable: {img_path}")

md_file_to_pdfjson_to_pptx_execute の両方で if image_paths: _validate_image_paths(image_paths) として利用可能です。

tests/test_client.py (1)

620-631: image_paths を指定した場合のクライアントテストが不足しています。

json_to_pptx_execute_v2image_paths を受け取ってマルチパート送信する新機能がありますが、test_client.py にはその経路のテストがありません。画像ファイルを渡した場合の files パラメータ構成やMIMEタイプ推測を検証するテストを追加することを推奨します。

Comment thread tests/cassettes/test_json_to_pptx_execute_v2_vcr.yaml
@mido-app mido-app merged commit 5c89946 into develop Feb 9, 2026
4 checks passed
@mido-app mido-app deleted the feature/json-to-pptx-form branch February 9, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant