@wix/ditto-codegen-public 1.0.123 → 1.0.125

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 (2) hide show
  1. package/dist/out.js +234 -543
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -78301,7 +78301,7 @@ var require_codeGenerationService = __commonJS({
78301
78301
  exports2.codeGenerationService = void 0;
78302
78302
  var CodeGenService_12 = require_CodeGenService();
78303
78303
  var context_12 = require_context();
78304
- var baseUrl2 = process.env.BASE_URL || "http://localhost:3000";
78304
+ var baseUrl2 = process.env.CODEGEN_BASE_URL || "http://localhost:3000";
78305
78305
  exports2.codeGenerationService = new CodeGenService_12.CodeGenService(baseUrl2, context_12.ctx.projectId);
78306
78306
  }
78307
78307
  });
@@ -116236,49 +116236,6 @@ var require_dist10 = __commonJS({
116236
116236
  }
116237
116237
  });
116238
116238
 
116239
- // ../../node_modules/zod/index.cjs
116240
- var require_zod = __commonJS({
116241
- "../../node_modules/zod/index.cjs"(exports2) {
116242
- "use strict";
116243
- var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
116244
- if (k2 === void 0) k2 = k;
116245
- var desc = Object.getOwnPropertyDescriptor(m, k);
116246
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
116247
- desc = { enumerable: true, get: function() {
116248
- return m[k];
116249
- } };
116250
- }
116251
- Object.defineProperty(o, k2, desc);
116252
- }) : (function(o, m, k, k2) {
116253
- if (k2 === void 0) k2 = k;
116254
- o[k2] = m[k];
116255
- }));
116256
- var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
116257
- Object.defineProperty(o, "default", { enumerable: true, value: v });
116258
- }) : function(o, v) {
116259
- o["default"] = v;
116260
- });
116261
- var __importStar2 = exports2 && exports2.__importStar || function(mod2) {
116262
- if (mod2 && mod2.__esModule) return mod2;
116263
- var result = {};
116264
- if (mod2 != null) {
116265
- for (var k in mod2) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod2, k)) __createBinding2(result, mod2, k);
116266
- }
116267
- __setModuleDefault2(result, mod2);
116268
- return result;
116269
- };
116270
- var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
116271
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding2(exports3, m, p);
116272
- };
116273
- Object.defineProperty(exports2, "__esModule", { value: true });
116274
- exports2.z = void 0;
116275
- var z = __importStar2(require_external());
116276
- exports2.z = z;
116277
- __exportStar2(require_external(), exports2);
116278
- exports2.default = z;
116279
- }
116280
- });
116281
-
116282
116239
  // dist/system-prompts/planner/apiSpec.js
116283
116240
  var require_apiSpec = __commonJS({
116284
116241
  "dist/system-prompts/planner/apiSpec.js"(exports2) {
@@ -117022,104 +116979,14 @@ var require_iteration = __commonJS({
117022
116979
  "use strict";
117023
116980
  Object.defineProperty(exports2, "__esModule", { value: true });
117024
116981
  exports2.iterationModePrompt = void 0;
117025
- var types_1 = require_types_impl2();
117026
- var ditto_codegen_types_12 = require_dist();
117027
- var insertExample = {
117028
- collections: [
117029
- {
117030
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
117031
- data: {
117032
- idSuffix: "handling-fees-rules",
117033
- displayName: "Handling Fees Rules",
117034
- displayField: "productId",
117035
- fields: [
117036
- {
117037
- key: "productId",
117038
- displayName: "Product",
117039
- type: "REFERENCE",
117040
- referenceOptions: {
117041
- referencedCollectionId: "Stores/Products"
117042
- }
117043
- },
117044
- { key: "oversizedFee", displayName: "Oversized Fee", type: "NUMBER" },
117045
- { key: "fragileFee", displayName: "Fragile Fee", type: "NUMBER" }
117046
- ],
117047
- dataPermissions: {
117048
- itemRead: types_1.AccessLevel.ANYONE,
117049
- itemInsert: types_1.AccessLevel.ANYONE,
117050
- itemUpdate: types_1.AccessLevel.ANYONE,
117051
- itemRemove: types_1.AccessLevel.ANYONE
117052
- }
117053
- }
117054
- }
117055
- ],
117056
- embeddedScriptParameters: [],
117057
- // No changes needed - existing ones stay as is
117058
- apiSpec: void 0
117059
- // No changes needed - existing spec stays as is
117060
- };
117061
- var updateExample = {
117062
- collections: [
117063
- {
117064
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.UPDATE,
117065
- data: {
117066
- idSuffix: "handling-fees-rules",
117067
- // make sure to use the same idSuffix as the existing collection
117068
- displayName: "Handling Fees Rules",
117069
- displayField: "productId",
117070
- fields: [
117071
- {
117072
- key: "productId",
117073
- displayName: "Product Id",
117074
- type: "REFERENCE",
117075
- referenceOptions: {
117076
- referencedCollectionId: "Stores/Products"
117077
- }
117078
- },
117079
- { key: "oversizedFee", displayName: "Oversized Fee", type: "NUMBER" },
117080
- { key: "fragileFee", displayName: "Fragile Fee", type: "NUMBER" }
117081
- ],
117082
- dataPermissions: {
117083
- itemRead: types_1.AccessLevel.ANYONE,
117084
- itemInsert: types_1.AccessLevel.ANYONE,
117085
- itemUpdate: types_1.AccessLevel.ANYONE,
117086
- itemRemove: types_1.AccessLevel.ANYONE
117087
- }
117088
- }
117089
- }
117090
- ],
117091
- embeddedScriptParameters: [],
117092
- // No changes needed - existing ones stay as is
117093
- apiSpec: void 0
117094
- // No changes needed - existing spec stays as is
117095
- };
117096
- var deleteExample = {
117097
- collections: [],
117098
- // No changes needed - no collections to change
117099
- embeddedScriptParameters: [
117100
- {
117101
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.DELETE,
117102
- data: {
117103
- extensionId: "site-popup",
117104
- keys: ["productId", "headline"]
117105
- }
117106
- }
117107
- ],
117108
- apiSpec: void 0
117109
- // No changes needed - existing spec stays as is
117110
- };
117111
- var emptyExample = {
117112
- collections: [],
117113
- embeddedScriptParameters: []
117114
- };
117115
- var iterationModePrompt = () => `
116982
+ var iterationModePrompt = ({ hasEmbeddedScriptExtensions, hasBackendApiExtensions }) => `
117116
116983
  <ITERATION_MODE>
117117
116984
  This is an ITERATION mode planning session. You will receive:
117118
116985
  1. The new blueprint (with new or modified extensions)
117119
116986
  2. Previous resources from the project (if any):
117120
- - collections: CMS collections that were previously created
117121
- - embeddedScriptParameters: Dynamic parameters that were previously defined
117122
- - apiSpec: API specification that was previously created
116987
+ - collections: CMS collections that were previously created${hasEmbeddedScriptExtensions ? `
116988
+ - embeddedScriptParameters: Dynamic parameters that were previously defined` : ""}${hasBackendApiExtensions ? `
116989
+ - apiSpec: API specification that was previously created` : ""}
117123
116990
 
117124
116991
  Your task is to determine which resources need to be changed using EXPLICIT OPERATIONS.
117125
116992
 
@@ -117156,7 +117023,7 @@ For CMS Collections:
117156
117023
  * Adding a dashboard to manage existing data does NOT require collection updates
117157
117024
  - Use "delete" ONLY if a collection is no longer needed and removing it won't break functionality
117158
117025
  - If a collection doesn't need changes, DON'T include it in your output
117159
-
117026
+ ${hasEmbeddedScriptExtensions ? `
117160
117027
  For Embedded Script Parameters:
117161
117028
  - **CRITICAL**: Embedded script parameters only support INSERT and DELETE operations (no UPDATE)
117162
117029
  - Use "insert" to add new parameters for an embedded script extension
@@ -117168,15 +117035,15 @@ For Embedded Script Parameters:
117168
117035
  * To "update" a parameter, use DELETE followed by INSERT with the new values
117169
117036
  - If parameters don't need changes, DON'T include them in your output
117170
117037
  - **COMMON PATTERN**: To modify a parameter value, delete the old one and insert with new values
117171
-
117038
+ ` : ""}${hasBackendApiExtensions ? `
117172
117039
  For API Spec:
117173
- - **CRITICAL**: Only create/update API specs when the blueprint explicitly includes BACKEND_API extension type
117040
+ - **CRITICAL**: API spec ONLY supports INSERT operation (no update or delete)
117041
+ - Only create API specs when the blueprint explicitly includes BACKEND_API extension type
117174
117042
  - Dashboard pages that work with CMS collections DON'T need API specs - they use Wix Data SDK directly
117175
- - Use "insert" ONLY when adding new BACKEND_API extensions that require custom endpoints
117176
- - Use "update" to modify the existing API spec (add/remove endpoints, update data models, etc.)
117177
- - Use "delete" ONLY if the entire API spec is no longer needed
117178
- - If the API spec doesn't need changes, DON'T include it in your output
117043
+ - Use "insert" to create the complete API specification with all endpoints
117044
+ - API specs cannot be deleted through this interface
117179
117045
  - **DO NOT CREATE API SPECS** for dashboard pages managing CMS collections - this is redundant
117046
+ ` : ""}
117180
117047
 
117181
117048
  IMPORTANT PRINCIPLES:
117182
117049
  - **BE EXTREMELY CONSERVATIVE** with changes - only output operations when changes are truly necessary
@@ -117195,38 +117062,19 @@ Many iteration requests are about fixing BUGS or IMPLEMENTATION ISSUES in the ge
117195
117062
  - "Fix the collection ID usage in backend event" \u2192 Code fix, collections stay unchanged
117196
117063
  - "The dashboard is using wrong parameters" \u2192 Code fix, collections/parameters stay unchanged
117197
117064
  - "Event handler has a bug" \u2192 Code fix, collections/parameters stay unchanged
117198
- - "Dashboard page crashes" \u2192 Code fix, collections/parameters stay unchanged
117199
- - "Embedded script not working correctly" \u2192 Code fix (unless explicitly asking for new parameters)
117065
+ - "Dashboard page crashes" \u2192 Code fix, collections/parameters stay unchanged${hasEmbeddedScriptExtensions ? `
117066
+ - "Embedded script not working correctly" \u2192 Code fix (unless explicitly asking for new parameters)` : ""}
117200
117067
  - ANY bug fix or implementation error \u2192 Code changes only, NO resource changes
117201
117068
 
117202
117069
  **RESOURCE CHANGES (OUTPUT operations)** - Only when explicitly requested:
117203
117070
  - "Add a new field to the collection" \u2192 Update collection
117204
- - "Change the permission on the collection" \u2192 Update collection
117205
- - "Add a new configuration parameter" \u2192 Update/insert embeddedScriptParameters
117071
+ - "Change the permission on the collection" \u2192 Update collection${hasEmbeddedScriptExtensions ? `- "Add a new configuration parameter" \u2192 Update/insert embeddedScriptParameters` : ""}
117206
117072
  - "Remove this field from the dashboard" \u2192 Might need collection update if removing from schema
117207
117073
  - "I want to also track cart value" \u2192 Update collection to add field
117208
117074
 
117209
117075
  IF THE USER IS REPORTING A BUG OR ERROR, DEFAULT TO RETURNING EMPTY ARRAYS:
117210
- - User mentions: "wrong", "error", "bug", "not working", "fix", "issue", "problem" \u2192 Code fix \u2192 Return: {"collections": [], "embeddedScriptParameters": []}
117076
+ - User mentions: "wrong", "error", "bug", "not working", "fix", "issue", "problem" \u2192 Code fix
117211
117077
  - Unless they EXPLICITLY say "add field", "change schema", "new parameter", etc.
117212
-
117213
- Example 1 - Adding a new collection (existing resources remain unchanged):
117214
-
117215
- ${JSON.stringify(insertExample, null, 2)}
117216
-
117217
- Example 2 - Updating an existing collection:
117218
- ${JSON.stringify(updateExample, null, 2)}
117219
-
117220
- Example 3 - Adding a dashboard for existing collection (NO collection update needed):
117221
- ${JSON.stringify(emptyExample, null, 2)}
117222
-
117223
- Example 4 - Bug fix in code (NO resource changes):
117224
- User says: "in the backend event you are using the collection id wrong, you added sentence of 'Cart Creation Events' to the id"
117225
- ${JSON.stringify(emptyExample, null, 2)}
117226
-
117227
- Example 5 - Deleting resources (BE VERY CAREFUL):
117228
- ${JSON.stringify(deleteExample, null, 2)}
117229
-
117230
117078
  </ITERATION_MODE>
117231
117079
  `;
117232
117080
  exports2.iterationModePrompt = iterationModePrompt;
@@ -117238,109 +117086,86 @@ var require_iterationScenarios = __commonJS({
117238
117086
  "dist/system-prompts/common/iterationScenarios.js"(exports2) {
117239
117087
  "use strict";
117240
117088
  Object.defineProperty(exports2, "__esModule", { value: true });
117241
- exports2.QUICK_DECISION_GUIDE = exports2.COMMON_SCENARIOS_DOCUMENTATION = void 0;
117242
- exports2.COMMON_SCENARIOS_DOCUMENTATION = `
117243
- <common_iteration_scenarios>
117244
- Below are common user request patterns and how they should be handled:
117245
-
117246
- ### 1. Collection ID Error
117247
- **User Request**: "Error with collection ID" / "collection not found"
117248
- **How to Handle**: CODE FIX - Ensure code uses FULL collection ID
117249
- **Requires Extensions**: Yes (modify existing code)
117250
- **Requires Planner**: No
117251
-
117252
- ### 2. Collection Permission Error
117253
- **User Request**: "Permission denied" / "update collection permissions" / "make collection accessible"
117254
- **How to Handle**: PLANNER OPERATION - Update collection permissions via PlannerAgent
117255
- **Requires Extensions**: No
117256
- **Requires Planner**: Yes
117257
- **Examples**:
117258
- - "Change permissions to everyone in collection"
117259
- - "Make collection public"
117260
- - "Update collection access settings"
117261
-
117262
- ### 3. TypeScript Type Error
117263
- **User Request**: "Type error" / "TypeScript error" / "type mismatch"
117264
- **How to Handle**: CODE FIX - Find the file with the type error and fix it
117265
- **Requires Extensions**: Yes (modify existing code)
117266
- **Requires Planner**: No
117267
-
117268
- ### 4. Embedded Script Parameters Mismatch
117269
- **User Request**: "Dashboard page not using correct params" / "embedded script params wrong"
117270
- **How to Handle**: CODE FIX - Ensure dashboard page and embedded script use SAME parameter keys
117271
- **Requires Extensions**: Yes (modify existing code)
117272
- **Requires Planner**: No
117273
-
117274
- ### 5. Modify Existing Code
117275
- **User Request**: "Change/update/modify existing functionality" / "fix bug" / "update logic"
117276
- **How to Handle**: CODE CHANGE - Modify relevant existing extension files
117277
- **Requires Extensions**: Yes (modify existing code)
117278
- **Requires Planner**: No
117279
-
117280
- ### 6. Add New Extension
117281
- **User Request**: "Create new dashboard" / "add new widget" / "build new component" / "add new feature"
117282
- **How to Handle**: CODE + PLANNER - Create new extension(s) and may need new collections/params
117283
- **Requires Extensions**: Yes (create new)
117284
- **Requires Planner**: Maybe (if needs new data structures)
117285
-
117286
- ### 7. Extension Using Existing Collection
117287
- **User Request**: "Create dashboard/widget/component that uses existing collection"
117288
- **How to Handle**: CODE ONLY - Create new extension, reuse existing collection
117289
- **Requires Extensions**: Yes (create new)
117290
- **Requires Planner**: No
117291
-
117292
- ### 8. Add/Remove Collection Fields
117293
- **User Request**: "Add field to collection" / "remove field from collection" / "update collection schema"
117294
- **How to Handle**: BOTH - PlannerAgent updates schema + CodeAgent updates code to use new/removed fields
117295
- **Requires Extensions**: Yes (modify code)
117296
- **Requires Planner**: Yes (update schema)
117297
-
117298
- ### 9. Add/Remove Embedded Script Parameters
117299
- **User Request**: "Add parameter to embedded script" / "remove parameter" / "update script params"
117300
- **How to Handle**: BOTH - PlannerAgent updates parameters + CodeAgent updates dashboard and script code
117301
- **Requires Extensions**: Yes (modify code)
117302
- **Requires Planner**: Yes (update params)
117303
-
117304
- ### 10. Add Initial Data to Collection
117305
- **User Request**: "Add initial data" / "populate collection with data" / "seed collection" / "add default items"
117306
- **How to Handle**: PLANNER OPERATION - Add data to collection's initialData field
117307
- **Requires Extensions**: No
117308
- **Requires Planner**: Yes
117309
- **Examples**:
117310
- - "Add some sample products to the collection"
117311
- - "Populate the collection with initial data"
117312
- - "Seed the collection with default values"
117313
-
117314
- **Legend**:
117315
- - **CODE FIX/CHANGE**: Modify existing extensions
117316
- - **PLANNER OPERATION**: Update collections, permissions, or params (no code changes)
117317
- - **BOTH**: Requires planner updates (data) AND code changes (extensions)
117318
-
117319
- </common_iteration_scenarios>
117320
- `;
117321
- exports2.QUICK_DECISION_GUIDE = `
117322
- <quick_decision_guide>
117323
- **When to return EMPTY arrays (no extensions needed)**:
117324
- - Collection permission changes
117325
- - Collection initial data (seed data, populate collection)
117326
- - Collection schema updates (add/remove fields) - unless code also needs updating
117327
- - Embedded script parameter updates - unless code also needs updating
117328
- - API spec changes
117329
- - Pure data structure modifications
117330
-
117331
- **When extensions ARE needed (modify/create extensions)**:
117332
- - Type errors, bugs, code fixes
117333
- - Collection ID errors in code
117334
- - Parameter mismatches between dashboard and embedded scripts
117335
- - Modifying existing functionality
117336
- - Creating new extensions with existing data structures
117337
-
117338
- **When BOTH planner AND extensions needed**:
117339
- - Adding new extensions that need new collections
117340
- - Collection schema changes that affect existing code
117341
- - Embedded script parameter changes that affect dashboard/script code
117342
- </quick_decision_guide>
117343
- `;
117089
+ exports2.getQuickDecisionGuide = exports2.getCommonScenariosDocumentation = void 0;
117090
+ var getCommonScenariosDocumentation = ({ hasEmbeddedScriptExtensions = true } = {}) => {
117091
+ const scenarios = [
117092
+ `<common_iteration_scenarios>`,
117093
+ `Below are common user request patterns and how they should be handled:`,
117094
+ ``,
117095
+ `### 1. Collection ID Error`,
117096
+ `**User Request**: "Error with collection ID" / "collection not found"`,
117097
+ `**How to Handle**: CODE FIX - Ensure code uses FULL collection ID`,
117098
+ `**Requires Extensions**: Yes (modify existing code)`,
117099
+ `**Requires Planner**: No`,
117100
+ ``,
117101
+ `### 2. Collection Permission Error`,
117102
+ `**User Request**: "Permission denied" / "update collection permissions" / "make collection accessible"`,
117103
+ `**How to Handle**: PLANNER OPERATION - Update collection permissions via PlannerAgent`,
117104
+ `**Requires Extensions**: No`,
117105
+ `**Requires Planner**: Yes`,
117106
+ `**Examples**:`,
117107
+ ` - "Change permissions to everyone in collection"`,
117108
+ ` - "Make collection public"`,
117109
+ ` - "Update collection access settings"`,
117110
+ ``,
117111
+ `### 3. TypeScript Type Error`,
117112
+ `**User Request**: "Type error" / "TypeScript error" / "type mismatch"`,
117113
+ `**How to Handle**: CODE FIX - Find the file with the type error and fix it`,
117114
+ `**Requires Extensions**: Yes (modify existing code)`,
117115
+ `**Requires Planner**: No`
117116
+ ];
117117
+ if (hasEmbeddedScriptExtensions) {
117118
+ scenarios.push(``, `### Embedded Script Parameters Mismatch`, `**User Request**: "Dashboard page not using correct params" / "embedded script params wrong"`, `**How to Handle**: CODE FIX - Ensure dashboard page and embedded script use SAME parameter keys`, `**Requires Extensions**: Yes (modify existing code)`, `**Requires Planner**: No`);
117119
+ scenarios.push(``, `### Add/Remove Embedded Script Parameters`, `**User Request**: "Add parameter to embedded script" / "remove parameter" / "update script params"`, `**How to Handle**: BOTH - PlannerAgent updates parameters + CodeAgent updates dashboard and script code`, `**Requires Extensions**: Yes (modify code)`, `**Requires Planner**: Yes (update params)`);
117120
+ }
117121
+ scenarios.push(``, `### Modify Existing Code`, `**User Request**: "Change/update/modify existing functionality" / "fix bug" / "update logic"`, `**How to Handle**: CODE CHANGE - Modify relevant existing extension files`, `**Requires Extensions**: Yes (modify existing code)`, `**Requires Planner**: No`, ``, `### Add New Extension`, `**User Request**: "Create new dashboard" / "add new widget" / "build new component" / "add new feature"`, `**How to Handle**: CODE + PLANNER - Create new extension(s) and may need new collections/params`, `**Requires Extensions**: Yes (create new)`, `**Requires Planner**: Maybe (if needs new data structures)`, ``, `### Extension Using Existing Collection`, `**User Request**: "Create dashboard/widget/component that uses existing collection"`, `**How to Handle**: CODE ONLY - Create new extension, reuse existing collection`, `**Requires Extensions**: Yes (create new)`, `**Requires Planner**: No`, ``, `### Add/Remove Collection Fields`, `**User Request**: "Add field to collection" / "remove field from collection" / "update collection schema"`, `**How to Handle**: BOTH - PlannerAgent updates schema + CodeAgent updates code to use new/removed fields`, `**Requires Extensions**: Yes (modify code)`, `**Requires Planner**: Yes (update schema)`);
117122
+ scenarios.push(``, `### Add Initial Data to Collection`, `**User Request**: "Add initial data" / "populate collection with data" / "seed collection" / "add default items"`, `**How to Handle**: PLANNER OPERATION - Add data to collection's initialData field`, `**Requires Extensions**: No`, `**Requires Planner**: Yes`, `**Examples**:`, ` - "Add some sample products to the collection"`, ` - "Populate the collection with initial data"`, ` - "Seed the collection with default values"`, ``, `**Legend**:`, `- **CODE FIX/CHANGE**: Modify existing extensions`, `- **PLANNER OPERATION**: Update collections, permissions, or params (no code changes)`, `- **BOTH**: Requires planner updates (data) AND code changes (extensions)`, ``, `</common_iteration_scenarios>`);
117123
+ return scenarios.join("\n");
117124
+ };
117125
+ exports2.getCommonScenariosDocumentation = getCommonScenariosDocumentation;
117126
+ var getQuickDecisionGuide = ({ hasEmbeddedScriptExtensions = true, hasBackendApiExtensions = true } = {}) => {
117127
+ const emptyArrayScenarios = [
117128
+ `- Collection permission changes`,
117129
+ `- Collection initial data (seed data, populate collection)`,
117130
+ `- Collection schema updates (add/remove fields) - unless code also needs updating`
117131
+ ];
117132
+ if (hasEmbeddedScriptExtensions) {
117133
+ emptyArrayScenarios.push(`- Embedded script parameter updates - unless code also needs updating`);
117134
+ }
117135
+ if (hasBackendApiExtensions) {
117136
+ emptyArrayScenarios.push(`- API spec changes`);
117137
+ }
117138
+ emptyArrayScenarios.push(`- Pure data structure modifications`);
117139
+ const extensionsNeeded = [
117140
+ `- Type errors, bugs, code fixes`,
117141
+ `- Collection ID errors in code`
117142
+ ];
117143
+ if (hasEmbeddedScriptExtensions) {
117144
+ extensionsNeeded.push(`- Parameter mismatches between dashboard and embedded scripts`);
117145
+ }
117146
+ extensionsNeeded.push(`- Modifying existing functionality`, `- Creating new extensions with existing data structures`, `- Deleting extensions (embedded scripts, dashboards, widgets, etc.)`);
117147
+ const bothNeeded = [
117148
+ `- Adding new extensions that need new collections`,
117149
+ `- Collection schema changes that affect existing code`
117150
+ ];
117151
+ if (hasEmbeddedScriptExtensions) {
117152
+ bothNeeded.push(`- Embedded script parameter changes that affect dashboard/script code`);
117153
+ }
117154
+ const sections = [
117155
+ `<quick_decision_guide>`,
117156
+ `**When to return EMPTY arrays (no extensions needed)**:`,
117157
+ ...emptyArrayScenarios,
117158
+ ``,
117159
+ `**When extensions ARE needed (modify/create extensions)**:`,
117160
+ ...extensionsNeeded,
117161
+ ``,
117162
+ `**When BOTH planner AND extensions needed**:`,
117163
+ ...bothNeeded,
117164
+ `</quick_decision_guide>`
117165
+ ];
117166
+ return sections.join("\n");
117167
+ };
117168
+ exports2.getQuickDecisionGuide = getQuickDecisionGuide;
117344
117169
  }
117345
117170
  });
117346
117171
 
@@ -117354,191 +117179,21 @@ var require_planner = __commonJS({
117354
117179
  var data_1 = require_data();
117355
117180
  var embeddedScriptDynamicParameters_1 = require_embeddedScriptDynamicParameters();
117356
117181
  var iteration_1 = require_iteration();
117357
- var types_1 = require_types_impl2();
117358
- var ditto_codegen_types_12 = require_dist();
117359
117182
  var iterationScenarios_1 = require_iterationScenarios();
117360
- var completeOutputExample = {
117361
- collections: [
117362
- {
117363
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
117364
- data: {
117365
- idSuffix: "handling-fees-rules",
117366
- displayName: "Handling Fees Rules",
117367
- displayField: "productId",
117368
- fields: [
117369
- {
117370
- key: "productId",
117371
- displayName: "Product",
117372
- type: "REFERENCE",
117373
- referenceOptions: {
117374
- referencedCollectionId: "Stores/Products"
117375
- }
117376
- },
117377
- { key: "oversizedFee", displayName: "Oversized Fee", type: "NUMBER" },
117378
- { key: "fragileFee", displayName: "Fragile Fee", type: "NUMBER" }
117379
- ],
117380
- dataPermissions: {
117381
- itemRead: types_1.AccessLevel.ANYONE,
117382
- itemInsert: types_1.AccessLevel.ANYONE,
117383
- itemUpdate: types_1.AccessLevel.ANYONE,
117384
- itemRemove: types_1.AccessLevel.ANYONE
117385
- }
117386
- }
117387
- }
117388
- ],
117389
- embeddedScriptParameters: [
117390
- {
117391
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
117392
- data: {
117393
- extensionId: "site-popup",
117394
- parameters: [
117395
- {
117396
- key: "headline",
117397
- displayName: "Headline",
117398
- type: "TEXT",
117399
- required: true
117400
- },
117401
- { key: "text", displayName: "Text", type: "TEXT", required: true }
117402
- ]
117403
- }
117404
- }
117405
- ],
117406
- apiSpec: {
117407
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
117408
- data: {
117409
- name: "Todo API",
117410
- description: "A simple todo application API for managing tasks",
117411
- endpoints: [
117412
- {
117413
- id: "get-todos",
117414
- path: "/api/todos",
117415
- method: "GET",
117416
- name: "Get All Todos",
117417
- description: "Retrieve all todo items",
117418
- parameters: [],
117419
- response: {
117420
- statusCode: 200,
117421
- type: "array"
117422
- }
117423
- },
117424
- {
117425
- id: "create-todo",
117426
- path: "/api/todos",
117427
- method: "POST",
117428
- name: "Create Todo",
117429
- description: "Create a new todo item",
117430
- parameters: [
117431
- {
117432
- name: "title",
117433
- type: "string",
117434
- required: true,
117435
- location: "body"
117436
- },
117437
- {
117438
- name: "description",
117439
- type: "string",
117440
- required: false,
117441
- location: "body"
117442
- },
117443
- {
117444
- name: "completed",
117445
- type: "boolean",
117446
- required: false,
117447
- location: "body"
117448
- }
117449
- ],
117450
- response: {
117451
- statusCode: 201,
117452
- type: "object"
117453
- }
117454
- }
117455
- ],
117456
- dataModels: [
117457
- {
117458
- name: "Todo",
117459
- properties: {
117460
- id: {
117461
- type: "string",
117462
- required: true
117463
- },
117464
- title: {
117465
- type: "string",
117466
- required: true
117467
- },
117468
- description: {
117469
- type: "string",
117470
- required: false
117471
- },
117472
- completed: {
117473
- type: "boolean",
117474
- required: true
117475
- },
117476
- createdAt: {
117477
- type: "string",
117478
- required: true
117479
- },
117480
- updatedAt: {
117481
- type: "string",
117482
- required: true
117483
- }
117484
- }
117485
- }
117486
- ]
117487
- }
117488
- }
117489
- };
117490
- var outputWithoutApiSpecExample = {
117491
- collections: [
117492
- {
117493
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
117494
- data: {
117495
- idSuffix: "products-config",
117496
- displayName: "Products Configuration",
117497
- displayField: "name",
117498
- fields: [
117499
- { key: "name", displayName: "Configuration Name", type: "TEXT" }
117500
- ],
117501
- dataPermissions: {
117502
- itemRead: types_1.AccessLevel.ANYONE,
117503
- itemInsert: types_1.AccessLevel.PRIVILEGED,
117504
- itemUpdate: types_1.AccessLevel.PRIVILEGED,
117505
- itemRemove: types_1.AccessLevel.PRIVILEGED
117506
- }
117507
- }
117508
- }
117509
- ],
117510
- embeddedScriptParameters: [
117511
- {
117512
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
117513
- data: {
117514
- extensionId: "my-script",
117515
- parameters: [
117516
- {
117517
- key: "enabled",
117518
- displayName: "Enable",
117519
- type: "BOOLEAN",
117520
- required: true,
117521
- defaultValue: "true"
117522
- }
117523
- ]
117524
- }
117525
- }
117526
- ]
117527
- };
117528
- var plannerPrompt = (hasEmbeddedScriptExtensions, hasBackendApiExtensions, isIteration = false) => {
117183
+ var plannerPrompt = ({ hasEmbeddedScriptExtensions, hasBackendApiExtensions, isIteration = false }) => {
117529
117184
  return `
117530
117185
  <WIXCLI_PLANNER_SYSTEM_PROMPT>
117531
117186
  You are a planner that generates a structured JSON response with specific top-level fields.
117532
117187
 
117533
- ${iterationScenarios_1.COMMON_SCENARIOS_DOCUMENTATION}
117188
+ ${(0, iterationScenarios_1.getCommonScenariosDocumentation)({ hasEmbeddedScriptExtensions })}
117534
117189
 
117535
- ${iterationScenarios_1.QUICK_DECISION_GUIDE}
117190
+ ${(0, iterationScenarios_1.getQuickDecisionGuide)({ hasEmbeddedScriptExtensions, hasBackendApiExtensions })}
117536
117191
 
117537
117192
  <your_responsibilities>
117538
- You are responsible for handling DATA OPERATIONS ONLY:
117193
+ You are responsible for handling OPERATIONS ONLY:
117539
117194
  - Collection schema changes (add/remove fields, update permissions)
117540
- - Embedded script parameter changes
117541
- - API specifications
117195
+ ${hasEmbeddedScriptExtensions ? "- Embedded script parameter changes" : ""}
117196
+ ${hasBackendApiExtensions ? "- API specifications" : ""}
117542
117197
 
117543
117198
  DO NOT handle:
117544
117199
  - Type errors (CodeAgent handles)
@@ -117550,57 +117205,10 @@ If the user request is ONLY about data structures (collections, permissions, par
117550
117205
  If the user request is about CODE FIXES (errors, bugs, logic), return EMPTY arrays - the CodeAgent will handle it.
117551
117206
  </your_responsibilities>
117552
117207
 
117553
- CRITICAL OUTPUT STRUCTURE:
117554
- Your JSON response MUST have exactly these top-level fields (and no others):
117555
- - "collections": array of collection operations
117556
- - "embeddedScriptParameters": array of embedded script parameter operations
117557
- - "apiSpec": (ONLY if backend API extensions exist) an object with "operation" and "data" fields, if the apiSpec is not needed, do not include the "apiSpec" field in your JSON response at all.
117558
-
117559
- COMPLETE OUTPUT EXAMPLES:
117560
-
117561
- Example 1 - WITH backend API extensions (includes apiSpec):
117562
- \`\`\`json
117563
- ${JSON.stringify(completeOutputExample, null, 2)}
117564
- \`\`\`
117565
-
117566
- Example 2 - WITHOUT backend API extensions (no apiSpec field):
117567
- \`\`\`json
117568
- ${JSON.stringify(outputWithoutApiSpecExample, null, 2)}
117569
- \`\`\`
117570
-
117571
- CRITICAL NOTES:
117572
- - "collections" and "embeddedScriptParameters" are ALWAYS top-level fields
117573
- - "apiSpec" is ALSO a top-level field when present (NOT nested inside anything)
117574
- - The "apiSpec" field has the structure: { "operation": "insert", "data": {...} }
117575
- - Each collection in "collections" array has: { "operation": "insert|update|delete", "data": {...} }
117576
- - Each item in "embeddedScriptParameters" has: { "operation": "insert|delete", "data": {...} }
117577
- * embeddedScriptParameters ONLY support INSERT and DELETE operations (no UPDATE)
117578
- * To modify a parameter, use DELETE (old) followed by INSERT (new)
117579
- - For "delete" operation on embeddedScriptParameters, data needs: { "extensionId": "...", "keys": ["key1", "key2", ...] }
117580
- - For "insert" operation on embeddedScriptParameters, data needs: { "extensionId": "...", "parameters": [...] }
117581
-
117582
- ${isIteration ? (0, iteration_1.iterationModePrompt)() : ""}
117583
-
117208
+ ${isIteration && (0, iteration_1.iterationModePrompt)({ hasEmbeddedScriptExtensions, hasBackendApiExtensions })}
117584
117209
  ${(0, data_1.cmsPlannerPrompt)()}
117585
-
117586
- ${hasBackendApiExtensions ? (0, apiSpec_1.apiSpecPrompt)() : `
117587
- <no_api_spec_needed>
117588
- NO BACKEND_API EXTENSIONS IN THE BLUEPRINT - DO NOT CREATE AN API SPEC.
117589
- CRITICAL: Do NOT include the "apiSpec" field in your JSON response at all. The field should be completely absent from your output, not set to null, undefined, or any string value.
117590
-
117591
- WRONG (DO NOT DO THIS):
117592
- {
117593
- "apiSpec": {
117594
- "collections": [],
117595
- "embeddedScriptParameters": []
117596
- }
117597
- }
117598
-
117599
- The "collections" and "embeddedScriptParameters" are TOP-LEVEL fields, not nested inside anything.
117600
- </no_api_spec_needed>
117601
- `}
117602
-
117603
- ${hasEmbeddedScriptExtensions ? (0, embeddedScriptDynamicParameters_1.embeddedScriptDynamicParametersPrompt)() : 'No embeddedScriptParameters needed, no embedded scripts in the blueprint, return an empty array: "embeddedScriptParameters": []'}
117210
+ ${hasBackendApiExtensions ? (0, apiSpec_1.apiSpecPrompt)() : ""}
117211
+ ${hasEmbeddedScriptExtensions ? (0, embeddedScriptDynamicParameters_1.embeddedScriptDynamicParametersPrompt)() : ""}
117604
117212
  </WIXCLI_PLANNER_SYSTEM_PROMPT>
117605
117213
  `;
117606
117214
  };
@@ -117608,6 +117216,49 @@ ${hasEmbeddedScriptExtensions ? (0, embeddedScriptDynamicParameters_1.embeddedSc
117608
117216
  }
117609
117217
  });
117610
117218
 
117219
+ // ../../node_modules/zod/index.cjs
117220
+ var require_zod = __commonJS({
117221
+ "../../node_modules/zod/index.cjs"(exports2) {
117222
+ "use strict";
117223
+ var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
117224
+ if (k2 === void 0) k2 = k;
117225
+ var desc = Object.getOwnPropertyDescriptor(m, k);
117226
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
117227
+ desc = { enumerable: true, get: function() {
117228
+ return m[k];
117229
+ } };
117230
+ }
117231
+ Object.defineProperty(o, k2, desc);
117232
+ }) : (function(o, m, k, k2) {
117233
+ if (k2 === void 0) k2 = k;
117234
+ o[k2] = m[k];
117235
+ }));
117236
+ var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
117237
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
117238
+ }) : function(o, v) {
117239
+ o["default"] = v;
117240
+ });
117241
+ var __importStar2 = exports2 && exports2.__importStar || function(mod2) {
117242
+ if (mod2 && mod2.__esModule) return mod2;
117243
+ var result = {};
117244
+ if (mod2 != null) {
117245
+ for (var k in mod2) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod2, k)) __createBinding2(result, mod2, k);
117246
+ }
117247
+ __setModuleDefault2(result, mod2);
117248
+ return result;
117249
+ };
117250
+ var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
117251
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding2(exports3, m, p);
117252
+ };
117253
+ Object.defineProperty(exports2, "__esModule", { value: true });
117254
+ exports2.z = void 0;
117255
+ var z = __importStar2(require_external());
117256
+ exports2.z = z;
117257
+ __exportStar2(require_external(), exports2);
117258
+ exports2.default = z;
117259
+ }
117260
+ });
117261
+
117611
117262
  // dist/agents/utils.js
117612
117263
  var require_utils11 = __commonJS({
117613
117264
  "dist/agents/utils.js"(exports2) {
@@ -118136,58 +117787,88 @@ var require_dist11 = __commonJS({
118136
117787
  }
118137
117788
  });
118138
117789
 
118139
- // dist/agents/PlannerAgent.js
118140
- var require_PlannerAgent = __commonJS({
118141
- "dist/agents/PlannerAgent.js"(exports2) {
117790
+ // dist/agents/planner/PlannerAgentSchema.js
117791
+ var require_PlannerAgentSchema = __commonJS({
117792
+ "dist/agents/planner/PlannerAgentSchema.js"(exports2) {
118142
117793
  "use strict";
117794
+ var __importDefault2 = exports2 && exports2.__importDefault || function(mod2) {
117795
+ return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
117796
+ };
118143
117797
  Object.defineProperty(exports2, "__esModule", { value: true });
118144
- exports2.PlannerAgent = exports2.PlannerOutputSchema = exports2.ApiSpecOperationSchema = exports2.CollectionOperationSchema = void 0;
118145
- var types_1 = require_types_impl();
118146
- var anthropic_1 = require_dist6();
118147
- var ai_1 = require_dist10();
118148
- var zod_1 = require_zod();
118149
- var planner_1 = require_planner();
118150
- var utils_1 = require_utils11();
117798
+ exports2.createPlannerOutputSchema = exports2.ApiSpecOperationSchema = void 0;
118151
117799
  var ApiSpecSchema_1 = require_ApiSpecSchema();
118152
117800
  var EmbeddedScriptSchema_1 = require_EmbeddedScriptSchema();
118153
117801
  var ditto_codegen_types_12 = require_dist();
118154
117802
  var wix_data_collections_extension_schema_1 = require_dist11();
117803
+ var zod_1 = __importDefault2(require_zod());
118155
117804
  var CollectionSchema = wix_data_collections_extension_schema_1.DataCollectionsExtensionSchema.shape.collections.element.describe("The collection data");
118156
- var DeleteCollectionDataSchema = zod_1.z.object({
118157
- idSuffix: zod_1.z.string().describe("The ID suffix of the collection to delete")
117805
+ var DeleteCollectionDataSchema = zod_1.default.object({
117806
+ idSuffix: zod_1.default.string().describe("The ID suffix of the collection to delete")
118158
117807
  });
118159
- exports2.CollectionOperationSchema = zod_1.z.discriminatedUnion("operation", [
118160
- zod_1.z.object({
118161
- operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
117808
+ var CollectionOperationSchema = zod_1.default.discriminatedUnion("operation", [
117809
+ zod_1.default.object({
117810
+ operation: zod_1.default.literal(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
118162
117811
  data: CollectionSchema.describe("Complete collection data for insertion")
118163
117812
  }),
118164
- zod_1.z.object({
118165
- operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.UPDATE),
117813
+ zod_1.default.object({
117814
+ operation: zod_1.default.literal(ditto_codegen_types_12.ExtensionGenerationOperation.UPDATE),
118166
117815
  data: CollectionSchema.describe("Complete collection data for update")
118167
117816
  }),
118168
- zod_1.z.object({
118169
- operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.DELETE),
117817
+ zod_1.default.object({
117818
+ operation: zod_1.default.literal(ditto_codegen_types_12.ExtensionGenerationOperation.DELETE),
118170
117819
  data: DeleteCollectionDataSchema.describe("Only idSuffix required for deletion")
118171
117820
  })
118172
117821
  ]);
118173
- exports2.ApiSpecOperationSchema = zod_1.z.object({
118174
- operation: zod_1.z.literal(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT).describe("Operation: insert (create new), api spec supports only insert operation").default(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
117822
+ exports2.ApiSpecOperationSchema = zod_1.default.object({
117823
+ operation: zod_1.default.literal(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT).describe("Operation: insert (create new), api spec supports only insert operation").default(ditto_codegen_types_12.ExtensionGenerationOperation.INSERT),
118175
117824
  data: ApiSpecSchema_1.ApiSpecSchema.describe("The API specification")
118176
117825
  });
118177
- exports2.PlannerOutputSchema = zod_1.z.object({
118178
- collections: zod_1.z.array(exports2.CollectionOperationSchema).default([]).describe("CMS collection operations - only include collections that need to be created, updated, or deleted"),
118179
- embeddedScriptParameters: zod_1.z.array(EmbeddedScriptSchema_1.EmbeddedScriptParametersOperationSchema).default([]).describe("Embedded script parameters operations - only include parameters that need to be created, updated, or deleted"),
118180
- apiSpec: exports2.ApiSpecOperationSchema.optional().describe("API specification operation - only include if API spec needs to be created, updated, or deleted")
118181
- });
117826
+ var createPlannerOutputSchema = (options) => {
117827
+ let schema = zod_1.default.object({
117828
+ collections: zod_1.default.array(CollectionOperationSchema).default([]).describe("CMS collection operations - only include collections that need to be created, updated, or deleted, return [] if no need to change")
117829
+ });
117830
+ if (options.hasEmbeddedScriptExtensions) {
117831
+ schema = schema.extend({
117832
+ embeddedScriptParameters: zod_1.default.array(EmbeddedScriptSchema_1.EmbeddedScriptParametersOperationSchema).default([]).describe("Embedded script parameters operations - only include parameters that need to be created, updated, or deleted, return [] if no need to change")
117833
+ });
117834
+ }
117835
+ if (options.hasBackendApiExtensions) {
117836
+ schema = schema.extend({
117837
+ apiSpec: exports2.ApiSpecOperationSchema.optional().describe("API specification operation - only include if API spec needs to be created")
117838
+ });
117839
+ }
117840
+ return schema;
117841
+ };
117842
+ exports2.createPlannerOutputSchema = createPlannerOutputSchema;
117843
+ }
117844
+ });
117845
+
117846
+ // dist/agents/planner/PlannerAgent.js
117847
+ var require_PlannerAgent = __commonJS({
117848
+ "dist/agents/planner/PlannerAgent.js"(exports2) {
117849
+ "use strict";
117850
+ Object.defineProperty(exports2, "__esModule", { value: true });
117851
+ exports2.PlannerAgent = void 0;
117852
+ var types_1 = require_types_impl();
117853
+ var anthropic_1 = require_dist6();
117854
+ var ai_1 = require_dist10();
117855
+ var planner_1 = require_planner();
117856
+ var utils_1 = require_utils11();
117857
+ var ditto_codegen_types_12 = require_dist();
117858
+ var PlannerAgentSchema_1 = require_PlannerAgentSchema();
118182
117859
  var PlannerAgent = class {
118183
117860
  constructor(apiKey) {
118184
117861
  this.apiKey = apiKey;
118185
117862
  this.name = "PlannerAgent";
118186
117863
  }
118187
117864
  buildSystemPrompt(hasEmbeddedScriptExtensions, hasBackendApiExtensions, isIteration) {
118188
- return (0, planner_1.plannerPrompt)(hasEmbeddedScriptExtensions, hasBackendApiExtensions, isIteration);
117865
+ return (0, planner_1.plannerPrompt)({
117866
+ hasEmbeddedScriptExtensions,
117867
+ hasBackendApiExtensions,
117868
+ isIteration
117869
+ });
118189
117870
  }
118190
- async generatePlan({ systemPrompt, blueprint, error, previousResources }) {
117871
+ async generatePlan({ systemPrompt, blueprint, error, previousResources, schema }) {
118191
117872
  const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-3-5-haiku-latest");
118192
117873
  const userContent = `
118193
117874
  ${JSON.stringify(blueprint, null, 2)}
@@ -118202,7 +117883,7 @@ ${error}` : ""}
118202
117883
  `;
118203
117884
  const result = await (0, ai_1.generateObject)({
118204
117885
  model,
118205
- schema: exports2.PlannerOutputSchema,
117886
+ schema,
118206
117887
  messages: [
118207
117888
  {
118208
117889
  role: "system",
@@ -118228,13 +117909,16 @@ ${error}` : ""}
118228
117909
  const extensions = blueprint?.extensions || [];
118229
117910
  if (extensions.length === 0) {
118230
117911
  return {
118231
- collections: [],
118232
- embeddedScriptParameters: []
117912
+ collections: []
118233
117913
  };
118234
117914
  }
118235
117915
  const hasEmbeddedScriptExtensions = extensions.some((ext) => ext.type === types_1.ExtensionType.EMBEDDED_SCRIPT);
118236
117916
  const hasBackendApiExtensions = extensions.some((ext) => ext.type === types_1.ExtensionType.BACKEND_API);
118237
117917
  const systemPrompt = this.buildSystemPrompt(hasEmbeddedScriptExtensions, hasBackendApiExtensions, isIteration);
117918
+ const schema = (0, PlannerAgentSchema_1.createPlannerOutputSchema)({
117919
+ hasEmbeddedScriptExtensions,
117920
+ hasBackendApiExtensions
117921
+ });
118238
117922
  let lastError;
118239
117923
  for (let i = 0; i < 3; i++) {
118240
117924
  try {
@@ -118242,7 +117926,8 @@ ${error}` : ""}
118242
117926
  systemPrompt,
118243
117927
  blueprint,
118244
117928
  error: lastError,
118245
- previousResources
117929
+ previousResources,
117930
+ schema
118246
117931
  });
118247
117932
  return result;
118248
117933
  } catch (error) {
@@ -122088,17 +121773,22 @@ var require_iterationAgentPrompt = __commonJS({
122088
121773
  You are an iteration agent for a Wix app code generation system.
122089
121774
  Given the full chat history, current user request, and all project files:
122090
121775
  1. Generate a clear summary of what the user wants to achieve
122091
- 2. Identify which existing extensions need to be MODIFIED to handle this request (currentExtensions)
121776
+ 2. Identify which existing extensions need to be MODIFIED or DELETED to handle this request (currentExtensions)
122092
121777
  3. Map each modified extension to the relevant file paths it needs to update
122093
121778
  4. Propose new extensions that need to be CREATED for functionality not covered by existing ones (additionalExtensions)
122094
121779
  5. **CRITICAL**: Only include existing extensions in currentExtensions if they actually need changes. If the user wants to ADD something new, use additionalExtensions instead.
122095
121780
 
122096
121781
  **IMPORTANT**: Before deciding on extensions, check if this is a data-only operation (handled by PlannerAgent). See common scenarios below.
121782
+
121783
+ **DELETION OPERATIONS**: When the user wants to DELETE an extension (e.g., "delete the embedded script", "remove the dashboard", "delete the widget"):
121784
+ - Include the extension in currentExtensions with its paths
121785
+ - Set relevantUserRequest to clearly state "Delete this extension" or similar
121786
+ - The code generation agent will handle removing the files
122097
121787
  </role>
122098
121788
 
122099
- ${iterationScenarios_1.COMMON_SCENARIOS_DOCUMENTATION}
121789
+ ${(0, iterationScenarios_1.getCommonScenariosDocumentation)()}
122100
121790
 
122101
- ${iterationScenarios_1.QUICK_DECISION_GUIDE}
121791
+ ${(0, iterationScenarios_1.getQuickDecisionGuide)()}
122102
121792
 
122103
121793
  <supported_extension_types>
122104
121794
 
@@ -122138,7 +121828,7 @@ When relevant existing extensions are identified:
122138
121828
  </extension_selection_logic>
122139
121829
 
122140
121830
  <constraints>
122141
- - Return the JSON schema with currentExtensions, additionalExtensions, and summary
121831
+ - Return a JSON object with currentExtensions, additionalExtensions, and summary fields
122142
121832
  - **CRITICAL**: Only propose additional extensions if existing ones cannot fulfill the user's request. Review "Relevant Existing Extensions" carefully before creating duplicates.
122143
121833
  - Be specific about which file paths are relevant for each current extension (all extension types)
122144
121834
  - Consider the full chat history context when making decisions
@@ -122155,6 +121845,7 @@ When relevant existing extensions are identified:
122155
121845
  - For currentExtensions, ensure relevantUserRequest precisely reflects the change to be applied in those files (e.g., "Update static fee from 5 ILS to 10 ILS"), not a generic description
122156
121846
  - For additionalExtensions, ensure relevantUserRequest describes the new functionality being created (e.g., "Add new 10 ILS static fee calculator")
122157
121847
  - **KEY RULE**: If the user wants to ADD something new (not modify existing), use additionalExtensions. If the user wants to MODIFY something existing, use currentExtensions.
121848
+ - **CRITICAL - EXTENSION-SPECIFIC DESCRIPTIONS**: The relevantUserRequest field becomes the extension's description and is passed directly to individual agents. Each agent ONLY sees its own extension - they don't have context about other extensions, the broader user request, or duplicate issues. Focus on WHAT THIS SPECIFIC EXTENSION should do, not WHY or how it relates to other extensions. Do not reference other extensions.
122158
121849
  </constraints>
122159
121850
 
122160
121851
 
@@ -122230,13 +121921,13 @@ var require_IterationAgent = __commonJS({
122230
121921
  name: zod_1.z.string().describe("A descriptive name for this extension"),
122231
121922
  relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
122232
121923
  paths: zod_1.z.array(zod_1.z.string()).describe("Paths relevant for this extension"),
122233
- relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension addresses")
121924
+ relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
122234
121925
  });
122235
121926
  var AdditionalExtensionSchema = zod_1.z.object({
122236
121927
  extensionType: zod_1.z.enum(types_1.ExtensionType).describe("The extension kind to add"),
122237
121928
  name: zod_1.z.string().describe("A descriptive name for this extension"),
122238
121929
  relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
122239
- relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension addresses")
121930
+ relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
122240
121931
  });
122241
121932
  var IterationPlanSchema = zod_1.z.object({
122242
121933
  currentExtensions: zod_1.z.array(CurrentExtensionSchema).describe("Existing extensions to be triggered"),
@@ -123500,9 +123191,9 @@ var require_extensionsRelevancePrompt = __commonJS({
123500
123191
 
123501
123192
  You evaluate ONE extension at a time for relevance to a user request.
123502
123193
 
123503
- ${iterationScenarios_1.COMMON_SCENARIOS_DOCUMENTATION}
123194
+ ${(0, iterationScenarios_1.getCommonScenariosDocumentation)()}
123504
123195
 
123505
- ${iterationScenarios_1.QUICK_DECISION_GUIDE}
123196
+ ${(0, iterationScenarios_1.getQuickDecisionGuide)()}
123506
123197
 
123507
123198
  ## Available Tools
123508
123199
 
@@ -134215,9 +133906,11 @@ var require_orchestrator = __commonJS({
134215
133906
  const start = Date.now();
134216
133907
  const { extensions = [] } = blueprint;
134217
133908
  const plan = await this.generatePlan(request);
134218
- const cmsFiles = (0, cms_1.getDataExtensionAndCollectionsFiles)(plan.collections);
134219
- if (cmsFiles.length > 0) {
134220
- (0, write_file_1.writeFile)(cmsFiles, outputPath);
133909
+ if (plan?.collections?.length > 0) {
133910
+ const cmsFiles = (0, cms_1.getDataExtensionAndCollectionsFiles)(plan.collections);
133911
+ if (cmsFiles.length > 0) {
133912
+ (0, write_file_1.writeFile)(cmsFiles, outputPath);
133913
+ }
134221
133914
  }
134222
133915
  const processedPlan = {
134223
133916
  ...plan,
@@ -353566,7 +353259,6 @@ var require_IterationOrchestrator = __commonJS({
353566
353259
  * Generate plan and resources for iteration
353567
353260
  */
353568
353261
  async generatePlan({ extensions, summary, previousResources }) {
353569
- this.emitEvent("planner:start", {});
353570
353262
  const planner = this.agentsFactory.getAgent({ type: "PLANNER" });
353571
353263
  const blueprint = {
353572
353264
  appName: "Iteration Update",
@@ -353578,7 +353270,6 @@ var require_IterationOrchestrator = __commonJS({
353578
353270
  previousResources
353579
353271
  });
353580
353272
  console.log("Iteration Plan", JSON.stringify(plan, null, 2));
353581
- this.emitEvent("planner:done", {});
353582
353273
  return plan;
353583
353274
  }
353584
353275
  /**
@@ -353782,7 +353473,7 @@ var initializeTracing = async () => {
353782
353473
  process.exit(1);
353783
353474
  }
353784
353475
  };
353785
- var baseUrl = process.env.BASE_URL || "http://localhost:3000";
353476
+ var baseUrl = process.env.CODEGEN_BASE_URL || "http://localhost:3000";
353786
353477
  exports.codeGenerationService = new CodeGenService_1.CodeGenService(baseUrl, context_1.ctx.projectId);
353787
353478
  exports.jobCancellationMonitor = new job_cancellation_monitor_1.JobCancellationMonitor(exports.codeGenerationService);
353788
353479
  var delay = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.123",
3
+ "version": "1.0.125",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -24,5 +24,5 @@
24
24
  "@wix/ditto-codegen": "1.0.0",
25
25
  "esbuild": "^0.25.9"
26
26
  },
27
- "falconPackageHash": "19d3322bb9349ba5025ce8a9309b3988b12fb19be7c908eba3ee3c88"
27
+ "falconPackageHash": "999c0c914818f243602e8995ec8c13ec98a9631166ba923f55c51136"
28
28
  }