* Rename agnes-metadata.json to marketplace-metadata.json
Curated marketplace enrichment file (.claude-plugin/agnes-metadata.json)
becomes marketplace-metadata.json. Clean cut, no fallback — curators of
upstream marketplace repos must rename the file on their side.
Python API renames mirror the file rename: read_agnes_metadata →
read_marketplace_metadata, AGNES_METADATA_REL → MARKETPLACE_METADATA_REL,
AGNES_METADATA_MAX_BYTES → MARKETPLACE_METADATA_MAX_BYTES. Synth Claude
Code marketplace strip rule (.agnes/** + the metadata file) follows the
new filename.
* Marketplace detail polish: window cover + 715:310 aspect + helper alignment
- Plugin & item (skill/agent) detail hero: 160x160 square cover replaced
with a macOS-style window frame (3 traffic-light dots + titlebar label
showing the entity name). Body is constrained to 715:310 so curator-
uploaded covers no longer crop to a square. Window is 380px wide; meta
column and absolutely-positioned top-right install/remove actions stay
put. Fallback when no cover_photo_url (translucent gradient + PL/SK/AG
initials) is unchanged, just inside the window body.
- Inner skill/agent cards in the plugin detail's Internal structure
section adopt the same 715:310 aspect (was fixed 78px tall). No window
chrome on inner cards — just the matching proportions so covers read
consistently across hero, grid tiles, and listing cards.
- Curated nested item helper text ("This skill is part of ... — add the
bundle to your stack to use it") now stacks UNDER the "Open parent
plugin" button instead of being a side-by-side flex sibling in the
actions-row. Added align-self: flex-end so the 260px helper box
anchors at the right edge of the 300px actions column, matching the
button's right edge.
* Marketplace My tab: surface the same category + type filters as Flea
- Frontend: mp-cat-row and mp-type-row now show on tab=my (previously
hidden — type was flea-only, category was flea/curated-only). Curated
browse stays plugin-only and continues to hide the type pills.
fetchOne() sends the `type` param for tab=my too, so the items
endpoint's existing my-branch filter actually receives it.
- Backend categories endpoint, tab=my branch: when the type filter is
set to skill/agent, skip counting curated subscriptions. Curated
plugins are always type='plugin', so they wouldn't survive the items
endpoint's type filter; including them in the category counts made
the pill numbers overstate what users could actually see in the
grid. type=None or type='plugin' keeps the previous behaviour.
- CHANGELOG entry under [Unreleased].
* Marketplace plugin detail: render rich content from marketplace-metadata.json
Adds five optional plugin-level fields to marketplace-metadata.json and
renders them on the curated plugin detail page + listing card:
* display_name — friendly h1 / listing-card name / mac-window titlebar
label (overrides the technical plugin id)
* tagline — punchy 1-line value prop for the hero subtitle and the
listing card description (replacing the verbose marketplace.json
description on cards)
* description — multi-paragraph markdown body, server-side rendered
through markdown-it-py and sanitized through nh3 with a
description-scoped allowlist (no iframes / no raw HTML / no
javascript: links). Powers the "What it does" panel.
* use_cases[] — {title, description, prompt} entries that render as a
3-column "When to use it" card grid; each card shows the literal
prompt as a code chip so users can copy-paste into Claude Code.
* sample_interaction — {user, assistant} dialog rendered in a Claude
Code-style dark Catppuccin Mocha transcript panel: monospace user
row with a green ">" prompt indicator + sans-serif assistant body
with markdown formatting (peach bold, yellow italic, pink inline
code, mantle-dark fenced code blocks).
All five fields are optional; UI sections only render when populated,
so plugins without enrichment look identical to before. Fields are
read on-demand from the working tree (cached by mtime per marketplace
slug) so curator edits land at the next request without waiting for
a sync cycle — same pattern as the existing inner-skill/agent
enrichment path. No DB schema bump.
Skill / agent rich-content rendering is deferred to a later phase
(needs a source-of-truth decision: extend plugin.yml? LLM-generate
from SKILL.md / agent.md?). The schema accepts the same fields at
skill/agent level today for forward compatibility but the UI ignores
them for now.
Also: stripped a stale `background-color: var(--bg)` from the global
`code` rule in style.css (was making inline code visually disappear
on the page background).
* Skill / agent detail: render rich content from marketplace-metadata.json
Brings the skill/agent detail pages to parity with the plugin detail
page. Same rich-content schema (display_name, tagline, description as
markdown, use_cases[], sample_interaction) plus two per-item additions:
* invocation — curator-provided literal command string. When set,
overrides the computed "<manifest_name>:<inner_name>" chip and
cleanly supports both "/" skill prefix and "@" agent prefix (the
hardcoded "/" in the chip markup is hidden when the curator provides
the invocation, so /grpn-eng:query <q> and @grpn-eng:cto-architect
both render correctly).
* when_to_use — markdown disambiguation block ("Use this for X. For
similar Y, see /other-skill") rendered into a new "When to use this"
panel below the Example section.
Skill / agent category is now per-item overridable in
marketplace-metadata.json. When absent, the API keeps the parent
plugin's category as the badge so existing items don't lose their
category until curators opt in to per-item categorization.
The new "Example" Q&A panel uses the same Claude Code-style dark
Catppuccin Mocha transcript treatment as the plugin detail —
monospace user row with a green ">" prompt indicator + sans-serif
assistant body with markdown formatting.
All new fields are optional and read on-demand from the working tree.
Skills / agents whose marketplace-metadata.json doesn't carry rich
content render exactly the same way they did before (frontmatter
description + computed slash command + cover from existing v32
enrichment). No DB schema bump.
* Fix TypeError in skill / agent detail when curator sets per-item category
`curated_skill_detail` and `curated_agent_detail` were passing both
`**parent` (from `_curated_inner_parent_fields`, which returns the
parent plugin's category as a fallback) and `**enrichment` (from
`_curated_inner_enrichment`, which returns the per-item category
override when the curator set one) into `InnerDetailResponse(...)`.
Python function-call kwargs unpacking with overlapping keys raises
`TypeError: got multiple values for keyword argument 'category'`
— it doesn't merge like a literal dict does. The bug only surfaced
when the marketplace-metadata.json carried a `category` field at
skill / agent level (curator opting into per-item categorization);
items without that override hit the endpoint cleanly because only
parent provided the key.
Fix: build `merged = {**parent, **enrichment}` first (literal-dict
syntax DOES merge, with the right-hand-side winning) and unpack the
merged dict. Curator override still wins via the merge order, and
the same pattern is future-proof for any other field that lands in
both layers later.
Plus a regression test in test_marketplace_metadata.py asserting
that the inner-resolver carries `category` for downstream merging.
* Marketplace detail: tolerate partial curator JSON
Server constructed UseCase / SampleInteraction via raw dict indexing
(uc["title"], sample["assistant"]), so a curator commit missing any
required Pydantic field crashed the whole plugin / skill / agent detail
endpoint with a 500. Route both constructions through _safe_use_case /
_safe_sample_interaction helpers — partial input silently drops the
malformed card / section instead of breaking the page.
Regression test in test_marketplace_api.py covers the three shapes:
use_case missing a key, use_case with an empty string, and
sample_interaction with only user (no assistant). Sibling rich fields
still render.
* Address PR-251 review (must-fixes + S2/S3 polish) + release-cut 0.50.0
Five must-fixes from the review pass (3 from @cvrysanek's two-stage
review, 2 from my independent pass), plus the 0.50.0 release-cut as the
last commit on this PR per CLAUDE.md (CLAUDE.md "Release-cut belongs
to the PR" rule added in v0.49.1).
Must-fixes
----------
1. Cache eviction: bounded LRU instead of per-marketplace predicate.
The previous predicate (`k[0] == marketplace_id and k[1] != mtime_ns`)
only swept stale entries for the CURRENT marketplace; with N>100
distinct marketplaces each holding one mtime key, the cap silently
failed and memory grew linearly. Replaced with OrderedDict-backed
bounded LRU at cap=256, drop oldest insert on overflow.
Cache stress test pinned in test_marketplace_metadata.py.
2. Render CPU cap: per-field byte cap on description / when_to_use /
sample_interaction.assistant via MARKETPLACE_METADATA_FIELD_MAX_BYTES
(= 64 KiB). Without this, a 1 MiB curator markdown body × QPS =
curator-controlled CPU burn through pure-Python markdown-it-py.
Truncation respects UTF-8 boundaries and logs a warning so the
curator sees the cap fire on the next sync. Test for cap +
UTF-8-boundary preservation.
3. Inner-detail bypassed the metadata cache. _curated_inner_enrichment,
_curated_inner_cover, and curated_detail all called
read_marketplace_metadata directly, defeating the mtime cache the
plugin listing already shared. Routed all three through
_read_metadata_cached so skill/agent detail hits are O(1) re-parses
per marketplace per mtime instead of O(QPS).
4. Truthy-vs-presence trap in plugin/inner enrichment merge. API-layer
writers used `if resolved.get(k):` which silently dropped any
future falsy-but-valid resolver field (bool featured=False, int
priority=0, str category=''). Switched to presence check
(`if k in resolved`) so the resolver is the authority on field
presence; `{**parent, **enrichment}` merge respects whatever the
resolver decided to ship.
5. Vendor-agnostic OSS cleanup. Removed operator-specific token
references (/grpn-eng:, @grpn-eng:, .foundryai/) from
src/marketplace_metadata.py docstring, app/web/templates/
marketplace_item_detail.html JS comment, docs/curated-marketplace-
format.md, and tests/test_marketplace_metadata.py fixtures. Replaced
with generic /my-plugin:tool / @my-agent:role / .example/ placeholders.
CHANGELOG
---------
- New "### Fixed (PR #251 follow-ups)" section documenting all 4
code-side must-fixes
- New "### Internal" section noting the vendor cleanup + new tests
- BREAKING bullet for the file rename now covers operator-side
migration: running instances see plugin enrichment disappear from
the UI until upstream curator renames + nightly sync overwrites the
working tree; POST /api/marketplaces/{id}/sync forces refresh sooner
- Stripped /grpn-eng: leaks from the existing skill/agent rich-content
bullet
Tests
-----
128 targeted tests pass (test_marketplace_metadata, test_marketplace_api,
test_marketplace, test_markdown_render, test_marketplace_synth_strip,
test_marketplace_filter). New tests added:
- 6 XSS regression tests on render_safe (javascript:/data:/vbscript:
schemes via autolink, reference link, and mixed-case + positive
http/https/mailto + noopener noreferrer rel)
- 3 byte-cap tests (truncation + UTF-8 boundary + under-cap pass-through)
- 1 cache eviction stress test (>256 marketplaces -> bounded at cap)
- 1 truthy-vs-presence resolver-contract test
Release-cut
-----------
- pyproject.toml 0.49.1 -> 0.50.0 (minor; BREAKING file rename per
pre-1.0 CHANGELOG note: "breaking changes called out under Changed
or Removed with the BREAKING marker")
- CHANGELOG [Unreleased] -> [0.50.0] - 2026-05-12, new empty
[Unreleased] on top.
---------
Co-authored-by: Minas Arustamyan <arustamyan.minas@gmail.com>
Co-authored-by: ZdenekSrotyr <zdenek.srotyr@keboola.com>
167 lines
6.4 KiB
Python
167 lines
6.4 KiB
Python
"""Verify Agnes-only files never leak into the synth Claude Code marketplace.
|
|
|
|
Two surfaces are covered:
|
|
|
|
* the ZIP delivery (``app/marketplace_server/packager.py::build_zip``),
|
|
* the git tree built from ``file_set_for_user`` (``app/marketplace_server/git_backend.py``).
|
|
|
|
Both must strip:
|
|
|
|
* ``.claude-plugin/marketplace-metadata.json`` (anywhere in the plugin tree),
|
|
* anything under ``.agnes/`` (anywhere in the plugin tree).
|
|
|
|
Test fixtures stand up a fake plugin dir on disk + a fake `plugins` list
|
|
that the packager / git_backend consume directly — we don't go through the
|
|
DB layer because the strip behavior is independent of plugin resolution.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import io
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
from src.marketplace_filter import is_agnes_only_path
|
|
|
|
|
|
def _build_plugin_dir(tmp_path: Path) -> Path:
|
|
"""Create a plugin directory with a mix of regular and Agnes-only files."""
|
|
plugin = tmp_path / "plugins" / "demo"
|
|
plugin.mkdir(parents=True)
|
|
|
|
# Standard Claude Code files
|
|
(plugin / ".claude-plugin").mkdir()
|
|
(plugin / ".claude-plugin" / "plugin.json").write_text(
|
|
'{"name":"demo","version":"1.0"}', encoding="utf-8",
|
|
)
|
|
(plugin / "skills").mkdir()
|
|
(plugin / "skills" / "foo").mkdir()
|
|
(plugin / "skills" / "foo" / "SKILL.md").write_text(
|
|
"---\nname: foo\n---\nbody", encoding="utf-8",
|
|
)
|
|
|
|
# Agnes-only files that MUST be stripped
|
|
(plugin / ".claude-plugin" / "marketplace-metadata.json").write_text(
|
|
'{"version":1}', encoding="utf-8",
|
|
)
|
|
(plugin / ".agnes").mkdir()
|
|
(plugin / ".agnes" / "cover.png").write_bytes(b"\x89PNG\r\n\x1a\nfake")
|
|
(plugin / ".agnes" / "docs").mkdir()
|
|
(plugin / ".agnes" / "docs" / "internal.md").write_text(
|
|
"# internal", encoding="utf-8",
|
|
)
|
|
|
|
return plugin
|
|
|
|
|
|
def _fake_plugin_record(plugin_dir: Path, *, prefixed_name: str = "test-demo") -> dict:
|
|
"""Shape the packager / git_backend expect from `resolve_user_marketplace`."""
|
|
return {
|
|
"marketplace_id": "test",
|
|
"marketplace_slug": "test",
|
|
"original_name": "demo",
|
|
"prefixed_name": prefixed_name,
|
|
"manifest_name": "demo",
|
|
"version": "1.0",
|
|
"plugin_dir": plugin_dir,
|
|
"raw": {"name": "demo", "version": "1.0", "description": "demo"},
|
|
"source": "marketplace",
|
|
}
|
|
|
|
|
|
# --- is_agnes_only_path ---------------------------------------------------
|
|
|
|
|
|
def test_is_agnes_only_path_strips_dot_agnes_at_root():
|
|
assert is_agnes_only_path((".agnes", "cover.png"))
|
|
assert is_agnes_only_path((".agnes", "docs", "x.md"))
|
|
|
|
|
|
def test_is_agnes_only_path_strips_dot_agnes_anywhere():
|
|
"""Even nested `.agnes/` dirs are stripped — e.g. inside a plugin."""
|
|
assert is_agnes_only_path(("plugins", "foo", ".agnes", "x.png"))
|
|
|
|
|
|
def test_is_agnes_only_path_strips_marketplace_metadata_json():
|
|
assert is_agnes_only_path((".claude-plugin", "marketplace-metadata.json"))
|
|
assert is_agnes_only_path(("nested", "marketplace-metadata.json"))
|
|
|
|
|
|
def test_is_agnes_only_path_keeps_normal_files():
|
|
"""`.claude-plugin/plugin.json`, `.claude-plugin/marketplace.json`, plain
|
|
plugin code etc. all survive the filter."""
|
|
assert not is_agnes_only_path((".claude-plugin", "plugin.json"))
|
|
assert not is_agnes_only_path((".claude-plugin", "marketplace.json"))
|
|
assert not is_agnes_only_path(("skills", "foo", "SKILL.md"))
|
|
assert not is_agnes_only_path(("agents", "bar.md"))
|
|
|
|
|
|
def test_is_agnes_only_path_does_not_match_lookalikes():
|
|
"""Naming collisions: a directory named ``.agneswriter`` (single segment
|
|
starting with `.agnes` but not equal) is NOT stripped."""
|
|
assert not is_agnes_only_path((".agneswriter", "x.md"))
|
|
assert not is_agnes_only_path(("not-marketplace-metadata.json",))
|
|
|
|
|
|
# --- ZIP path -------------------------------------------------------------
|
|
|
|
|
|
def test_zip_strips_agnes_only_files(tmp_path, monkeypatch):
|
|
"""End-to-end through the packager's ``_collect_members``: produce a ZIP
|
|
and assert no Agnes-only paths land inside it."""
|
|
from app.marketplace_server import packager
|
|
|
|
plugin_dir = _build_plugin_dir(tmp_path)
|
|
plugins = [_fake_plugin_record(plugin_dir)]
|
|
members = packager._collect_members(plugins, etag="testetag")
|
|
|
|
arcnames = {arc for arc, _ in members}
|
|
# Sanity: the regular files DID survive
|
|
assert any(a.endswith(".claude-plugin/plugin.json") for a in arcnames)
|
|
assert any(a.endswith("skills/foo/SKILL.md") for a in arcnames)
|
|
assert any(a.endswith(".claude-plugin/marketplace.json") for a in arcnames)
|
|
# Agnes-only files DID NOT
|
|
assert not any("marketplace-metadata.json" in a for a in arcnames), arcnames
|
|
assert not any(".agnes/" in a for a in arcnames), arcnames
|
|
|
|
|
|
def test_zip_etag_independent_of_agnes_files(tmp_path):
|
|
"""Compute_etag in marketplace_filter consumes the same is_agnes_only_path
|
|
filter, so adding/removing `.agnes/` content doesn't bust the ETag."""
|
|
from src import marketplace_filter
|
|
|
|
plugin_dir = _build_plugin_dir(tmp_path)
|
|
plugins = [_fake_plugin_record(plugin_dir)]
|
|
etag_with_agnes = marketplace_filter.compute_etag(plugins)
|
|
|
|
# Drop the `.agnes/` content and re-compute. ETag must match.
|
|
import shutil
|
|
shutil.rmtree(plugin_dir / ".agnes")
|
|
(plugin_dir / ".claude-plugin" / "marketplace-metadata.json").unlink()
|
|
etag_without_agnes = marketplace_filter.compute_etag(plugins)
|
|
assert etag_with_agnes == etag_without_agnes
|
|
|
|
|
|
# --- Git tree path -------------------------------------------------------
|
|
|
|
|
|
def test_git_tree_strips_agnes_only_files(tmp_path):
|
|
"""The git_backend ``file_set_for_user`` builds the same dict shape as
|
|
the ZIP, so the same strip applies."""
|
|
# We don't have an easy way to call file_set_for_user without a DB, so
|
|
# instead replicate the small block that walks plugin_dir and calls the
|
|
# filter — exact same code path as git_backend, identical inputs.
|
|
plugin_dir = _build_plugin_dir(tmp_path)
|
|
|
|
files: dict[str, bytes] = {}
|
|
prefix = "demo"
|
|
for f in sorted(p for p in plugin_dir.rglob("*") if p.is_file()):
|
|
rel_parts = f.relative_to(plugin_dir).parts
|
|
if is_agnes_only_path(rel_parts):
|
|
continue
|
|
files[f"plugins/{prefix}/{f.relative_to(plugin_dir).as_posix()}"] = f.read_bytes()
|
|
|
|
assert any(p.endswith("/SKILL.md") for p in files)
|
|
assert any(p.endswith("/.claude-plugin/plugin.json") for p in files)
|
|
assert not any("marketplace-metadata.json" in p for p in files)
|
|
assert not any(".agnes/" in p for p in files)
|