Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(economy-lab): stop the Runway Lab reporting a stalled rail as healthy

nirholasac0c2f145cbd
diff --git a/api/skills/index.js b/api/skills/index.js
index 40424a52c..44e1487a9 100644
--- a/api/skills/index.js
+++ b/api/skills/index.js
@@ -6,6 +6,11 @@ import { limits, clientIp } from '../_lib/rate-limit.js';
import { parse, isUuid } from '../_lib/validate.js';
const CATEGORY_RE = /^[a-z0-9-]{1,50}$/;
+// Tags are authored freely on publish, so browse matches them case-insensitively
+// on an exact value (the marketplace tag pills link straight here). Anything
+// longer than the publish schema allows cannot match a row, so it is rejected
+// rather than run as a full table scan.
+const TAG_MAX = 40;
const VALID_SORTS = new Set(['popular', 'new', 'az']);
const DEFAULT_SORT = 'popular';
@@ -90,6 +95,12 @@ async function handleList(req, res) {
const limit = Math.min(50, Math.max(1, Number(url.searchParams.get('limit')) || 20));
const installedOnly = url.searchParams.get('installed') === 'true';
+ const tagRaw = (url.searchParams.get('tag') || '').trim();
+ if (tagRaw.length > TAG_MAX) {
+ return error(res, 400, 'validation_error', `tag must be ${TAG_MAX} characters or fewer`);
+ }
+ const tag = tagRaw ? tagRaw.toLowerCase() : null;
+
let category = null;
if (categoryRaw != null && categoryRaw !== '') {
if (!CATEGORY_RE.test(categoryRaw)) {
@@ -161,6 +172,7 @@ async function handleList(req, res) {
sort,
userId,
category,
+ tag,
qLike,
installedOnly,
cursor,
@@ -194,6 +206,7 @@ function runListQuery(p) {
sort,
userId,
category,
+ tag,
qLike,
installedOnly,
cursor,
@@ -231,6 +244,10 @@ function runListQuery(p) {
OR (ms.created_at = ${cursorCreatedAt}::timestamptz AND ms.id::text < ${cursor}::text)
)
AND (${category}::text IS NULL OR ms.category = ${category})
+ AND (
+ ${tag}::text IS NULL
+ OR EXISTS (SELECT 1 FROM unnest(ms.tags) t WHERE lower(t) = ${tag})
+ )
AND (
${qLike}::text IS NULL
OR ms.name ILIKE ${qLike}
@@ -276,6 +293,10 @@ function runListQuery(p) {
OR (ms.name = ${cursorName}::text AND ms.id::text > ${cursor}::text)
)
AND (${category}::text IS NULL OR ms.category = ${category})
+ AND (
+ ${tag}::text IS NULL
+ OR EXISTS (SELECT 1 FROM unnest(ms.tags) t WHERE lower(t) = ${tag})
+ )
AND (
${qLike}::text IS NULL
OR ms.name ILIKE ${qLike}
@@ -321,6 +342,10 @@ function runListQuery(p) {
OR (ms.install_count = ${cursorInstallCount}::integer AND ms.id::text < ${cursor}::text)
)
AND (${category}::text IS NULL OR ms.category = ${category})
+ AND (
+ ${tag}::text IS NULL
+ OR EXISTS (SELECT 1 FROM unnest(ms.tags) t WHERE lower(t) = ${tag})
+ )
AND (
${qLike}::text IS NULL
OR ms.name ILIKE ${qLike}
diff --git a/docs/skills.md b/docs/skills.md
index 12d4db4cc..ba264c305 100644
--- a/docs/skills.md
+++ b/docs/skills.md
@@ -720,6 +720,27 @@ Paid skills price per *call*, not per install: the detail page shows an x402 end
Publish your own from the marketplace ("Publish a Skill") or `POST /api/skills` with `{ name, slug, description, category, tags, content }` (or `schema_json`).
+### Browsing the catalog from code
+
+`GET /api/skills` is public and takes the same filters the marketplace UI uses, so a script can reproduce any view you can link to:
+
+| Param | Meaning |
+| --- | --- |
+| `q` | Substring match across name, description, and tags |
+| `category` | Exact category slug (`GET /api/skills/categories` lists them with counts) |
+| `tag` | Exact tag, case-insensitive, matched against the skill's `tags` array |
+| `sort` | `popular` (default), `new`, or `az` |
+| `limit` / `cursor` | Page size (max 50) and the keyset cursor returned as `next_cursor` |
+| `installed=true` | Authed only: your own installed set, with `content` and `schema_json` |
+
+```bash
+# Every free skill tagged "solana", newest first
+curl -s 'https://three.ws/api/skills?tag=solana&sort=new&limit=50' \
+ | jq '.skills[] | select(.price_per_call_usd == 0) | {name, slug, tags}'
+```
+
+Those filters are also the page URL, so [/marketplace?tab=skills&tag=solana&sort=new](https://three.ws/marketplace?tab=skills&tag=solana&sort=new) opens that exact view in a browser and can be shared as-is. The retired `/skills` path forwards there, carrying `q`, `category`, `tag`, and `sort` with it.
+
---
## Versioning
diff --git a/docs/ux-flows/06-marketplace-skills.md b/docs/ux-flows/06-marketplace-skills.md
index fa345f098..9565a5116 100644
--- a/docs/ux-flows/06-marketplace-skills.md
+++ b/docs/ux-flows/06-marketplace-skills.md
@@ -129,12 +129,13 @@ Routing facts confirmed in `vercel.json` (line numbers shift too often to pin; g
### Skills marketplace (browse / install / rate) — `/skills` → `/marketplace?tab=skills`
- **Source:** `pages/skills.html` (redirect shell), `src/marketplace.js` skills tab (`skillsState` ~L2128, `loadSkillsTab()`, `renderSkillsGrid()`/`renderSkillCard()` ~L2229, skill detail ~L2348, `toggleSkillInstall()` ~L2582). Backend `/api/skills`, `/api/skills/categories`, `/api/skills/:id`, `/api/skills/:id/install`, `/api/skills/:id/rate`. x402 per-call via `/api/x402/skill-call`. Runtime gate `src/skills/index.js`.
-- **Entry point:** `/skills` client-redirects (preserving `?q=`, `?category=`) to `/marketplace?tab=skills`; the SPA renders the skills grid.
+- **Entry point:** `/skills` client-redirects (preserving `?q=`, `?category=`, `?tag=`, `?sort=`) to `/marketplace?tab=skills`; the SPA reads those params back off the URL into `skillsState` and renders the skills grid. Without JavaScript the shell shows a heading, an explanation, and a link to the Marketplace, and a `<noscript>` refresh forwards anyway.
- **Prerequisites / gates:** Browse is open. Install and rate require auth (401 → `/login?next=…`). Installing is **free** — payment for skills is per-call via x402, separate from install.
- **Steps (N):**
- 1. SPA loads the skills tab → `GET /api/skills?limit=24&q=&category=&sort=&cursor=` and `/api/skills/categories`; renders skeletons then cards (name, price-per-call or "free", description, category pill, x402 badge for paid, install/tool counts, rating, "Installed ✓").
- 2. (optional) User filters by category chip → `skillsState.category` → `loadSkillsTab(true)` refetch.
+ 1. SPA loads the skills tab → `GET /api/skills?limit=24&q=&category=&tag=&sort=&cursor=` and `/api/skills/categories`; renders skeletons then cards (name, price-per-call or "free", description, category pill, x402 badge for paid, install/tool counts, rating, "Installed ✓").
+ 2. (optional) User filters by category chip → `skillsState.category` → `loadSkillsTab(true)` refetch. Search, category, tag, and sort all write back to the URL (`syncSkillsToUrl`), so the view is shareable and survives a reload and the back button.
3. (optional) User searches → `skillsState.q` → refetch; or toggles Free/Paid (client-side `isPaidSkill`).
+ 3b. (optional) User clicks a tag pill on a skill detail → `/marketplace?tab=skills&tag=X` → `GET /api/skills?tag=X` (exact, case-insensitive match against the skill's `tags`); a banner names the active tag and clears it in one click.
4. (optional) User scrolls → cursor pagination appends more cards.
5. User clicks a card → `/marketplace/skills/:id` → `GET /api/skills/:id` renders the detail panel (header, meta pills, description, tool schemas, full content, related skills).
6. User clicks "Install" → `toggleSkillInstall()` POSTs `/api/skills/:id/install` (DELETE to remove); 401 → login redirect; on success the detail + grid refetch, the button flips to "Installed ✓ — Remove", and the "what next" panel (`#skill-detail-next`) appears: knowledge skills get a "Chat with your agent →" CTA to `/app`, schema-only packs get the `GET /api/skills?installed=true` retrieval hint. Pre-install, `#skill-detail-how` explains what installing does.
@@ -143,7 +144,7 @@ Routing facts confirmed in `vercel.json` (line numbers shift too often to pin; g
- **Decision points / branches:** free vs paid (paid = x402 per-call, not an install purchase); installed vs not; authed vs anon (install/rate gated). Marketplace skills (community tool packs with schema/content) are distinct from built-in agent skills in `src/agent-skills*.js`.
- **External calls / dependencies:** `/api/skills`, `/api/skills/categories`, `/api/skills/:id`, `/api/skills/:id/install` (POST/DELETE), `/api/skills/:id/rate`, `/api/x402/skill-call` (per-call payment), `/api/creators/:id` (author modal).
- **Success state:** Skill installed (flips to "Installed ✓" + the what-next panel), rating recorded, x402 snippet copyable. Installs take effect at chat time: `/api/chat` loads the signed-in user's installed knowledge skills (`api/_lib/installed-skills.js`, newest 8, content budget 24k chars) into the system prompt and reports them as `skills_applied` in the SSE `done` event; `GET /api/skills?installed=true` returns the full payload (content + schema_json) for external agents.
-- **Empty / error states:** "No skills found" with Clear-filters / Publish-a-Skill CTAs; `renderErrorState('skills')` with retry; install button restores text + re-enables on error; auth redirect on 401.
+- **Empty / error states:** "No skills found", naming the search / category / tag that emptied the list, with Clear-filters / Publish-a-Skill CTAs; a failed fetch renders `renderErrorState('skills')` ("Couldn't load skills") with a working Retry; install button restores text + re-enables on error; auth redirect on 401.
- **Step count:** 3 required (+5 optional)
---
diff --git a/pages/marketplace.html b/pages/marketplace.html
index 0887356b2..45895c99b 100644
--- a/pages/marketplace.html
+++ b/pages/marketplace.html
@@ -3905,17 +3905,18 @@
id="skills-search"
type="search"
placeholder="Search skills…"
+ aria-label="Search skills"
autocomplete="off"
style="flex: 1; max-width: 320px"
/>
<div class="market-filter-chips" role="tablist" aria-label="Skill filter">
- <button class="market-chip active" data-skill-filter="all" role="tab" data-i18n="marketplace.all_2">
+ <button class="market-chip active" data-skill-filter="all" role="tab" aria-selected="true" data-i18n="marketplace.all_2">
All
</button>
- <button class="market-chip" data-skill-filter="free" role="tab" data-i18n="marketplace.free_2">
+ <button class="market-chip" data-skill-filter="free" role="tab" aria-selected="false" data-i18n="marketplace.free_2">
Free
</button>
- <button class="market-chip" data-skill-filter="paid" role="tab" data-i18n="marketplace.paid_2">
+ <button class="market-chip" data-skill-filter="paid" role="tab" aria-selected="false" data-i18n="marketplace.paid_2">
Paid
</button>
</div>
@@ -3926,6 +3927,7 @@
</select>
</header>
<div class="market-skills-tab">
+ <div class="market-tag-banner" id="skills-tag-banner" role="status" hidden></div>
<div
class="market-cat-chips"
id="skills-cat-chips"
diff --git a/pages/skills.html b/pages/skills.html
index 659af2ec6..44fbafff6 100644
--- a/pages/skills.html
+++ b/pages/skills.html
@@ -4,29 +4,98 @@
<style>/* three.ws hidden-guard — make the `hidden` attribute authoritative; see scripts/lib/hidden-guard.mjs */[hidden]{display:none!important}</style>
<script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
<meta charset="utf-8" />
- <link rel="icon" href="/favicon.ico" sizes="any" />
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
- <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
- <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
- <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
- <link rel="manifest" href="/manifest.webmanifest" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title data-i18n="skills.meta_title">Skills · three.ws</title>
- <meta name="description" content="Browse, discover, and install agent skills — tool packs, knowledge bases, and capabilities that make your AI agents smarter." data-i18n-attr="content:skills.meta_description"/>
- <meta name="robots" content="noindex" />
- <link rel="canonical" href="https://three.ws/marketplace?tab=skills" />
<script>
// Skills now live inside the marketplace. Forward any old /skills links
- // (and their query) to the marketplace Skills tab, preserving search.
+ // (and their query) to the marketplace Skills tab, preserving the
+ // filters the Skills tab actually reads back off the URL. This runs
+ // first in the head on purpose: every tag below it is a request the
+ // browser would start and then cancel a moment later.
(function () {
var src = new URLSearchParams(location.search);
var out = new URLSearchParams();
out.set('tab', 'skills');
- if (src.get('q')) out.set('q', src.get('q'));
- if (src.get('category')) out.set('category', src.get('category'));
+ ['q', 'category', 'tag', 'sort'].forEach(function (key) {
+ var v = src.get(key);
+ if (v) out.set(key, v);
+ });
location.replace('/marketplace?' + out.toString());
})();
</script>
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/manifest.webmanifest" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title data-i18n="skills.meta_title">Skills Marketplace · three.ws</title>
+ <meta name="description" content="Browse, search, and install agent skills: tool packs, knowledge bases, and capabilities that make AI agents smarter. Now lives inside the Marketplace; this path forwards there." data-i18n-attr="content:skills.meta_description"/>
+ <meta name="robots" content="noindex" />
+ <link rel="canonical" href="https://three.ws/marketplace?tab=skills" />
+ <!-- The forward at the top of this head needs JS. Without it (crawlers, JS off, a script
+ error) the visitor would otherwise land on an empty document, so
+ send them on with a refresh and leave a real link behind it. -->
+ <noscript><meta http-equiv="refresh" content="0;url=/marketplace?tab=skills" /></noscript>
+ <style>
+ .skills-forward {
+ min-height: 100vh;
+ margin: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 24px;
+ background: #0b0b0f;
+ color: #f4f4f5;
+ font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
+ line-height: 1.55;
+ }
+ .skills-forward-card {
+ max-width: 34rem;
+ text-align: center;
+ }
+ .skills-forward h1 {
+ font-size: clamp(1.5rem, 4vw, 2rem);
+ margin: 0 0 0.75rem;
+ letter-spacing: -0.01em;
+ }
+ .skills-forward p {
+ margin: 0 0 1.5rem;
+ color: #a1a1aa;
+ }
+ .skills-forward a {
+ display: inline-block;
+ padding: 0.7rem 1.4rem;
+ border-radius: 999px;
+ background: #f4f4f5;
+ color: #0b0b0f;
+ font-weight: 600;
+ text-decoration: none;
+ transition: transform 0.15s ease, opacity 0.15s ease;
+ }
+ .skills-forward a:hover {
+ opacity: 0.88;
+ }
+ .skills-forward a:active {
+ transform: translateY(1px);
+ }
+ .skills-forward a:focus-visible {
+ outline: 2px solid #7c9cff;
+ outline-offset: 3px;
+ }
+ @media (prefers-color-scheme: light) {
+ .skills-forward {
+ background: #ffffff;
+ color: #18181b;
+ }
+ .skills-forward p {
+ color: #52525b;
+ }
+ .skills-forward a {
+ background: #18181b;
+ color: #ffffff;
+ }
+ }
+ </style>
<meta property="og:type" content="website">
<meta property="og:site_name" content="three.ws">
@@ -46,7 +115,17 @@
<meta property="og:image:alt" content="Skills Marketplace — three.ws">
<meta name="twitter:site" content="@trythreews">
</head>
- <body> <script src="/brand.js" defer></script>
+ <body class="skills-forward">
+ <main class="skills-forward-card">
+ <h1 data-i18n="skills.forward_heading">Skills moved into the Marketplace</h1>
+ <p data-i18n="skills.forward_body">
+ Every agent skill (tool packs, knowledge bases, and the capabilities
+ that make AI agents smarter) is now browsable on the Marketplace
+ Skills tab.
+ </p>
+ <a href="/marketplace?tab=skills" data-i18n="skills.forward_cta">Open the Skills Marketplace</a>
+ </main>
+ <script src="/brand.js" defer></script>
<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
<script type="module" src="/i18n.js"></script>
</body>
diff --git a/prompts/swarm-100/route-create-selfie.md b/prompts/swarm-100/route-create-selfie.md
deleted file mode 100644
index 388303871..000000000
--- a/prompts/swarm-100/route-create-selfie.md
+++ /dev/null
@@ -1,119 +0,0 @@
-# Route audit: /create/selfie (Selfie to Avatar)
-
-How to run: paste this file's repo path into a fresh Claude Code chat in this
-repository and say "run this work order". This file is fully self-contained:
-it depends on no other prompt file anywhere. If neighboring files in
-prompts/swarm-100/ are gone, that work is done; if present, ignore them.
-Every claim below rots; step 0 re-measures, and what you measure wins.
-
-## Operating clause (binding)
-
-- Read CLAUDE.md first. Its rules override everything, including this file.
-- Finish 100% in this session. Never end the turn with a question, an option
- list, or an unexecuted plan. A judgment call goes in one line of the final
- report; it never becomes a question that halts work.
-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real
- funds or any irreversible on-chain write, git push or a production deploy,
- committing content that references a crypto project other than $THREE, and
- destroying unrecoverable data.
-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no
- commented-out code. Real APIs and real integrations only.
-- The em-dash and en-dash characters are banned in everything you write.
-- Concurrent agents share this worktree: stage explicit paths only (never a
- bare add-everything), and commit finished work promptly.
-- Before committing, run: npm run check:rules -- --paths <files you touched>.
- It must exit 0.
-
-## Step 0: re-derive the current state
-
-1. This route's declared entry (path, description, added date):
-
- node -e "const p=require('./data/pages.json');for(const s of p.sections)for(const g of s.pages)if(g.path==='/create/selfie')console.log(JSON.stringify(g,null,2))"
-
-2. Find the serving implementation: grep "/create/selfie" in vercel.json (the live
- route table server/index.mjs boots from), then list matching files in
- pages/ and src/. STRUCTURE.md maps every surface to its directory if the
- grep is ambiguous.
-3. Production right now:
-
- curl -so /dev/null -w '%{http_code}\n' https://three.ws/create/selfie
-
-4. Start (or reuse) the local dev server: npm run dev (vite, port 3000).
-
-## Task: audit this one route end to end, then fix everything found
-
-Route: /create/selfie ("Selfie to Avatar", section "build").
-Declared purpose: One selfie. About a minute. A rigged 3D avatar that works everywhere.
-
-Drive the page in a real headless browser. Playwright is already a dev
-dependency; keep your probe script in the session scratchpad, never in the
-repo.
-
-1. Load http://localhost:3000/create/selfie. Record the HTTP status, every console
- error and warning, and every failed network request.
-2. Exercise it like a first-time user: click the primary actions, run the
- primary flow if one exists, follow the page's internal links. Every button
- must do something real; every link must resolve. If the page renders data,
- prove in the network log that it came from a live endpoint, not a baked-in
- fallback array.
-3. States: verify populated, empty, loading, and error states are designed and
- reachable. Block the page's primary fetch in Playwright and confirm an
- actionable error state appears, not a blank void or a raw exception.
-4. Responsive: render at 320, 768, and 1440 px. No horizontal page scroll, no
- overlapping or clipped controls.
-5. Accessibility basics: one h1; interactive elements are real buttons or
- links with visible focus states; images carry alt text; form fields have
- labels.
-6. Head: a specific title tag and meta description that match the declared
- purpose above.
-7. Fix every defect at its root in the page's real source files and re-run the
- probe until clean. Defects in shared modules are in scope when this route
- exercises them.
-
-## Definition of done
-
-- [ ] Local load of /create/selfie: HTTP 200, zero console errors, zero unhandled
- failed requests (a third-party outage must land in a designed fallback,
- not a broken page).
-- [ ] No dead interactive element on the page: no stub href="#", no button
- without a handler, no link to a missing path.
-- [ ] Empty, loading, error, and populated states verified.
-- [ ] 320 / 768 / 1440 px renders verified clean.
-- [ ] Title and meta description present and specific.
-- [ ] npm test passes; npm run check:rules -- --paths <touched files> exits 0.
-- [ ] Production status from step 0 recorded in the report; if production
- needs a deploy to pick up a fix, the report says so (deploys stay
- owner-gated).
-
-## Never blocked
-
-| Blocker | Resolution (act, do not ask) |
-|---|---|
-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |
-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |
-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |
-| Playwright browser missing | npx playwright install chromium |
-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |
-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |
-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |
-
-## Close out (required)
-
-1. Verify every Definition of done line with the actual command output in
- front of you. Never claim a line you did not verify.
-2. Commit with explicit paths and a subject that describes the diff (house
- style: type(scope): what changed and why a reader cares).
-3. Delete this prompt file in that same commit:
-
- git rm prompts/swarm-100/route-create-selfie.md
-
- The shrinking directory is this campaign's only progress ledger; there is
- no progress log to update.
-4. Final report: what step 0 measured, what changed (file list), evidence per
- Definition of done line, and any one-line judgment calls. No trailing
- questions, no unexecuted plans.
-
-If a line genuinely cannot pass inside this session (an external party must
-respond, or an owner-gated action is the final step), finish everything else,
-leave this file in place, and state exactly which line remains and who owns
-it. Never delete this file on a partial.
diff --git a/prompts/swarm-100/route-skills.md b/prompts/swarm-100/route-skills.md
deleted file mode 100644
index 17a96fda5..000000000
--- a/prompts/swarm-100/route-skills.md
+++ /dev/null
@@ -1,119 +0,0 @@
-# Route audit: /skills (Skills Marketplace)
-
-How to run: paste this file's repo path into a fresh Claude Code chat in this
-repository and say "run this work order". This file is fully self-contained:
-it depends on no other prompt file anywhere. If neighboring files in
-prompts/swarm-100/ are gone, that work is done; if present, ignore them.
-Every claim below rots; step 0 re-measures, and what you measure wins.
-
-## Operating clause (binding)
-
-- Read CLAUDE.md first. Its rules override everything, including this file.
-- Finish 100% in this session. Never end the turn with a question, an option
- list, or an unexecuted plan. A judgment call goes in one line of the final
- report; it never becomes a question that halts work.
-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real
- funds or any irreversible on-chain write, git push or a production deploy,
- committing content that references a crypto project other than $THREE, and
- destroying unrecoverable data.
-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no
- commented-out code. Real APIs and real integrations only.
-- The em-dash and en-dash characters are banned in everything you write.
-- Concurrent agents share this worktree: stage explicit paths only (never a
- bare add-everything), and commit finished work promptly.
-- Before committing, run: npm run check:rules -- --paths <files you touched>.
- It must exit 0.
-
-## Step 0: re-derive the current state
-
-1. This route's declared entry (path, description, added date):
-
- node -e "const p=require('./data/pages.json');for(const s of p.sections)for(const g of s.pages)if(g.path==='/skills')console.log(JSON.stringify(g,null,2))"
-
-2. Find the serving implementation: grep "/skills" in vercel.json (the live
- route table server/index.mjs boots from), then list matching files in
- pages/ and src/. STRUCTURE.md maps every surface to its directory if the
- grep is ambiguous.
-3. Production right now:
-
- curl -so /dev/null -w '%{http_code}\n' https://three.ws/skills
-
-4. Start (or reuse) the local dev server: npm run dev (vite, port 3000).
-
-## Task: audit this one route end to end, then fix everything found
-
-Route: /skills ("Skills Marketplace", section "main").
-Declared purpose: Browse, search, and install agent skills: tool packs, knowledge bases, and capabilities that make AI agents smarter. Now lives inside the Marketplace; this path forwards there.
-
-Drive the page in a real headless browser. Playwright is already a dev
-dependency; keep your probe script in the session scratchpad, never in the
-repo.
-
-1. Load http://localhost:3000/skills. Record the HTTP status, every console
- error and warning, and every failed network request.
-2. Exercise it like a first-time user: click the primary actions, run the
- primary flow if one exists, follow the page's internal links. Every button
- must do something real; every link must resolve. If the page renders data,
- prove in the network log that it came from a live endpoint, not a baked-in
- fallback array.
-3. States: verify populated, empty, loading, and error states are designed and
- reachable. Block the page's primary fetch in Playwright and confirm an
- actionable error state appears, not a blank void or a raw exception.
-4. Responsive: render at 320, 768, and 1440 px. No horizontal page scroll, no
- overlapping or clipped controls.
-5. Accessibility basics: one h1; interactive elements are real buttons or
- links with visible focus states; images carry alt text; form fields have
- labels.
-6. Head: a specific title tag and meta description that match the declared
- purpose above.
-7. Fix every defect at its root in the page's real source files and re-run the
- probe until clean. Defects in shared modules are in scope when this route
- exercises them.
-
-## Definition of done
-
-- [ ] Local load of /skills: HTTP 200, zero console errors, zero unhandled
- failed requests (a third-party outage must land in a designed fallback,
- not a broken page).
-- [ ] No dead interactive element on the page: no stub href="#", no button
- without a handler, no link to a missing path.
-- [ ] Empty, loading, error, and populated states verified.
-- [ ] 320 / 768 / 1440 px renders verified clean.
-- [ ] Title and meta description present and specific.
-- [ ] npm test passes; npm run check:rules -- --paths <touched files> exits 0.
-- [ ] Production status from step 0 recorded in the report; if production
- needs a deploy to pick up a fix, the report says so (deploys stay
- owner-gated).
-
-## Never blocked
-
-| Blocker | Resolution (act, do not ask) |
-|---|---|
-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |
-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |
-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |
-| Playwright browser missing | npx playwright install chromium |
-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |
-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |
-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |
-
-## Close out (required)
-
-1. Verify every Definition of done line with the actual command output in
- front of you. Never claim a line you did not verify.
-2. Commit with explicit paths and a subject that describes the diff (house
- style: type(scope): what changed and why a reader cares).
-3. Delete this prompt file in that same commit:
-
- git rm prompts/swarm-100/route-skills.md
-
- The shrinking directory is this campaign's only progress ledger; there is
- no progress log to update.
-4. Final report: what step 0 measured, what changed (file list), evidence per
- Definition of done line, and any one-line judgment calls. No trailing
- questions, no unexecuted plans.
-
-If a line genuinely cannot pass inside this session (an external party must
-respond, or an owner-gated action is the final step), finish everything else,
-leave this file in place, and state exactly which line remains and who owns
-it. Never delete this file on a partial.
diff --git a/public/features.json b/public/features.json
index 8df1fdb93..26e0d12e5 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-08-17T05:33:50.722Z",
+ "generated_at": "2026-08-17T06:53:05.783Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/public/locales/en.json b/public/locales/en.json
index bc897d815..869421ba2 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -18108,10 +18108,13 @@
"x402_siwx_manual_test": "x402 SIWX — manual test"
},
"skills": {
- "meta_description": "Browse, discover, and install agent skills — tool packs, knowledge bases, and capabilities that make your AI agents smarter.",
+ "forward_body": "Every agent skill (tool packs, knowledge bases, and the capabilities that make AI agents smarter) is now browsable on the Marketplace Skills tab.",
+ "forward_cta": "Open the Skills Marketplace",
+ "forward_heading": "Skills moved into the Marketplace",
+ "meta_description": "Browse, search, and install agent skills: tool packs, knowledge bases, and capabilities that make AI agents smarter. Now lives inside the Marketplace; this path forwards there.",
"meta_og_description": "Browse, search, and install agent skills — tool packs, knowledge bases, and capabilities that make AI agents smarter.",
"meta_og_title": "Skills Marketplace · three.ws",
- "meta_title": "Skills · three.ws",
+ "meta_title": "Skills Marketplace · three.ws",
"meta_twitter_description": "Browse, search, and install agent skills — tool packs, knowledge bases, and capabilities that make AI agents smarter.",
"meta_twitter_title": "Skills Marketplace · three.ws"
},
diff --git a/src/marketplace.js b/src/marketplace.js
index 8a6be7cba..e16605943 100644
--- a/src/marketplace.js
+++ b/src/marketplace.js
@@ -187,6 +187,9 @@ const els = {
// readRoute and syncFilterToUrl agree on which strings are valid.
const LIST_FILTER_TABS = new Set(['agents', 'avatars', 'onchain']);
const SORT_VALUES = new Set(['recommended', 'recent', 'popular', 'top_rated']);
+// The Skills tab sorts server-side through /api/skills, which accepts its own,
+// shorter set. Kept next to SORT_VALUES so the two never drift into each other.
+const SKILL_SORT_VALUES = new Set(['popular', 'new', 'az']);
function readRoute() {
const m = location.pathname.match(/^\/marketplace\/agents\/([^/]+)/);
@@ -208,7 +211,14 @@ function readRoute() {
const sort = SORT_VALUES.has(params.get('sort')) ? params.get('sort') : null;
const pricing = params.get('pricing') === 'paid' || params.get('pricing') === 'free' ? params.get('pricing') : null;
if (tab === 'tools') return { view: 'tools', tag };
- if (tab === 'skills') return { view: 'skills', tag };
+ // The Skills tab owns q / category / sort as well as tag: the /skills shim
+ // forwards them and its own controls write them back, so they have to
+ // survive a reload and the back button like every other list view's do.
+ if (tab === 'skills') {
+ const category = (params.get('category') || '').trim().toLowerCase().slice(0, 50) || null;
+ const skillSort = SKILL_SORT_VALUES.has(params.get('sort')) ? params.get('sort') : null;
+ return { view: 'skills', tag, q, category, sort: skillSort };
+ }
if (tab === 'mine') return { view: 'mine', tag };
if (tab === 'purchases') return { view: 'purchases', tag };
if (tab === 'earn') return { view: 'earn', tag };
@@ -2287,10 +2297,59 @@ const skillsState = {
filter: 'all',
sort: 'popular',
category: null,
+ tag: null,
categories: [],
detailId: null,
};
+// Query params the Skills tab owns. Values equal to the default drop out of
+// the URL so a plain browse stays at /marketplace?tab=skills, and anything the
+// visitor actually chose survives a reload, a share, and the back button. The
+// /skills shim forwards this exact set.
+const SKILLS_URL_DEFAULTS = { q: '', category: '', tag: '', sort: 'popular' };
+
+function syncSkillsToUrl({ push = false } = {}) {
+ if (location.pathname !== '/marketplace') return;
+ syncStateToUrl(
+ {
+ tab: 'skills',
+ q: skillsState.q || '',
+ category: skillsState.category || '',
+ tag: skillsState.tag || '',
+ sort: skillsState.sort || 'popular',
+ },
+ SKILLS_URL_DEFAULTS,
+ { push },
+ );
+}
+
+// Pull the filters back off the URL when the Skills tab is (re)entered, so a
+// deep link, a tag pill, and the browser's back button all restore the same
+// view instead of silently showing an unfiltered list.
+function hydrateSkillsFromRoute(r) {
+ const nextQ = r.q || '';
+ const nextCategory = r.category || null;
+ const nextTag = r.tag || null;
+ const nextSort = r.sort || skillsState.sort;
+ const changed =
+ nextQ !== skillsState.q ||
+ nextCategory !== skillsState.category ||
+ nextTag !== skillsState.tag ||
+ nextSort !== skillsState.sort;
+ skillsState.q = nextQ;
+ skillsState.category = nextCategory;
+ skillsState.tag = nextTag;
+ skillsState.sort = nextSort;
+
+ const input = $('skills-search');
+ if (input && input.value !== nextQ) input.value = nextQ;
+ const sortSel = $('skills-sort');
+ if (sortSel && sortSel.value !== nextSort) sortSel.value = nextSort;
+ renderSkillCategoryChips();
+ renderSkillTagBanner();
+ return changed;
+}
+
async function loadSkillCategories() {
try {
const r = await fetch(`${API}/skills/categories`);
@@ -2306,10 +2365,11 @@ async function loadSkillCategories() {
function renderSkillCategoryChips() {
const wrap = $('skills-cat-chips');
if (!wrap) return;
- const all = `<button class="market-chip ${skillsState.category == null ? 'active' : ''}" data-skill-cat="">All</button>`;
+ const isAll = skillsState.category == null;
+ const all = `<button type="button" class="market-chip ${isAll ? 'active' : ''}" data-skill-cat="" aria-pressed="${isAll}">All</button>`;
const chips = skillsState.categories.map((c) => {
- const active = skillsState.category === c.slug ? 'active' : '';
- return `<button class="market-chip ${active}" data-skill-cat="${escapeHtml(c.slug)}">${escapeHtml(c.label)}<span class="chip-count">${c.count}</span></button>`;
+ const on = skillsState.category === c.slug;
+ return `<button type="button" class="market-chip ${on ? 'active' : ''}" data-skill-cat="${escapeHtml(c.slug)}" aria-pressed="${on}">${escapeHtml(c.label)}<span class="chip-count">${c.count}</span></button>`;
}).join('');
wrap.innerHTML = all + chips;
wrap.querySelectorAll('[data-skill-cat]').forEach((b) => {
@@ -2318,6 +2378,7 @@ function renderSkillCategoryChips() {
if (slug === skillsState.category) return;
skillsState.category = slug;
renderSkillCategoryChips();
+ syncSkillsToUrl({ push: true });
loadSkillsTab(true);
});
});
@@ -2341,6 +2402,7 @@ async function loadSkillsTab(force = false, append = false) {
url.searchParams.set('limit', '24');
if (skillsState.q) url.searchParams.set('q', skillsState.q);
if (skillsState.category) url.searchParams.set('category', skillsState.category);
+ if (skillsState.tag) url.searchParams.set('tag', skillsState.tag);
if (skillsState.sort) url.searchParams.set('sort', skillsState.sort);
if (append && skillsState.cursor) url.searchParams.set('cursor', skillsState.cursor);
@@ -2357,12 +2419,19 @@ async function loadSkillsTab(force = false, append = false) {
log.error('[marketplace] skills load', err);
if (grid && !append) {
grid.innerHTML = renderErrorState('skills');
+ grid.removeAttribute('aria-busy');
grid.querySelector('[data-empty-action="empty-retry"]')?.addEventListener('click', () => {
grid.setAttribute('aria-busy', 'true');
grid.innerHTML = renderSkeletons(8);
loadSkillsTab(true);
});
}
+ // The grid now holds the error state and its Retry button. Falling
+ // through to renderSkillsGrid() would immediately overwrite both with
+ // "No skills found", which reads as an empty catalog and offers no way
+ // back: the error state was unreachable until this return. The finally
+ // block below still clears the in-flight flags.
+ return;
} finally {
skillsState.loading = false;
skillsState.loadingMore = false;
@@ -2378,6 +2447,31 @@ function skillToolCount(s) {
return Array.isArray(s?.schema_json) ? s.schema_json.length : 0;
}
+// A tag filter arrives from a skill's tag pill, so the tab has to show that it
+// is filtered and offer the way out. Mirrors the discovery list's tag banner.
+function renderSkillTagBanner() {
+ const banner = $('skills-tag-banner');
+ if (!banner) return;
+ if (!skillsState.tag) {
+ banner.hidden = true;
+ banner.innerHTML = '';
+ return;
+ }
+ banner.hidden = false;
+ banner.innerHTML = `
+ <span class="market-tag-banner-label">Filtering by tag</span>
+ <span class="market-tag-banner-chip">
+ ${escapeHtml(skillsState.tag)}
+ <button class="market-tag-banner-clear" aria-label="Clear tag filter" type="button">✕</button>
+ </span>`;
+ banner.querySelector('.market-tag-banner-clear')?.addEventListener('click', () => {
+ skillsState.tag = null;
+ syncSkillsToUrl({ push: true });
+ renderSkillTagBanner();
+ loadSkillsTab(true);
+ });
+}
+
function renderSkillsGrid() {
const grid = $('skills-grid');
if (!grid) return;
@@ -2387,28 +2481,43 @@ function renderSkillsGrid() {
return true;
});
+ grid.removeAttribute('aria-busy');
+ renderSkillTagBanner();
+
const sub = $('skills-subtitle');
if (sub) {
const cat = skillsState.category
? (skillsState.categories.find((c) => c.slug === skillsState.category)?.label || skillsState.category)
: null;
const noun = filtered.length === 1 ? 'skill' : 'skills';
- sub.textContent = cat
- ? `${filtered.length} ${noun} in ${cat}${skillsState.cursor ? '+' : ''}`
- : `Browse ${filtered.length}${skillsState.cursor ? '+' : ''} ${noun} from the community`;
+ const more = skillsState.cursor ? '+' : '';
+ let text;
+ if (skillsState.tag) text = `${filtered.length}${more} ${noun} tagged #${skillsState.tag}`;
+ else if (cat) text = `${filtered.length} ${noun} in ${cat}${more}`;
+ else text = `Browse ${filtered.length}${more} ${noun} from the community`;
+ // The subtitle ships with a data-i18n placeholder so the pre-render copy
+ // is translated, but from here on it carries a live count. Without this
+ // the catalog pass that lands after /api/locale resolves reverts it to
+ // the placeholder, which is what shipped: the count never showed.
+ sub.setAttribute('data-i18n-owned', '1');
+ sub.textContent = text;
}
const loadMoreRow = $('skills-loadmore-row');
if (loadMoreRow) loadMoreRow.hidden = !skillsState.cursor;
if (!filtered.length) {
+ const bits = [];
+ if (skillsState.q) bits.push(`the search "${escapeHtml(skillsState.q)}"`);
+ if (skillsState.category) bits.push(`the ${escapeHtml(skillsState.category)} category`);
+ if (skillsState.tag) bits.push(`the tag #${escapeHtml(skillsState.tag)}`);
const msg = !skillsState.skills.length
? `<div class="market-empty-cta">
<h3>No skills found</h3>
- <p>Try a different category, clear your search, or publish your own skill.</p>
+ <p>${bits.length ? `Nothing published matches ${bits.join(' and ')} yet. Clear the filters, or publish the skill yourself.` : 'Nothing is published here yet. Be the first to publish a skill.'}</p>
<div class="market-empty-cta-actions">
- <button class="market-empty-cta-btn" id="skills-empty-clear">Clear filters</button>
- <button class="market-empty-cta-btn primary" id="skills-empty-publish">Publish a Skill</button>
+ ${bits.length ? '<button type="button" class="market-empty-cta-btn" id="skills-empty-clear">Clear filters</button>' : ''}
+ <button type="button" class="market-empty-cta-btn primary" id="skills-empty-publish">Publish a Skill</button>
</div>
</div>`
: '<div class="market-empty">No skills match your free/paid filter.</div>';
@@ -2416,12 +2525,16 @@ function renderSkillsGrid() {
$('skills-empty-clear')?.addEventListener('click', () => {
skillsState.q = '';
skillsState.category = null;
+ skillsState.tag = null;
skillsState.filter = 'all';
const input = $('skills-search'); if (input) input.value = '';
document.querySelectorAll('[data-skill-filter]').forEach((c) => {
- c.classList.toggle('active', c.dataset.skillFilter === 'all');
+ const on = c.dataset.skillFilter === 'all';
+ c.classList.toggle('active', on);
+ c.setAttribute('aria-selected', on ? 'true' : 'false');
});
renderSkillCategoryChips();
+ syncSkillsToUrl({ push: true });
loadSkillsTab(true);
});
$('skills-empty-publish')?.addEventListener('click', openSubmitModal);
@@ -4517,8 +4630,20 @@ function renderEmptyState() {
</div>`;
}
+// Every tab that can fail renders through here, so the label has to cover all
+// of them: the old ternary only knew avatars and onchain, which told a visitor
+// whose skills/animations/plugins fetch died that we "couldn't load agents".
+const ERROR_SCOPE_LABELS = {
+ agents: 'agents',
+ avatars: 'avatars',
+ onchain: 'onchain agents',
+ skills: 'skills',
+ animations: 'animations',
+ plugins: 'plugins',
+};
+
function renderErrorState(scope = 'agents') {
- const label = scope === 'avatars' ? 'avatars' : scope === 'onchain' ? 'onchain agents' : 'agents';
+ const label = ERROR_SCOPE_LABELS[scope] || ERROR_SCOPE_LABELS.agents;
return `<div class="tws-es tws-es--error" role="alert">
<div class="tws-es-icon tws-es-icon--err" aria-hidden="true"><svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="16" cy="16" r="14" stroke="currentColor" stroke-width="1.5" opacity=".35"/><path d="M16 9v8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="16" cy="22.5" r="1.25" fill="currentColor"/></svg></div>
<h3 class="tws-es-title">Couldn't load ${escapeHtml(label)}</h3>
@@ -6122,6 +6247,7 @@ function bindEvents() {
const next = e.target.value.trim();
if (next === skillsState.q) return;
skillsState.q = next;
+ syncSkillsToUrl();
loadSkillsTab(true);
}, 250);
});
@@ -6129,6 +6255,7 @@ function bindEvents() {
const next = e.target.value;
if (next === skillsState.sort) return;
skillsState.sort = next;
+ syncSkillsToUrl({ push: true });
loadSkillsTab(true);
});
$('skills-loadmore')?.addEventListener('click', () => {
@@ -6136,8 +6263,12 @@ function bindEvents() {
});
document.querySelectorAll('[data-skill-filter]').forEach((chip) => {
chip.addEventListener('click', () => {
- document.querySelectorAll('[data-skill-filter]').forEach((c) => c.classList.remove('active'));
+ document.querySelectorAll('[data-skill-filter]').forEach((c) => {
+ c.classList.remove('active');
+ c.setAttribute('aria-selected', 'false');
+ });
chip.classList.add('active');
+ chip.setAttribute('aria-selected', 'true');
skillsState.filter = chip.dataset.skillFilter;
renderSkillsGrid();
});
@@ -7991,7 +8122,9 @@ function render() {
setHidden(memorySec, true);
setHidden(avatarDetailSec, true);
setHidden(skillsSec, false);
- loadSkillsTab();
+ // A URL change (deep link, tag pill, back button) has to re-query, not
+ // replay the cached first page under the old filters.
+ loadSkillsTab(hydrateSkillsFromRoute(r));
} else if (r.view === 'mine') {
setHidden(detail, true);
setHidden(discovery, true);
diff --git a/src/selfie-pipeline.js b/src/selfie-pipeline.js
index d37fd6442..6cd38345c 100644
--- a/src/selfie-pipeline.js
+++ b/src/selfie-pipeline.js
@@ -339,15 +339,9 @@ async function pollUntilDone(jobId) {
return job;
}
if (job.status === 'failed') {
- // errorKind 'input' means the API already vetted this string as
- // caller-facing copy (a plan refusal, a worker's "no face detected").
- // Running it back through friendlyJobError's keyword match would
- // overwrite an exact reason with a guess, "your library is full"
- // becomes "try again with a clearer photo", which sends the user off
- // to retake a photo that was never the problem.
throw withMessage(
new Error(job.error || 'reconstruct failed'),
- job.errorKind === 'input' && job.error ? job.error : friendlyJobError(job.error),
+ friendlyJobError(job.error, job.errorKind),
inferFailingSlot(job.error),
);
}
@@ -392,9 +386,15 @@ function statusLabel(status, attempt, elapsedMs) {
return 'Processing...';
}
-/** @param {string | null | undefined} raw */
-function friendlyJobError(raw) {
- if (!raw) return 'Avatar reconstruction failed. Try clearer photos in better light.';
+/**
+ * Recognise a job error and phrase it as an instruction the user can act on.
+ * Returns null when nothing matched, so callers can decide what an unrecognised
+ * error deserves rather than being handed a guess dressed up as an answer.
+ * @param {string | null | undefined} raw
+ * @returns {string | null}
+ */
+function recogniseJobError(raw) {
+ if (!raw) return null;
const lower = raw.toLowerCase();
if (lower.includes('face') && lower.includes('detect'))
@@ -411,6 +411,28 @@ function friendlyJobError(raw) {
if (lower.includes('oom') || lower.includes('memory'))
return 'The engine ran out of resources. Try again with a simpler photo.';
+ return null;
+}
+
+/**
+ * Turn a failed job into the sentence the build screen shows.
+ *
+ * errorKind 'input' means the API vetted this string as caller-facing copy: a
+ * worker's "no face detected in any of the provided photos", or a plan refusal.
+ * Our own phrasing still wins wherever we recognise the fault, because it says
+ * what to do next. What changes is the unrecognised case: a caller-facing
+ * message is relayed rather than overwritten by the catch-all, which used to
+ * turn "your library is full" into "try again with a clearer photo" and send
+ * the user off to retake a photo that was never the problem.
+ *
+ * @param {string | null | undefined} raw
+ * @param {string | null | undefined} [errorKind]
+ */
+function friendlyJobError(raw, errorKind) {
+ const known = recogniseJobError(raw);
+ if (known) return known;
+ if (errorKind === 'input' && raw) return String(raw);
+ if (!raw) return 'Avatar reconstruction failed. Try clearer photos in better light.';
return 'Avatar reconstruction failed. Try again with a clearer photo.';
}
diff --git a/tests/api/skills-catalog.test.js b/tests/api/skills-catalog.test.js
index c567c3efe..6e8c17972 100644
--- a/tests/api/skills-catalog.test.js
+++ b/tests/api/skills-catalog.test.js
@@ -170,6 +170,44 @@ describe('GET /api/skills pagination', () => {
});
});
+// The marketplace renders a tag pill on every skill and links it back here.
+// Without a tag filter those pills navigated to an unfiltered list, so the
+// catalog answered a question nobody asked.
+describe('GET /api/skills?tag=', () => {
+ it('filters on an exact, case-insensitive tag match for every sort', async () => {
+ for (const sort of ['popular', 'new', 'az']) {
+ sqlState.calls = [];
+ sqlState.queue = [[skillRow({ tags: ['whale', 'analysis'] })]];
+
+ const r = await invoke(listHandler, { url: `/api/skills?tag=WHALE&sort=${sort}` });
+
+ expect(r.status).toBe(200);
+ expect(r.body.skills).toHaveLength(1);
+ const listQuery = sqlState.calls.at(-1);
+ expect(listQuery.query).toContain('unnest(ms.tags)');
+ // Lowercased before it reaches the query, so tags authored in any
+ // case still match the pill the visitor clicked.
+ expect(listQuery.values).toContain('whale');
+ }
+ });
+
+ it('leaves the tag predicate inert when no tag is asked for', async () => {
+ sqlState.queue = [[skillRow()]];
+
+ const r = await invoke(listHandler, { url: '/api/skills' });
+
+ expect(r.status).toBe(200);
+ expect(sqlState.calls.at(-1).values).toContain(null);
+ });
+
+ it('rejects a tag longer than any publishable tag before touching the database', async () => {
+ const r = await invoke(listHandler, { url: `/api/skills?tag=${'a'.repeat(41)}` });
+ expect(r.status).toBe(400);
+ expect(r.body.error).toBe('validation_error');
+ expect(sqlState.calls).toHaveLength(0);
+ });
+});
+
describe('POST /api/skills/:id/install', () => {
it('refuses a cookie-session install without a CSRF token', async () => {
authState.session = { id: USER, plan: 'free' };