Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/cursor-listing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Cursor listing

# parser-test: runs on every PR that touches the probe. listing: daily and on demand, reads the live page.
on:
pull_request:
paths:
- ci/cursor-listing/**
- .github/workflows/cursor-listing.yml
schedule:
- cron: "17 6 * * *"
workflow_dispatch:

permissions:
contents: read

# bash (no -e flag form) runs with -eo pipefail, so a failing probe in a pipe to tee fails the step.
defaults:
run:
shell: bash

jobs:
parser-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Parser fixtures and positive controls
run: node --test ci/cursor-listing/probe.test.mjs

listing:
if: github.event_name != 'pull_request'
needs: parser-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Cursor marketplace listing is live
run: node ci/cursor-listing/probe.mjs --main-ref origin/main | tee -a "$GITHUB_STEP_SUMMARY"
4 changes: 4 additions & 0 deletions ci/cursor-listing/fixtures/listing-ok.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html><html><body>
<script nonce="x">self.__next_f.push([1,"0:[[\"$\",\"$L5a\",null,{\"pluginId\":\"5069\",\"initialPluginJson\":{\"id\":\"5069\",\"name\":\"clickup\",\"displayName\":\"ClickUp\",\"description\":\"Manage tasks, track time, and collaborate from your ClickUp workspace without switching context.\",\"status\":\"PLUGIN_STATUS_APPROVED\",\"repositoryUrl\":\"https://github.com/clickup/clickup-plugin\",\"tags\":[\"clickup\"],\"logoUrl\":\"https://cursor-cdn.com/plugin-logos/production/9e2e55107853e8ef.png\",\"isPublished\":true,\"createdAt\":\"1775516693089\",\"updatedAt\":\"1792446599476\",\"publisherId\":\"706\",\"publisher\":{\"id\":\"706\",\"name\":\"clickup\",\"displayName\":\"ClickUp\",\"isVerified\":true,\"logoUrl\":\"https://ptht05hbb1ssoooe.public.blob.vercel-storage.com/assets/uploads/clickup-logo.png\",\"websiteUrl\":\"https://clickup.com\"},\"marketplaceId\":\"34\",\"marketplace\":{\"id\":\"34\",\"name\":\"cursor-public\",\"displayName\":\"Cursor Plugin Marketplace\"},"])</script>
<script nonce="x">self.__next_f.push([1,"\"gitUrl\":\"https://github.com/clickup/clickup-plugin\",\"gitRef\":\"1f40631e03a8d3b393ad67a39eaae599fe9669c9\",\"gitPath\":\".\",\"fullRef\":\"clickup\",\"skills\":[],\"mcpServers\":[{\"name\":\"clickup\",\"sourcePath\":\".mcp.json\",\"sourceUrl\":\"https://github.com/clickup/clickup-plugin/blob/1f40631e03a8d3b393ad67a39eaae599fe9669c9/.mcp.json\"}],\"curatedCategoryKeys\":[\"PRODUCTIVITY\"],\"lifecycleState\":\"PLUGIN_LIFECYCLE_STATE_PUBLIC_LISTED\"},\"other\":{\"id\":\"11\",\"name\":\"other-plugin\",\"displayName\":\"Other\",\"status\":\"PLUGIN_STATUS_APPROVED\",\"repositoryUrl\":\"https://github.com/example/other-plugin\",\"isPublished\":true,\"gitRef\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"gitPath\":\".\",\"updatedAt\":\"1790000000000\"},\"fork\":{\"id\":\"12\",\"name\":\"clickup\",\"displayName\":\"ClickUp fork\",\"status\":\"PLUGIN_STATUS_PENDING\",\"repositoryUrl\":\"https://github.com/example/clickup-fork\",\"isPublished\":false,\"gitPath\":\".\"}}]]\n"])</script>
</body></html>
115 changes: 115 additions & 0 deletions ci/cursor-listing/probe.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Checks that the ClickUp plugin is live on the Cursor marketplace.
// Usage: node ci/cursor-listing/probe.mjs [--file page.html] [--main-ref origin/main]
// Without --file it fetches https://cursor.com/marketplace/clickup.
// Exit 0 when the clickup entry has status PLUGIN_STATUS_APPROVED, isPublished true and gitPath ".".
// Exit 1 with one FAIL line per assertion miss. gitRef, updatedAt and commits-behind-main are info only.
//
// The page is a Next.js page. Its data sits in self.__next_f.push([1,"..."]) script chunks.
// The page embeds about 40 plugins, so the entry is picked by name and repositoryUrl, never by the first isPublished.
import { readFile } from "node:fs/promises";
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";

export const LISTING_URL = "https://cursor.com/marketplace/clickup";
export const REPOSITORY_URL = "https://github.com/clickup/clickup-plugin";
export const EXPECTED = { status: "PLUGIN_STATUS_APPROVED", isPublished: true, gitPath: "." };

// Joins the string payload of every self.__next_f.push([1,"..."]) chunk. Chunks can split an object.
export function flightText(html) {
let text = "";
for (const match of html.matchAll(/self\.__next_f\.push\((\[1,"(?:[^"\\]|\\.)*"\])\)/g)) {
try {
text += JSON.parse(match[1])[1];
} catch {
// A chunk that does not parse cannot hold the entry; skip it.
}
}
return text;
}

// Returns the JSON object text that starts at text[start] === "{", or null. Respects strings and escapes.
function balancedObject(text, start) {
let depth = 0;
let inString = false;
for (let i = start; i < text.length; i += 1) {
const char = text[i];
if (inString) {
if (char === "\\") i += 1;
else if (char === '"') inString = false;
} else if (char === '"') inString = true;
else if (char === "{") depth += 1;
else if (char === "}" && --depth === 0) return text.slice(start, i + 1);
}
return null;
}

// Finds the plugin object with name "clickup" and our repositoryUrl. Returns null when there is none.
export function extractClickupEntry(html) {
const text = flightText(html);
for (const match of text.matchAll(/\{"id":"\d+","name":"clickup"/g)) {
const raw = balancedObject(text, match.index);
if (!raw) continue;
let entry;
try {
entry = JSON.parse(raw);
} catch {
continue;
}
if (entry.repositoryUrl === REPOSITORY_URL) return entry;
}
return null;
}

export function assertListing(entry) {
if (!entry) return [`no plugin entry with name "clickup" and repositoryUrl ${REPOSITORY_URL} on the page`];
const failures = [];
for (const [field, want] of Object.entries(EXPECTED)) {
if (entry[field] !== want) failures.push(`${field} is ${JSON.stringify(entry[field])}, want ${JSON.stringify(want)}`);
}
return failures;
}

export function commitsBehind(gitRef, mainRef) {
const run = spawnSync("git", ["rev-list", "--count", `${gitRef}..${mainRef}`], { encoding: "utf-8" });
return run.status === 0 ? run.stdout.trim() : null;
}

async function fetchPage(url) {
let lastError;
for (let attempt = 1; attempt <= 3; attempt += 1) {
try {
const response = await fetch(url, { headers: { "user-agent": "clickup-plugin-listing-probe" }, signal: AbortSignal.timeout(30_000) });
if (response.ok) return await response.text();
lastError = new Error(`GET ${url} returned ${response.status}`);
} catch (error) {
lastError = error;
}
}
throw lastError;
}

async function main(argv) {
const option = (name) => (argv.includes(name) ? argv[argv.indexOf(name) + 1] : undefined);
const file = option("--file");
const mainRef = option("--main-ref") ?? "origin/main";
const html = file ? await readFile(file, "utf-8") : await fetchPage(LISTING_URL);
const entry = extractClickupEntry(html);
const failures = assertListing(entry);
if (entry) {
const updated = Number.isFinite(Number(entry.updatedAt)) ? new Date(Number(entry.updatedAt)).toISOString() : "unknown";
const behind = typeof entry.gitRef === "string" ? commitsBehind(entry.gitRef, mainRef) : null;
console.log(`info gitRef=${entry.gitRef} updatedAt=${updated}`);
console.log(`info commits behind ${mainRef}: ${behind ?? "unknown (gitRef or ref not in this clone)"}`);
console.log(`info status=${entry.status} isPublished=${entry.isPublished} gitPath=${JSON.stringify(entry.gitPath)}`);
}
for (const failure of failures) console.error(`FAIL ${failure}`);
if (failures.length === 0) console.log("OK Cursor marketplace listing for clickup is live");
return failures.length === 0 ? 0 : 1;
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
process.exit(await main(process.argv.slice(2)).catch((error) => {
console.error(`FAIL could not read the listing: ${error.message}`);
return 1;
}));
}
79 changes: 79 additions & 0 deletions ci/cursor-listing/probe.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Fixture-driven test of the listing parser. Run: node --test ci/cursor-listing/
// listing-ok.html holds the clickup entry split across two flight chunks, plus a published and approved
// decoy plugin and a "clickup" fork with another repositoryUrl. Mutated copies are the positive controls:
// each one must fail the probe, and the decoys must not rescue it.
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
import { extractClickupEntry, assertListing } from "./probe.mjs";

const here = dirname(fileURLToPath(import.meta.url));
const fixture = await readFile(join(here, "fixtures", "listing-ok.html"), "utf-8");

// The clickup entry is the first object in the fixture, so the first match is the clickup field.
const mutate = (from, to) => {
assert.ok(fixture.includes(from), `fixture lacks ${from}`);
return fixture.replace(from, to);
};

test("the unmodified fixture passes", () => {
const entry = extractClickupEntry(fixture);
assert.equal(entry?.id, "5069");
assert.deepEqual(assertListing(entry), []);
});

test("the entry is scoped to clickup, not the first isPublished on the page", () => {
const entry = extractClickupEntry(fixture);
assert.equal(entry.repositoryUrl, "https://github.com/clickup/clickup-plugin");
assert.equal(entry.gitRef, "1f40631e03a8d3b393ad67a39eaae599fe9669c9");
});

const mutations = [
{ name: "status not approved", from: '\\"status\\":\\"PLUGIN_STATUS_APPROVED\\"', to: '\\"status\\":\\"PLUGIN_STATUS_PENDING\\"', message: "status" },
{ name: "not published", from: '\\"isPublished\\":true', to: '\\"isPublished\\":false', message: "isPublished" },
{ name: "wrong gitPath", from: '\\"gitPath\\":\\".\\"', to: '\\"gitPath\\":\\"plugins/clickup\\"', message: "gitPath" },
];
for (const { name, from, to, message } of mutations) {
test(`positive control: ${name} fails`, () => {
const failures = assertListing(extractClickupEntry(mutate(from, to)));
assert.equal(failures.length, 1);
assert.match(failures[0], new RegExp(message));
});
}

test("positive control: clickup entry removed fails even with approved decoys", () => {
const failures = assertListing(extractClickupEntry(mutate('\\"name\\":\\"clickup\\",\\"displayName\\":\\"ClickUp\\"', '\\"name\\":\\"gone\\",\\"displayName\\":\\"ClickUp\\"')));
assert.match(failures[0], /no plugin entry/);
});

test("CLI exit codes: ok fixture exits 0, mutated payload exits 1", async () => {
const { writeFile, mkdtemp } = await import("node:fs/promises");
const { tmpdir } = await import("node:os");
const dir = await mkdtemp(join(tmpdir(), "listing-"));
const bad = join(dir, "bad.html");
await writeFile(bad, mutate('\\"isPublished\\":true', '\\"isPublished\\":false'));
const probe = join(here, "probe.mjs");
const ok = spawnSync(process.execPath, [probe, "--file", join(here, "fixtures", "listing-ok.html")], { encoding: "utf-8" });
const fail = spawnSync(process.execPath, [probe, "--file", bad], { encoding: "utf-8" });
assert.equal(ok.status, 0);
assert.equal(fail.status, 1);
assert.match(fail.stderr, /FAIL isPublished is false, want true/);
});

test("the workflow sets shell: bash, so a pipe to tee keeps the probe exit code", async () => {
const { writeFile, mkdtemp, readFile: read } = await import("node:fs/promises");
const { tmpdir } = await import("node:os");
const workflow = await read(join(here, "..", "..", ".github", "workflows", "cursor-listing.yml"), "utf-8");
assert.match(workflow, /defaults:\s*\n\s+run:\s*\n\s+shell: bash\b/);
// GitHub runs `shell: bash` as `bash --noprofile --norc -eo pipefail {0}`. Same pipe as the listing step.
const dir = await mkdtemp(join(tmpdir(), "listing-"));
const bad = join(dir, "bad.html");
await writeFile(bad, mutate('\\"isPublished\\":true', '\\"isPublished\\":false'));
const probe = join(here, "probe.mjs");
const run = (flags) => spawnSync("bash", ["--noprofile", "--norc", ...flags, "-c", `node "${probe}" --file "${bad}" | tee /dev/null`], { encoding: "utf-8" });
assert.equal(run(["-eo", "pipefail"]).status, 1, "with pipefail the step must fail");
assert.equal(run(["-e"]).status, 0, "control: bash -e alone hides the failure, which is why pipefail is needed");
});
Loading