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>
66 lines
2.7 KiB
Python
66 lines
2.7 KiB
Python
"""Shared ``companion_unreachable`` error-hint helper.
|
|
|
|
Every companion-backed handler (cache_purge, bulk_meta, export,
|
|
site_health, transient_flush, audit_hook, regenerate_thumbnails,
|
|
capabilities) returns a structured JSON error when the companion
|
|
plugin isn't installed / reachable. This module provides a single
|
|
helper so the hint message, download URL, and install instructions
|
|
stay in sync.
|
|
|
|
F.20 will swap the download URL constant from the GitHub raw path to
|
|
``wordpress.org/plugins/airano-mcp-bridge/`` once the wp.org listing
|
|
is live. At that point a single edit here + the dashboard template
|
|
(``core/templates/dashboard/sites/manage.html``) covers everything.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
# Single source of truth for the companion download URL. Mirror of the
|
|
# constant used in ``core/dashboard/routes.py``. Kept as a plain string
|
|
# rather than imported to avoid a core→plugin import cycle.
|
|
COMPANION_DOWNLOAD_URL = (
|
|
"https://github.com/airano-ir/mcphub/raw/main/" "wordpress-plugin/airano-mcp-bridge.zip"
|
|
)
|
|
|
|
|
|
def companion_install_hint(
|
|
*,
|
|
min_version: str,
|
|
required_capability: str = "manage_options",
|
|
route: str | None = None,
|
|
) -> dict[str, str]:
|
|
"""Return a ``hint`` dict that every companion-backed handler can
|
|
merge into its ``companion_unreachable`` payload.
|
|
|
|
Args:
|
|
min_version: Earliest companion plugin version that exposes the
|
|
route this handler uses (e.g. ``"2.4.0"``). Surfaced in the
|
|
install hint so the user knows what they need.
|
|
required_capability: WordPress capability the calling user needs
|
|
for the companion route. Default ``manage_options``.
|
|
route: Optional route path — included in the hint when set so
|
|
the user can sanity-check by hitting the endpoint directly.
|
|
|
|
Returns:
|
|
Dict with ``install_url``, ``install_instructions``, and
|
|
``required_capability``. Callers merge into their existing
|
|
structured error response alongside ``error`` / ``message``.
|
|
"""
|
|
instructions = (
|
|
f"Install the Airano MCP Bridge companion plugin (v{min_version}+) "
|
|
"on the WordPress site. Download the zip, then in the WP admin: "
|
|
"Plugins → Add New → Upload Plugin → select the file → Activate. "
|
|
f"Ensure the Application Password user has the ``{required_capability}`` "
|
|
"capability. Run ``wordpress_probe_capabilities`` to verify the "
|
|
"route is advertised."
|
|
)
|
|
out = {
|
|
"install_url": COMPANION_DOWNLOAD_URL,
|
|
"install_instructions": instructions,
|
|
"required_capability": required_capability,
|
|
"companion_min_version": min_version,
|
|
}
|
|
if route:
|
|
out["route"] = route
|
|
return out
|