fix(custom-widgets): make embedded prompt standalone

This commit is contained in:
Thomas Camlong committed 2026-07-20 18:55:22 +02:00
1 parent 80d364c050
commit 48f73d919d
6 files changed
+35 -7

No files matched your search

+12 -3
View File
@@ -50,16 +50,25 @@ export function buildCustomWidgetAiPrompt(
documentationUrl?: string | null,
embeddedSkill?: string,
) {
const sections = [AUTHORING_PROMPT];
const requestedWidget = redactText(request?.trim() || "Describe the widget you want to create.");
const sections = [`# User request\n\n${requestedWidget}`];
if (documentationUrl) sections.push(`API documentation: ${redactUrl(documentationUrl)}`);
sections.push(`Requested widget: ${redactText(request?.trim() || "Describe the widget you want to create.")}`);
if (embeddedSkill) {
sections.push(`Use this embedded Homarr Custom Widget skill while authoring:\n\n${embeddedSkill}`);
sections.push(`## Execution mode: standalone copy/paste
You do not have to connect to Homarr MCP or access any \`homarr://\` resource to complete this request. Do not search for unavailable Homarr tools, do not stop because they are unavailable, and do not ask whether to proceed. Author the best valid widget you can from the instructions embedded below. Do not claim that you validated, previewed, or installed it; the user will paste your two output blocks into Homarr for validation.`);
}
sections.push(AUTHORING_PROMPT);
if (embeddedSkill) sections.push(`## Embedded Homarr Custom Widget skill\n\n${embeddedSkill}`);
if (rawResponse) sections.push(`Sample API response:\n\n\`\`\`json\n${redactResponse(rawResponse)}\n\`\`\``);
if (currentConfig) {
sections.push(`Current widget:\n\n\`\`\`json\n${JSON.stringify(redactValue(currentConfig), null, 2)}\n\`\`\``);
}
sections.push(`## Produce the response now
Create this widget: ${requestedWidget}
Return exactly one complete \`json\` fenced block and one complete \`jsx\` fenced block as specified above. Do not respond with a plan, a refusal, a tool-access warning, or a question.`);
const prompt = sections.join("\n\n");
return embeddedSkill ? prompt : prompt.slice(0, 8_000);
}
@@ -25,8 +25,14 @@ metadata:
Create one widget at a time. Repeat the workflow when the user asks for several widgets; do not invent packs or shared connections.
## Standalone workflow
When Homarr MCP tools and \`homarr://\` resources are unavailable, continue offline using this skill and the supplied authoring prompt. Do not search repeatedly for missing tools, stop, or ask whether to proceed. Produce the requested credential-free manifest and JSX directly, without claiming they were validated, previewed, or installed. The user will paste them into Homarr and return any diagnostics for correction.
## Connected workflow
Use this workflow only when the Homarr MCP tools and resources are actually available:
1. Get \`homarr-custom-widget-author\`, then read \`homarr://custom-widgets/schema\` and \`homarr://custom-widgets/components\`.
2. Read the API documentation supplied by the user. Ask for missing base URLs and credentials only when needed.
3. Build one \`homarr-custom-widget-v2\` document. Keep credentials outside the document.