Official
market
The plugin marketplace: browse, install through an agent's scan, update and publish plugins, and the marketplace tools of agents in the Plugins workspace.
The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/market@0.1.3
Permissions in 0.1.3
Files
browse.tsx7.8 KB
// The Browse tab: the search field, the category chips, the count with the
// sort, then one compact row per plugin: its mark, its name and publisher,
// one line of what it does, and at the end whether it is installed here or
// how many have it, beside its first screenshot when it has one.
import type { Element, ValueEvent } from "divergence";
import { SORTS, categoryMark, formatCount, isOfficial } from "./logic.ts";
import type { Controller } from "./controller.ts";
import type { Listing } from "./remote.ts";
import { EDGED, clickable, column, fill, row } from "./parts.tsx";
import type { Ctx } from "./parts.tsx";
// A row's mark, and the thumbnail of its first screenshot (16:10).
const MARK = 36;
const THUMB = { width: 72, height: 45 } as const;
// A row's inner padding across, which the list takes back in the gutter.
const ROW_INSET = 10;
// A listing's icon in a square of `size`: its own picture once the app has
// it, else its kind's symbol in its kind's colour on a quiet tile of the
// same size, so nothing moves when the picture arrives.
export function listingMark(ctx: Ctx, market: Controller, listing: Listing, size: number): Element {
const radius = Math.round(size * 0.25);
const icon = listing.listing?.icon;
const picture = icon ? market.mediaOf(icon, listing.id) : null;
if (picture?.fetch) ctx.run(picture.fetch);
if (picture?.path)
return <div {...EDGED} flexShrink={0} borderRadius={radius}><image path={picture.path} width={size} height={size} radius={radius} /></div>;
const mark = categoryMark(listing.categories);
return <div {...row} justifyContent="center" flexShrink={0} width={size} height={size} borderRadius={radius} background="muted"><icon name={mark.icon} color={mark.color} /></div>;
}
// Who made it, with the verified mark when the registry vouches for them.
export function publisherName(listing: Listing): Element {
const publisher = listing.publisher ?? {};
const verified = publisher.verified || isOfficial(listing.id);
return (
<div {...row} gap={4} flexShrink={0}>
<text style="body" size="xs" tone="muted">{publisher.displayName || publisher.name || listing.id.split("/")[0]}</text>
{verified ? <icon name="badge-check" small tone="primary" /> : null}
</div>
);
}
// The row's end: installed here (and whether an update waits), else how
// many have it, once anyone does.
function rowStatus(market: Controller, listing: Listing): Element | null {
if (listing.installed) {
const update = market.state.updates.some((item) => item.id === listing.id && item.latest);
return (
<div {...row} gap={4} flexShrink={0}>
<icon name={update ? "arrow-up" : "check"} small tone={update ? "primary" : "success"} />
<text style="body" size="xs" tone={update ? "primary" : "muted"}>{update ? "Update" : "Installed"}</text>
</div>
);
}
const installs = Number(listing.downloads) || 0;
return installs
? <text style="body" size="xs" tone="faint">{`${formatCount(installs)} ${installs === 1 ? "install" : "installs"}`}</text>
: null;
}
function resultRow(ctx: Ctx, market: Controller, result: Listing): Element {
const shot = result.listing?.screenshots?.[0];
const thumb = shot ? market.mediaOf(shot, result.id) : null;
if (thumb?.fetch) ctx.run(thumb.fetch);
return (
<div key={result.id} {...row} {...clickable} cursor="pointer" gap={12} paddingX={ROW_INSET} paddingY={10} borderRadius="md" hover={{ background: "hover" }} onClick={() => ctx.run(market.openListing(result.id))}>
{listingMark(ctx, market, result, MARK)}
<div {...column} {...fill} gap={2}>
<div {...row} gap={8}>
<text style="body" size="sm" weight={600} truncate>{result.name ?? result.id}</text>
{publisherName(result)}
</div>
{result.description ? <text style="body" size="sm" tone="muted" truncate>{result.description}</text> : null}
</div>
{rowStatus(market, result)}
{shot
? (
<div {...EDGED} flexShrink={0} borderRadius={6}>
<image path={thumb?.path ?? undefined} width={THUMB.width} height={THUMB.height} radius={6} />
</div>
)
: null}
</div>
);
}
// What the list holds: how many plugins, in which category, for which words.
function scopeLine(market: Controller): string {
const { state } = market;
const category = state.categories.find((c) => c.id !== null && c.id === state.category)?.title;
const count = `${formatCount(state.total)} ${state.total === 1 ? "plugin" : "plugins"}`;
return [count, category ? `in ${category}` : null, state.searched ? `for “${state.searched}”` : null]
.filter(Boolean)
.join(" ");
}
export function browsePage(ctx: Ctx, market: Controller): Element | null {
const { state } = market;
const chips = [{ id: null, title: "All" }, ...state.categories].map(
(category) =>
(
<button id={`market-category-${category.id ?? "all"}`} label={category.title} small variant="chip" active={state.category === category.id} onClick={() => {
market.state.category = category.id;
ctx.run(market.search());
}} />
),
);
const narrowed = !!state.searched || state.category !== null;
let body: Element | null;
if (state.searchError)
body = (
<div {...column} gap="small" alignItems="start">
<text style="body" size="sm">{`The marketplace did not answer: ${state.searchError}`}</text>
<button id="market-search-retry" label="Try again" small variant="outline" loading={state.searching} onClick={() => ctx.run(market.search())} />
</div>
);
else if (!state.results)
body = <div {...row} gap="small"><spinner /><text style="muted">Loading plugins…</text></div>;
else if (!state.results.length)
body = (
<div {...column} gap="small" alignItems="start">
<text style="body" size="sm">No plugins match.</text>
{narrowed
? (
<button id="market-clear" label="Show every plugin" small variant="outline" onClick={() => {
market.state.query = "";
market.state.category = null;
ctx.run(market.search());
}} />
)
: null}
</div>
);
// The rows' hover fill reaches into the gutter, so their marks stay on
// the page's left edge with the field and the chips above them.
else
body = <div {...column} marginX={-ROW_INSET}>{state.results.map((result) => resultRow(ctx, market, result))}</div>;
const more =
state.results && !state.searchError && state.results.length < state.total
? (
<div {...row} marginTop={12}>
<button id="market-more" label="More" small variant="outline" loading={state.searching} onClick={() => ctx.run(market.search(true))} />
</div>
)
: null;
return (
<div {...column}>
<input id="market-search" icon="search" value={state.query} placeholder="Search plugins" submitOnEnter onChange={(e: ValueEvent<string>) => {
market.state.query = e.value;
}} onSubmit={(e: ValueEvent<string>) => {
market.state.query = e.value;
ctx.run(market.search());
}} />
<div {...row} gap={6} flexWrap="wrap" marginTop={12}>{chips}</div>
<div {...row} gap="small" height={28} marginTop={16} marginBottom={4}>
<text style="body" size="xs" tone="muted">{state.results ? scopeLine(market) : ""}</text>
{state.searching && state.results ? <spinner /> : null}
<spacer />
<combobox id="market-sort" look="toolbar" value={state.sort} options={SORTS} onChange={(e: ValueEvent<string>) => {
market.state.sort = e.value;
ctx.run(market.search());
}} />
</div>
{body}
{more}
</div>
);
}Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.1.6latest | Nov 21, 2026 | >=5 <6 | 71.9 KB | 6 permissions | Listed |
| 0.1.5 | Nov 18, 2026 | >=5 <6 | 71.4 KB | 6 permissions | Listed |
| 0.1.4 | Nov 16, 2026 | >=5 <6 | 70.5 KB | 6 permissions | Listed |
| 0.1.3 | Nov 11, 2026 | >=5 <6 | 62.7 KB | 6 permissions | Listed |
| 0.1.2 | Nov 9, 2026 | >=5 <6 | 57.5 KB | 6 permissions | Listed |
| 0.1.1 | Oct 27, 2026 | >=2 <4 | 46.2 KB | 6 permissions | Listed |
No comments yet.