Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(marketplace): community browse/install/uninstall routes + skill finder pool

rubenluetke10-beep9964f3813fe0
diff --git a/jarvis/marketplace/agent_plugins_loader.py b/jarvis/marketplace/agent_plugins_loader.py
index cb064a6c09..1878dd5846 100644
--- a/jarvis/marketplace/agent_plugins_loader.py
+++ b/jarvis/marketplace/agent_plugins_loader.py
@@ -84,14 +84,10 @@ def _reject_http_urls(value: Any, where: str) -> None:
def _validate_auth_header_template(template: str) -> str:
"""The template must inject a token PLACEHOLDER, never a literal token."""
if not _HEADER_PLACEHOLDER_RE.search(template):
- raise AgentPluginError(
- "mcp_auth_header_template must reference a $plugin_… placeholder"
- )
+ raise AgentPluginError("mcp_auth_header_template must reference a $plugin_… placeholder")
remainder = _HEADER_PLACEHOLDER_RE.sub(" ", template)
if _TOKEN_LITERAL_RE.search(remainder):
- raise AgentPluginError(
- "mcp_auth_header_template may not embed literal credentials"
- )
+ raise AgentPluginError("mcp_auth_header_template may not embed literal credentials")
return template
@@ -100,9 +96,7 @@ def _convert_http_server(
) -> dict[str, Any]:
url = _require_str(server.get("url"), f"mcp.json server {name!r}: url")
if not url.lower().startswith("https://"):
- raise AgentPluginError(
- f"mcp.json server {name!r}: url must be https:// (got {url!r})"
- )
+ raise AgentPluginError(f"mcp.json server {name!r}: url must be https:// (got {url!r})")
if server.get("headers"):
# The spec forbids credentials in headers; community manifests get the
# stricter rule (no headers at all) because a static header IS how a
@@ -206,9 +200,7 @@ def convert_manifest(
description = _require_str(plugin_json.get("description"), "plugin description")
extensions = plugin_json.get("extensions")
- extension = (
- extensions.get(EXTENSION_NAMESPACE) if isinstance(extensions, Mapping) else None
- )
+ extension = extensions.get(EXTENSION_NAMESPACE) if isinstance(extensions, Mapping) else None
if not isinstance(extension, Mapping):
raise AgentPluginError(
f'plugin.json needs extensions["{EXTENSION_NAMESPACE}"] with the '
@@ -230,9 +222,7 @@ def convert_manifest(
)
_reject_http_urls(auth, "auth")
- mcp_server = (
- _convert_mcp_json(name, mcp_json, extension) if mcp_json is not None else None
- )
+ mcp_server = _convert_mcp_json(name, mcp_json, extension) if mcp_json is not None else None
logo_url = extension.get("logo_url")
if logo_url is not None:
@@ -264,11 +254,12 @@ def convert_manifest(
}
)
except ValidationError as exc:
- first = exc.errors()[0] if exc.errors() else {}
- location = ".".join(str(part) for part in first.get("loc", ())) or "manifest"
- raise AgentPluginError(
- f"manifest rejected at {location}: {first.get('msg', 'invalid value')}"
- ) from exc
+ errors = exc.errors()
+ location, message = "manifest", "invalid value"
+ if errors:
+ location = ".".join(str(part) for part in errors[0]["loc"]) or location
+ message = str(errors[0]["msg"])
+ raise AgentPluginError(f"manifest rejected at {location}: {message}") from exc
__all__ = ["AgentPluginError", "EXTENSION_NAMESPACE", "convert_manifest", "validate_spec_name"]
diff --git a/jarvis/marketplace/community_install.py b/jarvis/marketplace/community_install.py
new file mode 100644
index 0000000000..593c67c9e5
--- /dev/null
+++ b/jarvis/marketplace/community_install.py
@@ -0,0 +1,106 @@
+"""Persist community plugin installs into the user's ``data/`` catalog.
+
+"Install" was always designed to be a file write (public-marketplace-analysis
+§1): the catalog loader keeps override entries the seed does not know, so a
+community plugin becomes a first-class store card by appending its converted
+`PluginSpec` to ``data/plugin_catalog.json``. Uninstall removes exactly that
+entry — seed plugins are structurally out of reach here because the loader
+re-adds them from the package on every merge.
+
+Writes are atomic (tmp + replace) and go through one place so the
+read-modify-write cycle stays on the event loop thread without interleaved
+awaits — the same discipline `config_writer` applies to jarvis.toml.
+"""
+
+from __future__ import annotations
+
+import json
+import logging
+from functools import lru_cache
+from typing import Any
+
+from jarvis.marketplace import catalog_data
+from jarvis.marketplace.catalog import PluginSpec
+
+logger = logging.getLogger(__name__)
+
+
+@lru_cache(maxsize=1)
+def seed_plugin_ids() -> frozenset[str]:
+ """Ids shipped in the package seed — reserved against community installs."""
+ try:
+ raw = json.loads(catalog_data._PACKAGE_SEED_PATH.read_text(encoding="utf-8-sig"))
+ return frozenset(
+ str(plugin["id"])
+ for plugin in raw.get("plugins", [])
+ if isinstance(plugin, dict) and plugin.get("id")
+ )
+ except (OSError, ValueError):
+ # An unreadable seed already degrades catalog loading; the guard then
+ # fails open and the loader's own validation still applies.
+ logger.warning("seed catalog unreadable — reserved-id guard is empty")
+ return frozenset()
+
+
+def _read_override() -> dict[str, Any]:
+ """The user's override document, or a fresh skeleton matching the seed."""
+ try:
+ raw = json.loads(catalog_data._DEFAULT_CATALOG_PATH.read_text(encoding="utf-8-sig"))
+ if isinstance(raw, dict) and isinstance(raw.get("plugins"), list):
+ return raw
+ logger.warning("plugin catalog override has no plugins list — rebuilding")
+ except FileNotFoundError:
+ pass
+ except (OSError, ValueError) as exc:
+ # Never silently discard a user's catalog: an unreadable override is
+ # surfaced to the caller instead of being overwritten with a skeleton.
+ raise RuntimeError(
+ f"data/plugin_catalog.json exists but cannot be parsed ({exc}); "
+ "fix or remove it before installing community plugins"
+ ) from exc
+ version, schema_version = 1, "2026-05-09"
+ try:
+ seed = json.loads(catalog_data._PACKAGE_SEED_PATH.read_text(encoding="utf-8-sig"))
+ version = int(seed.get("version", version))
+ schema_version = str(seed.get("schema_version", schema_version))
+ except (OSError, ValueError):
+ logger.warning("seed catalog unreadable — using skeleton catalog header")
+ return {"version": version, "schema_version": schema_version, "plugins": []}
+
+
+def _write_override(document: dict[str, Any]) -> None:
+ catalog_data._DEFAULT_CATALOG_PATH.parent.mkdir(parents=True, exist_ok=True)
+ tmp = catalog_data._DEFAULT_CATALOG_PATH.with_suffix(".json.tmp")
+ tmp.write_text(json.dumps(document, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
+ tmp.replace(catalog_data._DEFAULT_CATALOG_PATH)
+ catalog_data.clear_cache()
+
+
+def install_plugin_spec(spec: PluginSpec) -> None:
+ """Add (or update) a community entry in the override catalog."""
+ document = _read_override()
+ document["plugins"] = [
+ plugin
+ for plugin in document["plugins"]
+ if not (isinstance(plugin, dict) and plugin.get("id") == spec.id)
+ ]
+ document["plugins"].append(spec.model_dump(mode="json"))
+ _write_override(document)
+
+
+def remove_community_plugin(plugin_id: str) -> bool:
+ """Drop a community entry from the override. Returns True when removed."""
+ document = _read_override()
+ before = len(document["plugins"])
+ document["plugins"] = [
+ plugin
+ for plugin in document["plugins"]
+ if not (isinstance(plugin, dict) and plugin.get("id") == plugin_id)
+ ]
+ if len(document["plugins"]) == before:
+ return False
+ _write_override(document)
+ return True
+
+
+__all__ = ["install_plugin_spec", "remove_community_plugin", "seed_plugin_ids"]
diff --git a/jarvis/marketplace/community_source.py b/jarvis/marketplace/community_source.py
index b27c82c2d5..5c46183a18 100644
--- a/jarvis/marketplace/community_source.py
+++ b/jarvis/marketplace/community_source.py
@@ -26,9 +26,7 @@ from pydantic import BaseModel, ConfigDict, Field, ValidationError
logger = logging.getLogger(__name__)
# Repo-root data/ — same resolution as jarvis/marketplace/catalog_data.py.
-_CACHE_PATH = (
- Path(__file__).resolve().parent.parent.parent / "data" / "marketplace_index.json"
-)
+_CACHE_PATH = Path(__file__).resolve().parent.parent.parent / "data" / "marketplace_index.json"
_FETCH_TIMEOUT = httpx.Timeout(connect=3.0, read=10.0, write=10.0, pool=10.0)
# How long a fetched index stays fresh before a view-open refetches it. The
diff --git a/jarvis/skills/finder.py b/jarvis/skills/finder.py
index 5551987b73..c1bc675668 100644
--- a/jarvis/skills/finder.py
+++ b/jarvis/skills/finder.py
@@ -303,6 +303,41 @@ async def _brain_rank(
# Finder
# ----------------------------------------------------------------------
+def _community_entries() -> list[dict[str, Any]]:
+ """Community skills from the CACHED marketplace index, in seed-entry shape.
+
+ Reads only the on-disk cache — search must stay fast and offline-safe, so
+ the network fetch happens at the route edge (TTL-gated), never here. An
+ unreadable or absent cache degrades to the seed catalog alone.
+ """
+ try:
+ from jarvis.marketplace.community_source import cached_index
+
+ index = cached_index()
+ except Exception: # noqa: BLE001 - a broken cache must not kill search
+ log.warning("community skill entries unavailable", exc_info=True)
+ return []
+ if index is None:
+ return []
+ return [
+ {
+ "name": skill.name,
+ "title": skill.title or skill.name,
+ "description": skill.description,
+ "source": "marketplace",
+ "source_url": skill.source_url or "",
+ "raw_url": skill.raw_url,
+ "trust": "community",
+ "stars": None,
+ "categories": list(skill.categories),
+ "languages": ["en"],
+ "risk": "monitor",
+ "tags": [],
+ }
+ for skill in index.skills
+ ]
+
+
class SkillFinder:
"""Mini-agent for skill search and installation."""
@@ -311,7 +346,13 @@ class SkillFinder:
async def search(self, filters: SearchFilters) -> list[SkillCandidate]:
"""Filter + rank — returns up to ``filters.limit`` candidates."""
- catalog = load_catalog()
+ catalog = list(load_catalog())
+ # Community entries join the pool AFTER the seed so a name the curated
+ # catalog already lists cannot be shadowed by a marketplace upload.
+ seen_names = {str(e.get("name")) for e in catalog}
+ catalog.extend(
+ e for e in _community_entries() if e["name"] not in seen_names
+ )
filtered = [e for e in catalog if _passes_filter(e, filters)]
if not filtered:
diff --git a/jarvis/ui/web/marketplace_routes.py b/jarvis/ui/web/marketplace_routes.py
index 96b2eb4d1b..2c7ec1d959 100644
--- a/jarvis/ui/web/marketplace_routes.py
+++ b/jarvis/ui/web/marketplace_routes.py
@@ -6,6 +6,10 @@ Endpoints:
POST /api/marketplace/plugins/{id}/connect/start — kick off OAuth redirect flow
GET /api/marketplace/plugins/{id}/connect/poll/{flow_id} — poll until completion
DELETE /api/marketplace/plugins/{id} — disconnect
+ GET /api/marketplace/community — community index browse
+ POST /api/marketplace/community/refresh — force index re-fetch
+ POST /api/marketplace/community/plugins/{id}/install — one-click install
+ DELETE /api/marketplace/community/plugins/{id} — uninstall + revoke
"""
from __future__ import annotations
@@ -723,3 +727,225 @@ async def disconnect(plugin_id: str, request: Request) -> dict[str, Any]:
# whether the user still has to remove the app at the provider.
"revocation": revocation,
}
+
+
+# ----------------------------------------------------------------------
+# Community marketplace (registry index browse / install / uninstall)
+# ----------------------------------------------------------------------
+
+
+def _community_payload(
+ index: Any, status: str
+) -> dict[str, Any]:
+ """Convert a fetched index into the wire shape the Plugins view renders.
+
+ Every plugin entry is run through the SAME converter the install path
+ uses, so "shown as installable" and "actually installs" cannot drift: an
+ entry the loader rejects renders as an explicit incompatible card instead
+ of failing later at install time. Skills carry their install state from
+ the user skills directory.
+ """
+ from jarvis.core.paths import user_skills_dir
+ from jarvis.marketplace.agent_plugins_loader import (
+ AgentPluginError,
+ convert_manifest,
+ )
+
+ catalog = load_catalog()
+ installed_specs = {spec.id: spec for spec in catalog.plugins}
+
+ plugins: list[dict[str, Any]] = []
+ skills: list[dict[str, Any]] = []
+ if index is not None:
+ for entry in index.plugins:
+ base = {
+ "name": entry.name,
+ "publisher": entry.publisher,
+ "version": entry.version,
+ "published_at": entry.published_at,
+ "source_url": entry.source_url,
+ }
+ try:
+ spec = convert_manifest(
+ entry.plugin_json,
+ entry.mcp_json,
+ publisher=entry.publisher,
+ version=entry.version,
+ source_url=entry.source_url,
+ )
+ if spec.id != entry.name:
+ raise AgentPluginError(
+ f"index name {entry.name!r} does not match manifest "
+ f"name {spec.id!r}"
+ )
+ except AgentPluginError as exc:
+ plugins.append({**base, "valid": False, "error": str(exc)})
+ continue
+ item = spec.model_dump(mode="json")
+ item.update(base)
+ item["valid"] = True
+ existing = installed_specs.get(spec.id)
+ item["installed"] = existing is not None and existing.source == "community"
+ item["installed_version"] = (
+ existing.version if existing is not None else None
+ )
+ # A community name colliding with a shipped plugin is never
+ # installable — surfaced so the UI explains WHY the button is off.
+ item["seed_conflict"] = (
+ existing is not None and existing.source != "community"
+ )
+ item["has_usage_card"] = bool(entry.usage_card)
+ plugins.append(item)
+
+ skills_root = user_skills_dir()
+ for skill in index.skills:
+ skills.append(
+ {
+ "name": skill.name,
+ "title": skill.title or skill.name,
+ "description": skill.description,
+ "publisher": skill.publisher,
+ "version": skill.version,
+ "published_at": skill.published_at,
+ "categories": list(skill.categories),
+ "source_url": skill.source_url,
+ "raw_url": skill.raw_url,
+ "installed": (skills_root / skill.name / "SKILL.md").exists(),
+ }
+ )
+
+ return {
+ "status": status,
+ "revision": getattr(index, "revision", None),
+ "generated_at": getattr(index, "generated_at", None),
+ "plugins": plugins,
+ "skills": skills,
+ }
+
+
[email protected]("/community", openapi_extra={"x-jarvis-readonly": True})
+async def community_browse(response: Response) -> dict[str, Any]:
+ """The community index (TTL-cached fetch), enriched with install state."""
+ from jarvis.marketplace import community_source
+
+ response.headers["Cache-Control"] = "no-store"
+ index, status = await community_source.get_index()
+ return _community_payload(index, status)
+
+
[email protected]("/community/refresh")
+async def community_refresh(response: Response) -> dict[str, Any]:
+ """Force a re-fetch of the community index, bypassing the TTL."""
+ from jarvis.marketplace import community_source
+
+ response.headers["Cache-Control"] = "no-store"
+ index, status = await community_source.get_index(force=True)
+ return _community_payload(index, status)
+
+
[email protected]("/community/plugins/{plugin_id}/install")
+async def community_install(plugin_id: str) -> dict[str, Any]:
+ """One-click install: convert the manifest, persist the catalog entry and
+ usage card, refresh the live registry. The plugin then behaves exactly
+ like a seed plugin (connect flows, relevance gate, worker bridge)."""
+ from jarvis.marketplace import community_source
+ from jarvis.marketplace.agent_plugins_loader import (
+ AgentPluginError,
+ convert_manifest,
+ )
+ from jarvis.marketplace.community_install import (
+ install_plugin_spec,
+ seed_plugin_ids,
+ )
+ from jarvis.marketplace.usage_cards.loader import save_usage_card
+
+ index, _ = await community_source.get_index()
+ entry = None
+ if index is not None:
+ entry = next((e for e in index.plugins if e.name == plugin_id), None)
+ if entry is None:
+ raise HTTPException(
+ status_code=404,
+ detail=f"plugin {plugin_id!r} is not in the community index",
+ )
+ if plugin_id in seed_plugin_ids():
+ raise HTTPException(
+ status_code=409,
+ detail=f"{plugin_id!r} is a built-in plugin id and cannot be "
+ "installed from the community index",
+ )
+ existing = load_catalog().by_id(plugin_id)
+ if existing is not None and existing.source != "community":
+ raise HTTPException(
+ status_code=409,
+ detail=f"{plugin_id!r} already exists in the local catalog",
+ )
+ try:
+ spec = convert_manifest(
+ entry.plugin_json,
+ entry.mcp_json,
+ publisher=entry.publisher,
+ version=entry.version,
+ source_url=entry.source_url,
+ )
+ if spec.id != plugin_id:
+ raise AgentPluginError(
+ f"index name {plugin_id!r} does not match manifest name {spec.id!r}"
+ )
+ except AgentPluginError as exc:
+ raise HTTPException(status_code=400, detail=str(exc)) from exc
+
+ try:
+ install_plugin_spec(spec)
+ except RuntimeError as exc:
+ raise HTTPException(status_code=500, detail=str(exc)) from exc
+ if entry.usage_card:
+ try:
+ save_usage_card(spec.id, entry.usage_card)
+ except (ValueError, OSError) as exc:
+ # Keywords are a quality upgrade, not a prerequisite — the
+ # relevance gate still matches on the plugin's own name/tools.
+ log.warning("usage card for %s not saved: %s", spec.id, exc)
+ _refresh_plugin_in_live_registry(spec.id)
+ item = spec.model_dump(mode="json")
+ item["status"] = "not_connected"
+ return {"ok": True, "plugin": item}
+
+
[email protected]("/community/plugins/{plugin_id}")
+async def community_uninstall(plugin_id: str) -> dict[str, Any]:
+ """Remove an installed community plugin: revoke + drop stored tokens,
+ remove the catalog entry and its usage card, refresh the live registry."""
+ from jarvis.marketplace.community_install import remove_community_plugin
+ from jarvis.marketplace.usage_cards.loader import delete_usage_card
+
+ spec = load_catalog().by_id(plugin_id)
+ if spec is None:
+ raise HTTPException(
+ status_code=404, detail=f"plugin {plugin_id!r} not in catalog"
+ )
+ if spec.source != "community":
+ raise HTTPException(
+ status_code=409,
+ detail=f"{plugin_id!r} is a built-in plugin — disconnect it "
+ "instead of uninstalling",
+ )
+
+ store = TokenStore()
+ revocation = "unsupported"
+ try:
+ tokens = store.load(plugin_id)
+ if tokens is not None:
+ revocation = await revoke_tokens(spec, tokens)
+ except Exception as exc: # noqa: BLE001 - never block the uninstall
+ log.info("plugin %s revocation skipped: %s", plugin_id, exc)
+ revocation = "failed"
+ store.delete(plugin_id)
+
+ try:
+ removed = remove_community_plugin(plugin_id)
+ except RuntimeError as exc:
+ raise HTTPException(status_code=500, detail=str(exc)) from exc
+ delete_usage_card(plugin_id)
+ _refresh_plugin_in_live_registry(plugin_id)
+ return {"ok": True, "removed": removed, "revocation": revocation}
diff --git a/tests/unit/marketplace/test_community_routes.py b/tests/unit/marketplace/test_community_routes.py
new file mode 100644
index 0000000000..511d7227c2
--- /dev/null
+++ b/tests/unit/marketplace/test_community_routes.py
@@ -0,0 +1,231 @@
+"""Community marketplace routes: browse, install, uninstall.
+
+Runs against the real FastAPI router with a pre-seeded index cache (no
+network) and all data/ paths redirected into tmp — the same end-to-end wiring
+the Plugins view exercises, minus the browser.
+"""
+
+from __future__ import annotations
+
+import json
+import time
+from pathlib import Path
+from typing import Any
+
+import httpx
+import pytest
+from fastapi import FastAPI
+
+from jarvis.marketplace import catalog_data, community_source
+from jarvis.marketplace.agent_plugins_loader import EXTENSION_NAMESPACE
+from jarvis.marketplace.usage_cards import loader as cards_loader
+from jarvis.ui.web.marketplace_routes import router
+
+
+def _plugin_entry(name: str = "todo-fox", **manifest_overrides: Any) -> dict[str, Any]:
+ plugin_json: dict[str, Any] = {
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
+ "name": name,
+ "description": "Tasks and reminders from TodoFox",
+ "version": "1.2.0",
+ "license": "MIT",
+ "extensions": {
+ EXTENSION_NAMESPACE: {
+ "display_name": "TodoFox",
+ "category": "Lists & Tasks",
+ "auth": {
+ "mode": "pat_paste",
+ "token_creation_url": "https://todofox.example/settings/tokens",
+ "token_prefix": "tfx_",
+ "validation_endpoint": "https://api.todofox.example/v1/me",
+ "instruction_md": "Create a token in Settings.",
+ },
+ }
+ },
+ }
+ plugin_json.update(manifest_overrides)
+ return {
+ "name": name,
+ "publisher": "octocat",
+ "version": "1.2.0",
+ "published_at": "2026-08-12T10:00:00Z",
+ "source_url": f"https://github.com/PersonalJarvis/marketplace/tree/main/plugins/{name}",
+ "plugin_json": plugin_json,
+ "mcp_json": {
+ "mcpServers": {
+ name: {
+ "type": "streamable-http",
+ "url": "https://mcp.todofox.example/mcp",
+ }
+ }
+ },
+ "usage_card": "---\nkeywords: todo, fox\n---\nUse TodoFox for task work.",
+ }
+
+
+def _index_payload(*plugin_entries: dict[str, Any]) -> dict[str, Any]:
+ return {
+ "revision": 1,
+ "generated_at": "2026-08-12T12:00:00Z",
+ "plugins": list(plugin_entries),
+ "skills": [
+ {
+ "name": "three-point-check",
+ "title": "Three Point Check",
+ "description": "Summarize any topic in three bullets",
+ "publisher": "octocat",
+ "raw_url": "https://raw.example/skills/three-point-check/SKILL.md",
+ "source_url": "https://github.com/PersonalJarvis/marketplace",
+ }
+ ],
+ }
+
+
+def community_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
+ """Redirect every data/ path into tmp and pre-seed a FRESH index cache."""
+ cache = tmp_path / "marketplace_index.json"
+ cache.write_text(
+ json.dumps({"fetched_at": time.time(), "index": _index_payload(_plugin_entry())}),
+ encoding="utf-8",
+ )
+ monkeypatch.setattr(community_source, "_CACHE_PATH", cache)
+ monkeypatch.setattr(community_source, "index_url", lambda: "https://reg.example/index.json")
+ monkeypatch.setattr(catalog_data, "_DEFAULT_CATALOG_PATH", tmp_path / "plugin_catalog.json")
+ monkeypatch.setattr(cards_loader, "_DATA_CARDS_DIR", tmp_path / "usage_cards")
+ monkeypatch.setattr("jarvis.core.paths.user_skills_dir", lambda: tmp_path / "skills")
+ catalog_data.clear_cache()
+ cards_loader.load_usage_card.cache_clear()
+ yield tmp_path
+ catalog_data.clear_cache()
+ cards_loader.load_usage_card.cache_clear()
+
+
+def _client() -> httpx.AsyncClient:
+ app = FastAPI()
+ app.include_router(router)
+ return httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://test")
+
+
+async def test_browse_lists_converted_plugins_and_skills(community_env: Path) -> None:
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/community")
+ assert resp.status_code == 200
+ data = resp.json()
+ assert data["status"] == "fresh"
+ plugin = data["plugins"][0]
+ assert plugin["valid"] is True
+ assert plugin["id"] == "todo-fox"
+ assert plugin["source"] == "community"
+ assert plugin["publisher"] == "octocat"
+ assert plugin["installed"] is False
+ assert plugin["seed_conflict"] is False
+ assert plugin["mcp_server"]["url"] == "https://mcp.todofox.example/mcp"
+ skill = data["skills"][0]
+ assert skill["name"] == "three-point-check"
+ assert skill["installed"] is False
+
+
+async def test_install_persists_catalog_entry_and_usage_card(
+ community_env: Path,
+) -> None:
+ async with _client() as client:
+ resp = await client.post("/api/marketplace/community/plugins/todo-fox/install")
+ assert resp.status_code == 200
+ assert resp.json()["plugin"]["status"] == "not_connected"
+
+ # The installed plugin is now a first-class store card…
+ listed = await client.get("/api/marketplace/plugins")
+ entry = next(p for p in listed.json()["plugins"] if p["id"] == "todo-fox")
+ assert entry["source"] == "community"
+ assert entry["status"] == "not_connected"
+
+ # …and browse reflects the install.
+ browse = await client.get("/api/marketplace/community")
+ assert browse.json()["plugins"][0]["installed"] is True
+
+ override = json.loads((community_env / "plugin_catalog.json").read_text(encoding="utf-8"))
+ assert any(p["id"] == "todo-fox" for p in override["plugins"])
+ card = cards_loader.load_usage_card("todo-fox")
+ assert card is not None and "todo" in card.keywords
+
+
+async def test_install_unknown_name_404(community_env: Path) -> None:
+ async with _client() as client:
+ resp = await client.post("/api/marketplace/community/plugins/nope/install")
+ assert resp.status_code == 404
+
+
+async def test_install_reserved_seed_id_409(
+ community_env: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ cache = community_env / "marketplace_index.json"
+ cache.write_text(
+ json.dumps(
+ {
+ "fetched_at": time.time(),
+ "index": _index_payload(_plugin_entry(name="github")),
+ }
+ ),
+ encoding="utf-8",
+ )
+ async with _client() as client:
+ resp = await client.post("/api/marketplace/community/plugins/github/install")
+ assert resp.status_code == 409
+ assert "built-in" in resp.json()["detail"]
+
+
+async def test_install_invalid_manifest_400(community_env: Path) -> None:
+ entry = _plugin_entry()
+ entry["mcp_json"]["mcpServers"]["todo-fox"]["url"] = "http://plain.example/mcp"
+ (community_env / "marketplace_index.json").write_text(
+ json.dumps({"fetched_at": time.time(), "index": _index_payload(entry)}),
+ encoding="utf-8",
+ )
+ async with _client() as client:
+ browse = await client.get("/api/marketplace/community")
+ assert browse.json()["plugins"][0]["valid"] is False
+ resp = await client.post("/api/marketplace/community/plugins/todo-fox/install")
+ assert resp.status_code == 400
+ assert "https" in resp.json()["detail"]
+
+
+async def test_uninstall_removes_entry_and_card(community_env: Path) -> None:
+ async with _client() as client:
+ await client.post("/api/marketplace/community/plugins/todo-fox/install")
+ resp = await client.delete("/api/marketplace/community/plugins/todo-fox")
+ assert resp.status_code == 200
+ assert resp.json()["removed"] is True
+
+ listed = await client.get("/api/marketplace/plugins")
+ assert all(p["id"] != "todo-fox" for p in listed.json()["plugins"])
+ assert cards_loader.load_usage_card("todo-fox") is None
+
+
+async def test_uninstall_seed_plugin_409(community_env: Path) -> None:
+ async with _client() as client:
+ resp = await client.delete("/api/marketplace/community/plugins/github")
+ assert resp.status_code == 409
+
+
+async def test_refresh_bypasses_ttl(community_env: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ calls: list[bool] = []
+ real_get_index = community_source.get_index
+
+ async def spy(*, force: bool = False, transport: Any = None) -> Any:
+ calls.append(force)
+ return await real_get_index(force=False, transport=transport)
+
+ monkeypatch.setattr(community_source, "get_index", spy)
+ async with _client() as client:
+ resp = await client.post("/api/marketplace/community/refresh")
+ assert resp.status_code == 200
+ assert calls == [True]
diff --git a/tests/unit/marketplace/test_community_source.py b/tests/unit/marketplace/test_community_source.py
index e6be939c82..85fa6a107d 100644
--- a/tests/unit/marketplace/test_community_source.py
+++ b/tests/unit/marketplace/test_community_source.py
@@ -52,9 +52,7 @@ def _transport(handler: Any) -> httpx.MockTransport:
def _seed_cache(path: Path, payload: dict[str, Any], fetched_at: float) -> None:
- path.write_text(
- json.dumps({"fetched_at": fetched_at, "index": payload}), encoding="utf-8"
- )
+ path.write_text(json.dumps({"fetched_at": fetched_at, "index": payload}), encoding="utf-8")
def _cache_exists(path: Path) -> bool:
@@ -94,9 +92,7 @@ async def test_force_refetches_inside_ttl(cache_path: Path) -> None:
def handler(request: httpx.Request) -> httpx.Response:
return httpx.Response(200, json=_index_payload(revision=2))
- index, status = await community_source.get_index(
- force=True, transport=_transport(handler)
- )
+ index, status = await community_source.get_index(force=True, transport=_transport(handler))
assert status == "fetched"
assert index is not None and index.revision == 2
diff --git a/tests/unit/skills/test_finder_community_pool.py b/tests/unit/skills/test_finder_community_pool.py
new file mode 100644
index 0000000000..c5442edd74
--- /dev/null
+++ b/tests/unit/skills/test_finder_community_pool.py
@@ -0,0 +1,76 @@
+"""Community marketplace skills join the finder's candidate pool (cache-only)."""
+
+from __future__ import annotations
+
+from typing import Any
+
+import pytest
+
+from jarvis.marketplace.community_source import CommunityIndex
+from jarvis.skills import finder as finder_module
+from jarvis.skills.finder import SearchFilters, SkillFinder
+
+
+def _index(**kwargs: Any) -> CommunityIndex:
+ return CommunityIndex.model_validate(
+ {
+ "revision": 1,
+ "skills": [
+ {
+ "name": "three-point-check",
+ "title": "Three Point Check",
+ "description": "Summarize any topic in three bullets",
+ "publisher": "octocat",
+ "raw_url": "https://raw.example/SKILL.md",
+ "source_url": "https://github.com/PersonalJarvis/marketplace",
+ },
+ *kwargs.get("extra_skills", []),
+ ],
+ }
+ )
+
+
+async def test_community_skill_appears_in_search(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setattr("jarvis.marketplace.community_source.cached_index", lambda: _index())
+ results = await SkillFinder().search(SearchFilters(query="three bullets summary", limit=20))
+ match = next((c for c in results if c.name == "three-point-check"), None)
+ assert match is not None
+ assert match.trust == "community"
+ assert match.source == "marketplace"
+ assert match.raw_url == "https://raw.example/SKILL.md"
+
+
+async def test_seed_entry_shadows_community_name(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ seed = finder_module.load_catalog()
+ if not seed:
+ pytest.skip("no seed catalog entries available")
+ seed_name = str(seed[0]["name"])
+ index = _index(
+ extra_skills=[
+ {
+ "name": seed_name,
+ "description": "imposter",
+ "raw_url": "https://evil.example/SKILL.md",
+ }
+ ]
+ )
+ monkeypatch.setattr("jarvis.marketplace.community_source.cached_index", lambda: index)
+ results = await SkillFinder().search(SearchFilters(query=seed_name, limit=50))
+ hits = [c for c in results if c.name == seed_name]
+ assert hits, "seed entry must remain findable"
+ assert all(c.raw_url != "https://evil.example/SKILL.md" for c in hits)
+
+
+async def test_missing_cache_degrades_to_seed_only(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setattr("jarvis.marketplace.community_source.cached_index", lambda: None)
+ results = await SkillFinder().search(SearchFilters(query="anything", limit=5))
+ assert all(c.source != "marketplace" for c in results)