sitezen-mcp 1.0.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 +107 -0
- package/dist/conversion-log.js +67 -0
- package/dist/conversion-rules.md +1361 -0
- package/dist/errors.js +37 -0
- package/dist/figma.js +1369 -0
- package/dist/index.js +37 -0
- package/dist/license.js +121 -0
- package/dist/normalize.js +692 -0
- package/dist/state.js +81 -0
- package/dist/tools-session.js +131 -0
- package/dist/tools.js +1378 -0
- package/dist/validate.js +114 -0
- package/dist/wp-client.js +130 -0
- package/package.json +35 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Structured error contract for the SiteZen MCP.
|
|
2
|
+
//
|
|
3
|
+
// EVERY tool that can fail returns one of:
|
|
4
|
+
// { ok: true, data: ... }
|
|
5
|
+
// { ok: false, error_code: "...", user_message: "...", what_to_do: "..." }
|
|
6
|
+
//
|
|
7
|
+
// Claude is instructed to surface `user_message` to the user verbatim and
|
|
8
|
+
// NEVER retry with guessed values. No silent fallbacks. No partial conversion.
|
|
9
|
+
//
|
|
10
|
+
// Adding a new failure mode? Add the code here, add a fail() helper if it
|
|
11
|
+
// takes parameters (so the message stays consistent across the codebase),
|
|
12
|
+
// document it in start_conversion's error_catalog so Claude knows what to do.
|
|
13
|
+
export function fail(code, user_message, what_to_do) {
|
|
14
|
+
return { ok: false, error_code: code, user_message, what_to_do };
|
|
15
|
+
}
|
|
16
|
+
// Helpers for the most common cases so call sites stay short and messages
|
|
17
|
+
// stay consistent. Add a new helper when a code is used in 2+ places.
|
|
18
|
+
export const Errors = {
|
|
19
|
+
noScreenshot: () => fail("NO_SCREENSHOT", "I can't see a section screenshot. Please attach a screenshot of the exact section you want me to convert, then send your message again.", "Attach the screenshot in the chat and resend."),
|
|
20
|
+
noFigmaUrl: () => fail("NO_FIGMA_URL", "I need the Figma URL of the design. Please paste it in the chat (e.g. https://www.figma.com/design/...).", "Paste the Figma URL and resend."),
|
|
21
|
+
noPageName: () => fail("NO_PAGE_NAME", "What should I name this page in WordPress?", "Tell me the page title."),
|
|
22
|
+
noSiteUrl: () => fail("NO_SITE_URL", "I don't know which WordPress site to push to. Please tell me the site URL (e.g. https://example.com).", "Share the site URL."),
|
|
23
|
+
noConnectionKey: (siteUrl) => fail("NO_CONNECTION_KEY", `I don't have a saved SiteZen connection key for ${siteUrl}. Please share the connection key — you can find it in WordPress under SiteZen → Connection.`, "Share the connection key for that site."),
|
|
24
|
+
noLicenseKey: () => fail("NO_LICENSE_KEY", "No SiteZen license key is set. Visit https://sitezen.io/pricing to grab one (the free plan is enough to start), then paste it into your claude_desktop_config.json as SITEZEN_LICENSE_KEY and restart Claude Desktop.", "Set SITEZEN_LICENSE_KEY in your Claude Desktop config, then restart."),
|
|
25
|
+
invalidLicense: () => fail("INVALID_LICENSE", "Your SiteZen license key isn't recognised. Check it for typos, or generate a fresh one at https://sitezen.io/dashboard.", "Update SITEZEN_LICENSE_KEY in the config and restart Claude Desktop."),
|
|
26
|
+
limitReachedConversions: (plan, upgradeUrl) => fail("LIMIT_REACHED_CONVERSIONS", `You've used all the conversions in your ${plan} plan. Upgrade at ${upgradeUrl} — your existing converted pages stay live.`, "Upgrade the plan to keep converting."),
|
|
27
|
+
limitReachedSites: (plan, sitesAllowed, upgradeUrl) => fail("LIMIT_REACHED_SITES", `Your ${plan} plan allows ${sitesAllowed} site(s) and you're already at the limit. Disconnect a site you no longer use (disconnect_site), or upgrade at ${upgradeUrl}.`, "Disconnect an existing site or upgrade the plan."),
|
|
28
|
+
noFigmaToken: () => fail("NO_FIGMA_TOKEN", "No Figma access token is set. Generate one at https://www.figma.com/developers/api#access-tokens, then paste it into your claude_desktop_config.json as FIGMA_TOKEN and restart Claude Desktop.", "Set FIGMA_TOKEN in your Claude Desktop config, then restart."),
|
|
29
|
+
siteUnreachable: (siteUrl) => fail("SITE_UNREACHABLE", `I can't reach ${siteUrl}. The site might be offline, the URL might be wrong, or your network might be blocking it.`, "Check the site is online and the URL is exactly right."),
|
|
30
|
+
invalidConnectionKey: (siteUrl) => fail("INVALID_CONNECTION_KEY", `The SiteZen connection key for ${siteUrl} isn't valid. Generate a fresh one in WordPress under SiteZen → Connection.`, "Get a fresh connection key and share it."),
|
|
31
|
+
figmaRateLimit: () => fail("FIGMA_RATE_LIMIT", "Figma is rate-limiting your token right now. Wait about 5 minutes and try the same prompt again — I won't lose your inputs.", "Wait 5 minutes and retry."),
|
|
32
|
+
figmaTokenInvalid: () => fail("FIGMA_TOKEN_INVALID", "Figma rejected your access token. It might have expired or been revoked. Generate a new one at https://www.figma.com/developers/api#access-tokens and update FIGMA_TOKEN in your config.", "Refresh FIGMA_TOKEN in the config and restart Claude Desktop."),
|
|
33
|
+
figmaNotFound: (figmaUrl) => fail("FIGMA_NOT_FOUND", `I can't find that Figma file or it's not shared with your token. Make sure ${figmaUrl} is accessible by the account whose token is in your config.`, "Check the Figma URL and the token's file access."),
|
|
34
|
+
sectionMatchUnclear: () => fail("SECTION_MATCH_UNCLEAR", "Your screenshot doesn't clearly match any section in the Figma file. Please share a clearer screenshot of just the one section you want — full width, no Figma editor chrome.", "Resend a higher-quality screenshot of one section."),
|
|
35
|
+
noSitesConnected: () => fail("NO_SITES_CONNECTED", "You haven't connected any WordPress sites yet. Tell me the site URL and connection key — I'll save them so you only have to share them once.", "Share site URL + connection key in the chat."),
|
|
36
|
+
siteNotFound: (siteUrl) => fail("SITE_NOT_FOUND", `I don't have ${siteUrl} saved. Connect it first by sharing the site URL and connection key.`, "Share the site URL and connection key."),
|
|
37
|
+
};
|