Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to `markdown-pdf-export`. The format follows

## [Unreleased]

### Added

- `doctor` and `doctor --json` report the Markdown PDF Export plugin for Cursor (`plugin` on the Cursor entry, and a note next to Cursor's AI tools), and warn when the plugin and a `markdown-pdf` entry in `~/.cursor/mcp.json` are both there, since Cursor then lists the AI tools twice. `setup cursor` and Studio's **Add to my editor** say when the plugin is installed but still offer the `mcp.json` entry: Cursor keeps its copy of a plugin after uninstalling it, so the copy does not prove the plugin is on.

## [2.10.2] - 2026-11-27

### Changed
Expand Down
3 changes: 3 additions & 0 deletions cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
editorStatus,
launchSpec,
pendingItems,
setupNote,
} from "./lib/editor-setup.mjs";

const BIN = "markdown-pdf-export";
Expand Down Expand Up @@ -742,6 +743,8 @@ async function setupInteractive(setups, c) {
continue;
}
const what = todo.map((i) => ITEM_LABELS[i.kind]).join(" + ");
const note = setupNote(status[setup.id], todo);
if (note) out.write(` ${c.dim(note)}\n`);
const yes = await ask(`${c.cyan("?")} Set up ${c.bold(setup.name)} (${what})? ${c.dim("[Y/n]")} `);
if (aborted) {
out.write(`\n${c.yellow("Setup stopped.")}\n`);
Expand Down
8 changes: 8 additions & 0 deletions lib/__tests__/doctor-report.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ test("editors section: done, missing with fix, warnings, not found", () => {
assert.match(text, /only in some project folders/);
assert.match(text, /Not found: Cursor/);
});

test("editors section: Cursor plugin without the mcp.json entry", () => {
const text = formatEditors([
{ id: "cursor", name: "Cursor", detected: true, task: true, mcp: false, plugin: true, warnings: [] },
]);
assert.match(text, /AI tools not set up in mcp.json \(the plugin gives them in the folders where it is on\)/);
assert.match(text, /setup cursor --write/);
});
24 changes: 24 additions & 0 deletions lib/__tests__/editor-setup.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import os from "node:os";
import path from "node:path";

import {
CURSOR_PLUGIN_NAME,
EDITOR_IDS,
MCP_KEY,
SERVER_NAME,
Expand Down Expand Up @@ -281,6 +282,29 @@ describe("editorStatus", () => {
const setup = buildEditorSetup("cursor", NPX, { home, platform: "linux", env: {} });
assert.deepEqual(pendingItems(setup, s.cursor).map((i) => i.kind), ["mcp"]);
});

it("Cursor: reports the plugin, still offers the AI tools, and warns when both are there", () => {
const pluginDir = path.join(home, ".cursor", "plugins", "cache", "some-marketplace", CURSOR_PLUGIN_NAME, "8f3071b");
fs.mkdirSync(path.join(pluginDir, ".cursor-plugin"), { recursive: true });
fs.writeFileSync(path.join(pluginDir, ".cursor-plugin", "plugin.json"), JSON.stringify({ name: CURSOR_PLUGIN_NAME }));
let s = status();
assert.equal(s.cursor.plugin, true);
assert.equal(s.cursor.mcp, false);
assert.deepEqual(s.cursor.warnings, []);
const setup = buildEditorSetup("cursor", NPX, { home, platform: "linux", env: {} });
assert.deepEqual(pendingItems(setup, s.cursor).map((i) => i.kind), ["mcp"]);

fs.writeFileSync(path.join(home, ".cursor", "mcp.json"), JSON.stringify({ mcpServers: { [MCP_KEY]: {} } }));
s = status();
assert.equal(s.cursor.mcp, true);
assert.match(s.cursor.warnings[0], /plugin .* twice/);
});

it("Cursor: no plugin without its plugin.json", () => {
fs.rmSync(path.join(home, ".cursor", "plugins"), { recursive: true, force: true });
fs.mkdirSync(path.join(home, ".cursor", "plugins", "cache", "m", CURSOR_PLUGIN_NAME, "abc"), { recursive: true });
assert.equal(status().cursor.plugin, false);
});
});

describe("applySetupItem", () => {
Expand Down
16 changes: 16 additions & 0 deletions lib/__tests__/studio-server.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import http from "node:http";
import os from "node:os";
import path from "node:path";
import { previewReport, safeLogoName, startStudio } from "../studio-server.mjs";
import { CURSOR_PLUGIN_NAME, CURSOR_PLUGIN_NOTE } from "../editor-setup.mjs";

const PNG = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",
Expand Down Expand Up @@ -303,6 +304,21 @@ async function withFakeHome(fn) {
}
}

test("editors: Cursor plugin found, the AI tools are still offered with a note", async () => {
await withFakeHome(async (home) => {
const plugin = path.join(home, ".cursor", "plugins", "cache", "m", CURSOR_PLUGIN_NAME, "abc", ".cursor-plugin");
fs.mkdirSync(plugin, { recursive: true });
fs.writeFileSync(path.join(plugin, "plugin.json"), "{}");
await withStudio(async ({ call }) => {
const editors = await (await call("/api/editors")).json();
const cursor = editors.find((e) => e.id === "cursor");
assert.equal(cursor.note, CURSOR_PLUGIN_NOTE);
assert.equal(cursor.items.find((i) => i.kind === "mcp").pending, true);
assert.equal(editors.find((e) => e.id === "zed").note, null);
});
});
});

test("editors: steps are listed, applied once, then refused as already set up", async () => {
await withFakeHome(async () => {
await withStudio(async ({ call }) => {
Expand Down
4 changes: 3 additions & 1 deletion lib/doctor-report.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export function formatEditors(editors, bin = "markdown-pdf-export", style = plai
if (missing.length === 0) {
lines.push(` ${c.green("✓")} ${c.bold(e.name)}: ${label(done)}`);
} else {
const note = e.mcp === "project" ? " (only in some project folders)" : "";
let note = "";
if (e.mcp === "project") note = " (only in some project folders)";
else if (e.plugin && !e.mcp) note = " in mcp.json (the plugin gives them in the folders where it is on)";
lines.push(
` ${c.yellow("·")} ${c.bold(e.name)}: ${done.length ? `${label(done)} ${c.green("✓")}, ` : ""}` +
c.yellow(`${label(missing)} not set up${note}`),
Expand Down
51 changes: 50 additions & 1 deletion lib/editor-setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const MCP_KEY = "markdown-pdf";
export const TASK_LABEL = "Markdown: Export to PDF";
/** Id of the Zed extension (zed-markdown-pdf-export) that provides the MCP server. */
export const ZED_EXTENSION_ID = "markdown-pdf-export";
/** Name of the Cursor plugin (cursor-markdown-pdf-export) that provides the MCP server. */
export const CURSOR_PLUGIN_NAME = "markdown-pdf-export";
/** Shown by `setup` and Studio when the plugin is found and the AI tools are offered anyway. */
export const CURSOR_PLUGIN_NOTE =
"The Markdown PDF Export plugin is installed in Cursor: if it is on, it already gives the AI tools.";
/**
* Zed shortcut for the export task. Free in Zed's default keymaps on every
* platform; cmd/ctrl-shift-o would hide the outline (outline::Toggle).
Expand Down Expand Up @@ -416,6 +421,30 @@ const hasTask = (text) => text !== null && text.includes(SERVER_NAME);
const hasMcpKey = (text) => text !== null && text.includes(`"${MCP_KEY}"`);
const hasKey = (text) => text !== null && text.includes(TASK_LABEL);

/**
* Whether Cursor has a copy of the Markdown PDF Export plugin:
* ~/.cursor/plugins/cache/<marketplace>/<plugin>/<commit>/.cursor-plugin/plugin.json.
* Seen after a local install; the marketplace folder name of a Marketplace
* install is not known, hence any. The copy stays after the plugin is
* uninstalled, so this only informs: it never counts as the AI tools set up.
* @param {string} home
*/
function hasCursorPlugin(home) {
const cache = path.join(home, ".cursor", "plugins", "cache");
const list = (dir) => {
try {
return fs.readdirSync(dir);
} catch {
return [];
}
};
return list(cache).some((marketplace) =>
list(path.join(cache, marketplace, CURSOR_PLUGIN_NAME)).some((commit) =>
fs.existsSync(path.join(cache, marketplace, CURSOR_PLUGIN_NAME, commit, ".cursor-plugin", "plugin.json")),
),
);
}

/**
* Claude Code keeps user-scope servers at the top of ~/.claude.json and
* local-scope ones per project. "project" = only set up for some folders.
Expand All @@ -439,9 +468,11 @@ function claudeCodeMcp(file) {
* `task` / `mcp` / `key` are undefined when the editor has no such thing.
* Zed's MCP counts as set up when the Markdown PDF Export extension is
* installed: it provides the server, and a settings entry would replace it.
* Cursor's `plugin` only reports the Markdown PDF Export plugin: it may be on
* for some folders only, so `mcp` still means the ~/.cursor/mcp.json entry.
* `warnings` flags configs known to cause trouble (an old settings override).
* @param {{home?: string, platform?: string, env?: NodeJS.ProcessEnv}} [ctx]
* @returns {{id: string, name: string, detected: boolean, task?: boolean, mcp?: boolean|"project", key?: boolean, extension?: boolean, warnings: string[]}[]}
* @returns {{id: string, name: string, detected: boolean, task?: boolean, mcp?: boolean|"project", key?: boolean, extension?: boolean, plugin?: boolean, warnings: string[]}[]}
*/
export function editorStatus(ctx = {}) {
const home = ctx.home ?? os.homedir();
Expand All @@ -468,6 +499,14 @@ export function editorStatus(ctx = {}) {
out.mcp = hasMcpKey(
readText(id === "cursor" ? path.join(home, ".cursor", "mcp.json") : path.join(userDir, "mcp.json")),
);
if (id === "cursor") {
out.plugin = hasCursorPlugin(home);
if (out.plugin && out.mcp) {
out.warnings.push(
`if the Markdown PDF Export plugin is on in Cursor, the "${MCP_KEY}" entry in ~/.cursor/mcp.json gives the AI tools twice: keep one`,
);
}
}
break;
}
case "claude-code":
Expand All @@ -494,6 +533,16 @@ export function editorStatus(ctx = {}) {
});
}

/**
* A note to show before setting up an editor, or null: the Cursor plugin
* found while the AI tools are still offered.
* @param {{plugin?: boolean}|undefined} status
* @param {SetupItem[]} todo pendingItems() for that editor
*/
export function setupNote(status, todo) {
return status?.plugin && todo.some((item) => item.kind === "mcp") ? CURSOR_PLUGIN_NOTE : null;
}

/** What a setup item adds, in words. */
export const ITEM_LABELS = { task: "export task", key: "keyboard shortcut", mcp: "AI tools" };

Expand Down
5 changes: 4 additions & 1 deletion lib/studio-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
editorStatus,
launchSpec,
pendingItems,
setupNote,
} from "./editor-setup.mjs";
import { IMAGE_FORMATS } from "./types.mjs";

Expand Down Expand Up @@ -451,11 +452,13 @@ export async function startStudio(opts = {}) {
res,
200,
editors().map((e) => {
const todo = new Set(pendingItems(e, status[e.id]));
const pending = pendingItems(e, status[e.id]);
const todo = new Set(pending);
return {
id: e.id,
name: e.name,
detected: e.detected || Boolean(status[e.id]?.detected),
note: setupNote(status[e.id], pending),
items: e.items.map((i) => ({
kind: i.kind,
label: i.label,
Expand Down
2 changes: 2 additions & 0 deletions studio/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ async function openEditors() {
{ class: "editor" },
editor.detected ? el("p", { class: "found-note", text: `${editor.name} is on this computer.` }) : null,
EDITOR_NOTES[editor.id] ? el("p", { class: "editor-note", text: EDITOR_NOTES[editor.id] }) : null,
editor.note ? el("p", { class: "editor-note", text: editor.note }) : null,
...editor.items.map((item, index) => {
const result = el("div", { class: "result", role: "status" });
const copy = copyButton(item.snippet);
Expand Down Expand Up @@ -794,6 +795,7 @@ function quickSetup(found) {
toggle,
el("label", { for: id, class: "quick-name", text: editor.name }),
el("span", { class: "quick-what", text: what }),
editor.note ? el("p", { class: "quick-note", text: editor.note }) : null,
result,
);
return { row, toggle, editor, todo, result };
Expand Down
1 change: 1 addition & 0 deletions studio/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ dialog .hint { margin: 0 0 6px; }
.quick-what { color: var(--quiet); font-size: 13px; text-align: right; }
.quick-row.done .quick-what { color: var(--ok); }
.quick-row .tick { color: var(--ok); font-weight: 700; text-align: center; }
.quick-note { grid-column: 2 / -1; margin: 0; font-size: 13px; color: var(--quiet); }
.quick-result { grid-column: 2 / -1; }
.quick-result:empty { display: none; }
.quick-result p { margin: 4px 0 0; font-size: 13px; }
Expand Down
Loading