@parhelia/page-wizard 0.1.11652 → 0.1.11666

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.
@@ -93,11 +93,11 @@ export function ContentStep({ wizard, step, parentItem, pageModel, setPageModel,
93
93
  return;
94
94
  }
95
95
  const processedPrompt = templateResult.value;
96
- const promptContent = `${processedPrompt?.trim()}
97
- You can use get-children to explore existing items and create-item to create new items if needed.
98
- Reply with a json object of type { id: string; path: string; } containing the ID and path of the target item.
99
- The language of the content is ${language}.
100
- Current parent item: ${fullParentItem?.path || parentItem?.id}
96
+ const promptContent = `${processedPrompt?.trim()}
97
+ You can use get-children to explore existing items and create-item to create new items if needed.
98
+ Reply with a json object of type { id: string; path: string; } containing the ID and path of the target item.
99
+ The language of the content is ${language}.
100
+ Current parent item: ${fullParentItem?.path || parentItem?.id}
101
101
  `;
102
102
  console.log("PROMPT (selectTargetItem):", promptContent);
103
103
  const result = await executePromptWithJsonResult([
@@ -193,13 +193,13 @@ export function ContentStep({ wizard, step, parentItem, pageModel, setPageModel,
193
193
  return;
194
194
  }
195
195
  const processedInstructions = templateResult.value;
196
- const promptContent = `${processedInstructions?.trim()} Reply with a json object of type PageModel = { name: string; };
197
- The language of the page is ${language}.
196
+ const promptContent = `${processedInstructions?.trim()} Reply with a json object of type PageModel = { name: string; };
197
+ The language of the page is ${language}.
198
198
  `;
199
199
  console.log("PROMPT (generatePageName):", promptContent);
200
200
  const pageModelResult = await executePromptWithJsonResult([
201
201
  {
202
- content: `${processedInstructions?.trim()} Reply with a json object of type PageModel = { name: string; };
202
+ content: `${processedInstructions?.trim()} Reply with a json object of type PageModel = { name: string; };
203
203
  The language of the page is ${language}.`,
204
204
  name: "system",
205
205
  role: "system",
@@ -641,27 +641,27 @@ export function ContentStep({ wizard, step, parentItem, pageModel, setPageModel,
641
641
  const processedInstructions = templateResult.value;
642
642
  const prompt = [
643
643
  {
644
- content: `${processedInstructions ? processedInstructions?.trim() : ""} Reply with a json object of type PageModel = { fields: Field[]; components: Component[]; message: string; };
645
- Component = { id: string | undefined, name: string, type: string; fields: Field[]; placeholder?: string; children?: Component[]; };
646
- Field = { name: string; value: string; type: string; };
647
- Generate a descriptive name for each component including the topic.
648
- Only use component types that are in the page schema.
649
- Keep existing components with their ids. Leave id field empty for new components.
650
- To generate images write generate: <keywords> into the picture / image field value.
651
- ${(existingPageModel && `Existing page model: ${JSON.stringify(existingPageModel)}`) || ""}
644
+ content: `${processedInstructions ? processedInstructions?.trim() : ""} Reply with a json object of type PageModel = { fields: Field[]; components: Component[]; message: string; };
645
+ Component = { id: string | undefined, name: string, type: string; fields: Field[]; placeholder?: string; children?: Component[]; };
646
+ Field = { name: string; value: string; type: string; };
647
+ Generate a descriptive name for each component including the topic.
648
+ Only use component types that are in the page schema.
649
+ Keep existing components with their ids. Leave id field empty for new components.
650
+ To generate images write generate: <keywords> into the picture / image field value.
651
+ ${(existingPageModel && `Existing page model: ${JSON.stringify(existingPageModel)}`) || ""}
652
652
  Fill empty fields of existing components before you insert new components. Page fields: ${JSON.stringify(schema.pageFields.map((f) => {
653
653
  return {
654
654
  name: f.name,
655
655
  type: f.type,
656
656
  };
657
- }))}
657
+ }))}
658
658
  Available component types: ${JSON.stringify(filteredSchema)} Root level component types ${filteredSchema
659
659
  .filter((c) => c.allowedOnRoot)
660
660
  .map((c) => c.type)
661
- .join(", ")}
662
- Tell the user your reasoning in the message field.
663
-
664
- The language of the page is ${language || editContextRef.current.page.item.language}.
661
+ .join(", ")}
662
+ Tell the user your reasoning in the message field.
663
+
664
+ The language of the page is ${language || editContextRef.current.page.item.language}.
665
665
  `,
666
666
  name: "system",
667
667
  role: "system",
@@ -145,23 +145,23 @@ export function FindItemsStep({ step, data, setData, setStepCompleted, internalS
145
145
  setLoadingAI(false);
146
146
  return;
147
147
  }
148
- const basePrompt = `
149
- ${systemInstructionsResult.value || ""}
150
-
151
- You need to suggest relevant content items from a content tree. Here are the details:
152
-
153
-
154
- Source Root IDs: ${JSON.stringify(rootItemIds)}
155
- Multi-select: ${multiSelect}
156
- Max selections needed: ${multiSelect ? "multiple" : "1"}
157
-
158
- You can use the get-children function to traverse the content tree and find relevant items.
159
- Start from the root IDs provided and explore the tree to find items that match the input data.
160
-
161
- Return a JSON object with suggested item IDs in this format:
162
- {
163
- "suggestions": ["item-id-1", "item-id-2", ...],
164
- "reasoning": "Brief explanation of why these items were selected"
148
+ const basePrompt = `
149
+ ${systemInstructionsResult.value || ""}
150
+
151
+ You need to suggest relevant content items from a content tree. Here are the details:
152
+
153
+
154
+ Source Root IDs: ${JSON.stringify(rootItemIds)}
155
+ Multi-select: ${multiSelect}
156
+ Max selections needed: ${multiSelect ? "multiple" : "1"}
157
+
158
+ You can use the get-children function to traverse the content tree and find relevant items.
159
+ Start from the root IDs provided and explore the tree to find items that match the input data.
160
+
161
+ Return a JSON object with suggested item IDs in this format:
162
+ {
163
+ "suggestions": ["item-id-1", "item-id-2", ...],
164
+ "reasoning": "Brief explanation of why these items were selected"
165
165
  } Do not add comments to the JSON.`;
166
166
  // Log input data for AI processing but don't auto-populate selections
167
167
  console.log("INPUT DATA FOR AI PROCESSING: ", evaluatedInputData, basePrompt);
@@ -41,13 +41,13 @@ export const ImagesStep = (props) => {
41
41
  "Please analyze the provided data and suggest images.";
42
42
  const aiPromptResult = await executePrompt([
43
43
  {
44
- content: `You are an AI assistant for building a web page. You will later have to create images for the page.
45
- ${imageInstructions}
46
-
47
- Reply with a json object of type WizardPageModel = { message: string; components: Component[]; };
48
-
49
- Where components are of type Component = { id: string; name: string; imageFields: {name: string; value: string; alt: string; prompt: string; }[]; };
50
- You should update images existing images in fields in the components array. Update the prompt field for each image, keep name, value and alt unchanged. Make sure you populate prompt field for every image.
44
+ content: `You are an AI assistant for building a web page. You will later have to create images for the page.
45
+ ${imageInstructions}
46
+
47
+ Reply with a json object of type WizardPageModel = { message: string; components: Component[]; };
48
+
49
+ Where components are of type Component = { id: string; name: string; imageFields: {name: string; value: string; alt: string; prompt: string; }[]; };
50
+ You should update images existing images in fields in the components array. Update the prompt field for each image, keep name, value and alt unchanged. Make sure you populate prompt field for every image.
51
51
  `,
52
52
  name: "system",
53
53
  role: "system",
@@ -37,21 +37,21 @@ export function LayoutStep({ wizard, step, data, setData, setStepCompleted, inte
37
37
  const filteredSchema = convertPageSchemaToWizardComponents(schema, selectedComponentTypes);
38
38
  const result = await executePrompt([
39
39
  {
40
- content: `${customInstructions?.trim()} Reply with a json object of type PageModel = { name: string; metaDescription: string; components: Component[]; message: string; };
41
- Where components are of type Component = { id: string; name: string; fields: FieldDefinition[]; styles: string; };
42
- And fields are of type FieldDefinition = { name: string; type: string; value: string; };
43
-
44
-
45
-
46
- Types: Row: Use this to group components horizontally. Section: Use this to group components with a background color or spacing. Title: Use for titles and headings. Text: Use for general text content. Quote: Use for quotes and callouts. Image: Use for images and media. TeaserList: Use for lists of items with images and descriptions. Test: Component for testing and prototyping.
47
-
48
- Component Guidelines:
49
- - Use Row components to group related content horizontally
50
- - Use Section components as containers for logical page sections
51
- - Populate all required fields with realistic content
52
- - Use appropriate HTML structure within styles
53
- - Make the content relevant to: ${JSON.stringify(data)}
54
-
40
+ content: `${customInstructions?.trim()} Reply with a json object of type PageModel = { name: string; metaDescription: string; components: Component[]; message: string; };
41
+ Where components are of type Component = { id: string; name: string; fields: FieldDefinition[]; styles: string; };
42
+ And fields are of type FieldDefinition = { name: string; type: string; value: string; };
43
+
44
+
45
+
46
+ Types: Row: Use this to group components horizontally. Section: Use this to group components with a background color or spacing. Title: Use for titles and headings. Text: Use for general text content. Quote: Use for quotes and callouts. Image: Use for images and media. TeaserList: Use for lists of items with images and descriptions. Test: Component for testing and prototyping.
47
+
48
+ Component Guidelines:
49
+ - Use Row components to group related content horizontally
50
+ - Use Section components as containers for logical page sections
51
+ - Populate all required fields with realistic content
52
+ - Use appropriate HTML structure within styles
53
+ - Make the content relevant to: ${JSON.stringify(data)}
54
+
55
55
  Please create a well-structured page layout with proper content hierarchy.`,
56
56
  name: "system",
57
57
  role: "system",
@@ -61,11 +61,11 @@ export function SelectStep({ step, data, setData, setStepCompleted, internalStat
61
61
  const abortController = new AbortController();
62
62
  const result = await executePromptWithJsonResult([
63
63
  {
64
- content: `You are a helpful assistant that generates options for a wizard select step.
65
-
66
- Return a JSON array of objects with the following structure:
67
- [{ "value": "option_value", "label": "Option Label", "description": "Brief description", id: "unique_id" }]
68
-
64
+ content: `You are a helpful assistant that generates options for a wizard select step.
65
+
66
+ Return a JSON array of objects with the following structure:
67
+ [{ "value": "option_value", "label": "Option Label", "description": "Brief description", id: "unique_id" }]
68
+
69
69
  Create ${step.fields.numberOfOptions || 5} relevant options.`,
70
70
  name: "system",
71
71
  role: "system",
@@ -89,10 +89,10 @@ export function StructureStep({ step, data, setData, setStepCompleted, internalS
89
89
  setLoading(false);
90
90
  return;
91
91
  }
92
- const basePrompt = `
93
- ${systemInstructionsResult.value || ""}
94
-
95
- ${customInstructionsResult.value ? `Additional requirements: ${customInstructionsResult.value}` : ""}
92
+ const basePrompt = `
93
+ ${systemInstructionsResult.value || ""}
94
+
95
+ ${customInstructionsResult.value ? `Additional requirements: ${customInstructionsResult.value}` : ""}
96
96
  `;
97
97
  try {
98
98
  const result = await executePrompt([
@@ -133,9 +133,9 @@ export function TranslateStep({ step, data, setData, setStepCompleted, internalS
133
133
  }
134
134
  setIsDetectingLanguage(true);
135
135
  try {
136
- const prompt = `Analyze the following text and identify the language it is written in. Return only the language name in English (e.g., "Spanish", "French", "German", "Italian", etc.). Do not include any other text or explanation.
137
-
138
- Text to analyze:
136
+ const prompt = `Analyze the following text and identify the language it is written in. Return only the language name in English (e.g., "Spanish", "French", "German", "Italian", etc.). Do not include any other text or explanation.
137
+
138
+ Text to analyze:
139
139
  ${documentContent.substring(0, 1000)}`;
140
140
  const abortController = new AbortController();
141
141
  const result = await executePrompt([
@@ -220,28 +220,28 @@ ${documentContent.substring(0, 1000)}`;
220
220
  fieldName: field.fieldName,
221
221
  originalValue: field.value,
222
222
  })));
223
- const prompt = `You are a translation assistant. You have been given a document in ${targetLanguage.name} and a list of fields that need to be translated from ${sourceLanguage} to ${targetLanguage.name}.
224
-
225
- Your task is to:
226
- 1. Match the content from the provided document to the fields that need translation
227
- 2. Return ONLY the translated text from the document - do not change, modify, or create any new text
228
- 3. If you cannot find a suitable translation in the document for a field, leave the translatedValue empty
229
-
230
- Document content:
231
- ${documentContent}
232
-
233
- Fields to translate:
234
- ${JSON.stringify(fieldsForTranslation, null, 2)}
235
-
236
- Return your response as a JSON object in this exact format:
237
- {
238
- "translations": [
239
- {
240
- "itemId": "item-id",
241
- "fieldId": "field-id",
242
- "translatedValue": "exact text from document"
243
- }
244
- ]
223
+ const prompt = `You are a translation assistant. You have been given a document in ${targetLanguage.name} and a list of fields that need to be translated from ${sourceLanguage} to ${targetLanguage.name}.
224
+
225
+ Your task is to:
226
+ 1. Match the content from the provided document to the fields that need translation
227
+ 2. Return ONLY the translated text from the document - do not change, modify, or create any new text
228
+ 3. If you cannot find a suitable translation in the document for a field, leave the translatedValue empty
229
+
230
+ Document content:
231
+ ${documentContent}
232
+
233
+ Fields to translate:
234
+ ${JSON.stringify(fieldsForTranslation, null, 2)}
235
+
236
+ Return your response as a JSON object in this exact format:
237
+ {
238
+ "translations": [
239
+ {
240
+ "itemId": "item-id",
241
+ "fieldId": "field-id",
242
+ "translatedValue": "exact text from document"
243
+ }
244
+ ]
245
245
  }`;
246
246
  const abortController = new AbortController();
247
247
  const result = await executePrompt([
@@ -309,23 +309,23 @@ Return your response as a JSON object in this exact format:
309
309
  setTranslatingFields((prev) => new Set(prev).add(fieldKey));
310
310
  try {
311
311
  // Create a prompt for this specific field
312
- const prompt = `You are a translation assistant. You have been given a document in ${targetLanguage.name} and a single field that needs to be translated from ${sourceLanguage} to ${targetLanguage.name}.
313
-
314
- Your task is to:
315
- 1. Find content from the provided document that matches this field
316
- 2. Return ONLY the translated text from the document - do not change, modify, or create any new text
317
- 3. If you cannot find a suitable translation in the document for this field, return an empty string
318
-
319
- Document content:
320
- ${documentContent}
321
-
322
- Field to translate:
323
- - Field Name: ${field.fieldName}
324
- - Value (${sourceLanguage}): ${field.value}
325
-
326
- Return your response as a JSON object in this exact format:
327
- {
328
- "translatedValue": "exact text from document or empty string if no match found"
312
+ const prompt = `You are a translation assistant. You have been given a document in ${targetLanguage.name} and a single field that needs to be translated from ${sourceLanguage} to ${targetLanguage.name}.
313
+
314
+ Your task is to:
315
+ 1. Find content from the provided document that matches this field
316
+ 2. Return ONLY the translated text from the document - do not change, modify, or create any new text
317
+ 3. If you cannot find a suitable translation in the document for this field, return an empty string
318
+
319
+ Document content:
320
+ ${documentContent}
321
+
322
+ Field to translate:
323
+ - Field Name: ${field.fieldName}
324
+ - Value (${sourceLanguage}): ${field.value}
325
+
326
+ Return your response as a JSON object in this exact format:
327
+ {
328
+ "translatedValue": "exact text from document or empty string if no match found"
329
329
  }`;
330
330
  const abortController = new AbortController();
331
331
  const result = await executePrompt([
@@ -379,26 +379,26 @@ Return your response as a JSON object in this exact format:
379
379
  const fieldKey = `${itemId}-${fieldId}`;
380
380
  setCheckingFields((prev) => new Set(prev).add(fieldKey));
381
381
  try {
382
- const prompt = `You are a translation quality checker. Your task is to evaluate if a translation is complete and accurate.
383
-
384
- Original text (${sourceLanguage}):
385
- ${originalText}
386
-
387
- Translated text (${targetLanguage?.name || "target language"}):
388
- ${translatedText}
389
-
390
- Field context: ${fieldName}
391
-
392
- Is the translation complete (no missing content)? Do not assess the quality of the translation, just if it is complete. Only report missing sentences missing completely.
393
- Do not report missing words, phrases, or content that is present in the original text. We just want to make sure we copied all content from the translation document.
394
-
395
- If the translation is incomplete, identify specific content, phrases, or meaning that exists in the original but is missing in the translation, and suggest the exact text that should be added to make the translation complete.
396
-
397
- Return your response as a JSON object in this exact format:
398
- {
399
- "isComplete": true/false,
400
- "reason": "Brief explanation of your assessment",
401
- "missingSuggestions": "If isComplete is false, provide specific suggestions for what needs to be added to complete the translation. Include the actual text that should be added. If isComplete is true, leave this empty."
382
+ const prompt = `You are a translation quality checker. Your task is to evaluate if a translation is complete and accurate.
383
+
384
+ Original text (${sourceLanguage}):
385
+ ${originalText}
386
+
387
+ Translated text (${targetLanguage?.name || "target language"}):
388
+ ${translatedText}
389
+
390
+ Field context: ${fieldName}
391
+
392
+ Is the translation complete (no missing content)? Do not assess the quality of the translation, just if it is complete. Only report missing sentences missing completely.
393
+ Do not report missing words, phrases, or content that is present in the original text. We just want to make sure we copied all content from the translation document.
394
+
395
+ If the translation is incomplete, identify specific content, phrases, or meaning that exists in the original but is missing in the translation, and suggest the exact text that should be added to make the translation complete.
396
+
397
+ Return your response as a JSON object in this exact format:
398
+ {
399
+ "isComplete": true/false,
400
+ "reason": "Brief explanation of your assessment",
401
+ "missingSuggestions": "If isComplete is false, provide specific suggestions for what needs to be added to complete the translation. Include the actual text that should be added. If isComplete is true, leave this empty."
402
402
  }`;
403
403
  const abortController = new AbortController();
404
404
  const result = await executePrompt([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parhelia/page-wizard",
3
- "version": "0.1.11652",
3
+ "version": "0.1.11666",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"