@commmerce/review 1.21.3 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -65
- package/bin/commmerce-review.mjs +3 -2
- package/lib/index.mjs +2 -9
- package/package.json +3 -9
- package/dist/components.json +0 -1
- package/lib/api.mjs +0 -91
- package/lib/browser.mjs +0 -37
- package/lib/check.mjs +0 -205
- package/lib/cli.mjs +0 -188
- package/lib/components-index.mjs +0 -76
- package/lib/components.mjs +0 -11
- package/lib/mcp-protocol.mjs +0 -90
- package/lib/shoot.mjs +0 -86
- package/lib/submit.mjs +0 -48
- package/lib/tools.mjs +0 -113
package/lib/mcp-protocol.mjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Minimal MCP server core (tools only), transport-agnostic. The same file is in the public repo
|
|
2
|
-
// (packages/review/lib/mcp-protocol.mjs): keep both copies identical.
|
|
3
|
-
//
|
|
4
|
-
// createMcp({ name, version, instructions, tools }) returns handle(message, ctx) -> response | null.
|
|
5
|
-
// A tool is { name, title?, description, inputSchema, annotations?, handler(args, ctx) }. The handler returns a string
|
|
6
|
-
// or a JSON-able value (sent as pretty-printed text); throwing returns the message as a tool error (isError: true), so
|
|
7
|
-
// the calling agent sees it and can correct itself.
|
|
8
|
-
|
|
9
|
-
export const PROTOCOL_VERSIONS = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05'];
|
|
10
|
-
|
|
11
|
-
export class ToolError extends Error {}
|
|
12
|
-
|
|
13
|
-
const rpcError = (id, code, message) => ({ jsonrpc: '2.0', id: id ?? null, error: { code, message } });
|
|
14
|
-
|
|
15
|
-
export function createMcp({ name, version, instructions, tools }) {
|
|
16
|
-
const byName = new Map(tools.map((t) => [t.name, t]));
|
|
17
|
-
|
|
18
|
-
async function one(msg, ctx) {
|
|
19
|
-
if (!msg || typeof msg !== 'object' || msg.jsonrpc !== '2.0') return rpcError(msg?.id, -32600, 'Invalid request');
|
|
20
|
-
const isRequest = msg.id !== undefined && msg.id !== null;
|
|
21
|
-
if (typeof msg.method !== 'string') return null; // a response from the client: nothing to answer
|
|
22
|
-
if (!isRequest) return null; // notifications (initialized, cancelled, ...)
|
|
23
|
-
const ok = (result) => ({ jsonrpc: '2.0', id: msg.id, result });
|
|
24
|
-
const params = msg.params ?? {};
|
|
25
|
-
switch (msg.method) {
|
|
26
|
-
case 'initialize': {
|
|
27
|
-
const asked = params.protocolVersion;
|
|
28
|
-
return ok({
|
|
29
|
-
protocolVersion: PROTOCOL_VERSIONS.includes(asked) ? asked : PROTOCOL_VERSIONS[0],
|
|
30
|
-
capabilities: { tools: { listChanged: false } },
|
|
31
|
-
serverInfo: { name, version },
|
|
32
|
-
instructions,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
case 'ping': return ok({});
|
|
36
|
-
case 'tools/list':
|
|
37
|
-
return ok({ tools: tools.map(({ name: n, title, description, inputSchema, annotations }) => ({ name: n, ...(title ? { title } : {}), description, inputSchema, ...(annotations ? { annotations } : {}) })) });
|
|
38
|
-
case 'tools/call': {
|
|
39
|
-
const tool = byName.get(params.name);
|
|
40
|
-
if (!tool) return rpcError(msg.id, -32602, `Unknown tool: ${params.name}`);
|
|
41
|
-
const args = params.arguments ?? {};
|
|
42
|
-
const missing = (tool.inputSchema.required ?? []).filter((k) => args[k] === undefined || args[k] === null || args[k] === '');
|
|
43
|
-
if (missing.length) return ok({ content: [{ type: 'text', text: `Missing required argument(s): ${missing.join(', ')}` }], isError: true });
|
|
44
|
-
try {
|
|
45
|
-
const out = await tool.handler(args, ctx);
|
|
46
|
-
return ok({ content: [{ type: 'text', text: typeof out === 'string' ? out : JSON.stringify(out, null, 2) }] });
|
|
47
|
-
} catch (e) {
|
|
48
|
-
return ok({ content: [{ type: 'text', text: e instanceof Error ? e.message : String(e) }], isError: true });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
default:
|
|
52
|
-
return rpcError(msg.id, -32601, `Method not found: ${msg.method}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return async function handle(msg, ctx = {}) {
|
|
57
|
-
if (Array.isArray(msg)) {
|
|
58
|
-
if (!msg.length) return rpcError(null, -32600, 'Invalid request');
|
|
59
|
-
const out = (await Promise.all(msg.map((m) => one(m, ctx)))).filter(Boolean);
|
|
60
|
-
return out.length ? out : null;
|
|
61
|
-
}
|
|
62
|
-
return one(msg, ctx);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Line-delimited JSON-RPC over stdin/stdout (the MCP stdio transport). Logs go to stderr only.
|
|
67
|
-
export function serveStdio(handle, { input = process.stdin, output = process.stdout, ctx = {} } = {}) {
|
|
68
|
-
// Requests run concurrently (a slow page check must not hold up a ping); each answer carries its request's id.
|
|
69
|
-
let buf = '';
|
|
70
|
-
const pending = new Set();
|
|
71
|
-
input.setEncoding('utf8');
|
|
72
|
-
input.on('data', (chunk) => {
|
|
73
|
-
buf += chunk;
|
|
74
|
-
let i;
|
|
75
|
-
while ((i = buf.indexOf('\n')) >= 0) {
|
|
76
|
-
const line = buf.slice(0, i).trim();
|
|
77
|
-
buf = buf.slice(i + 1);
|
|
78
|
-
if (!line) continue;
|
|
79
|
-
const p = (async () => {
|
|
80
|
-
let msg;
|
|
81
|
-
try { msg = JSON.parse(line); } catch { output.write(JSON.stringify(rpcError(null, -32700, 'Parse error')) + '\n'); return; }
|
|
82
|
-
const res = await handle(msg, ctx);
|
|
83
|
-
if (res) output.write(JSON.stringify(res) + '\n');
|
|
84
|
-
})();
|
|
85
|
-
pending.add(p);
|
|
86
|
-
p.finally(() => pending.delete(p));
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return new Promise((resolve) => input.on('end', () => Promise.all(pending).then(() => resolve())));
|
|
90
|
-
}
|
package/lib/shoot.mjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// Screenshots for `submit`, taken locally (so localhost works), and the personal-data scan of the visible text.
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { basename, extname } from 'node:path';
|
|
4
|
-
import { launchChromium, open } from './browser.mjs';
|
|
5
|
-
|
|
6
|
-
export const SHOT_WIDTHS = [390, 768, 1280];
|
|
7
|
-
const MAX_IMAGE = 4 * 1024 * 1024;
|
|
8
|
-
const MAX_HEIGHT = 6000;
|
|
9
|
-
|
|
10
|
-
// RFC 2606/6761 names are demo data by definition.
|
|
11
|
-
const DEMO_DOMAIN = /(^|\.)(example\.(com|org|net)|[a-z0-9-]+\.(example|test|invalid|localhost))$/i;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Emails and phone numbers in visible text. Demo addresses (example.com, *.test) are not reported.
|
|
15
|
-
* @param {string} text @returns {{ emails: string[], phones: string[] }}
|
|
16
|
-
*/
|
|
17
|
-
export function findPersonalData(text) {
|
|
18
|
-
const emails = [...new Set((text.match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi) ?? []).filter((e) => !DEMO_DOMAIN.test(e.split('@')[1])))];
|
|
19
|
-
const phones = [...new Set((text.match(/(?:\+\d{1,3}[\s.-]?)?(?:\(\d{2,5}\)[\s.-]?)?\d[\d\s.-]{7,14}\d/g) ?? [])
|
|
20
|
-
.map((p) => p.trim())
|
|
21
|
-
.filter((p) => { const d = p.replace(/\D/g, ''); return d.length >= 10 && d.length <= 13 && !/^(19|20)\d{2}[.-]\d{2}[.-]\d{2}/.test(p) && !/^\d{1,3}(,\d{3})+$/.test(p); }))];
|
|
22
|
-
return { emails, phones };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Mask all but the last 2 characters for display. @param {string} s */
|
|
26
|
-
export const mask = (s) => s.replace(/[^@\s+.-](?=.{2})/g, '•');
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {{ name: string, url: string }[]} screens
|
|
30
|
-
* @param {{ widths?: number[], browser?: import('playwright').Browser }} [opts]
|
|
31
|
-
*/
|
|
32
|
-
export async function shoot(screens, opts = {}) {
|
|
33
|
-
const widths = opts.widths ?? SHOT_WIDTHS;
|
|
34
|
-
const browser = opts.browser ?? await launchChromium();
|
|
35
|
-
/** @type {{ name: string, width: number, image: string, bytes: number }[]} */
|
|
36
|
-
const images = [];
|
|
37
|
-
let text = '';
|
|
38
|
-
/** @type {string | null} */
|
|
39
|
-
let uiVersion = null;
|
|
40
|
-
try {
|
|
41
|
-
for (const s of screens) {
|
|
42
|
-
for (const width of widths) {
|
|
43
|
-
const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: 'reduce' });
|
|
44
|
-
const page = await ctx.newPage();
|
|
45
|
-
const res = await open(page, s.url);
|
|
46
|
-
if (res && res.status() >= 400) throw new Error(`${s.url} answered HTTP ${res.status()}`);
|
|
47
|
-
const info = await page.evaluate(() => {
|
|
48
|
-
const u = [...document.querySelectorAll('script[src], link[href]')].map((e) => e.getAttribute('src') || e.getAttribute('href') || '');
|
|
49
|
-
let v = null;
|
|
50
|
-
for (const x of u) { const m = /commmerceui\/v\/(\d+\.\d+\.\d+[\w.-]*)\//.exec(x) || /@commmerce\/(?:ui|tokens)@(\d+\.\d+\.\d+[\w.-]*)/.exec(x); if (m) { v = m[1]; break; } }
|
|
51
|
-
return { text: document.body?.innerText ?? '', height: document.scrollingElement?.scrollHeight ?? 900, version: v };
|
|
52
|
-
});
|
|
53
|
-
text += `\n${info.text}`;
|
|
54
|
-
uiVersion ??= info.version;
|
|
55
|
-
const clip = info.height > MAX_HEIGHT ? { x: 0, y: 0, width, height: MAX_HEIGHT } : undefined;
|
|
56
|
-
let buf = await page.screenshot({ fullPage: true, clip, type: 'png' });
|
|
57
|
-
if (buf.length > MAX_IMAGE) buf = await page.screenshot({ fullPage: true, clip, type: 'jpeg', quality: 80 });
|
|
58
|
-
if (buf.length > MAX_IMAGE) buf = await page.screenshot({ fullPage: true, clip: { x: 0, y: 0, width, height: Math.min(info.height, 3000) }, type: 'jpeg', quality: 70 });
|
|
59
|
-
images.push({ name: s.name, width, image: buf.toString('base64'), bytes: buf.length });
|
|
60
|
-
await ctx.close();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} finally {
|
|
64
|
-
if (!opts.browser) await browser.close();
|
|
65
|
-
}
|
|
66
|
-
return { images, text, uiVersion };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Images given by path: `name@width=path`, `name=path` or just a path (name from the file, width read from the PNG,
|
|
71
|
-
* or 1280).
|
|
72
|
-
* @param {string[]} specs
|
|
73
|
-
*/
|
|
74
|
-
export function readImages(specs) {
|
|
75
|
-
return specs.map((spec) => {
|
|
76
|
-
const m = /^([^=@]+)(?:@(\d+))?=(.+)$/.exec(spec);
|
|
77
|
-
const path = m ? m[3] : spec;
|
|
78
|
-
const ext = extname(path).toLowerCase();
|
|
79
|
-
if (!['.png', '.jpg', '.jpeg', '.webp'].includes(ext)) throw new Error(`${path}: images must be PNG, JPEG or WebP`);
|
|
80
|
-
const buf = readFileSync(path);
|
|
81
|
-
if (buf.length > MAX_IMAGE) throw new Error(`${path} is over 4 MB`);
|
|
82
|
-
const pngWidth = ext === '.png' && buf.length > 24 ? buf.readUInt32BE(16) : 0;
|
|
83
|
-
const width = m?.[2] ? Number(m[2]) : (pngWidth >= 200 && pngWidth <= 5000 ? pngWidth : 1280);
|
|
84
|
-
return { name: m ? m[1] : basename(path, ext), width, image: buf.toString('base64'), bytes: buf.length };
|
|
85
|
-
});
|
|
86
|
-
}
|
package/lib/submit.mjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// Builds a review submission (shared by the CLI and the stdio MCP server's submit_review).
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { shoot, readImages, findPersonalData, SHOT_WIDTHS } from './shoot.mjs';
|
|
4
|
-
|
|
5
|
-
export const MAX_IMAGES = 12;
|
|
6
|
-
const MAX_SOURCE = 200 * 1024;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {{ app: string, url?: string, screens?: { name: string, path: string }[], images?: string[], questions?: string[],
|
|
10
|
-
* sourceFiles?: string[], resubmissionOf?: string, uiVersion?: string }} input
|
|
11
|
-
*/
|
|
12
|
-
export async function prepareSubmission(input) {
|
|
13
|
-
if (!input.app) throw new Error('app is required (your app or product name).');
|
|
14
|
-
/** @type {{ name: string, width: number, image: string, bytes: number }[]} */
|
|
15
|
-
let images = [];
|
|
16
|
-
let text = '';
|
|
17
|
-
let uiVersion = input.uiVersion ?? null;
|
|
18
|
-
const fromFiles = !!input.images?.length;
|
|
19
|
-
if (fromFiles) {
|
|
20
|
-
images = readImages(/** @type {string[]} */ (input.images));
|
|
21
|
-
} else {
|
|
22
|
-
if (!input.url) throw new Error('Give a url (screenshots are taken locally at 390, 768 and 1280px) or images.');
|
|
23
|
-
const screens = input.screens?.length
|
|
24
|
-
? input.screens.map((s) => ({ name: s.name, url: new URL(s.path, /** @type {string} */ (input.url)).href }))
|
|
25
|
-
: [{ name: 'page', url: input.url }];
|
|
26
|
-
if (screens.length * SHOT_WIDTHS.length > MAX_IMAGES) throw new Error(`At most ${MAX_IMAGES / SHOT_WIDTHS.length} screens per review (each is taken at ${SHOT_WIDTHS.join(', ')}px).`);
|
|
27
|
-
const shot = await shoot(screens);
|
|
28
|
-
images = shot.images; text = shot.text; uiVersion ??= shot.uiVersion;
|
|
29
|
-
}
|
|
30
|
-
if (images.length > MAX_IMAGES) throw new Error(`At most ${MAX_IMAGES} images per review.`);
|
|
31
|
-
const source_files = (input.sourceFiles ?? []).map((path) => ({ path, text: readFileSync(path, 'utf8') }));
|
|
32
|
-
const srcBytes = source_files.reduce((n, f) => n + Buffer.byteLength(f.text) + Buffer.byteLength(f.path), 0);
|
|
33
|
-
if (srcBytes > MAX_SOURCE) throw new Error('Source files are over 200 KB together: send only the screens\' markup.');
|
|
34
|
-
for (const f of source_files) text += `\n${f.text}`;
|
|
35
|
-
const personal = findPersonalData(text);
|
|
36
|
-
const body = {
|
|
37
|
-
app: input.app,
|
|
38
|
-
...(input.url && /^https?:\/\//.test(input.url) ? { url: input.url } : {}),
|
|
39
|
-
screens: images.map(({ name, width, image }) => ({ name, width, image })),
|
|
40
|
-
questions: input.questions ?? [],
|
|
41
|
-
...(uiVersion ? { ui_version: uiVersion } : {}),
|
|
42
|
-
...(source_files.length ? { source_files } : {}),
|
|
43
|
-
...(input.resubmissionOf ? { resubmission_of: input.resubmissionOf } : {}),
|
|
44
|
-
};
|
|
45
|
-
return { body, personal, fromFiles, summary: images.map((i) => `${i.name} @${i.width}px (${Math.round(i.bytes / 1024)} KB)`) };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const DEMO_DATA_RULE = 'Submissions must show demo data only: no real customer names, emails, phone numbers or addresses.';
|
package/lib/tools.mjs
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// The stdio MCP server's tools. The remote endpoint (https://commmerce.com/commmerceui/api/mcp) has the same tool names
|
|
2
|
-
// and arguments; there, check_page explains how to run it locally and submit_review takes base64 screenshots.
|
|
3
|
-
import { search, find } from './components-index.mjs';
|
|
4
|
-
import { components } from './components.mjs';
|
|
5
|
-
import { checkPage } from './check.mjs';
|
|
6
|
-
import { prepareSubmission, DEMO_DATA_RULE } from './submit.mjs';
|
|
7
|
-
import { mask } from './shoot.mjs';
|
|
8
|
-
|
|
9
|
-
export const INSTRUCTIONS = `Commmerce UI review tools. Commmerce UI is the design system for apps in the Commmerce admin (web components named cm-*).
|
|
10
|
-
Workflow:
|
|
11
|
-
1. BEFORE building or changing a screen, call search_components with what the screen needs, then get_component for each component you will use. Use cm-* components (with their attributes and slots) instead of native controls or custom CSS.
|
|
12
|
-
2. When a screen is done, run check_page on its URL (localhost works) and fix every blocker.
|
|
13
|
-
3. Then call submit_review (screenshots are taken locally at 390, 768 and 1280px; demo data only) and poll get_review until the status is done. Apply each finding's fix (the Commmerce UI way, with the docs link) and resubmit with resubmission_of.
|
|
14
|
-
4. Missing a component? request_component. Found a bug or have a suggestion? send_feedback.
|
|
15
|
-
PRIVATE: everything sent through these tools (or the feedback form, https://commmerce.com/commmerceui/#apps--feedback) is seen only by Commmerce and your team, never published; replies come back only to you (get_review, or the form's private status link). Screenshots and source are deleted 30 days after the item is done. Public GitHub issues are optional, only for someone who wants to report a library bug in public. No key yet? Ask the user for their work email, name and team, then call request_key: Commmerce emails the key with the command to add it.`;
|
|
16
|
-
|
|
17
|
-
export const ANON_TOOLS = ['search_components', 'get_component', 'check_page', 'request_key'];
|
|
18
|
-
export const ANON_INSTRUCTIONS = `Commmerce UI review tools, running without a key (COMMMERCE_REVIEW_KEY is not set). Commmerce UI is the design system for apps in the Commmerce admin (web components named cm-*).
|
|
19
|
-
Available now: search_components and get_component (look components up BEFORE building UI), check_page (local, nothing is sent), and request_key.
|
|
20
|
-
To send reviews and feedback the user needs a key: ask them for their work email, their name and their team (or app) name, then call request_key. Commmerce emails the key with the command to add it; it is never shown in this chat.`;
|
|
21
|
-
|
|
22
|
-
const COMPONENT_HINT = 'Always look components up before building UI: Commmerce UI has ready-made, accessible cm-* components, and reviews flag native controls or custom CSS where a cm-* component exists.';
|
|
23
|
-
|
|
24
|
-
/** @param {ReturnType<typeof import('./api.mjs').createClient>} client */
|
|
25
|
-
export function localTools(client) {
|
|
26
|
-
return [
|
|
27
|
-
{
|
|
28
|
-
name: 'search_components',
|
|
29
|
-
title: 'Search Commmerce UI components',
|
|
30
|
-
description: `Find Commmerce UI components for what you are building ("orders table with bulk actions", "date filter", "save bar"). Returns tag, name, summary and docs link. ${COMPONENT_HINT} Then call get_component for the full API.`,
|
|
31
|
-
inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'What the screen or control needs to do.' }, limit: { type: 'integer', minimum: 1, maximum: 30 } }, required: ['query'] },
|
|
32
|
-
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
33
|
-
handler: async (/** @type {any} */ { query, limit }) => ({ components: search(components(), query, limit ?? 8) }),
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: 'get_component',
|
|
37
|
-
title: 'Get a Commmerce UI component',
|
|
38
|
-
description: `Full reference for one component (tag like "cm-button", slug or name): attributes and properties, slots, events, methods, examples (HTML), do/don't, content and accessibility rules, docs link. Use it before writing markup for that component. ${COMPONENT_HINT}`,
|
|
39
|
-
inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Tag (cm-data-table), slug (data-table) or name (Data table).' } }, required: ['name'] },
|
|
40
|
-
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
41
|
-
handler: async (/** @type {any} */ { name }) => {
|
|
42
|
-
const c = find(components(), name);
|
|
43
|
-
if (!c) throw new Error(`No component "${name}". Closest: ${search(components(), name, 5).map((x) => x.tag).join(', ') || 'none'}. Use search_components.`);
|
|
44
|
-
return c;
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'request_key',
|
|
49
|
-
title: 'Request a review key',
|
|
50
|
-
description: 'Get a Commmerce UI review key for the user, by email. Ask the user for their work email, name and team (or app) name first: never guess them. Commmerce emails the key with the exact command to add it (it is never returned here). Work emails at commmerce.com or outdoinc.com get an internal key; others get a third-party key (10 reviews a day). Asking again for the same email and team replaces a key not yet delivered.',
|
|
51
|
-
inputSchema: { type: 'object', properties: { email: { type: 'string', description: "The user's work email address." }, name: { type: 'string', description: "The user's name." }, team: { type: 'string', description: 'Team or app name.' }, kind: { type: 'string', enum: ['internal', 'third-party'] } }, required: ['email', 'name', 'team'] },
|
|
52
|
-
handler: async (/** @type {any} */ a) => client.requestKey({ email: a.email, name: a.name, team: a.team, ...(a.kind ? { kind: a.kind } : {}) }),
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'check_page',
|
|
56
|
-
title: 'Check a page',
|
|
57
|
-
description: 'Deterministic checks of a running page, in a local headless Chromium (localhost works; nothing is sent anywhere): Commmerce UI present and its version, axe-core accessibility, sideways scroll at 320/390/768/1280px, text under 12px, targets under 24px, native controls where a cm-* component exists. Run it after building a screen and fix every blocker before submit_review. Needs Playwright in the project.',
|
|
58
|
-
inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'Page to check, e.g. http://localhost:5173/orders' }, widths: { type: 'array', items: { type: 'integer' } } }, required: ['url'] },
|
|
59
|
-
annotations: { readOnlyHint: true },
|
|
60
|
-
handler: async (/** @type {any} */ { url, widths }) => checkPage(url, { widths }),
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'submit_review',
|
|
64
|
-
title: 'Submit screens for review',
|
|
65
|
-
description: `Send finished screens to Commmerce for a PRIVATE design and code review against Commmerce UI (only Commmerce and your team see it; the result comes back only through get_review). Screenshots are taken locally at 390, 768 and 1280px from url (+ each screen path; localhost works), or pass image file paths. ${DEMO_DATA_RULE} If emails or phone numbers are visible the tool refuses: replace them with demo data, or ask the user to confirm they are fake and set confirm_demo_data. Returns an id: poll get_review until status is done, then apply the findings. On a resubmission pass resubmission_of with the previous id.`,
|
|
66
|
-
inputSchema: {
|
|
67
|
-
type: 'object',
|
|
68
|
-
properties: {
|
|
69
|
-
app: { type: 'string', description: 'App or product name.' },
|
|
70
|
-
url: { type: 'string', description: 'Base URL of the running app, e.g. http://localhost:5173' },
|
|
71
|
-
screens: { type: 'array', maxItems: 4, items: { type: 'object', properties: { name: { type: 'string' }, path: { type: 'string', description: 'Path relative to url, e.g. /orders' } }, required: ['name', 'path'] } },
|
|
72
|
-
images: { type: 'array', maxItems: 12, items: { type: 'string' }, description: 'Instead of url: image files, as "name@width=path" or a path.' },
|
|
73
|
-
questions: { type: 'array', items: { type: 'string' }, description: 'What you want the reviewer to look at.' },
|
|
74
|
-
source_files: { type: 'array', items: { type: 'string' }, description: 'Paths of the screens\' markup/code to include (200 KB max in total).' },
|
|
75
|
-
resubmission_of: { type: 'string', description: 'Id of the previous review of the same screens.' },
|
|
76
|
-
confirm_demo_data: { type: 'boolean', description: 'Set true only when the user confirmed the emails/phone numbers shown are fake.' },
|
|
77
|
-
},
|
|
78
|
-
required: ['app'],
|
|
79
|
-
},
|
|
80
|
-
handler: async (/** @type {any} */ a) => {
|
|
81
|
-
const prep = await prepareSubmission({ app: a.app, url: a.url, screens: a.screens, images: a.images, questions: a.questions, sourceFiles: a.source_files, resubmissionOf: a.resubmission_of });
|
|
82
|
-
const { emails, phones } = prep.personal;
|
|
83
|
-
if ((emails.length || phones.length) && a.confirm_demo_data !== true) {
|
|
84
|
-
throw new Error(`Not sent. ${DEMO_DATA_RULE} Visible on the page: ${[...emails, ...phones].slice(0, 8).map(mask).join(', ')}. Replace them with demo data (e.g. name@example.com), or ask the user to confirm they are fake and call again with confirm_demo_data: true.`);
|
|
85
|
-
}
|
|
86
|
-
const res = await client.submitReview(prep.body);
|
|
87
|
-
return { ...res, images: prep.summary, next: `Call get_review with id ${res.id} after ${res.poll_after_s}s.` };
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: 'get_review',
|
|
92
|
-
title: 'Get a review (or any submitted item)',
|
|
93
|
-
description: 'Status and result of something you submitted (review, component request or feedback) by id. A review is done when status is "done": then read verdict, summary and findings (each with severity, element, problem, fix in the Commmerce UI way, and a docs link). While queued or reviewing, wait poll_after_s seconds and call again.',
|
|
94
|
-
inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] },
|
|
95
|
-
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
96
|
-
handler: async (/** @type {any} */ { id }) => client.getItem(id),
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: 'request_component',
|
|
100
|
-
title: 'Request a component',
|
|
101
|
-
description: 'Ask Commmerce for a component Commmerce UI does not have yet. Search first (search_components). Describe the need, not the implementation; give an example (markup or a link) if you have one.',
|
|
102
|
-
inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Short name, e.g. "Kanban swimlanes".' }, need: { type: 'string', description: 'What the screen needs and why existing components fall short.' }, app: { type: 'string' }, example: { type: 'string' } }, required: ['name', 'need', 'app'] },
|
|
103
|
-
handler: async (/** @type {any} */ a) => client.requestComponent({ name: a.name, need: a.need, app: a.app, ...(a.example ? { example: a.example } : {}) }),
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: 'send_feedback',
|
|
107
|
-
title: 'Send feedback',
|
|
108
|
-
description: 'Report a Commmerce UI bug, suggest a refinement, or ask a question. Include steps, the component and version. Private: only Commmerce sees it and the reply comes back only to you (get_review). People can also use the private feedback form: https://commmerce.com/commmerceui/#apps--feedback.',
|
|
109
|
-
inputSchema: { type: 'object', properties: { kind: { type: 'string', enum: ['bug', 'refinement', 'question'] }, title: { type: 'string' }, body: { type: 'string' }, app: { type: 'string' } }, required: ['kind', 'title', 'body'] },
|
|
110
|
-
handler: async (/** @type {any} */ a) => client.sendFeedback({ kind: a.kind, title: a.title, body: a.body, ...(a.app ? { app: a.app } : {}) }),
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
|
-
}
|