Wix Headless Replatform
WixOfficialPublished by Wix
- Skill
- Workflow
- Software development
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The wix-headless-replatform skill acts as a central supervisor for migrating or cloning a public website's home page into a Wix Headless environment. It enforces a structured, multi-stage process that includes browser-based extraction, build planning, implementation, and visual verification. The skill ensures visual fidelity, SEO preservation, and structural integrity by utilizing a frozen manifest approach, where every stage produces durable artifacts that inform the next. It supports both standalone cloning and integrated migration modes, with specific protocols for handling gaps and ensuring the final output is a functional Wix CLI project.
What it does
- Clones or migrates a public website home page to a Wix Headless frontend.
- Manages the end-to-end workflow through distinct stages: context, evidence, implementation, and verification.
- Uses browser-backed extraction to capture visual and structural data.
- Enforces strict visual fidelity and SEO preservation standards.
- Supports one-click automation for migration handoffs.
- Generates a final report and terminal receipt for migration completion.
When to use it
- When you need to clone a public website home page into a new Wix Headless project.
- When performing a migration of an existing site to a Wix Headless architecture.
- When you require a structured, verifiable process for rebuilding a frontend with high visual fidelity.
- When working within a migration handoff that provides specific project and data-binding intent.
Advantages
- Ensures consistent results through a rigid, stage-based supervisor protocol.
- Maintains high visual and functional fidelity to the source website.
- Provides a clear path for recovery and gap resolution during the build process.
- Automates the transition from extraction to a runnable Wix CLI scaffold.
Usage examples
- “Clone the home page of a website into a new Wix Headless project.”
- The agent initiates the standalone clone workflow, resolving the source URL and proceeding through the context and evidence stages to create a new Wix CLI project.
- “Migrate this website using the provided handoff file.”
- The agent enters migration mode, reads the handoff configuration, and continues the build process within the existing migration-owned project structure.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/wix/wix-headless-replatform-p46x/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip wix-headless-replatform.zip -d .agents/skills
Documentation by Wix
wix-headless-replatform
Role
Drive a close-enough, visually polished Wix Headless frontend from a source website.
The implemented scope is one resolved home page and the default output is
projects/<project-name>, derived from the hostname. Use Wix CLI Headless, Astro,
TypeScript, and Tailwind; use React only for complex interactive islands.
Reject additional-page and explicit-URL scope with an actionable explanation until a later
approved workflow defines page resolution and shared evidence across routes.
This entry skill is the supervisor. It decides the next workflow stage and loads only the resource for that stage. Do not preload every resource or reference: stage-specific rules are deliberately demand-loaded.
Two modes exist:
Standalone clone: source URL to a new, real Wix CLI Headless project.
Migration phase:
--handoff <migration-project>/website/handoff.jsoncontinues on the migration-owned destination. Never omit--handofffor an integrated migration: the standalone command creates a second site.
Non-negotiable invariants
Treat the requested public branded homepage as authorized; apply the boundaries in
references/safety.mdwithout asking a separate routine authorization question.Browser-backed extraction is mandatory. Do not substitute HTML-only extraction.
Resolve the home page before capture. Build only from a validated frozen extraction manifest; raw observations are never builder inputs.
A standalone output must be a successful Wix CLI scaffold with valid Wix identity and runnable
devandbuildscripts. Never hand-create a Wix-shaped substitute.In migration mode, reuse the handoff's site/project and route/data-binding intent; do not create or retarget a second destination.
Preserve source structure, first-viewport evidence, chrome hierarchy, source assets, fonts, core interactions, SEO, internal URL behavior, and branded fallback behavior.
A build is not completion. Completion requires the accepted post-build visual-review and gap-loop evidence described by
rp-qa-gap-loop, plus optional facelift acceptance only when the user explicitly selected facelift mode.
Supervisor protocol
On every new or resumed run:
Resolve the source URL, output directory, and mode. In migration mode read
website/handoff.jsonanddocs/site-clone/frontend-automation-state.jsonfirst.Select the first incomplete stage from the table below and read only that resource's
SKILL.mdplus the references it explicitly needs.Execute that stage until it writes its required durable artifact, or records a specific genuine blocker with evidence and an exact unblock action.
Re-select the stage after every boundary. Do not say that a required next step “needs to happen” and end the run; load its resource and perform it.
| Stage | Load only when | Resource | Durable outcome |
|---|---|---|---|
| Context | mode, scope, project, or browser environment is unresolved | resources/rp-project-context/SKILL.md | valid context, approval record, runnable project/plan state, or blocker |
| Evidence | frozen home-page extraction is absent or stale | resources/rp-source-evidence/SKILL.md | validated extraction/latest.json and frozen manifest, or global blocker |
| Implementation | frozen build plan exists and home UI is incomplete | resources/rp-ui-implementation/SKILL.md | manifest-hash-aware runnable home implementation |
| Verify and improve | build, QA, comparison, review, fix, report, release, or receipt is incomplete | resources/rp-qa-gap-loop/SKILL.md | accepted result, done_with_gaps, or global blocker |
| Optional facelift | normal clone accepted and automation state says facelift is requested | resources/rp-facelift/SKILL.md | accepted facelift review, or blocker |
When frontendPhase.allowedNow is plan, complete only the plan-eligible context and
evidence work and leave a resumable plan-state record. When it is build, continue through
implementation and verification against the migration-owned project.
One-click continuation
A migration handoff declaring automationMode: "one_click" authorizes routine scope and
frontend checkpoints. Record those approvals in
docs/site-clone/frontend-automation-state.json; do not pause to ask whether to proceed
with a required stage, screenshot review, or authorized gap-fix pass.
An explicit facelift request may be carried from 1-click intake, but it remains gated until
normal clone acceptance; 1-click never implies facelift by itself.
In a one-click build run, keep selecting and executing stages until one of these durable outcomes exists:
website/completion.jsonis valid and the latest visual review is complete with no open critical/high identity finding; orfive visual gap cycles have been completed and
website/completion.jsonrecords the truthful terminal statusdone_with_gapswith the final reviewed evidence; ora genuine blocker is recorded with owner, evidence, attempted recovery, and exact next authority/action needed.
An owned local extraction gap is not a genuine blocker. Continue unrelated work, use no more
than two distinct targeted recovery attempts, then build the affected dependency closure
provisionally and surface post-assembly choices in final-report.json and .md.
Before classifying a shell, browser, or network failure as a blocker, use the
repo-local Wix/Yarn toolchain PATH ordering and follow the recovery order in
resources/rp-project-context/SKILL.md: aligned-shell retry, then the
required browser/network escalation and retry, then blocker only if it still
fails or approval is pending. After every gap iteration, immediately return to
the stage table; never treat a first build, a reported plan, or backend import
as frontend completion.
In migration mode the build must also leave the final route manifest that old-link
preservation consumes (output-contract.md, "Migration terminal receipt"). A built site is
not proof that old URLs work; redirect application and public verification stay pending
until the cutover step runs them.
Commands
Run node scripts/site-clone.mjs <source-url> for standalone mode, or
node scripts/site-clone.mjs <source-url> --handoff <path> for migration mode. The active
resource gives the exact commands and inputs for its stage.
References
Resources load their own references. The shared contracts are kept under references/:
safety.md, workflow.md, extraction-schema.md, output-contract.md,
qa-checklist.md, and the interaction/layout/control/normalization/gap contracts.
Files
- .publish-manifest.json228 B
- ATTRIBUTION.mdAdded by AutoGineer833 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md6.7 KiB
- VERSION6 B
- agents/openai.yaml259 B
- references/control-and-visual-fidelity-contract.md2.1 KiB
- references/extraction-schema.md8.6 KiB
- references/interaction-runtime-contract.md5.5 KiB
- references/layout-blueprint-contract.md2.1 KiB
- references/output-contract.md5.0 KiB
- references/post-build-gap-contract.md5.5 KiB
- references/qa-checklist.md4.7 KiB
- references/safety.md1.0 KiB
- references/ui-normalization-contract.md2.8 KiB
- references/workflow.md8.5 KiB
- registry/README.md958 B
- registry/approvals/button/shadcn-default-ac60ef5.json980 B
- registry/items/button/shadcn-default-ac60ef5/button.tsxScript1.9 KiB
- registry/items/button/shadcn-default-ac60ef5/capabilities.json2.7 KiB
- registry/items/button/shadcn-default-ac60ef5/contract.md2.1 KiB
- registry/licenses/shadcn-ui-ac60ef5-MIT.txt1.0 KiB
- registry/registry.json1.4 KiB
- schemas/build-plan.schema.json628 B
- schemas/candidate.schema.json949 B
- schemas/common.schema.json1.2 KiB
- schemas/decision-patch.schema.json621 B
- schemas/decision-request.schema.json825 B
- schemas/extraction-gap.schema.json1.6 KiB
- schemas/extraction-manifest.schema.json1.6 KiB
- schemas/final-report.schema.json744 B
- schemas/foundation.schema.json950 B
- schemas/metadata.schema.json801 B
- schemas/observation-packet.schema.json661 B
- schemas/page-capture.schema.json1015 B
- schemas/page-resolution.schema.json1.4 KiB
- schemas/shared-chrome.schema.json940 B
- schemas/unit.schema.json1.8 KiB
- scripts/assemble-extraction.mjsScript36.1 KiB
- scripts/benchmark-extraction.mjsScript9.1 KiB
- scripts/browser-extraction-preflight.mjsScript1.2 KiB
- scripts/build-extracted-homepage.mjsScript17.1 KiB
- scripts/clear-wix-starter.mjsScript2.3 KiB
- scripts/create-wix-project.mjsScript17.7 KiB
- scripts/discover-urls.mjsScript4.4 KiB
- scripts/extract-assets.mjsScript4.6 KiB
- scripts/extract-design-system.mjsScript23.9 KiB
- scripts/extract-interactions.mjsScript83.5 KiB
- scripts/extract-page.mjsScript118.0 KiB
- scripts/extract-seo.mjsScript848 B
- scripts/extract-tokens.mjsScript2.6 KiB
- scripts/finalize-extraction-report.mjsScript6.4 KiB
- scripts/finalize-gap-review.mjsScript12.2 KiB
- scripts/finalize-gap-review.test.mjsScript5.3 KiB
- scripts/finalize-migration-website.mjsScript6.2 KiB
- scripts/generate-control-state-contract.mjsScript9.6 KiB
- scripts/generate-design-md.mjsScript11.7 KiB
- scripts/generate-extraction-validators.mjsScript5.4 KiB
- scripts/generate-invoice-download-backend.mjsScript16.5 KiB
- scripts/generate-layout-blueprint.mjsScript8.7 KiB
- scripts/generate-repeater-cms.mjsScript4.9 KiB
- scripts/generate-route-plan.mjsScript4.6 KiB
- scripts/generate-scene-contract.mjsScript16.2 KiB
- scripts/generate-ui-normalization.mjsScript13.3 KiB
- scripts/generate-visual-assets.mjsScript6.3 KiB
- scripts/lib/browser-tooling.mjsScript19.9 KiB
- scripts/lib/common.mjsScript9.0 KiB
- scripts/lib/component-capabilities.mjsScript7.9 KiB
- scripts/lib/component-registry.mjsScript15.7 KiB
- scripts/lib/content-boundary.mjsScript2.8 KiB
- scripts/lib/extraction-contract.mjsScript19.1 KiB
- scripts/lib/extraction-detectors.mjsScript11.4 KiB
- scripts/lib/extraction-validators.generated.mjsScript25.2 KiB
- scripts/lib/font-contract.mjsScript10.0 KiB
- scripts/lib/frontend-automation-state.mjsScript6.6 KiB
- scripts/lib/gap-analysis.mjsScript26.1 KiB
- scripts/lib/html-extract.mjsScript5.7 KiB
- scripts/lib/interaction-bootstrap.mjsScript296 B
- scripts/lib/interaction-runtime.mjsScript8.1 KiB
- scripts/lib/interaction-timeline.mjsScript13.9 KiB
- scripts/lib/layout-blueprint/classifiers.mjsScript7.8 KiB
- scripts/lib/layout-blueprint/geometry.mjsScript1.8 KiB
- scripts/lib/layout-blueprint/vocabulary.mjsScript872 B
- scripts/lib/playwright-request-guard.cjsScript2.4 KiB
- scripts/lib/ui-normalization.css1.5 KiB
- scripts/lib/url-safety.mjsScript6.8 KiB
- scripts/optimize-svg.mjsScript895 B
- scripts/post-build-gap.mjsScript16.5 KiB
- scripts/provision-repeater-cms.mjs2.8 KiB
- scripts/record-gap-decision.mjs2.3 KiB
- scripts/replay-extraction.mjs5.3 KiB
- scripts/resolve-home-page.mjs4.0 KiB
- scripts/site-clone.mjs35.8 KiB
- scripts/validate-font-contract.mjs1.3 KiB
- scripts/verify-interactions.mjs32.1 KiB
- scripts/visual-qa.mjs20.6 KiB
scripts/generate-invoice-download-backend.mjs
#!/usr/bin/env node
import { createRequire } from "node:module";
import path from "node:path";
import { parseArgs, readJson, resolveOutputDir, writeJson, writeText } from "./lib/common.mjs";
// Generates the server-side backend that hands a member their preserved invoice document: a pure
// handler, the Wix adapters that give it real data, and the route that wires them together.
//
// This is the one place the invoice feature can leak BETWEEN customers, so the shape is not
// negotiable: the handler accepts an ORDER id and nothing else, checks that the calling member
// can read that order, and resolves the private file id server-side. If it accepted a file id
// from the client, any member could ask for another member's tax invoice by guessing or
// harvesting one — and an invoice carries a name, an address and a purchase history.
//
// The preserved document is a PRIVATE Media file, so it is not reachable by URL without a
// generated download link. That link is minted per request with an explicit short expiry: the
// API's own default is 600 minutes, which is not short-lived for a tax document.
//
// The field names are read from the migration's own contract at GENERATION time rather than
// written out here. Two copies of a field name is exactly the drift the contract adapter exists
// to prevent, and this generator is the third consumer of it.
const require = createRequire(import.meta.url);
const invoiceContract = require("../../wix-replatform/resources/rp-target-wix/lib/order-invoice-contract.js");
// The scaffold ships @wix/sdk, @wix/astro and @wix/essentials, and nothing else. Without these
// the generated route imports modules that are not installed and the build fails — which is
// better than the previous behaviour, where it built fine and answered 401 forever.
export const REQUIRED_DEPENDENCIES = Object.freeze({
"@wix/ecom": "^1.0.0",
"@wix/media": "^1.0.0",
"@wix/members": "^1.0.0",
"@wix/essentials": "^1.0.6",
});
function handlerSource({ fileIdField, numberField, contractVersion }) {
return `// GENERATED by generate-invoice-download-backend.mjs — do not edit by hand.
// Field names generated from order-invoice contract ${contractVersion}.
//
// Hands a signed-in member a short-lived download link for the invoice document preserved on one
// of THEIR orders.
//
// The security contract, in order:
// 1. A client-supplied file id is REJECTED outright. The client names an order; the server
// resolves the file. Accepting a file id would let any member fetch any member's invoice.
// 2. The member must be authenticated.
// 3. The order must be readable BY THAT MEMBER. Order scoping is the authorization boundary.
// 4. The file id is read from the order's own extended fields, server-side.
// 5. The download URL is minted with an explicit short expiry and is never logged.
export const INVOICE_FILE_FIELD = ${JSON.stringify(fileIdField)};
export const INVOICE_NUMBER_FIELD = ${JSON.stringify(numberField)};
export const DOWNLOAD_EXPIRY_MINUTES = 10;
export function createInvoiceDownloadHandler({ getMemberId, getOrderForMember, generateDownloadUrl }) {
if (typeof getMemberId !== "function") throw new Error("getMemberId is required");
if (typeof getOrderForMember !== "function") throw new Error("getOrderForMember is required");
if (typeof generateDownloadUrl !== "function") throw new Error("generateDownloadUrl is required");
return async function handleInvoiceDownload(request = {}) {
try {
return await respond(request);
} catch (error) {
// A dependency being down is not a refusal. Reported without detail — the member learns
// nothing about the order either way — but with a status a client may retry and monitoring
// can tell apart from a denial.
if (error && error.transient === true) return { status: 503, error: "service-temporarily-unavailable" };
throw error;
}
};
async function respond(request) {
const body = request.body && typeof request.body === "object" ? request.body : {};
// 1. The client may not name a file. Any attempt is refused rather than ignored, so a
// misbuilt caller fails loudly instead of silently working for the wrong reason.
for (const forbidden of ["fileId", "file_id", "fileID", "mediaId", "media_id"]) {
if (Object.prototype.hasOwnProperty.call(body, forbidden)) {
return { status: 400, error: "client-supplied-file-id-rejected" };
}
}
const orderId = typeof body.orderId === "string" ? body.orderId.trim() : "";
if (!orderId) return { status: 400, error: "order-id-required" };
// 2. Authentication.
const memberId = await getMemberId(request);
if (!memberId) return { status: 401, error: "authentication-required" };
// 3. Authorization is the order read: if this member cannot read this order, there is nothing
// to talk about. Never fall back to an unscoped order read.
const order = await getOrderForMember({ orderId, memberId });
if (!order) return { status: 403, error: "order-not-readable-by-member" };
// 4. Resolve the file server-side.
const namespaces = (order.extendedFields && order.extendedFields.namespaces) || {};
const fields = namespaces._user_fields || {};
const fileId = typeof fields[INVOICE_FILE_FIELD] === "string" ? fields[INVOICE_FILE_FIELD].trim() : "";
if (!fileId) return { status: 404, error: "no-preserved-invoice-for-order" };
// 5. Mint a short-lived link. The URL is returned to the caller and never logged.
const url = await generateDownloadUrl({ fileId, expirationInMinutes: DOWNLOAD_EXPIRY_MINUTES });
if (!url) return { status: 502, error: "download-url-unavailable" };
return {
status: 200,
url,
expiresInMinutes: DOWNLOAD_EXPIRY_MINUTES,
// The invoice number is the merchant's own reference and is safe to show. The file id is
// internal and is deliberately not echoed.
invoiceNumber: typeof fields[INVOICE_NUMBER_FIELD] === "string" ? fields[INVOICE_NUMBER_FIELD] : null,
};
}
}
`;
}
// The authorization logic, with no Wix import in it. Split out from the adapters deliberately:
// a module that statically imports @wix/ecom cannot be loaded by a test without the whole SDK
// installed, and "we could not test it" is how the previous version of this backend shipped a
// seam that answered 401 to everything. What is left in the adapters file is wiring with no
// branches in it.
const AUTHORIZATION_SOURCE = `// GENERATED by generate-invoice-download-backend.mjs — do not edit by hand.
//
// Who may download which invoice. No Wix imports here on purpose, so this file can be run and
// tested on its own; the adapters supply the four functions that talk to Wix.
//
// Two facts shape it, both from the API docs rather than assumed:
//
// 1. Get Order called with a MEMBER's identity returns the order only if that member placed it.
// That check is Wix's, not ours, and it is the authorization boundary.
// 2. The migration's invoice fields are declared readable by \`apps\` and \`users\` — deliberately
// NOT by \`users-of-users\`, because they are merchant data. So the member-identity read that
// proves ownership does NOT return the field values, and a second, elevated read is needed
// to get them.
//
// So ownership is established by the unelevated read, and only then is anything elevated. The
// rule is then checked a SECOND time, by us, against the elevated order's buyerInfo.
//
// Be precise about what that second check is worth. It is a second IMPLEMENTATION, not a second
// source of evidence: both it and Wix's check rest on the same stored \`buyerInfo.memberId\`. It
// catches an elevated read that answers about the wrong order, or a change in what elevation
// returns. It does NOT catch an order attributed to the wrong member in the first place -- if the
// import writes Alice's order with Bob's memberId, both checks agree and Bob gets Alice's
// invoice. Correct \`buyerInfo.memberId\` on imported orders is a PREREQUISITE of this feature,
// not something it can verify. An order carrying no memberId fails closed.
// The SDK renames \`id\` to \`_id\`. Read both rather than pick one and be wrong on a version bump.
export function orderIdOf(order) {
if (!order || typeof order !== "object") return null;
const value = order._id ?? order.id;
return typeof value === "string" && value.length > 0 ? value : null;
}
// Not every failure is a refusal. Collapsing them told a member "you are not allowed" during a
// Wix outage, and left monitoring unable to tell a denial from a dependency being down.
//
// The Wix SDK throws \`SDKError\` carrying \`response.status\`. A 401, 403 or 404 is a real answer
// to the question asked, and becomes \`null\` — indistinguishable, on purpose, so a prober cannot
// learn from the difference between "not yours" and "does not exist". Anything else, including a
// 5xx and a network error with no status at all, is us failing rather than the caller being
// refused, and is raised so the route can say so.
const DENIAL_STATUSES = new Set([401, 403, 404]);
export class InvoiceBackendUnavailable extends Error {
constructor(status) {
super(\`the invoice backend could not reach Wix (status \${status ?? "unknown"})\`);
this.name = "InvoiceBackendUnavailable";
this.transient = true;
this.status = status ?? null;
}
}
async function orNull(operation) {
try {
return (await operation()) ?? null;
} catch (error) {
const status = error && error.response && error.response.status;
if (DENIAL_STATUSES.has(status)) return null;
throw new InvoiceBackendUnavailable(status);
}
}
export function createInvoiceAdapters({
getCurrentMember,
getOrderAsCaller,
getOrderElevated,
generateDownloadUrlElevated,
}) {
for (const [name, fn] of Object.entries({ getCurrentMember, getOrderAsCaller, getOrderElevated, generateDownloadUrlElevated })) {
if (typeof fn !== "function") throw new Error(\`\${name} is required\`);
}
return {
async getMemberId() {
// \`getCurrentMember()\` resolves to \`{ member }\`, NOT to the member. The docs example shows
// a bare member object and is wrong; the published type is
// \`Promise<GetMyMemberResponse>\` with \`member?: Member\`. Reading \`_id\` off the response
// made every signed-in member resolve as anonymous, so the route answered 401 to everyone
// — the same failure as the \`locals\` seam it replaced, one layer in.
//
// Both shapes are accepted: the wrapper is what ships, the bare member is what the docs
// promise, and being wrong about which one arrives must not lock members out again.
const response = await orNull(getCurrentMember);
const member = (response && response.member) || response;
const id = member && (member._id ?? member.id);
return typeof id === "string" && id.length > 0 ? id : null;
},
async getOrderForMember({ orderId, memberId }) {
if (typeof orderId !== "string" || orderId.length === 0) return null;
if (typeof memberId !== "string" || memberId.length === 0) return null;
// 1. Wix's check. Nothing is elevated until this passes.
const asCaller = await orNull(() => getOrderAsCaller(orderId));
if (!asCaller || orderIdOf(asCaller) !== orderId) return null;
// 2. Our own read, elevated, because the fields are not member-readable.
const elevated = await orNull(() => getOrderElevated(orderId));
if (!elevated || orderIdOf(elevated) !== orderId) return null;
// 3. Our check, independent of Wix's. An order whose buyer is not this member is not this
// member's order, and an order with no member buyer at all belongs to nobody who can ask
// for it here. Email is never accepted as proof: it is changeable and guessable.
const buyerMemberId = elevated.buyerInfo && elevated.buyerInfo.memberId;
if (typeof buyerMemberId !== "string" || buyerMemberId !== memberId) return null;
return elevated;
},
async generateDownloadUrl({ fileId, expirationInMinutes }) {
if (typeof fileId !== "string" || fileId.length === 0) return null;
const result = await orNull(() => generateDownloadUrlElevated(fileId, { expirationInMinutes }));
const first = result && Array.isArray(result.downloadUrls) ? result.downloadUrls[0] : null;
const url = first && first.url;
return typeof url === "string" && url.length > 0 ? url : null;
},
};
}
`;
const ADAPTERS_SOURCE = `// GENERATED by generate-invoice-download-backend.mjs — do not edit by hand.
//
// Wiring only. Every decision lives in invoice-download-authorization.mjs; this file exists to
// name the four Wix calls, and there is deliberately no logic in it to get wrong.
import { members } from "@wix/members";
import { orders } from "@wix/ecom";
import { files } from "@wix/media";
import { auth } from "@wix/essentials";
import { createInvoiceAdapters } from "./invoice-download-authorization.mjs";
export const wixInvoiceAdapters = createInvoiceAdapters({
getCurrentMember: () => members.getCurrentMember(),
// Unelevated ON PURPOSE. This call running as the caller is the whole authorization mechanism.
getOrderAsCaller: (id) => orders.getOrder(id),
getOrderElevated: (id) => auth.elevate(orders.getOrder)(id),
generateDownloadUrlElevated: (fileId, options) => auth.elevate(files.generateFileDownloadUrl)(fileId, options),
});
`;
const ROUTE_SOURCE = `// GENERATED by generate-invoice-download-backend.mjs — do not edit by hand.
//
// Thin transport wrapper. All authorization lives in the handler and the adapters; this file only
// moves JSON.
import { createInvoiceDownloadHandler } from "../../lib/invoice-download.mjs";
import { wixInvoiceAdapters } from "../../lib/invoice-download-adapters.mjs";
const handler = createInvoiceDownloadHandler(wixInvoiceAdapters);
export async function POST({ request }) {
let body = {};
try {
body = await request.json();
} catch {
return new Response(JSON.stringify({ error: "invalid-json" }), { status: 400, headers: { "content-type": "application/json" } });
}
const result = await handler({ body });
const { status, ...payload } = result;
return new Response(JSON.stringify(payload), { status, headers: { "content-type": "application/json" } });
}
`;
export function buildHandlerSource() {
return handlerSource({
fileIdField: invoiceContract.ROLES.fileId,
numberField: invoiceContract.ROLES.number,
contractVersion: invoiceContract.version(),
});
}
// Adds what the generated route imports. Merges rather than overwrites: the scaffold owns its own
// versions, and a project that already pins one of these keeps its pin.
export async function ensureInvoiceDependencies({ outputDir }) {
const packagePath = path.join(outputDir, "package.json");
let manifest;
try {
manifest = await readJson(packagePath);
} catch {
return { packagePath, added: [], skipped: "no package.json at the output dir" };
}
const dependencies = manifest.dependencies || {};
const added = [];
for (const [name, version] of Object.entries(REQUIRED_DEPENDENCIES)) {
if (!dependencies[name]) {
dependencies[name] = version;
added.push(name);
}
}
if (added.length === 0) return { packagePath, added };
manifest.dependencies = dependencies;
await writeJson(packagePath, manifest);
return { packagePath, added };
}
export async function generateInvoiceDownloadBackend({ outputDir }) {
const handlerPath = path.join(outputDir, "src", "lib", "invoice-download.mjs");
const authorizationPath = path.join(outputDir, "src", "lib", "invoice-download-authorization.mjs");
const adaptersPath = path.join(outputDir, "src", "lib", "invoice-download-adapters.mjs");
const routePath = path.join(outputDir, "src", "pages", "api", "invoice-download.mjs");
await writeText(handlerPath, HANDLER_SOURCE);
await writeText(authorizationPath, AUTHORIZATION_SOURCE);
await writeText(adaptersPath, ADAPTERS_SOURCE);
await writeText(routePath, ROUTE_SOURCE);
const dependencies = await ensureInvoiceDependencies({ outputDir });
return { handlerPath, authorizationPath, adaptersPath, routePath, dependencies };
}
async function main() {
const args = parseArgs();
const outputDir = resolveOutputDir(args._[0] || args.url, args.out);
const written = await generateInvoiceDownloadBackend({ outputDir });
if (args.json) process.stdout.write(`${JSON.stringify(written, null, 2)}\n`);
}
// Computed once so consumers -- the tests included -- read exactly the bytes that get written.
export const HANDLER_SOURCE = buildHandlerSource();
export { AUTHORIZATION_SOURCE, ADAPTERS_SOURCE, ROUTE_SOURCE };
if (import.meta.url === `file://${process.argv[1]}`) {
await main();
}
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Wix
- Publisher
- Wix (Official)
- Source
- wix/skills · skills/wix-headless-replatform · commit d168bc2
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Wix.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download wix-headless-replatform.zip