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): read an entry before installing it, and copy the line that installs it

Haraldfe892495ea0b
diff --git a/jarvis/marketplace/community_source.py b/jarvis/marketplace/community_source.py
index 25a800bf30..713923baf1 100644
--- a/jarvis/marketplace/community_source.py
+++ b/jarvis/marketplace/community_source.py
@@ -70,6 +70,22 @@ class CommunityPluginEntry(_Tolerant):
_SKILL_NAME_RE = re.compile(r"^[a-z0-9](?:[a-z0-9.-]{0,62}[a-z0-9])?$")
+# The two frontmatter profiles a published skill can carry. ``jarvis`` is this
+# app's own schema (triggers, risk policy, execution mode); ``portable`` is a
+# plain Agent Skill written for the open ecosystem — the format `npx skills`
+# and every SKILL.md-reading agent consumes. Anything else is treated as
+# unknown and falls back to ``jarvis``, which is what every entry published
+# before the split was.
+SKILL_FLAVORS: frozenset[str] = frozenset({"jarvis", "portable"})
+
+# Ceilings for the publisher-written compatibility list. It is free text from
+# an auto-merged submission that lands in the store UI, so it is bounded here
+# rather than trusted: a hundred entries of a thousand characters each is a
+# layout attack, not a fact about the skill.
+_MAX_COMPATIBLE_AGENTS = 8
+_MAX_AGENT_NAME_LEN = 32
+
+
class CommunitySkillEntry(_Tolerant):
name: str
title: str | None = None
@@ -82,6 +98,13 @@ class CommunitySkillEntry(_Tolerant):
# Direct download of the SKILL.md — consumed by the existing
# /api/skills/catalog/install route.
raw_url: str | None = None
+ #: Which frontmatter the SKILL.md carries (see ``SKILL_FLAVORS``). Absent
+ #: on an index published by an older registry — the reader treats a missing
+ #: value exactly like ``"jarvis"``.
+ flavor: str | None = None
+ #: Agents the publisher states the skill works in ("Claude Code", "Cursor",
+ #: …). Display only: nothing in the app branches on it.
+ compatible_agents: list[str] = Field(default_factory=list)
@field_validator("raw_url")
@classmethod
@@ -95,6 +118,41 @@ class CommunitySkillEntry(_Tolerant):
return None
return value
+ @field_validator("flavor")
+ @classmethod
+ def _known_flavor(cls, value: str | None) -> str | None:
+ if value is None:
+ return None
+ cleaned = value.strip().lower()
+ if cleaned in SKILL_FLAVORS:
+ return cleaned
+ # A newer registry may invent a third profile. Forgetting the word is
+ # right: the entry stays browsable and installable under the default,
+ # instead of the whole index failing over one unknown string.
+ logger.warning("community index: unknown skill flavor %r", value)
+ return None
+
+ @field_validator("compatible_agents", mode="before")
+ @classmethod
+ def _clean_agents(cls, value: Any) -> list[str]:
+ if not isinstance(value, list):
+ return []
+ cleaned: list[str] = []
+ for item in value:
+ if not isinstance(item, str):
+ continue
+ name = " ".join(item.split())[:_MAX_AGENT_NAME_LEN].strip()
+ if name and name not in cleaned:
+ cleaned.append(name)
+ if len(cleaned) >= _MAX_COMPATIBLE_AGENTS:
+ break
+ return cleaned
+
+ @property
+ def is_portable(self) -> bool:
+ """True when the SKILL.md is a plain Agent Skill, not a Jarvis one."""
+ return self.flavor == "portable"
+
class CommunityWallpaperEntry(_Tolerant):
"""One installable wallpaper.
@@ -275,6 +333,7 @@ async def get_index(
__all__ = [
+ "SKILL_FLAVORS",
"CommunityIndex",
"CommunityPluginEntry",
"CommunitySkillEntry",
diff --git a/jarvis/ui/web/frontend/src/components/InstallTerminal.tsx b/jarvis/ui/web/frontend/src/components/InstallTerminal.tsx
new file mode 100644
index 0000000000..cf8a2adecd
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/InstallTerminal.tsx
@@ -0,0 +1,152 @@
+/**
+ * The install commands for one marketplace listing, drawn as a small terminal.
+ *
+ * The same block the storefront on personaljarvis.ai shows above its listings
+ * (`src/components/marketplace/InstallTerminal.astro` over there), so a user
+ * who saw a command on the website recognises it here — one install language
+ * across both surfaces.
+ *
+ * A listing can carry more than one standard: `jarvis marketplace install …`
+ * for this app, and `npx skills add …` for every other agent that reads
+ * SKILL.md files (see `installStandard.ts`). Each gets a tab, because they are
+ * alternatives — running both installs the same skill twice, in two places.
+ * With a single command the tab strip stays out of the way entirely.
+ *
+ * One deliberate difference from the website's copy: no OS switch. The app
+ * runs where the command would run, so it draws the prompt this machine
+ * actually uses instead of asking.
+ *
+ * Colours come from theme tokens, never a hardcoded mode: on a dark
+ * appearance this reads as a terminal, on a light one as a code block with a
+ * window bar, and both are the app's own palette.
+ */
+import { useCallback, useEffect, useRef, useState } from "react";
+import { Check, Copy } from "lucide-react";
+
+import { robustCopy } from "@/lib/clipboard";
+import { shellPrompt, type InstallCommand } from "@/lib/installStandard";
+import { cn } from "@/lib/utils";
+
+export function InstallTerminal({
+ commands,
+ path,
+ comment,
+ className,
+}: {
+ /** The install standards this listing supports, in the order shown. */
+ commands: InstallCommand[];
+ /** What the window bar shows as the working directory. */
+ path: string;
+ /** The dimmed line above the command. */
+ comment?: string;
+ className?: string;
+}) {
+ const [activeId, setActiveId] = useState(commands[0]?.id);
+ const [copied, setCopied] = useState(false);
+ const resetTimer = useRef<number | undefined>(undefined);
+
+ // A pending copy must never outlive the dialog it was started from.
+ useEffect(() => () => window.clearTimeout(resetTimer.current), []);
+
+ const active = commands.find((c) => c.id === activeId) ?? commands[0];
+
+ const onCopy = useCallback(async () => {
+ if (!active) return;
+ const ok = await robustCopy(active.command);
+ if (!ok) return;
+ setCopied(true);
+ window.clearTimeout(resetTimer.current);
+ resetTimer.current = window.setTimeout(() => setCopied(false), 2000);
+ }, [active]);
+
+ if (!active) return null;
+
+ return (
+ <div className={className}>
+ {commands.length > 1 && (
+ <div role="tablist" aria-label="Install method" className="mb-1.5 flex gap-1">
+ {commands.map((cmd) => (
+ <button
+ key={cmd.id}
+ type="button"
+ role="tab"
+ aria-selected={cmd.id === active.id}
+ onClick={() => {
+ setActiveId(cmd.id);
+ // The confirmation belongs to the line that was copied; leaving
+ // it up after a switch would claim the new line is on the
+ // clipboard when it is not.
+ window.clearTimeout(resetTimer.current);
+ setCopied(false);
+ }}
+ className={cn(
+ "rounded-md border px-2 py-1 font-mono text-[11px] transition-colors",
+ cmd.id === active.id
+ ? "border-accent bg-accent/10 text-foreground"
+ : "border-border text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {cmd.label}
+ </button>
+ ))}
+ </div>
+ )}
+
+ <div className="relative overflow-hidden rounded-xl border border-border bg-card/60">
+ {/* The hairline of accent light along the top edge — the same signal
+ cue the website's terminals carry. */}
+ <span
+ aria-hidden
+ className="pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-accent/60 to-transparent"
+ />
+
+ <div className="flex items-center gap-3 border-b border-border bg-muted/40 px-3 py-2">
+ <span aria-hidden className="flex shrink-0 gap-1.5">
+ <i className="h-2 w-2 rounded-full bg-accent/70" />
+ <i className="h-2 w-2 rounded-full bg-muted-foreground/30" />
+ <i className="h-2 w-2 rounded-full bg-muted-foreground/30" />
+ </span>
+ <span className="truncate font-mono text-[11px] text-muted-foreground">
+ {path}
+ </span>
+ <button
+ type="button"
+ onClick={onCopy}
+ aria-label="Copy the install command"
+ className={cn(
+ "ml-auto inline-flex shrink-0 items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-[11px] transition-colors",
+ copied
+ ? "border-accent bg-accent text-accent-foreground"
+ : "border-border text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {copied ? (
+ <Check className="h-3 w-3" />
+ ) : (
+ <Copy className="h-3 w-3" />
+ )}
+ {copied ? "Copied" : "Copy"}
+ </button>
+ </div>
+
+ <div className="px-3 py-2.5">
+ {comment && (
+ <p className="install-cmd text-[12px] text-muted-foreground">
+ {comment}
+ </p>
+ )}
+ <p className="install-cmd text-[12.5px] text-foreground">
+ <span className="mr-1.5 select-none font-semibold text-accent">
+ {shellPrompt()}
+ </span>
+ {active.command}
+ <span aria-hidden className="install-caret" />
+ </p>
+ </div>
+ </div>
+ {active.note && (
+ <p className="mt-1.5 text-[11px] text-muted-foreground">{active.note}</p>
+ )}
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/index.css b/jarvis/ui/web/frontend/src/index.css
index cec65ad863..03abe0013c 100644
--- a/jarvis/ui/web/frontend/src/index.css
+++ b/jarvis/ui/web/frontend/src/index.css
@@ -233,6 +233,51 @@
transform: scale(1.08);
}
}
+
+ /* ---- the marketplace install command ----------------------------------
+ A shell line has to render character by character: the mono face ligates
+ `--` into a single dash, which turns `uvx --from` into a command nobody
+ can retype from what they see. */
+ .install-cmd {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ font-variant-ligatures: none;
+ font-feature-settings:
+ "liga" 0,
+ "calt" 0;
+ }
+
+ /* The block cursor at the end of the command — the cue that says "this is a
+ terminal, and it is waiting for you". */
+ .install-caret {
+ display: inline-block;
+ width: 0.5em;
+ height: 1em;
+ margin-left: 0.25em;
+ vertical-align: text-bottom;
+ border-radius: 1px;
+ background: hsl(var(--accent));
+ animation: install-caret-blink 1.05s steps(1, end) infinite;
+ }
+
+ @keyframes install-caret-blink {
+ 0%,
+ 49% {
+ opacity: 1;
+ }
+ 50%,
+ 100% {
+ opacity: 0;
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .install-caret {
+ animation: none;
+ opacity: 1;
+ }
+ }
}
::-webkit-scrollbar {
width: 10px;
diff --git a/jarvis/ui/web/frontend/src/lib/installStandard.test.ts b/jarvis/ui/web/frontend/src/lib/installStandard.test.ts
new file mode 100644
index 0000000000..a484ac032a
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/installStandard.test.ts
@@ -0,0 +1,166 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ installBlock,
+ shellPrompt,
+ skillsShCommand,
+ skillsShTarget,
+} from "@/lib/installStandard";
+
+// The storefront on personaljarvis.ai computes these same strings in
+// `src/lib/install-standard.ts` and pins them in its own check. Both surfaces
+// have to advertise a command that actually works, so the expected values
+// below are the contract between them: change one, change both.
+describe("the marketplace install standard", () => {
+ it("builds the three surfaces for a skill", () => {
+ const block = installBlock("three-point-check", "skill");
+ expect(block).toMatchObject({
+ cli: "jarvis marketplace install three-point-check",
+ runner:
+ "uvx --from personal-jarvis jarvis marketplace install three-point-check",
+ prompt:
+ 'Install the "three-point-check" skill from the community marketplace.',
+ });
+ });
+
+ it("carries the kind into the agent prompt", () => {
+ expect(installBlock("todo-fox", "plugin")?.prompt).toBe(
+ 'Install the "todo-fox" plugin from the community marketplace.',
+ );
+ });
+
+ it("accepts the dots and digits a registry name may carry", () => {
+ expect(installBlock("web.search2", "plugin")?.cli).toBe(
+ "jarvis marketplace install web.search2",
+ );
+ });
+
+ // A name that would need quoting is a name no store should print: the index
+ // validators reject it anyway, so no command beats a scary one.
+ it.each([
+ ["a space", "todo fox"],
+ ["a shell metacharacter", "todo;rm"],
+ ["a path escape", "../etc"],
+ ["a leading dash", "-todo"],
+ ["an underscore", "todo_fox"],
+ ["an empty name", ""],
+ ])("refuses %s", (_label, name) => {
+ expect(installBlock(name, "skill")).toBeNull();
+ });
+
+ it("draws the prompt of the machine it runs on", () => {
+ // jsdom reports a Windows-free user agent, so this is the unix branch.
+ expect(["$", "PS>"]).toContain(shellPrompt());
+ });
+});
+
+// The second standard: `npx skills add` (skills.sh) installs a SKILL.md into
+// whichever agent is configured locally. It resolves `owner/repo` against
+// github.com and nothing else, so the derivation has to be exact about what it
+// can and cannot answer.
+describe("the skills.sh target", () => {
+ it("reads owner, repo, and folder out of a raw file URL", () => {
+ expect(
+ skillsShTarget("three-point-check", {
+ rawUrl:
+ "https://raw.githubusercontent.com/PersonalJarvis/marketplace/main/skills/three-point-check/SKILL.md",
+ }),
+ ).toEqual({ repo: "PersonalJarvis/marketplace", skill: "three-point-check" });
+ });
+
+ it("does not mistake a refs/heads branch for the skill folder", () => {
+ expect(
+ skillsShTarget("solo", {
+ rawUrl:
+ "https://raw.githubusercontent.com/octocat/one-skill/refs/heads/main/SKILL.md",
+ }),
+ ).toEqual({ repo: "octocat/one-skill", skill: null });
+ });
+
+ it("has no --skill argument for a SKILL.md at the repository root", () => {
+ const target = skillsShTarget("solo", {
+ rawUrl: "https://raw.githubusercontent.com/octocat/one-skill/main/SKILL.md",
+ });
+ expect(skillsShCommand(target!)).toBe("npx skills add octocat/one-skill");
+ });
+
+ it("falls back to the entry name when only the repository is known", () => {
+ expect(
+ skillsShTarget("three-point-check", {
+ sourceUrl: "https://github.com/PersonalJarvis/marketplace",
+ }),
+ ).toEqual({ repo: "PersonalJarvis/marketplace", skill: "three-point-check" });
+ });
+
+ it("prefers the raw URL over the repository URL", () => {
+ // The raw URL names the actual file, so it wins over the guess: the folder
+ // there is what `--skill` has to match.
+ expect(
+ skillsShTarget("listed-name", {
+ sourceUrl: "https://github.com/octocat/skills",
+ rawUrl:
+ "https://raw.githubusercontent.com/octocat/skills/main/packs/real-folder/SKILL.md",
+ }),
+ ).toEqual({ repo: "octocat/skills", skill: "real-folder" });
+ });
+
+ it("tolerates a .git suffix and a /tree/ tail", () => {
+ expect(
+ skillsShTarget("pack", {
+ sourceUrl: "https://github.com/octocat/skills.git/tree/main/pack",
+ })?.repo,
+ ).toBe("octocat/skills");
+ });
+
+ // Anything not on GitHub simply has no skills.sh line — that installer knows
+ // no other host, so inventing one would advertise a broken command.
+ it.each([
+ ["a non-GitHub host", { sourceUrl: "https://gitlab.com/octocat/skills" }],
+ ["plain http", { sourceUrl: "http://github.com/octocat/skills" }],
+ ["a raw URL that is not a SKILL.md", {
+ rawUrl: "https://raw.githubusercontent.com/octocat/skills/main/README.md",
+ }],
+ ["no URLs at all", {}],
+ ])("returns nothing for %s", (_label, source) => {
+ expect(skillsShTarget("pack", source)).toBeNull();
+ });
+
+ it("refuses a repository segment that would not survive a shell line", () => {
+ expect(
+ skillsShTarget("pack", {
+ sourceUrl: "https://github.com/octo%20cat/skills",
+ }),
+ ).toBeNull();
+ });
+});
+
+describe("the commands a listing offers", () => {
+ it("gives a GitHub-published skill both standards, Jarvis first", () => {
+ const block = installBlock("three-point-check", "skill", {
+ sourceUrl: "https://github.com/PersonalJarvis/marketplace",
+ rawUrl:
+ "https://raw.githubusercontent.com/PersonalJarvis/marketplace/main/skills/three-point-check/SKILL.md",
+ });
+ expect(block?.commands.map((c) => c.command)).toEqual([
+ "jarvis marketplace install three-point-check",
+ "npx skills add PersonalJarvis/marketplace --skill three-point-check",
+ ]);
+ });
+
+ // A plugin carries an MCP server and a sign-in flow; `npx skills` installs
+ // instruction files. Offering it there would advertise an install that
+ // cannot work.
+ it("never offers skills.sh for a plugin", () => {
+ const block = installBlock("todo-fox", "plugin", {
+ sourceUrl: "https://github.com/octocat/todo-fox",
+ });
+ expect(block?.commands.map((c) => c.id)).toEqual(["jarvis"]);
+ });
+
+ it("falls back to the Jarvis command alone when nothing is on GitHub", () => {
+ const block = installBlock("three-point-check", "skill", {
+ sourceUrl: "https://example.com/skills/three-point-check",
+ });
+ expect(block?.commands.map((c) => c.id)).toEqual(["jarvis"]);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/installStandard.ts b/jarvis/ui/web/frontend/src/lib/installStandard.ts
new file mode 100644
index 0000000000..c2b996d61a
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/installStandard.ts
@@ -0,0 +1,246 @@
+/**
+ * The marketplace install commands — the lines that add a listing.
+ *
+ * Both stores show the same lines: this file inside the app, and the website's
+ * `src/lib/install-standard.ts` on personaljarvis.ai. A visitor who reads a
+ * command on the storefront and a user who reads it in the Plugins view have
+ * to see the same string, or one of the two is advertising a command that does
+ * not work. `installStandard.test.ts` pins the exact output, so a rename on
+ * either side fails a test instead of going live unnoticed.
+ *
+ * TWO standards, not one:
+ *
+ * - **Personal Jarvis** — `jarvis marketplace install <name>` installs into
+ * this app. Available for every listing, because the registry is ours.
+ * - **skills.sh** — `npx skills add <owner>/<repo>` is the open agent-skills
+ * installer (Vercel Labs; see https://skills.sh). It reads a `SKILL.md`
+ * straight out of a GitHub repository and drops it into whichever agent is
+ * configured locally: Claude Code, Cursor, Codex, Copilot, and the rest.
+ * Offered for SKILLS only — a plugin carries an MCP server and a connect
+ * flow, which that installer knows nothing about.
+ *
+ * The skills.sh line is derived, never stored: a published entry already
+ * carries the two URLs it needs (`raw_url`, `source_url`). The derivation is
+ * exact when `raw_url` points at the file (the folder holding `SKILL.md` IS
+ * the `--skill` argument, and a `SKILL.md` at the repository root means no
+ * `--skill` at all). With only a repository URL the entry name is used, which
+ * is what the registry publishes as `skills/<name>/SKILL.md`.
+ *
+ * The commands themselves are identical on every operating system. Only the
+ * shell prompt drawn in front of them differs, which is what `shellPrompt`
+ * answers.
+ */
+
+export type EntryKind = "plugin" | "skill";
+
+/** Which install standard a line belongs to. */
+export type InstallStandardId = "jarvis" | "skills";
+
+/** One copyable install line. */
+export interface InstallCommand {
+ id: InstallStandardId;
+ /** Tab label — the name of the standard, not of the entry. */
+ label: string;
+ /** The line to show and copy. */
+ command: string;
+ /** One line under the terminal saying where this command works. */
+ note: string;
+}
+
+/** The install surfaces for one listing. */
+export interface InstallBlock {
+ /** For a machine that already has the CLI — what the app itself runs. */
+ cli: string;
+ /** The zero-install equivalent of `npx`, for a machine without the CLI. */
+ runner: string;
+ /** Plain language to paste at a coding agent, which runs the same command. */
+ prompt: string;
+ /** Every standard this listing can be installed with, Jarvis first. */
+ commands: InstallCommand[];
+}
+
+/** The published URLs of one entry, as the community index carries them. */
+export interface EntrySource {
+ /** The listing's page — for a GitHub-published skill, its repository. */
+ sourceUrl?: string | null;
+ /** Direct download of the `SKILL.md`. */
+ rawUrl?: string | null;
+}
+
+/** A repository plus the skill folder inside it, ready for `npx skills add`. */
+export interface SkillsShTarget {
+ /** `owner/repo`. */
+ repo: string;
+ /** The folder holding the `SKILL.md`, or null when it sits at the root. */
+ skill: string | null;
+}
+
+/**
+ * The Agent Plugins name rule, mirroring
+ * `agent_plugins_loader.validate_spec_name` and
+ * `community_source._SKILL_NAME_RE`. Names matching it are `[a-z0-9.-]` only,
+ * so they survive a shell line unquoted — which is what makes a copy-paste
+ * one-liner possible at all.
+ */
+const NAME_RE = /^[a-z0-9](?:[a-z0-9.-]{0,62}[a-z0-9])?$/;
+
+/**
+ * What a GitHub owner, repository, or folder segment may contain.
+ *
+ * Deliberately its own rule rather than `NAME_RE`: GitHub allows uppercase and
+ * underscores (`PersonalJarvis/marketplace`), which our registry names do not.
+ * It stays strict about everything a shell would interpret, because this value
+ * is pasted into a command line unquoted.
+ */
+const GITHUB_SEGMENT_RE = /^[A-Za-z0-9._-]{1,100}$/;
+
+/** A path segment that is a git ref prefix rather than part of the file path. */
+function stripRefPrefix(segments: string[]): string[] {
+ // raw.githubusercontent.com serves both `<owner>/<repo>/<ref>/<path>` and the
+ // longer `<owner>/<repo>/refs/heads/<ref>/<path>`. Counting the ref as one
+ // segment in the second shape would make the branch name look like the skill
+ // folder ("main"), so the longer form is consumed as the three parts it is.
+ if (segments[0] === "refs" && (segments[1] === "heads" || segments[1] === "tags")) {
+ return segments.slice(3);
+ }
+ return segments.slice(1);
+}
+
+function safeSegment(value: string | undefined): string | null {
+ if (!value) return null;
+ if (value === "." || value === "..") return null;
+ return GITHUB_SEGMENT_RE.test(value) ? value : null;
+}
+
+/**
+ * The `npx skills add` target for one entry, or null when there is none.
+ *
+ * Null is the honest answer for anything not published from GitHub: that
+ * installer resolves `owner/repo` against github.com and nothing else, so a
+ * skill hosted elsewhere simply has no skills.sh line.
+ */
+export function skillsShTarget(
+ name: string,
+ source: EntrySource = {},
+): SkillsShTarget | null {
+ const raw = parseRawUrl(source.rawUrl);
+ if (raw) return raw;
+ const repo = parseRepoUrl(source.sourceUrl);
+ if (!repo) return null;
+ // Only the repository is known. The registry publishes every skill as
+ // `skills/<name>/SKILL.md`, so the entry name is the folder — and a wrong
+ // guess costs a listing from the installer, not a broken install.
+ return { repo, skill: safeSegment(name) };
+}
+
+/** `https://raw.githubusercontent.com/<owner>/<repo>/<ref>/<path>/SKILL.md` */
+function parseRawUrl(rawUrl: string | null | undefined): SkillsShTarget | null {
+ const url = parseHttpsUrl(rawUrl);
+ if (!url || url.hostname !== "raw.githubusercontent.com") return null;
+ const parts = url.pathname.split("/").filter(Boolean);
+ const owner = safeSegment(parts[0]);
+ const repo = safeSegment(stripGitSuffix(parts[1]));
+ if (!owner || !repo) return null;
+
+ const path = stripRefPrefix(parts.slice(2));
+ const file = path[path.length - 1];
+ if (file !== "SKILL.md") return null;
+ // The folder holding the file is the `--skill` argument; a SKILL.md sitting
+ // at the repository root has none, and `npx skills add owner/repo` is then
+ // the whole command.
+ const folder = path.length >= 2 ? safeSegment(path[path.length - 2]) : null;
+ return { repo: `${owner}/${repo}`, skill: folder };
+}
+
+/** `https://github.com/<owner>/<repo>` (with or without a `/tree/...` tail). */
+function parseRepoUrl(sourceUrl: string | null | undefined): string | null {
+ const url = parseHttpsUrl(sourceUrl);
+ if (!url) return null;
+ if (url.hostname !== "github.com" && url.hostname !== "www.github.com") {
+ return null;
+ }
+ const parts = url.pathname.split("/").filter(Boolean);
+ const owner = safeSegment(parts[0]);
+ const repo = safeSegment(stripGitSuffix(parts[1]));
+ if (!owner || !repo) return null;
+ return `${owner}/${repo}`;
+}
+
+function stripGitSuffix(value: string | undefined): string | undefined {
+ return value?.endsWith(".git") ? value.slice(0, -4) : value;
+}
+
+function parseHttpsUrl(value: string | null | undefined): URL | null {
+ if (!value) return null;
+ try {
+ const url = new URL(value);
+ return url.protocol === "https:" ? url : null;
+ } catch {
+ return null;
+ }
+}
+
+/** The `npx skills add …` line for a resolved target. */
+export function skillsShCommand(target: SkillsShTarget): string {
+ const base = `npx skills add ${target.repo}`;
+ return target.skill ? `${base} --skill ${target.skill}` : base;
+}
+
+/**
+ * The install strings for one community entry.
+ *
+ * Returns null when the name would not survive a shell line unquoted. Both
+ * index validators already enforce the same rule, so a miss here means the
+ * entry is invalid anyway — showing no command beats showing a quoted, and
+ * therefore alarming, one.
+ */
+export function installBlock(
+ name: string,
+ kind: EntryKind,
+ source: EntrySource = {},
+): InstallBlock | null {
+ if (!NAME_RE.test(name) || name.includes("..")) return null;
+ const cli = `jarvis marketplace install ${name}`;
+ const commands: InstallCommand[] = [
+ {
+ id: "jarvis",
+ label: "Personal Jarvis",
+ command: cli,
+ note: "Runs in any terminal while Personal Jarvis is running.",
+ },
+ ];
+
+ // A plugin is a connector with an MCP server and a sign-in flow; `npx skills`
+ // installs instruction files. Offering it there would advertise an install
+ // that cannot work.
+ if (kind === "skill") {
+ const target = skillsShTarget(name, source);
+ if (target) {
+ commands.push({
+ id: "skills",
+ label: "skills.sh",
+ command: skillsShCommand(target),
+ note: "Installs the same skill into Claude Code, Cursor, Codex, and other agents.",
+ });
+ }
+ }
+
+ return {
+ cli,
+ runner: `uvx --from personal-jarvis ${cli}`,
+ prompt: `Install the "${name}" ${kind} from the community marketplace.`,
+ commands,
+ };
+}
+
+/**
+ * The shell prompt to draw in front of the command on THIS machine.
+ *
+ * The app runs where the command would run, so it knows the answer and does
+ * not ask — unlike the website, which has to offer a switch.
+ */
+export function shellPrompt(): string {
+ if (typeof navigator === "undefined") return "$";
+ const ua = navigator.userAgent;
+ return /windows/i.test(ua) ? "PS>" : "$";
+}
diff --git a/jarvis/ui/web/frontend/src/views/PluginsCommunity.contents.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsCommunity.contents.test.tsx
new file mode 100644
index 0000000000..7f5a020ef2
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/PluginsCommunity.contents.test.tsx
@@ -0,0 +1,149 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { CommunityTab, type CommunityResponse } from "@/views/PluginsCommunity";
+
+// What the reader must be able to see BEFORE installing: the actual text a
+// skill would hand the assistant, and the actual picture a wallpaper installs.
+const SKILL_TEXT = "---\nname: three-point-check\n---\n\nAlways answer in three bullets.\n";
+
+const COMMUNITY: CommunityResponse = {
+ status: "fresh",
+ plugins: [],
+ skills: [
+ {
+ name: "three-point-check",
+ title: "Three Point Check",
+ description: "Summarize any topic in three bullets",
+ publisher: "octocat",
+ version: "1.0.0",
+ categories: ["productivity"],
+ source_url: "https://github.com/PersonalJarvis/marketplace",
+ raw_url: "https://raw.example/skills/three-point-check/SKILL.md",
+ installed: false,
+ },
+ ],
+ wallpapers: [
+ {
+ name: "rain-antenna-city",
+ title: "Rain Antenna City",
+ description: "Neon rooftops in the rain",
+ publisher: "octocat",
+ version: "1.0.0",
+ categories: ["dark"],
+ source_url: "https://github.com/PersonalJarvis/marketplace",
+ raw_url: "https://raw.example/wallpapers/rain-antenna-city.webp",
+ theme: "dark",
+ installed: false,
+ },
+ ],
+};
+
+function installFetchMock() {
+ const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
+ const url = String(input);
+ const method = init?.method ?? "GET";
+ if (url === "/api/marketplace/community" && method === "GET") {
+ return { ok: true, status: 200, json: async () => COMMUNITY } as Response;
+ }
+ if (url === "/api/marketplace/community/three-point-check/contents") {
+ return {
+ ok: true,
+ status: 200,
+ json: async () => ({
+ kind: "skill",
+ name: "three-point-check",
+ title: "Three Point Check",
+ root: "skills/three-point-check",
+ files: [
+ { path: "SKILL.md", size: 72, text: SKILL_TEXT, truncated: false },
+ ],
+ image_url: null,
+ error: null,
+ }),
+ } as Response;
+ }
+ if (url === "/api/marketplace/community/install/rain-antenna-city") {
+ return {
+ ok: true,
+ status: 200,
+ json: async () => ({ ok: true, kind: "wallpaper", id: "rain-antenna-city" }),
+ } as Response;
+ }
+ throw new Error(`unexpected fetch ${method} ${url}`);
+ });
+ (globalThis as unknown as { fetch: typeof fetch }).fetch =
+ fetchMock as unknown as typeof fetch;
+ return fetchMock;
+}
+
+function renderTab() {
+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ return render(
+ <QueryClientProvider client={qc}>
+ <CommunityTab />
+ </QueryClientProvider>,
+ );
+}
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+describe("reading an entry before installing it", () => {
+ it("shows the published SKILL.md text when a skill card is opened", async () => {
+ installFetchMock();
+ renderTab();
+
+ // Opening happens by clicking the card itself — reading must not require
+ // intending to install.
+ fireEvent.click(await screen.findByTitle(/Read what Three Point Check/i));
+
+ expect(await screen.findByText(/Always answer in three bullets/)).toBeDefined();
+ expect(screen.getByText("skills/three-point-check")).toBeDefined();
+ expect(screen.getByText("SKILL.md")).toBeDefined();
+ });
+
+ it("says so honestly when the published file cannot be read", async () => {
+ const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url === "/api/marketplace/community") {
+ return { ok: true, status: 200, json: async () => COMMUNITY } as Response;
+ }
+ return { ok: false, status: 502, json: async () => ({}) } as Response;
+ });
+ (globalThis as unknown as { fetch: typeof fetch }).fetch =
+ fetchMock as unknown as typeof fetch;
+ renderTab();
+
+ fireEvent.click(await screen.findByTitle(/Read what Three Point Check/i));
+ expect(
+ await screen.findByText(/could not be read just now/i),
+ ).toBeDefined();
+ });
+
+ it("lists wallpapers and installs the previewed one by name", async () => {
+ const fetchMock = installFetchMock();
+ renderTab();
+
+ fireEvent.click(await screen.findByTitle(/Preview Rain Antenna City/i));
+ // The picture at full size IS the disclosure for a wallpaper.
+ const preview = await screen.findByAltText("Rain Antenna City");
+ expect(preview.getAttribute("src")).toBe(
+ "https://raw.example/wallpapers/rain-antenna-city.webp",
+ );
+
+ // Scoped to the dialog: the skill card behind it carries an Install too.
+ const dialog = screen.getByRole("dialog");
+ fireEvent.click(within(dialog).getByRole("button", { name: "Install" }));
+ await waitFor(() =>
+ expect(
+ fetchMock.mock.calls.some(
+ ([u]) => String(u) === "/api/marketplace/community/install/rain-antenna-city",
+ ),
+ ).toBe(true),
+ );
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/PluginsCommunity.install-command.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsCommunity.install-command.test.tsx
new file mode 100644
index 0000000000..621a236e5f
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/PluginsCommunity.install-command.test.tsx
@@ -0,0 +1,185 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+ within,
+} from "@testing-library/react";
+import type { ReactElement } from "react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import {
+ InstallConsentDialog,
+ SkillInstallConsentDialog,
+ type CommunityPluginWire,
+ type CommunitySkillWire,
+} from "@/views/PluginsCommunity";
+
+// The command shown here and the command shown on the storefront have to be
+// the same string — a store that advertises a line the CLI does not accept is
+// worse than one that shows none. installStandard.test.ts pins the formula;
+// this pins that the dialog actually puts it in front of the reader.
+
+const SKILL: CommunitySkillWire = {
+ name: "three-point-check",
+ title: "Three Point Check",
+ description: "Summarize any topic in three bullets",
+ publisher: "octocat",
+ version: "1.0.0",
+ categories: ["productivity"],
+ source_url: "https://github.com/PersonalJarvis/marketplace",
+ raw_url: "https://raw.example/skills/three-point-check/SKILL.md",
+ installed: false,
+};
+
+const PLUGIN: CommunityPluginWire = {
+ name: "todo-fox",
+ valid: true,
+ publisher: "octocat",
+ version: "1.0.0",
+ id: "todo-fox",
+ display_name: "Todo Fox",
+ description: "A todo list connector",
+ category: "productivity",
+ installed: false,
+};
+
+function stubFetch() {
+ // ContentsPanel fetches the published files; this test is about the command
+ // line, so every request answers empty rather than failing the render.
+ const fetchMock = vi.fn(
+ async () =>
+ ({ ok: false, status: 404, json: async () => ({}) }) as Response,
+ );
+ (globalThis as unknown as { fetch: typeof fetch }).fetch =
+ fetchMock as unknown as typeof fetch;
+}
+
+/** The dialog carries a ContentsPanel, which is a query — so it needs a client. */
+function renderDialog(ui: ReactElement) {
+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ return render(<QueryClientProvider client={qc}>{ui}</QueryClientProvider>);
+}
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+describe("the install command inside the consent dialog", () => {
+ it("shows the storefront's command for a skill", () => {
+ stubFetch();
+ renderDialog(
+ <SkillInstallConsentDialog
+ skill={SKILL}
+ isPending={false}
+ errorMessage={null}
+ onCancel={() => {}}
+ onConfirm={() => {}}
+ />,
+ );
+
+ expect(
+ screen.getByText("jarvis marketplace install three-point-check", {
+ exact: false,
+ }),
+ ).toBeDefined();
+ });
+
+ it("shows the storefront's command for a plugin", () => {
+ stubFetch();
+ renderDialog(
+ <InstallConsentDialog
+ plugin={PLUGIN}
+ isPending={false}
+ errorMessage={null}
+ onCancel={() => {}}
+ onConfirm={() => {}}
+ />,
+ );
+
+ expect(
+ screen.getByText("jarvis marketplace install todo-fox", { exact: false }),
+ ).toBeDefined();
+ });
+
+ // A skill published from GitHub can also be installed with `npx skills add`,
+ // which puts it into Claude Code, Cursor, Codex, and the rest. The dialog has
+ // to offer that line too, or the store hides half of what the entry can do.
+ it("offers the skills.sh command next to the Jarvis one", () => {
+ stubFetch();
+ renderDialog(
+ <SkillInstallConsentDialog
+ skill={SKILL}
+ isPending={false}
+ errorMessage={null}
+ onCancel={() => {}}
+ onConfirm={() => {}}
+ />,
+ );
+
+ const dialog = screen.getByRole("dialog");
+ fireEvent.click(within(dialog).getByRole("tab", { name: "skills.sh" }));
+
+ expect(
+ screen.getByText(
+ "npx skills add PersonalJarvis/marketplace --skill three-point-check",
+ { exact: false },
+ ),
+ ).toBeDefined();
+ });
+
+ // A plugin has an MCP server and a sign-in flow; `npx skills` installs
+ // instruction files. A tab strip there would advertise a broken install.
+ it("keeps a plugin on the Jarvis command alone", () => {
+ stubFetch();
+ renderDialog(
+ <InstallConsentDialog
+ plugin={PLUGIN}
+ isPending={false}
+ errorMessage={null}
+ onCancel={() => {}}
+ onConfirm={() => {}}
+ />,
+ );
+
+ expect(screen.queryByRole("tab", { name: "skills.sh" })).toBeNull();
+ });
+
+ it("copies the command, and says it did", async () => {
+ stubFetch();
+ const writeText = vi.fn(async () => {});
+ Object.defineProperty(navigator, "clipboard", {
+ value: { writeText },
+ configurable: true,
+ });
+
+ renderDialog(
+ <SkillInstallConsentDialog
+ skill={SKILL}
+ isPending={false}
+ errorMessage={null}
+ onCancel={() => {}}
+ onConfirm={() => {}}
+ />,
+ );
+
+ const dialog = screen.getByRole("dialog");
+ fireEvent.click(
+ within(dialog).getByRole("button", {
+ name: /copy the install command/i,
+ }),
+ );
+
+ await waitFor(() =>
+ expect(writeText).toHaveBeenCalledWith(
+ "jarvis marketplace install three-point-check",
+ ),
+ );
+ // The confirmation is the whole point of a copy button: without it a
+ // reader cannot tell a working button from a dead one.
+ expect(await screen.findByText("Copied")).toBeDefined();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/PluginsCommunity.tsx b/jarvis/ui/web/frontend/src/views/PluginsCommunity.tsx
index 463df08143..5ff21f3c53 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsCommunity.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsCommunity.tsx
@@ -11,7 +11,9 @@ import {
UploadCloud,
} from "lucide-react";
import { Button } from "@/components/ui/button";
+import { InstallTerminal } from "@/components/InstallTerminal";
import { cn } from "@/lib/utils";
+import { installBlock } from "@/lib/installStandard";
import { openExternalUrl } from "@/lib/openExternal";
import { PRODUCT_NAME } from "@/lib/branding";
@@ -67,6 +69,37 @@ export interface CommunitySkillWire {
source_url?: string | null;
raw_url?: string | null;
installed: boolean;
+ /**
+ * Which frontmatter the published SKILL.md carries: `"jarvis"` uses this
+ * app's schema (triggers, risk policy), `"portable"` is a plain Agent Skill
+ * written for the open ecosystem. Absent on an older index — treated as
+ * `"jarvis"`, which is what every entry published before the split was.
+ */
+ flavor?: "jarvis" | "portable" | null;
+ /** Agents the publisher states this skill works in, for a portable entry. */
+ compatible_agents?: string[] | null;
+}
+
+/** The one-line "runs in other agents too" note, or null for a Jarvis skill. */
+function portableNote(skill: CommunitySkillWire): string | null {
+ if (skill.flavor !== "portable") return null;
+ const agents = (skill.compatible_agents ?? []).filter(Boolean);
+ return agents.length > 0
+ ? `Portable skill · also runs in ${agents.join(", ")}`
+ : "Portable skill · also runs in other agents";
+}
+
+export interface CommunityWallpaperWire {
+ name: string;
+ title: string;
+ description: string;
+ publisher?: string | null;
+ version?: string | null;
+ categories: string[];
+ source_url?: string | null;
+ raw_url?: string | null;
+ theme?: string | null;
+ installed: boolean;
}
export interface CommunityResponse {
@@ -75,6 +108,25 @@ export interface CommunityResponse {
generated_at?: string | null;
plugins: CommunityPluginWire[];
skills: CommunitySkillWire[];
+ wallpapers?: CommunityWallpaperWire[];
+}
+
+/** One readable file of a published entry — mirrors ``_text_file`` server-side. */
+export interface EntryFileWire {
+ path: string;
+ size: number;
+ text: string;
+ truncated: boolean;
+}
+
+export interface EntryContentsWire {
+ kind: "skill" | "plugin" | "wallpaper";
+ name: string;
+ title: string;
+ root: string;
+ files: EntryFileWire[];
+ image_url?: string | null;
+ error?: string | null;
}
async function fetchCommunity(): Promise<CommunityResponse> {
@@ -83,6 +135,33 @@ async function fetchCommunity(): Promise<CommunityResponse> {
return res.json();
}
+/** The published package of ONE entry, fetched only when a card is opened.
+ *
+ * Never part of the browse request: pulling every skill's text just to draw a
+ * list would download the whole registry to show two lines per card. */
+function useEntryContents(name: string | null) {
+ return useQuery({
+ queryKey: ["marketplace-community-contents", name],
+ enabled: name !== null,
+ // The published bytes of a given version do not change under us, and the
+ // server caches the download too — refetching on every reopen is waste.
+ staleTime: 5 * 60 * 1000,
+ queryFn: async (): Promise<EntryContentsWire> => {
+ const res = await fetch(
+ `/api/marketplace/community/${encodeURIComponent(name ?? "")}/contents`,
+ { cache: "no-store" },
+ );
+ if (!res.ok) throw new Error(`Could not read that entry (${res.status})`);
+ return res.json();
+ },
+ });
+}
+
+function formatBytes(bytes: number): string {
+ if (bytes < 1024) return `${bytes} B`;
+ return `${(bytes / 1024).toFixed(1)} kB`;
+}
+
const AUTH_MODE_LABEL: Record<string, string> = {
pat_paste: "Personal access token",
oauth_device_flow: "Device sign-in",
@@ -100,6 +179,7 @@ export function CommunityTab() {
const [query, setQuery] = useState("");
const [consentPlugin, setConsentPlugin] = useState<CommunityPluginWire | null>(null);
const [consentSkill, setConsentSkill] = useState<CommunitySkillWire | null>(null);
+ const [consentPaper, setConsentPaper] = useState<CommunityWallpaperWire | null>(null);
const refreshMutation = useMutation({
mutationFn: async (): Promise<CommunityResponse> => {
@@ -181,6 +261,31 @@ export function CommunityTab() {
},
});
+ const paperInstallMutation = useMutation({
+ mutationFn: async (paper: CommunityWallpaperWire) => {
+ // The by-name route already resolves the kind and does the download,
+ // re-encode and origin receipt — a picture needs no second install path.
+ const res = await fetch(
+ `/api/marketplace/community/install/${encodeURIComponent(paper.name)}`,
+ { method: "POST" },
+ );
+ if (!res.ok) {
+ const detail = await res
+ .json()
+ .then((body: { detail?: string }) => body.detail)
+ .catch(() => undefined);
+ throw new Error(detail ?? `Install failed (${res.status})`);
+ }
+ return res.json();
+ },
+ onSuccess: () => {
+ setConsentPaper(null);
+ queryClient.invalidateQueries({ queryKey: ["marketplace-community"] });
+ // The picker reads its own store — it has to learn about the new tile.
+ queryClient.invalidateQueries({ queryKey: ["wallpapers"] });
+ },
+ });
+
const q = query.trim().toLowerCase();
const plugins = useMemo(
() =>
@@ -206,6 +311,18 @@ export function CommunityTab() {
}),
[data, q],
);
+ const wallpapers = useMemo(
+ () =>
+ (data?.wallpapers ?? []).filter((w) => {
+ if (!q) return true;
+ return (
+ w.name.toLowerCase().includes(q) ||
+ w.title.toLowerCase().includes(q) ||
+ w.description.toLowerCase().includes(q)
+ );
+ }),
+ [data, q],
+ );
return (
<div className="space-y-8">
@@ -244,7 +361,10 @@ export function CommunityTab() {
<StatusNotice status={data?.status} error={error} isLoading={isLoading} />
- {(data?.plugins.length ?? 0) + (data?.skills.length ?? 0) > 0 && (
+ {(data?.plugins.length ?? 0) +
+ (data?.skills.length ?? 0) +
+ (data?.wallpapers?.length ?? 0) >
+ 0 && (
<label className="flex items-center gap-2 rounded-lg border border-border bg-card/40 px-3 py-2">
<Search className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<input
@@ -305,6 +425,40 @@ export function CommunityTab() {
</section>
)}
+ {wallpapers.length > 0 && (
+ <section>
+ <h3 className="mb-3 font-display text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground">
+ Wallpapers
+ </h3>
+ <div className="grid gap-3 sm:grid-cols-3 lg:grid-cols-4">
+ {wallpapers.map((w) => (
+ <CommunityWallpaperCard
+ key={w.name}
+ paper={w}
+ onOpen={() => setConsentPaper(w)}
+ />
+ ))}
+ </div>
+ </section>
+ )}
+
+ {consentPaper && (
+ <WallpaperPreviewDialog
+ paper={consentPaper}
+ isPending={paperInstallMutation.isPending}
+ errorMessage={
+ paperInstallMutation.error instanceof Error
+ ? paperInstallMutation.error.message
+ : null
+ }
+ onCancel={() => {
+ setConsentPaper(null);
+ paperInstallMutation.reset();
+ }}
+ onConfirm={() => paperInstallMutation.mutate(consentPaper)}
+ />
+ )}
+
{consentPlugin && (
<InstallConsentDialog
plugin={consentPlugin}
@@ -417,6 +571,80 @@ function Notice({
);
}
+/** The published package itself, readable before anything is installed.
+ *
+ * This is the answer to the badge above it: a card that says "not reviewed"
+ * is only honest if the reader can see what they would be installing. Files
+ * are shown open — a fold would put the content one click away again, which
+ * is the state this panel exists to end. */
+function ContentsPanel({ name }: { name: string }) {
+ const { data, isLoading, error } = useEntryContents(name);
+
+ if (isLoading) {
+ return (
+ <p className="flex items-center gap-2 text-xs text-muted-foreground">
+ <Loader2 className="h-3.5 w-3.5 animate-spin" /> Reading the published files…
+ </p>
+ );
+ }
+ if (error || !data) {
+ return (
+ <Notice tone="warn">
+ The published files could not be read just now. The install below is
+ unaffected — but you would be installing something you have not seen.
+ </Notice>
+ );
+ }
+ if (data.error) return <Notice tone="warn">{data.error}</Notice>;
+ if (data.files.length === 0) return null;
+
+ const total = data.files.reduce((sum, file) => sum + file.size, 0);
+ return (
+ <div>
+ <div className="mb-1.5 flex items-baseline justify-between gap-3">
+ <p className="text-xs font-medium text-foreground">What's inside</p>
+ <p className="shrink-0 text-[11px] text-muted-foreground">
+ {data.files.length === 1 ? "1 file" : `${data.files.length} files`} ·{" "}
+ {formatBytes(total)}
+ </p>
+ </div>
+ <div className="overflow-hidden rounded-md border border-border">
+ <p className="border-b border-border bg-muted/40 px-2.5 py-1.5 font-mono text-[11px] text-muted-foreground">
+ {data.root}
+ </p>
+ {data.files.map((file) => (
+ <div key={file.path} className="border-b border-border last:border-b-0">
+ <div className="flex items-baseline justify-between gap-3 bg-card/60 px-2.5 py-1.5">
+ <span className="truncate font-mono text-[11px] text-foreground">
+ {file.path}
+ </span>
+ <span className="shrink-0 font-mono text-[10px] text-muted-foreground">
+ {formatBytes(file.size)}
+ </span>
+ </div>
+ {/* Long lines scroll inside the file rather than widening the
+ dialog. The text is interpolated, never dangerouslySetInnerHTML
+ — a publisher's file is untrusted text and stays text. */}
+ <pre className="max-h-[420px] overflow-auto bg-background/60 px-2.5 py-2 font-mono text-[11px] leading-relaxed text-muted-foreground">
+ {file.text}
+ </pre>
+ {file.truncated && (
+ <p className="bg-card/60 px-2.5 py-1.5 text-[11px] text-amber-500">
+ Shown up to 256 kB — the published file is longer. Open the
+ source to read the rest.
+ </p>
+ )}
+ </div>
+ ))}
+ </div>
+ <p className="mt-1.5 text-[11px] text-muted-foreground/70">
+ Exactly as published. These are the bytes {PRODUCT_NAME} downloads when
+ you install it — nothing is added or rewritten in between.
+ </p>
+ </div>
+ );
+}
+
/** Coloured brand tile with monogram fallback — the same three-tier idea as
* the main store, minus bundled assets (community brands ship none). */
function CommunityTile({ plugin }: { plugin: CommunityPluginWire }) {
@@ -493,7 +721,14 @@ function CommunityPluginRow({
)}
>
<CommunityTile plugin={plugin} />
- <div className="min-w-0 flex-1">
+ {/* The whole card body opens the entry — reading what a stranger
+ published must not require intending to install it. */}
+ <button
+ type="button"
+ onClick={onInstall}
+ className="min-w-0 flex-1 text-left"
+ title={`Read what ${name} contains`}
+ >
<div className="flex flex-wrap items-center gap-x-2 gap-y-0.5">
<h4 className="min-w-0 max-w-full truncate text-sm font-semibold tracking-tight text-foreground">
{name}
@@ -514,7 +749,7 @@ function CommunityPluginRow({
{plugin.publisher ? `by ${plugin.publisher}` : "unknown publisher"}
{plugin.version ? ` · v${plugin.version}` : ""}
</p>
- </div>
+ </button>
{plugin.source_url && (
<button
type="button"
@@ -576,7 +811,14 @@ function CommunitySkillRow({
: "border-border hover:border-primary/40 hover:bg-card/70",
)}
>
- <div className="min-w-0 flex-1">
+ {/* Same as the plugin card: the body opens the skill so its instructions
+ can be read without committing to an install. */}
+ <button
+ type="button"
+ onClick={onInstall}
+ className="min-w-0 flex-1 text-left"
+ title={`Read what ${skill.title} tells the assistant`}
+ >
<div className="flex flex-wrap items-center gap-x-2 gap-y-0.5">
<h4 className="min-w-0 max-w-full truncate text-sm font-semibold tracking-tight text-foreground">
{skill.title}
@@ -584,6 +826,14 @@ function CommunitySkillRow({
<span className="shrink-0 text-[9px] font-medium uppercase tracking-wider text-amber-500/80">
Community · not reviewed
</span>
+ {skill.flavor === "portable" && (
+ <span
+ className="shrink-0 rounded-full border border-border px-1.5 text-[9px] font-medium uppercase tracking-wider text-muted-foreground"
+ title={portableNote(skill) ?? undefined}
+ >
+ Portable
+ </span>
+ )}
</div>
<p className="truncate text-xs text-muted-foreground" title={skill.description}>
{skill.description}
@@ -592,7 +842,7 @@ function CommunitySkillRow({
{skill.publisher ? `by ${skill.publisher}` : "unknown publisher"}
{installError ? ` · ${installError}` : ""}
</p>
- </div>
+ </button>
{skill.source_url && (
<button
type="button"
@@ -624,6 +874,160 @@ function CommunitySkillRow({
);
}
+/** A published wallpaper, shown as the thing it is: a picture.
+ *
+ * A tile rather than a row — a filename tells nobody whether they want the
+ * picture, and the whole card opens the full-size preview. */
+function CommunityWallpaperCard({
+ paper,
+ onOpen,
+}: {
+ paper: CommunityWallpaperWire;
+ onOpen: () => void;
+}) {
+ const [failed, setFailed] = useState(false);
+ return (
+ <button
+ type="button"
+ onClick={onOpen}
+ title={`Preview ${paper.title}`}
+ className={cn(
+ "group overflow-hidden rounded-lg border bg-card/40 text-left transition-colors",
+ paper.installed
+ ? "border-primary/30"
+ : "border-border hover:border-primary/40 hover:bg-card/70",
+ )}
+ >
+ <div className="grid aspect-video place-items-center overflow-hidden bg-muted">
+ {failed || !paper.raw_url ? (
+ <span className="text-[11px] text-muted-foreground">No preview</span>
+ ) : (
+ <img
+ src={paper.raw_url}
+ alt=""
+ loading="lazy"
+ className="h-full w-full object-cover transition-transform group-hover:scale-[1.03]"
+ onError={() => setFailed(true)}
+ />
+ )}
+ </div>
+ <div className="px-2.5 py-2">
+ <div className="flex items-center gap-1.5">
+ <h4 className="min-w-0 truncate text-xs font-semibold text-foreground">
+ {paper.title}
+ </h4>
+ {paper.installed && (
+ <Check className="h-3 w-3 shrink-0 text-primary" aria-label="Installed" />
+ )}
+ </div>
+ <p className="truncate text-[11px] text-muted-foreground/70">
+ {paper.publisher ? `by ${paper.publisher}` : "unknown publisher"}
+ </p>
+ </div>
+ </button>
+ );
+}
+
+/** The picture at full size before it lands in the picker.
+ *
+ * A wallpaper carries no code and no credentials, so there is nothing to
+ * disclose beyond the image itself — which makes seeing it big the entire
+ * decision. */
+export function WallpaperPreviewDialog({
+ paper,
+ isPending,
+ errorMessage,
+ onCancel,
+ onConfirm,
+}: {
+ paper: CommunityWallpaperWire;
+ isPending: boolean;
+ errorMessage: string | null;
+ onCancel: () => void;
+ onConfirm: () => void;
+}) {
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === "Escape" && !isPending) onCancel();
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [onCancel, isPending]);
+
+ return (
+ <div
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="community-wallpaper-title"
+ className="fixed inset-0 z-50 flex items-center justify-center bg-scrim/70 backdrop-blur-sm"
+ onClick={(e) => {
+ if (e.target === e.currentTarget && !isPending) onCancel();
+ }}
+ >
+ <div className="relative flex max-h-[88vh] w-full max-w-3xl flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-[0_20px_60px_rgba(0,0,0,0.6)]">
+ <header className="border-b border-border px-5 py-4">
+ <h2
+ id="community-wallpaper-title"
+ className="font-display text-base font-semibold tracking-tight"
+ >
+ {paper.installed ? paper.title : `Install ${paper.title}?`}
+ </h2>
+ <p className="text-[11px] uppercase tracking-wider text-amber-500/80">
+ Community wallpaper · not reviewed
+ {paper.installed ? " · installed" : ""}
+ </p>
+ </header>
+
+ <div className="min-h-0 flex-1 space-y-3 overflow-y-auto px-5 py-4 text-sm">
+ {paper.raw_url ? (
+ <img
+ src={paper.raw_url}
+ alt={paper.title}
+ className="max-h-[52vh] w-full rounded-lg border border-border object-contain"
+ />
+ ) : (
+ <Notice tone="warn">This wallpaper publishes no downloadable image.</Notice>
+ )}
+ {paper.description && (
+ <p className="text-muted-foreground">{paper.description}</p>
+ )}
+ <p className="text-xs text-muted-foreground">
+ Published by{" "}
+ <span className="text-foreground">
+ {paper.publisher ?? "an unknown author"}
+ </span>
+ {paper.version ? ` · version ${paper.version}` : ""}
+ </p>
+ <p className="text-xs text-muted-foreground">
+ Installing downloads the picture and stores it beside your own
+ uploads. It carries no code and no credentials.
+ </p>
+ {errorMessage && (
+ <p className="flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-2 py-1.5 text-xs text-destructive">
+ <AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
+ {errorMessage}
+ </p>
+ )}
+ </div>
+
+ <footer className="flex shrink-0 justify-end gap-2 border-t border-border px-5 py-3">
+ <Button size="sm" variant="ghost" onClick={onCancel} disabled={isPending}>
+ {paper.installed ? "Close" : "Cancel"}
+ </Button>
+ {!paper.installed && paper.raw_url && (
+ <Button size="sm" onClick={onConfirm} disabled={isPending}>
+ {isPending ? (
+ <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
+ ) : null}
+ Install
+ </Button>
+ )}
+ </footer>
+ </div>
+ </div>
+ );
+}
+
/** Skills get the same trust boundary as plugins: a community skill is
* instructions the assistant will follow, downloaded from a URL nobody
* reviewed — so the dialog shows that exact URL and reminds the user to
@@ -649,6 +1053,14 @@ export function SkillInstallConsentDialog({
return () => window.removeEventListener("keydown", onKey);
}, [onCancel, isPending]);
+ // The published URLs travel into the command builder: a skill hosted on
+ // GitHub also has an `npx skills add` line, which installs it into every
+ // other agent that reads SKILL.md files.
+ const skillInstall = installBlock(skill.name, "skill", {
+ sourceUrl: skill.source_url,
+ rawUrl: skill.raw_url,
+ });
+
return (
<div
role="dialog"
@@ -659,20 +1071,21 @@ export function SkillInstallConsentDialog({
if (e.target === e.currentTarget && !isPending) onCancel();
}}
>
- <div className="relative w-full max-w-md overflow-hidden rounded-2xl border border-border bg-card shadow-[0_20px_60px_rgba(0,0,0,0.6)]">
+ <div className="relative flex max-h-[88vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-[0_20px_60px_rgba(0,0,0,0.6)]">
<header className="border-b border-border px-5 py-4">
<h2
id="community-skill-install-title"
className="font-display text-base font-semibold tracking-tight"
>
- Install {skill.title}?
+ {skill.installed ? skill.title : `Install ${skill.title}?`}
</h2>
<p className="text-[11px] uppercase tracking-wider text-amber-500/80">
Community skill · not reviewed
+ {skill.installed ? " · installed" : ""}
</p>
</header>
- <div className="space-y-3 px-5 py-4 text-sm">
+ <div className="min-h-0 flex-1 space-y-3 overflow-y-auto px-5 py-4 text-sm">
<p className="text-muted-foreground">{skill.description}</p>
<p className="text-xs text-muted-foreground">
Published by{" "}
@@ -681,6 +1094,18 @@ export function SkillInstallConsentDialog({
</span>
{skill.version ? ` · version ${skill.version}` : ""}
</p>
+ {/* A portable skill was written for the open format, not for this
+ app. Saying so up front explains both the extra install command
+ below and why settings meant for another agent are ignored. */}
+ {portableNote(skill) && (
+ <p className="text-xs text-muted-foreground">
+ {portableNote(skill)}. {PRODUCT_NAME} follows its instructions and
+ ignores the settings meant for other agents.
+ </p>
+ )}
+ {/* The instructions themselves, before the fine print: a skill IS
+ its text, so reading it is the decision this dialog asks for. */}
+ <ContentsPanel name={skill.name} />
<div>
<p className="mb-1 text-xs font-medium text-foreground">
The instructions are downloaded from:
@@ -689,9 +1114,19 @@ export function SkillInstallConsentDialog({
{skill.raw_url}
</code>
</div>
+ {/* The same line the storefront shows, and the same one the Install
+ button below runs — worth having when the install belongs in a
+ setup script or in a message to someone else. */}
+ {skillInstall && (
+ <InstallTerminal
+ commands={skillInstall.commands}
+ path={`~/marketplace/${skill.name}`}
+ comment="# The same install, from a terminal."
+ />
+ )}
<p className="text-xs text-muted-foreground">
- A skill is a set of instructions the assistant follows. Read the
- installed instructions before you switch it on.
+ A skill is a set of instructions the assistant follows — the text
+ above is exactly what it would be told to do.
</p>
{errorMessage && (
<p className="flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-2 py-1.5 text-xs text-destructive">
@@ -701,16 +1136,18 @@ export function SkillInstallConsentDialog({
)}
</div>
- <footer className="flex justify-end gap-2 border-t border-border px-5 py-3">
+ <footer className="flex shrink-0 justify-end gap-2 border-t border-border px-5 py-3">
<Button size="sm" variant="ghost" onClick={onCancel} disabled={isPending}>
- Cancel
- </Button>
- <Button size="sm" onClick={onConfirm} disabled={isPending}>
- {isPending ? (
- <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
- ) : null}
- Install
+ {skill.installed ? "Close" : "Cancel"}
</Button>
+ {!skill.installed && (
+ <Button size="sm" onClick={onConfirm} disabled={isPending}>
+ {isPending ? (
+ <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
+ ) : null}
+ Install
+ </Button>
+ )}
</footer>
</div>
</div>
@@ -745,6 +1182,7 @@ export function InstallConsentDialog({
const name = plugin.display_name ?? plugin.name;
const mcp = plugin.mcp_server ?? null;
const authLabel = plugin.auth ? AUTH_MODE_LABEL[plugin.auth.mode] : undefined;
+ const pluginInstall = installBlock(plugin.name, "plugin");
return (
<div
@@ -756,7 +1194,7 @@ export function InstallConsentDialog({
if (e.target === e.currentTarget && !isPending) onCancel();
}}
>
- <div className="relative w-full max-w-md overflow-hidden rounded-2xl border border-border bg-card shadow-[0_20px_60px_rgba(0,0,0,0.6)]">
+ <div className="relative flex max-h-[88vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-[0_20px_60px_rgba(0,0,0,0.6)]">
<header className="flex items-center gap-3 border-b border-border px-5 py-4">
<CommunityTile plugin={plugin} />
<div className="min-w-0">
@@ -764,15 +1202,16 @@ export function InstallConsentDialog({
id="community-install-title"
className="font-display text-base font-semibold tracking-tight"
>
- Install {name}?
+ {plugin.installed ? name : `Install ${name}?`}
</h2>
<p className="text-[11px] uppercase tracking-wider text-amber-500/80">
Community plugin · not reviewed
+ {plugin.installed ? " · installed" : ""}
</p>
</div>
</header>
- <div className="space-y-3 px-5 py-4 text-sm">
+ <div className="min-h-0 flex-1 space-y-3 overflow-y-auto px-5 py-4 text-sm">
<p className="text-muted-foreground">{plugin.description}</p>
<p className="text-xs text-muted-foreground">
Published by{" "}
@@ -816,6 +1255,22 @@ export function InstallConsentDialog({
</p>
)}
+ {/* The manifests in full. The address above is the summary; this is
+ the document it was read from, so a claim can be checked rather
+ than trusted. */}
+ <ContentsPanel name={plugin.name} />
+
+ {/* The same line the storefront shows, and the same one the Install
+ button below runs — worth having when the install belongs in a
+ setup script or in a message to someone else. */}
+ {pluginInstall && (
+ <InstallTerminal
+ commands={pluginInstall.commands}
+ path={`~/marketplace/${plugin.name}`}
+ comment="# The same install, from a terminal."
+ />
+ )}
+
{errorMessage && (
<p className="flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-2 py-1.5 text-xs text-destructive">
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
@@ -824,16 +1279,18 @@ export function InstallConsentDialog({
)}
</div>
- <footer className="flex justify-end gap-2 border-t border-border px-5 py-3">
+ <footer className="flex shrink-0 justify-end gap-2 border-t border-border px-5 py-3">
<Button size="sm" variant="ghost" onClick={onCancel} disabled={isPending}>
- Cancel
- </Button>
- <Button size="sm" onClick={onConfirm} disabled={isPending}>
- {isPending ? (
- <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
- ) : null}
- Install
+ {plugin.installed ? "Close" : "Cancel"}
</Button>
+ {!plugin.installed && (
+ <Button size="sm" onClick={onConfirm} disabled={isPending}>
+ {isPending ? (
+ <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
+ ) : null}
+ Install
+ </Button>
+ )}
</footer>
</div>
</div>
diff --git a/jarvis/ui/web/marketplace_routes.py b/jarvis/ui/web/marketplace_routes.py
index 9c8e6174bc..0d764facc9 100644
--- a/jarvis/ui/web/marketplace_routes.py
+++ b/jarvis/ui/web/marketplace_routes.py
@@ -7,6 +7,7 @@ Endpoints:
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
+ GET /api/marketplace/community/{id}/contents — read an entry before installing
POST /api/marketplace/community/refresh — force index re-fetch
POST /api/marketplace/community/install/{id} — install by name (any kind)
POST /api/marketplace/community/plugins/{id}/install — one-click install
@@ -16,7 +17,9 @@ Endpoints:
from __future__ import annotations
import asyncio
+import json
import logging
+import time
from dataclasses import dataclass
from datetime import UTC, datetime
from pathlib import Path
@@ -814,6 +817,12 @@ def _community_payload(
"categories": list(skill.categories),
"source_url": skill.source_url,
"raw_url": skill.raw_url,
+ # Which frontmatter the file carries, and where else it
+ # runs. A missing flavor stays missing on the wire: the
+ # view treats absent and "jarvis" alike, and inventing a
+ # value here would claim the registry said something.
+ "flavor": skill.flavor,
+ "compatible_agents": list(skill.compatible_agents),
"installed": (skills_root / skill.name / "SKILL.md").exists(),
}
)
@@ -839,8 +848,13 @@ def _community_payload(
"published_at": paper.published_at,
"categories": list(paper.categories),
"source_url": paper.source_url,
- "raw_url": paper.raw_url,
+ # Both names travel: `image_url` is what the registry
+ # emits, `raw_url` keeps the shape the other two kinds use.
+ "image_url": paper.download_url,
+ "raw_url": paper.download_url,
+ "thumb_url": paper.thumb_url,
"theme": paper.theme,
+ "license": paper.license,
"installed": paper.name in installed_sources,
}
)
@@ -875,6 +889,164 @@ async def community_refresh(response: Response) -> dict[str, Any]:
return _community_payload(index, status)
+# ----------------------------------------------------------------------
+# Reading an entry BEFORE installing it
+#
+# "Nobody reviewed this" is only an honest warning if the reader can act on
+# it, and nobody can act on a one-line description plus a URL. So the whole
+# published package is served as text: the instructions a skill would hand the
+# assistant, the manifest that says where a plugin would send the token, the
+# picture a wallpaper would install. Reading runs the same fetch the install
+# would run, minus writing anything to disk.
+# ----------------------------------------------------------------------
+
+# A SKILL.md is prose. The ceiling exists so a hostile entry cannot stream
+# megabytes into the desktop app, not because real files come close to it.
+_MAX_CONTENT_BYTES = 256 * 1024
+# The same quarter hour the index itself caches for: reopening a card is free.
+_CONTENT_TTL_SECONDS = 900.0
+_content_cache: dict[str, tuple[float, str, bool]] = {}
+
+
+async def _download_text(raw_url: str, *, transport: Any = None) -> tuple[str, bool]:
+ """Fetch one published text file over https. Returns ``(text, truncated)``.
+
+ Oversize is cut, not refused: half a hostile file is still readable
+ evidence, while refusing outright would leave the reader with nothing. The
+ redirect chain is re-checked for the reason ``_download_image`` re-checks
+ it — the index validator only ever saw the URL it was given, and a 302 to
+ plain http would put the server back on an SSRF path.
+ """
+ hit = _content_cache.get(raw_url)
+ if hit is not None and (time.time() - hit[0]) < _CONTENT_TTL_SECONDS:
+ return hit[1], hit[2]
+
+ chunks: list[bytes] = []
+ total = 0
+ truncated = False
+ async with httpx.AsyncClient(
+ follow_redirects=True,
+ timeout=httpx.Timeout(connect=5.0, read=20.0, write=20.0, pool=20.0),
+ transport=transport,
+ ) as client:
+ try:
+ async with client.stream("GET", raw_url) as resp:
+ if resp.url.scheme != "https":
+ raise HTTPException(
+ status_code=400,
+ detail=f"refusing a non-https redirect to {resp.url}",
+ )
+ resp.raise_for_status()
+ async for chunk in resp.aiter_bytes():
+ if total + len(chunk) > _MAX_CONTENT_BYTES:
+ chunks.append(chunk[: _MAX_CONTENT_BYTES - total])
+ truncated = True
+ break
+ total += len(chunk)
+ chunks.append(chunk)
+ except httpx.HTTPError as exc:
+ raise HTTPException(
+ status_code=502, detail=f"download from {raw_url} failed: {exc}"
+ ) from exc
+
+ # errors="replace": one broken byte must not hide the whole file, which is
+ # the only thing this route exists to show.
+ text = b"".join(chunks).decode("utf-8", errors="replace")
+ _content_cache[raw_url] = (time.time(), text, truncated)
+ return text, truncated
+
+
+def _text_file(path: str, text: str, *, truncated: bool = False) -> dict[str, Any]:
+ """One readable file in the wire shape the view renders."""
+ return {
+ "path": path,
+ "size": len(text.encode("utf-8")),
+ "text": text,
+ "truncated": truncated,
+ }
+
+
+def _plugin_manifest_files(entry: Any) -> list[dict[str, Any]]:
+ """A plugin's manifests, pretty-printed.
+
+ They travel inside the index itself, so this needs no network at all — and
+ they are the two files that decide what a plugin may do: ``plugin.json``
+ names it, ``mcp.json`` says which server or command it talks to.
+ """
+ files = [_text_file("plugin.json", json.dumps(entry.plugin_json, indent=2, ensure_ascii=False))]
+ if entry.mcp_json:
+ files.append(
+ _text_file("mcp.json", json.dumps(entry.mcp_json, indent=2, ensure_ascii=False))
+ )
+ return files
+
+
[email protected]("/community/{item_id}/contents", openapi_extra={"x-jarvis-readonly": True})
+async def community_contents(item_id: str, response: Response) -> dict[str, Any]:
+ """What one published entry actually contains — skill, plugin or wallpaper.
+
+ Reading is never installing: nothing is written, no registry is touched.
+ A download that fails degrades to an ``error`` string on an otherwise
+ complete answer rather than an exception, so one unreachable file leaves
+ the card usable instead of blanking the panel.
+ """
+ from jarvis.marketplace import community_source
+
+ response.headers["Cache-Control"] = "no-store"
+ index, _ = await community_source.get_index()
+ plugin = skill = paper = None
+ if index is not None:
+ plugin = next((e for e in index.plugins if e.name == item_id), None)
+ skill = next((s for s in index.skills if s.name == item_id), None)
+ paper = next((w for w in index.wallpapers if w.name == item_id), None)
+ entry = plugin or skill or paper
+ if entry is None:
+ raise _install_by_name_404(item_id, index)
+
+ kind = "plugin" if plugin is not None else "skill" if skill is not None else "wallpaper"
+ out: dict[str, Any] = {
+ "kind": kind,
+ "name": entry.name,
+ "title": getattr(entry, "title", None) or entry.name,
+ "publisher": entry.publisher,
+ "version": entry.version,
+ "source_url": entry.source_url,
+ "root": f"{kind}s/{entry.name}",
+ "files": [],
+ "image_url": None,
+ "error": None,
+ }
+
+ if plugin is not None:
+ out["files"] = _plugin_manifest_files(plugin)
+ return out
+
+ if paper is not None:
+ # A picture has no text to read — the preview IS the content. Both the
+ # url and the "nothing to show" verdict come from `download_url`, the
+ # same field the install fetches: judging by `raw_url` alone told every
+ # wallpaper the registry publishes as `image_url` that it had no image,
+ # right next to the preview that was already loading.
+ out["image_url"] = paper.download_url
+ if not paper.download_url:
+ out["error"] = "This wallpaper publishes no downloadable image."
+ return out
+
+ if not skill.raw_url:
+ out["error"] = "This skill publishes no direct download — open its source to read it."
+ return out
+ try:
+ text, truncated = await _download_text(skill.raw_url)
+ except HTTPException as exc:
+ # Honest degradation: say the text could not be fetched, rather than
+ # show an empty panel that reads like an empty skill.
+ log.warning("community contents: %s unreadable (%s)", item_id, exc.detail)
+ out["error"] = f"The file could not be downloaded: {exc.detail}"
+ return out
+ out["files"] = [_text_file("SKILL.md", text, truncated=truncated)]
+ return out
+
+
async def _install_community_plugin(plugin_id: str) -> dict[str, Any]:
"""Install one community plugin; return its catalog item.
@@ -1073,7 +1245,8 @@ async def _install_community_wallpaper(entry: Any) -> dict[str, Any]:
WallpaperUploads,
)
- if not entry.raw_url:
+ download_url = entry.download_url
+ if not download_url:
# Either absent or dropped by the index validator for not being https.
raise HTTPException(
status_code=400,
@@ -1089,7 +1262,7 @@ async def _install_community_wallpaper(entry: Any) -> dict[str, Any]:
f"{existing.title!r}. Remove it there before installing again."
),
)
- data = await _download_image(entry.raw_url, MAX_UPLOAD_BYTES)
+ data = await _download_image(download_url, MAX_UPLOAD_BYTES)
try:
item = store.add(
data,
@@ -1147,11 +1320,11 @@ def _install_by_name_404(item_id: str, index: Any) -> HTTPException:
@router.post("/community/install/{item_id}")
async def community_install_by_name(item_id: str, request: Request) -> dict[str, Any]:
- """Install a marketplace entry by name — skill or plugin, one call.
+ """Install a marketplace entry by name — skill, plugin or wallpaper, one call.
The one-liner a downloader copies off a marketplace page
- (``jarvis marketplace install <name>``) never says which of the two an
- entry is, so the KIND is resolved here and both kinds answer in one shape:
+ (``jarvis marketplace install <name>``) never says which of the three an
+ entry is, so the KIND is resolved here and all three answer in one shape:
what landed, where it landed, whether it is usable right now, and what is
still missing. Every surface (CLI, desktop, an agent driving the API) can
therefore report an honest status instead of a bare 200.
diff --git a/tests/unit/marketplace/test_community_contents.py b/tests/unit/marketplace/test_community_contents.py
new file mode 100644
index 0000000000..59c331d6e9
--- /dev/null
+++ b/tests/unit/marketplace/test_community_contents.py
@@ -0,0 +1,245 @@
+"""Reading a community entry BEFORE installing it.
+
+The contents route is what makes the "nobody reviewed this" badge actionable:
+it hands over the published bytes themselves. These tests pin the three kinds
+(plugin manifests, skill text, wallpaper picture), the size ceiling, and the
+rule that a failed download degrades to an honest message instead of an
+exception.
+"""
+
+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.ui.web import marketplace_routes
+from jarvis.ui.web.marketplace_routes import router
+
+SKILL_TEXT = "---\nname: three-point-check\n---\n\nSummarize in three bullets.\n"
+
+
+def _index_payload() -> dict[str, Any]:
+ return {
+ "revision": 1,
+ "generated_at": "2026-08-12T12:00:00Z",
+ "plugins": [
+ {
+ "name": "todo-fox",
+ "publisher": "octocat",
+ "version": "1.2.0",
+ "source_url": "https://github.com/PersonalJarvis/marketplace",
+ "plugin_json": {
+ "name": "todo-fox",
+ "description": "Tasks and reminders from TodoFox",
+ "version": "1.2.0",
+ "license": "MIT",
+ "extensions": {
+ EXTENSION_NAMESPACE: {
+ "display_name": "TodoFox",
+ "category": "Lists & Tasks",
+ }
+ },
+ },
+ "mcp_json": {
+ "mcpServers": {
+ "todo-fox": {
+ "type": "streamable-http",
+ "url": "https://mcp.todofox.example/mcp",
+ }
+ }
+ },
+ }
+ ],
+ "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",
+ }
+ ],
+ "wallpapers": [
+ {
+ "name": "rain-antenna-city",
+ "title": "Rain Antenna City",
+ "description": "Neon rooftops in the rain",
+ "publisher": "octocat",
+ "raw_url": "https://raw.example/wallpapers/rain-antenna-city.webp",
+ "theme": "dark",
+ }
+ ],
+ }
+
+
+def community_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
+ """A fresh index cache in tmp, and an empty download cache per test."""
+ cache = tmp_path / "marketplace_index.json"
+ cache.write_text(
+ json.dumps({"fetched_at": time.time(), "index": _index_payload()}),
+ 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("jarvis.core.paths.user_skills_dir", lambda: tmp_path / "skills")
+ # Module-global by design (one process-wide download cache) — so a test
+ # must never inherit another test's fetch.
+ marketplace_routes._content_cache.clear()
+ catalog_data.clear_cache()
+ yield tmp_path
+ marketplace_routes._content_cache.clear()
+ catalog_data.clear_cache()
+
+
+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_plugin_contents_are_the_manifests_verbatim(community_env: Path) -> None:
+ """A plugin's manifests need no network — they ride inside the index."""
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/community/todo-fox/contents")
+ assert resp.status_code == 200
+ data = resp.json()
+ assert data["kind"] == "plugin"
+ assert data["root"] == "plugins/todo-fox"
+ names = [f["path"] for f in data["files"]]
+ assert names == ["plugin.json", "mcp.json"]
+ # Pretty-printed and complete: the reader can check the claim the consent
+ # dialog makes about where the token goes.
+ assert "https://mcp.todofox.example/mcp" in data["files"][1]["text"]
+ assert json.loads(data["files"][0]["text"])["name"] == "todo-fox"
+ assert data["files"][0]["truncated"] is False
+
+
+async def test_skill_contents_download_the_published_text(
+ community_env: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ async def _fake(raw_url: str, **_: Any) -> tuple[str, bool]:
+ assert raw_url == "https://raw.example/skills/three-point-check/SKILL.md"
+ return SKILL_TEXT, False
+
+ monkeypatch.setattr(marketplace_routes, "_download_text", _fake)
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/community/three-point-check/contents")
+ data = resp.json()
+ assert data["kind"] == "skill"
+ assert data["files"][0]["path"] == "SKILL.md"
+ assert data["files"][0]["text"] == SKILL_TEXT
+ assert data["files"][0]["size"] == len(SKILL_TEXT.encode("utf-8"))
+ assert data["error"] is None
+
+
+async def test_unreachable_skill_file_degrades_to_a_message(
+ community_env: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """A dead raw_url must leave the card usable, not raise a 502 at the view."""
+ from fastapi import HTTPException
+
+ async def _boom(raw_url: str, **_: Any) -> tuple[str, bool]:
+ raise HTTPException(status_code=502, detail="host unreachable")
+
+ monkeypatch.setattr(marketplace_routes, "_download_text", _boom)
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/community/three-point-check/contents")
+ assert resp.status_code == 200
+ data = resp.json()
+ assert data["files"] == []
+ assert "host unreachable" in data["error"]
+
+
+async def test_wallpaper_contents_are_the_picture(community_env: Path) -> None:
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/community/rain-antenna-city/contents")
+ data = resp.json()
+ assert data["kind"] == "wallpaper"
+ assert data["files"] == []
+ assert data["image_url"] == "https://raw.example/wallpapers/rain-antenna-city.webp"
+
+
+async def test_a_wallpaper_published_as_image_url_still_previews(
+ community_env: Path,
+) -> None:
+ """The published registry emits `image_url`, not `raw_url`.
+
+ Judging the preview by `raw_url` alone told every real wallpaper that it
+ "publishes no downloadable image" — while the install, which asks for
+ `download_url`, would have fetched it happily.
+ """
+ payload = _index_payload()
+ payload["wallpapers"] = [
+ {
+ "name": "moonlit-wave",
+ "title": "Moonlit Wave",
+ "publisher": "octocat",
+ "image_url": "https://pages.example/wallpapers/moonlit-wave/wallpaper.webp",
+ }
+ ]
+ community_source._CACHE_PATH.write_text(
+ json.dumps({"fetched_at": time.time(), "index": payload}), encoding="utf-8"
+ )
+
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/community/moonlit-wave/contents")
+
+ data = resp.json()
+ assert data["image_url"].endswith("moonlit-wave/wallpaper.webp")
+ assert data["error"] is None
+
+
+async def test_unknown_entry_404(community_env: Path) -> None:
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/community/nope/contents")
+ assert resp.status_code == 404
+
+
+async def test_download_cuts_oversize_instead_of_refusing() -> None:
+ """Half a hostile file is readable evidence; refusing leaves nothing."""
+ marketplace_routes._content_cache.clear()
+ body = b"x" * (marketplace_routes._MAX_CONTENT_BYTES + 5000)
+ transport = httpx.MockTransport(lambda request: httpx.Response(200, content=body))
+ text, truncated = await marketplace_routes._download_text(
+ "https://raw.example/big.md", transport=transport
+ )
+ assert truncated is True
+ assert len(text) == marketplace_routes._MAX_CONTENT_BYTES
+ marketplace_routes._content_cache.clear()
+
+
+async def test_download_is_cached_so_reopening_costs_nothing() -> None:
+ marketplace_routes._content_cache.clear()
+ calls = 0
+
+ def _handler(request: httpx.Request) -> httpx.Response:
+ nonlocal calls
+ calls += 1
+ return httpx.Response(200, content=SKILL_TEXT.encode("utf-8"))
+
+ transport = httpx.MockTransport(_handler)
+ url = "https://raw.example/cached.md"
+ first, _ = await marketplace_routes._download_text(url, transport=transport)
+ second, _ = await marketplace_routes._download_text(url, transport=transport)
+ assert first == second == SKILL_TEXT
+ assert calls == 1
+ marketplace_routes._content_cache.clear()