feat(v3.12.0): media pipeline, AI image generation, capability probe, companion v2.9.0
Some checks failed
Release / Test before release (push) Has been cancelled
Release / Publish to PyPI (push) Has been cancelled
Release / Publish to Docker Hub (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled

Three-month batch sync from internal repo (~80 commits) covering Tracks F.5a, F.7e, F.8, F.17, F.18, F.X.

WordPress media pipeline
- Pillow-based optimization, AI image generation (OpenAI / Stability / Replicate / Google Nano Banana / OpenRouter), chunked + resumable uploads, bulk delete/reassign, idempotent retries.

Capability discovery (F.7e)
- Per-site credential probe + adapters for WordPress / WooCommerce / Gitea, tier-fit unions granted ∪ roles, capability badge UI with HTMX partial re-check, install hint in every companion-unreachable error.

Companion plugin overhaul
- Renamed wordpress-plugin/airano-mcp-seo-bridge → wordpress-plugin/airano-mcp-bridge.
- Eight new endpoints: /capabilities, /bulk-meta, /export, /cache-purge, /transient-flush, /site-health, /audit-hook, /upload-and-attach.
- wp.org Plugin Check pass: i18n, WP_Filesystem, scheme allowlist on audit-hook URL.

Other
- Gitea ergonomics (F.17): batch files, tree, search, compare, releases, fork.
- Opportunistic bcrypt upgrade for legacy SHA-256 admin keys (F.8).
- n8n refactor: structured errors, capability probe, missing tools backfilled.
- Idempotency-Key dedup for AI media upload retries; WP client fast-fails on unreachable sites.

Docs
- README + CLAUDE.md drop the fixed "633 tools" claim. The total grows with each release; per-plugin approximations + dashboard-surfaced counts replace it.
- Tools/Tests badges removed in favour of "Plugins: 10".

Deployment
- PyPI mirror chain, optional BUILD_HTTP_PROXY, Alpine→Yandex apk mirror, Debian-slim Plan-B Dockerfile, mirror.gcr.io variant.

CI
- Black + Ruff clean on Python 3.12; pytest tests/ green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-25 16:25:58 +02:00
parent 788439e377
commit f203ca88de
140 changed files with 23802 additions and 2253 deletions

View File

@@ -0,0 +1,96 @@
"""F.X.fix #6 — get_media / list_media expose post_parent.
Regression: neither endpoint returned the parent post, so MCP clients
had no way to verify "is media X attached to post Y" without a second
round trip. Fix adds ``post_parent`` (int, 0 when unattached).
"""
from __future__ import annotations
import json
from unittest.mock import AsyncMock
import pytest
from plugins.wordpress.handlers.media import MediaHandler
def _make_media(media_id: int, *, post: int = 0) -> dict:
return {
"id": media_id,
"title": {"rendered": f"media-{media_id}"},
"mime_type": "image/webp",
"media_type": "image",
"source_url": f"https://example.com/uploads/{media_id}.webp",
"date": "2026-04-17T10:00:00",
"alt_text": "",
"link": f"https://example.com/?attachment_id={media_id}",
"post": post,
"caption": {"rendered": ""},
"description": {"rendered": ""},
"media_details": {},
}
@pytest.fixture
def handler():
client = AsyncMock()
return MediaHandler(client), client
class TestGetMediaPostParent:
@pytest.mark.asyncio
async def test_get_media_returns_attached_parent(self, handler):
h, client = handler
client.get = AsyncMock(return_value=_make_media(77, post=42))
raw = await h.get_media(media_id=77)
data = json.loads(raw)
assert data["post_parent"] == 42
@pytest.mark.asyncio
async def test_get_media_returns_zero_when_unattached(self, handler):
h, client = handler
client.get = AsyncMock(return_value=_make_media(78, post=0))
raw = await h.get_media(media_id=78)
data = json.loads(raw)
# WP's own REST returns 0 for unattached; we preserve that.
assert data["post_parent"] == 0
@pytest.mark.asyncio
async def test_get_media_handles_missing_post_key(self, handler):
h, client = handler
payload = _make_media(79, post=0)
del payload["post"] # older WP installs or partial fields=
client.get = AsyncMock(return_value=payload)
raw = await h.get_media(media_id=79)
data = json.loads(raw)
assert data["post_parent"] == 0
class TestListMediaPostParent:
@pytest.mark.asyncio
async def test_list_media_shape_includes_post_parent(self, handler):
h, client = handler
client.get = AsyncMock(
return_value=[
_make_media(1, post=42),
_make_media(2, post=0),
_make_media(3, post=99),
]
)
raw = await h.list_media()
data = json.loads(raw)
parents = [m["post_parent"] for m in data["media"]]
assert parents == [42, 0, 99]
@pytest.mark.asyncio
async def test_list_media_unattached_reports_zero_not_null(self, handler):
h, client = handler
item = _make_media(5, post=0)
item["post"] = None # Some older WP payloads send null
client.get = AsyncMock(return_value=[item])
raw = await h.list_media()
data = json.loads(raw)
# MCP consumers expect an int they can compare against; None
# makes type-strict callers crash. Normalise to 0.
assert data["media"][0]["post_parent"] == 0