@alpaca-editor/core 1.0.4013 → 1.0.4015

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.
Files changed (79) hide show
  1. package/dist/components/ui/popover.js +6 -3
  2. package/dist/components/ui/popover.js.map +1 -1
  3. package/dist/editor/Terminal.d.ts +6 -0
  4. package/dist/editor/Terminal.js +10 -4
  5. package/dist/editor/Terminal.js.map +1 -1
  6. package/dist/editor/ai/Agents.js +133 -13
  7. package/dist/editor/ai/Agents.js.map +1 -1
  8. package/dist/editor/ai/AiTerminal.d.ts +2 -1
  9. package/dist/editor/ai/AiTerminal.js +86 -139
  10. package/dist/editor/ai/AiTerminal.js.map +1 -1
  11. package/dist/editor/media-selector/AiImageSearch.js +2 -1
  12. package/dist/editor/media-selector/AiImageSearch.js.map +1 -1
  13. package/dist/editor/media-selector/AiImageSearchPrompt.js +2 -1
  14. package/dist/editor/media-selector/AiImageSearchPrompt.js.map +1 -1
  15. package/dist/editor/page-editor-chrome/useInlineAICompletion.js +4 -2
  16. package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
  17. package/dist/editor/services/agentService.d.ts +59 -0
  18. package/dist/editor/services/agentService.js +26 -0
  19. package/dist/editor/services/agentService.js.map +1 -0
  20. package/dist/editor/services/aiService.d.ts +22 -4
  21. package/dist/editor/services/aiService.js +131 -20
  22. package/dist/editor/services/aiService.js.map +1 -1
  23. package/dist/editor/services/contextService.js +6 -4
  24. package/dist/editor/services/contextService.js.map +1 -1
  25. package/dist/editor/sidebar/SidebarView.js +2 -5
  26. package/dist/editor/sidebar/SidebarView.js.map +1 -1
  27. package/dist/editor/sidebar/ViewSelector.js +1 -1
  28. package/dist/editor/sidebar/ViewSelector.js.map +1 -1
  29. package/dist/editor/ui/SimpleIconButton.d.ts +2 -2
  30. package/dist/editor/ui/SimpleIconButton.js +5 -3
  31. package/dist/editor/ui/SimpleIconButton.js.map +1 -1
  32. package/dist/editor/utils/jsonCleaner.d.ts +8 -0
  33. package/dist/editor/utils/jsonCleaner.js +76 -0
  34. package/dist/editor/utils/jsonCleaner.js.map +1 -0
  35. package/dist/editor/views/CompareView.js +2 -2
  36. package/dist/editor/views/CompareView.js.map +1 -1
  37. package/dist/page-wizard/steps/ContentStep.js +7 -2
  38. package/dist/page-wizard/steps/ContentStep.js.map +1 -1
  39. package/dist/page-wizard/steps/FindItemsStep.js +4 -1
  40. package/dist/page-wizard/steps/FindItemsStep.js.map +1 -1
  41. package/dist/page-wizard/steps/ImagesStep.js +13 -7
  42. package/dist/page-wizard/steps/ImagesStep.js.map +1 -1
  43. package/dist/page-wizard/steps/LayoutStep.d.ts +1 -1
  44. package/dist/page-wizard/steps/LayoutStep.js +22 -20
  45. package/dist/page-wizard/steps/LayoutStep.js.map +1 -1
  46. package/dist/page-wizard/steps/MetaDataStep.js +8 -15
  47. package/dist/page-wizard/steps/MetaDataStep.js.map +1 -1
  48. package/dist/page-wizard/steps/SelectStep.js +9 -4
  49. package/dist/page-wizard/steps/SelectStep.js.map +1 -1
  50. package/dist/page-wizard/steps/StructureStep.js +3 -1
  51. package/dist/page-wizard/steps/StructureStep.js.map +1 -1
  52. package/dist/revision.d.ts +2 -2
  53. package/dist/revision.js +2 -2
  54. package/dist/styles.css +10 -11
  55. package/package.json +1 -1
  56. package/src/components/ui/popover.tsx +6 -3
  57. package/src/editor/Terminal.tsx +12 -3
  58. package/src/editor/ai/Agents.tsx +212 -16
  59. package/src/editor/ai/AiTerminal.tsx +113 -173
  60. package/src/editor/ai/GhostWriter.tsx_ +3 -3
  61. package/src/editor/media-selector/AiImageSearch.tsx +2 -2
  62. package/src/editor/media-selector/AiImageSearchPrompt.tsx +2 -2
  63. package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +5 -5
  64. package/src/editor/services/agentService.ts +83 -0
  65. package/src/editor/services/aiService.ts +176 -33
  66. package/src/editor/services/contextService.ts +5 -6
  67. package/src/editor/sidebar/SidebarView.tsx +10 -6
  68. package/src/editor/sidebar/ViewSelector.tsx +2 -2
  69. package/src/editor/ui/SimpleIconButton.tsx +20 -14
  70. package/src/editor/utils/jsonCleaner.ts +92 -0
  71. package/src/editor/views/CompareView.tsx +2 -2
  72. package/src/page-wizard/steps/ContentStep.tsx +10 -9
  73. package/src/page-wizard/steps/FindItemsStep.tsx +7 -5
  74. package/src/page-wizard/steps/ImagesStep.tsx +16 -11
  75. package/src/page-wizard/steps/LayoutStep.tsx +24 -28
  76. package/src/page-wizard/steps/MetaDataStep.tsx +11 -21
  77. package/src/page-wizard/steps/SelectStep.tsx +11 -8
  78. package/src/page-wizard/steps/StructureStep.tsx +4 -5
  79. package/src/revision.ts +2 -2
@@ -18,6 +18,7 @@ export function LayoutStep({
18
18
  setStepCompleted,
19
19
  internalState,
20
20
  setInternalState,
21
+ setPageModel, // Add missing prop
21
22
  }: StepComponentProps) {
22
23
  const editContext = useEditContext();
23
24
  const abortController = new AbortController();
@@ -66,31 +67,31 @@ export function LayoutStep({
66
67
  const result = await executePrompt(
67
68
  [
68
69
  {
69
- content: `${customInstructions?.trim()} Reply with a json object of type PageModel = { name: string; metaDescription: string; components: Component[]; message: string; };
70
- Component = { name: string, type: string; fields: Field[]; placeholder?: string; children?: Component[]; };
71
- Field = { name: string; value: string; type: string; };
72
- Generate a descriptive name for each component including the topic.
73
- Only use component types that are in the page schema. Also suggest a page name following default sitecore item naming conventions (no underscores, no white space, no umlaute, no special characters, hyphens are allowed) and the page meta description.
74
- Component types: ${JSON.stringify(
75
- filteredSchema,
76
- )} Root level component types ${filteredSchema
77
- .filter((c) => c.allowedOnRoot)
78
- .map((c) => c.type)
79
- .join(", ")}
80
- Tell the user your reasoning in the message field.
81
- Fill image ids into picture / image fields.
82
- Input data: ${JSON.stringify(data)}`,
83
-
70
+ content: `${customInstructions?.trim()} Reply with a json object of type PageModel = { name: string; metaDescription: string; components: Component[]; message: string; };
71
+ Where components are of type Component = { id: string; name: string; fields: FieldDefinition[]; styles: string; };
72
+ And fields are of type FieldDefinition = { name: string; type: string; value: string; };
73
+
74
+ Input data: ${JSON.stringify(data)}
75
+
76
+ 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.
77
+
78
+ Component Guidelines:
79
+ - Use Row components to group related content horizontally
80
+ - Use Section components as containers for logical page sections
81
+ - Populate all required fields with realistic content
82
+ - Use appropriate HTML structure within styles
83
+ - Make the content relevant to: ${JSON.stringify(data)}
84
+
85
+ Please create a well-structured page layout with proper content hierarchy.`,
84
86
  name: "system",
85
87
  role: "system",
88
+ id: crypto.randomUUID(), // Use proper UUID instead of Date.now()
86
89
  },
87
90
  ],
88
- editContext,
89
- createWizardAiContext,
90
- {},
91
- { signal: localAbortController.signal },
92
- "gpt-4.1",
93
- (response) => {
91
+ { editContext, createAiContext: createWizardAiContext },
92
+ { model: "gpt-4.1" },
93
+ { signal: abortController.signal },
94
+ (response: any) => {
94
95
  try {
95
96
  // Handle streaming response - might have different structure during streaming
96
97
  const content =
@@ -99,14 +100,9 @@ export function LayoutStep({
99
100
  if (content) {
100
101
  const newLayout = JSON.parse(content) as WizardPageModel;
101
102
 
102
- if (newLayout) {
103
- setData((prev: WizardData) => ({
104
- ...prev,
105
- pageModel: newLayout,
106
- }));
103
+ if (newLayout && setPageModel) {
104
+ setPageModel(newLayout);
107
105
  }
108
-
109
- setMessage(newLayout.message);
110
106
  }
111
107
  } catch (parseError: unknown) {}
112
108
  },
@@ -60,33 +60,23 @@ export function MetaDataStep({
60
60
  const result = await executePrompt(
61
61
  [
62
62
  {
63
- content: `${metaInstructions?.trim()} Reply with a json object of type PageModel = { metaDescription: string; metaKeywords: string; };
64
- Generate SEO-optimized meta description and keywords.
65
- The language of the page is ${parentItem?.language || "en"}.
66
- Input data: ${JSON.stringify(data)}`,
63
+ content: `${metaInstructions?.trim()} Reply with a json object of type PageModel = { metaDescription: string; metaKeywords: string; };
64
+ The language of the page is ${parentItem?.language || "en"}.
65
+ Input data: ${JSON.stringify(data)}`,
67
66
  name: "system",
68
67
  role: "system",
68
+ id: crypto.randomUUID(), // Use proper UUID instead of Date.now()
69
69
  },
70
70
  ],
71
- editContext,
72
- createWizardAiContext,
73
- {},
71
+ { editContext, createAiContext: createWizardAiContext },
72
+ { model: "gpt-4.1" },
74
73
  { signal: abortController.signal },
75
- "gpt-4.1",
76
- (response) => {
74
+ (response: any) => {
77
75
  try {
78
- // Handle streaming response - might have different structure during streaming
79
- const content =
80
- response.content ||
81
- response.messages?.[response.messages.length - 1]?.content;
82
- if (content) {
83
- const newLayout = JSON.parse(content) as WizardPageModel;
84
-
85
- setPageModel({
86
- ...pageModel,
87
- metaDescription: newLayout.metaDescription,
88
- metaKeywords: newLayout.metaKeywords,
89
- });
76
+ const newLayout = JSON.parse(response.content) as WizardPageModel;
77
+
78
+ if (newLayout && setPageModel) {
79
+ setPageModel(newLayout);
90
80
  }
91
81
  } catch (parseError: unknown) {}
92
82
  },
@@ -92,27 +92,30 @@ export function SelectStep({
92
92
  )}`;
93
93
 
94
94
  // Call the executePrompt function with the prompt
95
+ const abortController = new AbortController();
95
96
  const result = await executePrompt(
96
97
  [
97
98
  {
98
99
  content: `You are a helpful assistant that generates options for a wizard select step.
99
- Generate a JSON array of options based on the instructions and current data.
100
- ONLY respond with a valid JSON array without any explanation or additional text.
101
- JSON format: {options: {title: string, description: string}[] }`,
100
+
101
+ Return a JSON array of objects with the following structure:
102
+ [{ "value": "option_value", "label": "Option Label", "description": "Brief description" }]
103
+
104
+ Create ${step.fields.numberOfOptions || 5} relevant options.`,
102
105
  name: "system",
103
106
  role: "system",
107
+ id: crypto.randomUUID(), // Use proper UUID instead of Date.now()
104
108
  },
105
109
  {
106
110
  content: prompt,
107
111
  name: "user",
108
112
  role: "user",
113
+ id: crypto.randomUUID(), // Use proper UUID instead of Date.now()
109
114
  },
110
115
  ],
111
- editContext,
112
- createWizardAiContext,
113
- { allowedFunctions: [] },
114
- undefined,
115
- step.fields.aiModel || "gpt-4.1",
116
+ { editContext, createAiContext: createWizardAiContext },
117
+ { model: step.fields.aiModel || "gpt-4.1" },
118
+ { signal: abortController.signal },
116
119
  );
117
120
 
118
121
  // Parse the result and set options
@@ -130,18 +130,17 @@ ${JSON.stringify(data)}`;
130
130
  content: `You are an expert content strategist helping to structure content. Return ONLY a valid JSON array with section objects in this exact format: {sections: [{type: string, content: string, description: string}] }`,
131
131
  name: "system",
132
132
  role: "system",
133
+ id: crypto.randomUUID(), // Use proper UUID instead of Date.now()
133
134
  },
134
135
  {
135
136
  content: basePrompt,
136
137
  name: "user",
137
138
  role: "user",
139
+ id: crypto.randomUUID(), // Use proper UUID instead of Date.now()
138
140
  },
139
141
  ],
140
- editContext,
141
- createWizardAiContext,
142
- { allowedFunctions: [] },
143
- undefined,
144
- step.fields.aiModel || "gpt-4.1",
142
+ { editContext, createAiContext: createWizardAiContext },
143
+ { allowedFunctions: [], model: step.fields.aiModel || "gpt-4.1" },
145
144
  );
146
145
 
147
146
  console.log("AI RESULT: ", result);
package/src/revision.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = "1.0.4013";
2
- export const buildDate = "2025-07-23 08:21:59";
1
+ export const version = "1.0.4015";
2
+ export const buildDate = "2025-07-24 09:45:13";