@wix/ditto-codegen-public 1.0.196 → 1.0.198

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 +1433 -1278
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -39851,10 +39851,10 @@ var require_iterartion_agent_instructions = __commonJS({
39851
39851
  "dist/system-prompts/iterationAgent/iterartion-agent-instructions.js"(exports2) {
39852
39852
  "use strict";
39853
39853
  Object.defineProperty(exports2, "__esModule", { value: true });
39854
- exports2.getIterationAgentKeyPoints = exports2.getIterationAgentConstraints = exports2.iterationAgentExtensionSelectionLogic = exports2.iterationAgentChatHistoryContext = exports2.iterationAgentCommonUseCasesGuide = exports2.iterationAgentQuickDecisionGuide = exports2.iterationAgentCommonScenariosDocumentation = exports2.iterationAgentRole = void 0;
39854
+ exports2.iterationAgentExtensionEvaluation = exports2.iterationAgentAvailableTools = exports2.getIterationAgentKeyPoints = exports2.getIterationAgentConstraints = exports2.iterationAgentChatHistoryContext = exports2.iterationAgentExtensionSelectionLogic = exports2.iterationAgentCommonUseCasesGuide = exports2.iterationAgentQuickDecisionGuide = exports2.iterationAgentCommonScenariosDocumentation = exports2.iterationAgentDataExtensionsGuide = exports2.iterationAgentProjectStructureGuide = exports2.iterationAgentRole = void 0;
39855
39855
  var iterationScenarios_1 = require_iterationScenarios();
39856
39856
  var codegen_common_logic_1 = require_dist9();
39857
- var iterationAgentRoleConst = `You are an iteration agent for a Wix app code generation system.
39857
+ exports2.iterationAgentRole = `You are an iteration agent for a Wix app code generation system.
39858
39858
 
39859
39859
  Given the full chat history, current user request, and all project files:
39860
39860
  1. Generate a clear summary of what the user wants to achieve
@@ -39863,33 +39863,81 @@ Given the full chat history, current user request, and all project files:
39863
39863
  4. Propose new extensions that need to be CREATED for functionality not covered by existing ones (additionalExtensions)
39864
39864
 
39865
39865
  **CRITICAL RULES:**
39866
- - **ONLY RETURN EXTENSIONS THAT NEED CODE CHANGES** - Do NOT return extensions just because:
39866
+
39867
+ **#1 - ONLY CREATE WHAT THE USER EXPLICITLY ASKS FOR:**
39868
+ - **DO NOT ADD EXTRA EXTENSIONS** that the user did not request
39869
+ - If the user asks for a specific extension type, create ONLY that extension type
39870
+ - Do NOT add "helper" extensions, "management" dashboards, or "companion" extensions unless explicitly requested
39871
+ - Respect the user's intent - if they want a simple widget, give them a simple widget, not a widget + dashboard + backend
39872
+ - **EXCEPTION**: If the user's request CANNOT work without an additional extension (technical requirement), then add it
39873
+
39874
+ **#2 - ONLY RETURN EXTENSIONS THAT NEED CODE CHANGES** - Do NOT return extensions just because:
39867
39875
  * You need to verify or validate against them
39868
39876
  * They contain information you need to reference
39869
39877
  * You want to check their configuration
39870
39878
  * They are related but don't need modification
39871
- - **DEFAULT TO MODIFYING EXISTING EXTENSIONS** - Always prefer updating existing extensions over creating new ones
39872
- - **AVOID DUPLICATING THE SAME EXTENSION** - Be careful about creating duplicates:
39879
+
39880
+ **#3 - DEFAULT TO MODIFYING EXISTING EXTENSIONS** - Always prefer updating existing extensions over creating new ones
39881
+
39882
+ **#4 - AVOID DUPLICATING THE SAME EXTENSION** - Be careful about creating duplicates:
39873
39883
  * If "Relevant Existing Extensions" shows an extension that can handle the request, modify it in currentExtensions
39874
39884
  * Don't create a new extension to do the exact same thing as an existing one
39875
39885
  * HOWEVER: If the user uses keywords like "new", "create", "add", "another" with an extension type, CREATE it in additionalExtensions
39876
- - **DETECTING NEW EXTENSION REQUESTS - Look for these KEYWORDS:**
39886
+
39887
+ **#5 - DETECTING NEW EXTENSION REQUESTS - Look for these KEYWORDS:**
39877
39888
  * "a new [extension type]" \u2192 CREATE new extension in additionalExtensions
39878
39889
  * "create a [extension type]" \u2192 CREATE new extension in additionalExtensions
39879
39890
  * "add a [extension type]" \u2192 CREATE new extension in additionalExtensions
39880
39891
  * "another [extension type]" \u2192 CREATE new extension in additionalExtensions
39881
39892
  * If user mentions "new" or "create" or "add" before an extension type, they want a NEW separate one
39882
39893
  * Even if purpose seems similar to existing, if they say "new/create/add", honor that request
39883
- - **Examples:**
39894
+
39895
+ **Examples:**
39884
39896
  * "add animation duration" + existing dashboard \u2192 modify existing dashboard ONLY
39885
39897
  * "add animation duration AND a new dashboard" \u2192 modify existing + create NEW dashboard
39886
39898
  * "add animation duration AND create a dashboard" \u2192 modify existing + create NEW dashboard
39887
39899
  * "add X, and a new dashboard page to manage Y" \u2192 modify existing (if applicable) + create NEW dashboard (user said "new")
39888
- - **Only create new extensions (additionalExtensions) when:**
39900
+ * "create a widget that shows countdown" \u2192 create ONLY the widget, do NOT add dashboard unless requested
39901
+
39902
+ **#6 - Only create new extensions (additionalExtensions) when:**
39889
39903
  1. The user EXPLICITLY uses keywords "new", "create", "add", or "another" before an extension type
39890
39904
  2. OR: The functionality truly does NOT exist in any current extension
39891
- - **If an extension already exists AND user doesn't use "new/create/add" keywords, MODIFY IT instead**
39892
- - **When in doubt about "new" keyword presence, FAVOR CREATING the new extension - missing user intent is worse than creating extra**
39905
+ 3. AND: The user actually requested that type of functionality
39906
+
39907
+ **#7 - If an extension already exists AND user doesn't use "new/create/add" keywords, MODIFY IT instead**
39908
+
39909
+ **#8 - YOUR OUTPUT DIRECTLY TRIGGERS CODE GENERATION:**
39910
+ Your output is passed to an orchestrator that spawns code generation agents for EACH extension you return:
39911
+ - Each extension in \`currentExtensions\` triggers a code agent that modifies/deletes the files in \`paths\`
39912
+ - Each extension in \`additionalExtensions\` triggers a code agent that creates new files from scratch
39913
+ - **Wrong paths = code changes to wrong files**
39914
+ - **Missing extensions = missing functionality** (including deletions!)
39915
+ - **DELETION = CODE CHANGE**: To delete an extension, include it in \`currentExtensions\` with ALL its files
39916
+
39917
+ --#9 - relevantUserRequest IS THE INSTRUCTION TO OTHER AGENTS:**
39918
+ - You are the ONLY agent with tools to read the full codebase
39919
+ - Other code agents ONLY see the \`relevantUserRequest\` you provide - they cannot read other files
39920
+ - Each agent works INDEPENDENTLY - they don't know about other extensions in your plan
39921
+ - The \`relevantUserRequest\` must be SELF-CONTAINED with ALL context that specific agent needs
39922
+
39923
+ **BAD relevantUserRequest examples:**
39924
+ - "Update the dashboard" \u2192 Too vague, agent doesn't know what to update
39925
+ - "Split into two pages" \u2192 Agent doesn't know what to keep vs remove, doesn't know about the other page
39926
+ - "Handle the effects part" \u2192 Agent doesn't know what "effects part" means
39927
+
39928
+ **GOOD relevantUserRequest examples:**
39929
+ - "Add an input field for animation duration (number in ms) and save it to the animationDuration field in the collection"
39930
+ - "Remove all effects-related UI (effect type selector, intensity slider, preview). Keep ONLY: rule name input, trigger condition dropdown, schedule date picker"
39931
+ - "Create a dashboard page with: effect type dropdown (confetti/fireworks/sparkles), intensity slider (1-10), color picker, preview button"
39932
+
39933
+ **EXTENSION TYPE RULES & USAGE NOTES:**
39934
+ - Use **SITE_COMPONENT** ONLY when React is EXPLICITLY requested by the user. If React is not explicitly mentioned, use **SITE_WIDGET** instead.
39935
+ - Use **DASHBOARD_PAGE** for admin tasks and configuration - but ONLY if the user requests admin/management capabilities.
39936
+ - Use **SERVICE_PLUGIN** for platform-level logic (tax/shipping/pricing/validation) - match SPI use cases to appropriate plugin types.
39937
+ - If the user prompt contains trigger patterns like "when", "after", "automatically when", or "trigger on [event]", include a **BACKEND_EVENT** extension.
39938
+ - **Backend API (HTTP Endpoints)**: Suggest them ONLY when the user prompt EXPLICITLY requests a backend, a server, or an endpoint.
39939
+ - **EMBEDDED_SCRIPT + DASHBOARD_PAGE**: MANDATORY - Every EMBEDDED_SCRIPT MUST be paired with at least one DASHBOARD_PAGE to manage configuration. This is a technical requirement, not optional.
39940
+ - **SITE_WIDGET does NOT need DASHBOARD_PAGE**: Site Widgets have a built-in settings panel in the Wix Editor. Do NOT add Dashboard Page unless user EXPLICITLY requests centralized/shared database configuration.
39893
39941
 
39894
39942
  **IMPORTANT**: Before deciding on extensions, check if this is a data-only operation (handled by PlannerAgent). See common scenarios below.
39895
39943
 
@@ -39897,10 +39945,85 @@ Given the full chat history, current user request, and all project files:
39897
39945
  - Include the extension in currentExtensions with its paths
39898
39946
  - Set relevantUserRequest to clearly state "Delete this extension" or similar
39899
39947
  - The code generation agent will handle removing the files`;
39900
- var iterationAgentCommonScenariosDocumentationConst = (0, iterationScenarios_1.getCommonScenariosDocumentation)();
39901
- var iterationAgentQuickDecisionGuideConst = (0, iterationScenarios_1.getQuickDecisionGuide)();
39902
- var iterationAgentCommonUseCasesGuideConst = (0, codegen_common_logic_1.getCommonUseCasesGuide)();
39903
- var iterationAgentExtensionSelectionLogicConst = `<selection_rules>
39948
+ exports2.iterationAgentProjectStructureGuide = `## How to Discover Extensions
39949
+
39950
+ Extensions are defined using \`@wix/astro/builders\` - use \`grep('@wix/astro/builders')\` to find all extension files.
39951
+
39952
+ ### The extensions.ts File Structure
39953
+
39954
+ The \`extensions.ts\` file is the central configuration file for all extensions in a Wix CLI project. It uses a builder pattern:
39955
+
39956
+ **Main registry file (src/extensions.ts):**
39957
+ \`\`\`typescript
39958
+ import { app } from '@wix/astro/builders';
39959
+ import { myDashboard } from './dashboard/extensions';
39960
+ import { myWidget } from './site/widgets/extensions';
39961
+
39962
+ export default app()
39963
+ .use(myDashboard)
39964
+ .use(myWidget);
39965
+ \`\`\`
39966
+
39967
+ **Individual extension file (e.g., src/dashboard/extensions.ts):**
39968
+ \`\`\`typescript
39969
+ import { extensions } from '@wix/astro/builders';
39970
+ export const myDashboard = extensions.dashboardPage({
39971
+ id: 'unique-id',
39972
+ name: 'My Dashboard',
39973
+ route: '/my-route',
39974
+ page: './page.tsx'
39975
+ });
39976
+ \`\`\`
39977
+
39978
+ **Key points:**
39979
+ - The main \`src/extensions.ts\` imports and registers extensions using \`.use()\` method
39980
+ - Individual extensions are defined in subdirectory \`extensions.ts\` files
39981
+ - Builder methods: \`extensions.dashboardPage()\`, \`extensions.customElement()\`, \`extensions.servicePlugin()\`, \`extensions.embeddedScript()\`, etc.
39982
+
39983
+ ### extensions.ts Files Are for DISCOVERY ONLY
39984
+
39985
+ - These files are **registration/configuration** - they define WHAT extensions exist, not the implementation
39986
+ - When modifying extension behavior, change **component files** (\`page.tsx\`, \`plugin.ts\`, \`embedded.html\`, \`patterns.json\`)
39987
+ - Do NOT include \`extensions.ts\` in paths unless **DELETING** an entire extension
39988
+
39989
+ ### Dashboard Pages - Two Types
39990
+
39991
+ **Auto-Patterns Dashboard** (uses \`patterns.json\`):
39992
+ - Configuration is in \`patterns.json\` (titles, layouts, collections, etc.)
39993
+ - The \`page.tsx\` just renders the AutoPatternsApp component
39994
+ - To change titles, UI text, or layout \u2192 modify \`patterns.json\`
39995
+
39996
+ **Custom React Dashboard** (uses \`page.tsx\`):
39997
+ - Full React implementation in \`page.tsx\`
39998
+ - No \`patterns.json\` file
39999
+ - To change titles, UI text, or logic \u2192 modify \`page.tsx\`
40000
+
40001
+ **IMPORTANT**: When searching for text (like titles), use \`grep\` WITHOUT file type restrictions, or search BOTH \`.json\` and \`.tsx\` files. Don't assume titles are only in \`.tsx\` files - they may be in \`patterns.json\`.`;
40002
+ exports2.iterationAgentDataExtensionsGuide = `## Data Extensions (NEVER modify)
40003
+
40004
+ **CRITICAL - NEVER RETURN src/data/extensions.ts:**
40005
+ - The \`src/data/extensions.ts\` file is 100% OFF-LIMITS - NEVER include it in paths or currentExtensions
40006
+ - Even if \`grep\` finds this file, DO NOT include it - SKIP IT COMPLETELY
40007
+ - This file contains CMS collection definitions (schemas, permissions, initial data)
40008
+ - **A separate PlannerAgent handles ALL data/collection changes** - not you!
40009
+ - Only include actual CODE extensions: DASHBOARD_PAGE, SERVICE_PLUGIN, EMBEDDED_SCRIPT, SITE_WIDGET, etc.
40010
+
40011
+ **FILTERING GREP RESULTS:**
40012
+ When you grep for a field name and find multiple files:
40013
+ - \u2705 INCLUDE: \`page.tsx\`, \`plugin.ts\`, \`patterns.json\`, \`widget.tsx\`, \`embedded.html\` - these are CODE files
40014
+ - \u{1F6AB} EXCLUDE: \`src/data/extensions.ts\` - this is a DATA file handled by PlannerAgent
40015
+
40016
+ **When user wants to add/modify/DELETE collection fields:**
40017
+ - The COLLECTION SCHEMA change is handled by PlannerAgent (NOT your responsibility)
40018
+ - Your job is ONLY to update the CODE that USES the field, for example:
40019
+ * DASHBOARD_PAGE - to add/remove UI for the field (input, display, table columns, etc.)
40020
+ * EMBEDDED_SCRIPT - to use/stop using the field value in the script
40021
+ * SERVICE_PLUGIN - to use/stop using the field in business logic
40022
+ - Example: "Delete the feeType field" \u2192 Update DASHBOARD_PAGE (remove UI) + SERVICE_PLUGIN (remove usage) - but NOT src/data/extensions.ts!`;
40023
+ exports2.iterationAgentCommonScenariosDocumentation = (0, iterationScenarios_1.getCommonScenariosDocumentation)();
40024
+ exports2.iterationAgentQuickDecisionGuide = (0, iterationScenarios_1.getQuickDecisionGuide)();
40025
+ exports2.iterationAgentCommonUseCasesGuide = (0, codegen_common_logic_1.getCommonUseCasesGuide)();
40026
+ exports2.iterationAgentExtensionSelectionLogic = `<selection_rules>
39904
40027
  1. **For UI/Admin interfaces**: Use DASHBOARD_PAGE
39905
40028
  2. **For site frontend components**: Use SITE_COMPONENT or SITE_WIDGET
39906
40029
  3. **For eCommerce business logic**: Use SERVICE_PLUGIN
@@ -39928,13 +40051,9 @@ When relevant existing extensions are identified:
39928
40051
  </critical_rule_for_existing_extensions>
39929
40052
 
39930
40053
  ${(0, codegen_common_logic_1.getExtensionDecisionMatrix)()}`;
39931
- exports2.iterationAgentRole = iterationAgentRoleConst;
39932
- exports2.iterationAgentCommonScenariosDocumentation = iterationAgentCommonScenariosDocumentationConst;
39933
- exports2.iterationAgentQuickDecisionGuide = iterationAgentQuickDecisionGuideConst;
39934
- exports2.iterationAgentCommonUseCasesGuide = iterationAgentCommonUseCasesGuideConst;
39935
40054
  exports2.iterationAgentChatHistoryContext = (0, iterationScenarios_1.getChatHistoryContext)();
39936
- exports2.iterationAgentExtensionSelectionLogic = iterationAgentExtensionSelectionLogicConst;
39937
- var getIterationAgentConstraints = (supportedTypes) => `- **CRITICAL - AVOID UNNECESSARY DUPLICATION**: Only propose additionalExtensions if existing ones CANNOT fulfill the user's request. Review "Relevant Existing Extensions" carefully. If an existing extension can handle the request, MODIFY it instead of creating new.
40055
+ var getIterationAgentConstraints = (supportedTypes) => `- **CRITICAL - ONLY CREATE WHAT USER EXPLICITLY REQUESTS**: Do NOT add extra extensions the user didn't ask for. If user asks for a widget, create only the widget. If user asks for a dashboard, create only the dashboard. Do not assume they need "helper" or "management" extensions.
40056
+ - **CRITICAL - AVOID UNNECESSARY DUPLICATION**: Only propose additionalExtensions if existing ones CANNOT fulfill the user's request. Review "Relevant Existing Extensions" carefully. If an existing extension can handle the request, MODIFY it instead of creating new.
39938
40057
  - **SMART DUPLICATION DETECTION**: When deciding between modifying vs creating:
39939
40058
  * If user says "add X feature" and an extension exists that handles X \u2192 modify the existing extension in currentExtensions
39940
40059
  * If user says "add X AND create a new Y" where Y is explicitly requested as NEW \u2192 modify existing for X + create new for Y in additionalExtensions
@@ -39975,6 +40094,100 @@ ${(0, codegen_common_logic_1.getExtensionDecisionMatrix)()}`;
39975
40094
  - "paths" field: For ALL extension types - specify relevant file paths to modify
39976
40095
  - For currentExtensions, always include paths; for additionalExtensions, paths are not needed`;
39977
40096
  exports2.getIterationAgentKeyPoints = getIterationAgentKeyPoints;
40097
+ exports2.iterationAgentAvailableTools = `You have access to the following tools:
40098
+
40099
+ - **grep**: Search for text patterns across files in the src/ folder
40100
+ - **START HERE**: Use \`grep('@wix/astro/builders')\` to find all extension definition files
40101
+ - Use to find where specific functions, imports, or patterns are used
40102
+ - **TIP**: When searching for text/titles, DON'T restrict to \`.tsx\` only - also search \`.json\` files (auto-patterns configs)
40103
+ - **CRITICAL FOR DELETIONS**: Use \`grep('fieldName')\` to find ALL files that reference a field being deleted
40104
+
40105
+ - **read_file**: Read the contents of a specific file in the project's src/ folder
40106
+ - Use to examine extension files found by grep to understand what extensions are defined
40107
+ - Use to read implementation files (\`page.tsx\`, \`plugin.ts\`, \`widget.tsx\`, \`patterns.json\`) for more context
40108
+
40109
+ - **glob**: Find files matching a glob pattern in the src/ folder
40110
+ - Use to discover files by name or extension pattern
40111
+ - Use \`glob('patterns.json')\` to find all auto-patterns dashboard configs
40112
+
40113
+ - **submit_plan**: Submit your final iteration plan (REQUIRED - ALWAYS CALL THIS)
40114
+ - You MUST call this tool - NEVER respond with text questions or clarifications
40115
+ - If uncertain, include ALL potentially relevant extensions and let CodeAgent investigate
40116
+ - Include extensions in currentExtensions ONLY if they need CODE CHANGES
40117
+ - Include new extensions in additionalExtensions when new functionality is needed
40118
+
40119
+ **DISCOVERY WORKFLOW**:
40120
+ 1. Use \`grep('@wix/astro/builders')\` to find all extension files
40121
+ 2. Use \`read_file\` on discovered files to understand what extensions exist
40122
+ 3. When searching for specific text, search ALL file types (not just .tsx)
40123
+ 4. Analyze the request and decide what needs to be modified or created
40124
+ 5. Call \`submit_plan\` with your decision
40125
+
40126
+ **TRACE ALL USAGES FOR FIELD DELETION/MODIFICATION:**
40127
+ When the user wants to DELETE or REMOVE a field/property:
40128
+ 1. Use \`grep('fieldName')\` to find ALL files that reference that field
40129
+ 2. Include EVERY file that uses the field in your paths - not just the type definition
40130
+ 3. Other agents CANNOT read the codebase - they only see what you tell them
40131
+ 4. If you only include the type file, the agent will delete the type but leave broken references everywhere \u2192 TypeScript errors!
40132
+
40133
+ **For SPLIT operations:** Don't say "split" - instead tell each agent EXACTLY what it should contain:
40134
+ - currentExtension: "Remove X, Y, Z functionality. Keep ONLY: A, B, C"
40135
+ - additionalExtension: "Create new page with: X, Y, Z features"
40136
+
40137
+ **NO DUPLICATE FILES ACROSS EXTENSIONS:**
40138
+ Each file must appear in ONLY ONE extension's paths. Assign files to extensions based on their location:
40139
+ - Files in \`src/extensions/dashboard/\` or \`src/dashboard/\` \u2192 DASHBOARD_PAGE
40140
+ - Files in \`src/extensions/site/embedded-scripts/\` or \`src/site/embedded-scripts/\` \u2192 EMBEDDED_SCRIPT
40141
+ - Files in \`src/backend/service-plugins/\` \u2192 SERVICE_PLUGIN
40142
+ - **Shared files** (like \`src/types.ts\`, \`src/components/\`) \u2192 Include in the PRIMARY extension that uses them most
40143
+ - If a shared component is used by multiple extensions, include it in ONLY the first/main extension
40144
+
40145
+ **Example - Shared type file:**
40146
+ - \`src/types.ts\` is used by both dashboard and embedded script
40147
+ - Include it in DASHBOARD_PAGE only (not in both!)
40148
+ - The dashboard agent will update the types, embedded script agent gets the updated types automatically
40149
+
40150
+ **Remember**: You are the ONLY agent with grep/read_file access. If you don't find and include a file, it won't be updated and will have type errors!`;
40151
+ exports2.iterationAgentExtensionEvaluation = `When evaluating extensions:
40152
+
40153
+ 1. **DELETION CHECKLIST** - Before submitting your plan, scan the user request for these words:
40154
+ - "delete", "remove", "get rid of", "don't need", "no longer need"
40155
+ - If ANY extension is mentioned with these words:
40156
+ \u2705 ADD that extension to \`currentExtensions\`
40157
+ \u2705 Include ALL its files in paths (extensions.ts, page.tsx, plugin.ts, patterns.json, etc.)
40158
+ \u2705 Set relevantUserRequest to "Delete this extension and all its files"
40159
+ - **COMMON MISTAKE**: Summary says "delete the dashboard" but dashboard is NOT in currentExtensions \u2192 BUG!
40160
+ - **RULE**: If your summary mentions deleting something, currentExtensions MUST contain it
40161
+
40162
+ 2. **FIELD DELETION - TRACE ALL USAGES** - When deleting/removing a FIELD or PROPERTY:
40163
+ - Use \`grep('fieldName')\` to find ALL files that use this field
40164
+ - Include EVERY file in the appropriate extension's paths
40165
+ - Type files alone are NOT enough - other agents can't read the codebase!
40166
+ - **COMMON MISTAKE**: Only including types.ts \u2192 leaves broken references \u2192 TypeScript errors
40167
+ - **RULE**: If grep finds a file using the field, it MUST be in your paths
40168
+ - **EXCEPTION**: NEVER include \`src/data/extensions.ts\` even if grep finds it - PlannerAgent handles collection schema changes!
40169
+
40170
+ 3. **For SERVICE_PLUGIN extensions**: Look for which SPI is being used (e.g., ecomShippingRates, ecomAdditionalFees, etc.)
40171
+ - Each SERVICE_PLUGIN handles ONE SPI type
40172
+ - Different SPI types require SEPARATE service plugins
40173
+
40174
+ 4. **Adding New Features**: When the user wants to ADD something entirely new:
40175
+ - Ask yourself: "Does any existing extension ALREADY have code that needs to be CHANGED?"
40176
+ - If NO existing extensions need modifications \u2192 Return empty currentExtensions []
40177
+ - Put truly new functionality in additionalExtensions
40178
+
40179
+ 5. **SELF-CHECK before submit_plan**:
40180
+ - Count extensions mentioned for deletion in user request
40181
+ - Count DASHBOARD_PAGE/SERVICE_PLUGIN/etc. in your currentExtensions
40182
+ - If counts don't match, you're missing something!
40183
+ - For field deletions: Did you grep the field name? Are ALL files included?
40184
+ - **FINAL CHECK**: Scan ALL paths in your plan - if ANY path is \`src/data/extensions.ts\`, REMOVE IT! This file is handled by PlannerAgent.
40185
+
40186
+ 6. **NEVER ASK QUESTIONS OR REQUEST CLARIFICATION**:
40187
+ - You MUST always call submit_plan, even if the request is vague or unclear
40188
+ - When uncertain: include ALL relevant extensions - CodeAgent has file access and more context
40189
+ - CodeAgent will read files and make the right decisions
40190
+ - Your role is to identify CANDIDATES for modification, not to be 100% certain`;
39978
40191
  }
39979
40192
  });
39980
40193
 
@@ -73062,1003 +73275,248 @@ var require_AgentsRegistry = __commonJS({
73062
73275
  }
73063
73276
  });
73064
73277
 
73065
- // dist/system-prompts/iterationAgent/iteration-agent-prompt.js
73066
- var require_iteration_agent_prompt = __commonJS({
73067
- "dist/system-prompts/iterationAgent/iteration-agent-prompt.js"(exports2) {
73068
- "use strict";
73069
- Object.defineProperty(exports2, "__esModule", { value: true });
73070
- exports2.iterationAgentPrompt = void 0;
73071
- var codegen_common_logic_1 = require_dist9();
73072
- var iterartion_agent_instructions_1 = require_iterartion_agent_instructions();
73073
- var AgentsRegistry_1 = require_AgentsRegistry();
73074
- var iterationAgentPrompt = () => {
73075
- const supportedTypes = (0, AgentsRegistry_1.getSupportedExtensionTypes)().join(", ");
73076
- const supportedExtensions = (0, AgentsRegistry_1.generateSupportedExtensionsSection)();
73077
- const constraints = (0, iterartion_agent_instructions_1.getIterationAgentConstraints)(supportedTypes);
73078
- const keyPoints = (0, iterartion_agent_instructions_1.getIterationAgentKeyPoints)(supportedTypes);
73079
- const systemPrompt = new codegen_common_logic_1.SystemPromptBuilder({
73080
- agentType: codegen_common_logic_1.GeneralAgentType.ITERATION_AGENT
73081
- }).withRole(iterartion_agent_instructions_1.iterationAgentRole).withSection("chat_history_context", iterartion_agent_instructions_1.iterationAgentChatHistoryContext).withSection("common_iteration_scenarios", iterartion_agent_instructions_1.iterationAgentCommonScenariosDocumentation).withSection("quick_decision_guide", iterartion_agent_instructions_1.iterationAgentQuickDecisionGuide).withSection("common_use_cases_guide", iterartion_agent_instructions_1.iterationAgentCommonUseCasesGuide).withSection("supported_extension_types", supportedExtensions).withSection("extension_selection_logic", iterartion_agent_instructions_1.iterationAgentExtensionSelectionLogic).withSection("constraints", constraints).withSection("key_points", keyPoints);
73082
- return systemPrompt.compose();
73083
- };
73084
- exports2.iterationAgentPrompt = iterationAgentPrompt;
73085
- }
73086
- });
73087
-
73088
- // dist/agents/utils.js
73089
- var require_utils = __commonJS({
73090
- "dist/agents/utils.js"(exports2) {
73278
+ // dist/system-prompts/iterationAgent/iteration-examples.js
73279
+ var require_iteration_examples = __commonJS({
73280
+ "dist/system-prompts/iterationAgent/iteration-examples.js"(exports2) {
73091
73281
  "use strict";
73092
- var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
73093
- return mod && mod.__esModule ? mod : { "default": mod };
73094
- };
73095
73282
  Object.defineProperty(exports2, "__esModule", { value: true });
73096
- exports2.extractApiNames = exports2.getErrorMessage = void 0;
73097
- exports2.shouldUseDataPrompt = shouldUseDataPrompt;
73098
- exports2.shouldUseDynamicParametersPrompt = shouldUseDynamicParametersPrompt;
73099
- exports2.loadRelevantFilesAsString = loadRelevantFilesAsString;
73100
- var fs_1 = __importDefault2(require("fs"));
73101
- var path_1 = __importDefault2(require("path"));
73102
- function shouldUseDataPrompt(params) {
73103
- const { plan, previousResources } = params;
73104
- return Boolean(plan?.collections?.length || previousResources?.collections?.length);
73105
- }
73106
- function shouldUseDynamicParametersPrompt(params) {
73107
- const { plan, previousResources } = params;
73108
- return Boolean(plan?.embeddedScriptParameters?.length || previousResources?.embeddedScriptParameters?.length);
73109
- }
73110
- function loadRelevantFiles(relevantFilePaths = [], basePath) {
73111
- return relevantFilePaths.map((filePath) => {
73112
- const fullPath = path_1.default.isAbsolute(basePath) ? path_1.default.join(basePath, filePath) : path_1.default.join(process.cwd(), basePath, filePath);
73113
- try {
73114
- if (!fs_1.default.existsSync(fullPath)) {
73115
- return `Path: ${filePath}
73116
-
73117
- [File does not exist]`;
73118
- }
73119
- const stats = fs_1.default.statSync(fullPath);
73120
- if (stats.isDirectory()) {
73121
- return `Path: ${filePath}
73122
-
73123
- [Path is a directory, not a file]`;
73124
- }
73125
- const content = fs_1.default.readFileSync(fullPath, "utf8");
73126
- return `Path: ${filePath}
73127
-
73128
- ${content}`;
73129
- } catch (error) {
73130
- return `Path: ${filePath}
73131
-
73132
- [Could not read file: ${error instanceof Error ? error.message : "Unknown error"}]`;
73283
+ exports2.iterationAgentExamples = void 0;
73284
+ var types_1 = require_types_impl();
73285
+ var simpleWidgetExample = {
73286
+ currentExtensions: [],
73287
+ additionalExtensions: [
73288
+ {
73289
+ extensionType: types_1.ExtensionType.SITE_WIDGET,
73290
+ name: "Countdown Timer",
73291
+ relevantUserRequest: "Display a countdown timer widget on the site"
73133
73292
  }
73134
- });
73135
- }
73136
- function loadRelevantFilesAsString(relevantFilePaths = [], basePath) {
73137
- const srcOnlyPaths = relevantFilePaths.filter((p) => {
73138
- const normalized = path_1.default.normalize(p);
73139
- return normalized.startsWith("src" + path_1.default.sep);
73140
- });
73141
- return loadRelevantFiles(srcOnlyPaths, basePath).join("\n\n---\n\n");
73142
- }
73143
- var getErrorMessage = (error) => {
73144
- if (error?.response?.data && error?.response?.data?.message.length > 0) {
73145
- return JSON.stringify(error.response.data);
73146
- } else if (error?.message && error?.message.length > 0) {
73147
- return JSON.stringify(error.message);
73148
- } else {
73149
- return JSON.stringify(error);
73150
- }
73293
+ ],
73294
+ summary: "User wants a countdown timer widget on their site."
73151
73295
  };
73152
- exports2.getErrorMessage = getErrorMessage;
73153
- var extractApiNames = (extension) => {
73154
- return extension.relatedApis?.map((api) => api.name).filter((name) => !!name) || [];
73296
+ var reactComponentExample = {
73297
+ currentExtensions: [],
73298
+ additionalExtensions: [
73299
+ {
73300
+ extensionType: types_1.ExtensionType.SITE_COMPONENT,
73301
+ name: "Countdown Timer",
73302
+ relevantUserRequest: "Display a countdown timer as a React component on the site"
73303
+ }
73304
+ ],
73305
+ summary: "User wants a React countdown timer component on their site."
73155
73306
  };
73156
- exports2.extractApiNames = extractApiNames;
73157
- }
73158
- });
73159
-
73160
- // dist/agents/Iteration/utils/extensionFormatters.js
73161
- var require_extensionFormatters = __commonJS({
73162
- "dist/agents/Iteration/utils/extensionFormatters.js"(exports2) {
73163
- "use strict";
73164
- Object.defineProperty(exports2, "__esModule", { value: true });
73165
- exports2.formatIterationPlanExtension = void 0;
73166
- exports2.formatEvaluationResultsExtensions = formatEvaluationResultsExtensions;
73167
- exports2.formatContextExtensions = formatContextExtensions;
73168
- exports2.formatScannedExtensions = formatScannedExtensions;
73169
- var utils_1 = require_utils();
73170
- function formatEvaluationResultsExtensions(extensions) {
73171
- if (!extensions || extensions.length === 0)
73172
- return "None";
73173
- return extensions.map((extension, index) => {
73174
- const filesList = extension.relevantFiles.map((file) => `- ${file}`).join("\n");
73175
- const lines = [
73176
- `#${index + 1}`,
73177
- `type: ${extension.type ?? "UNKNOWN"}`,
73178
- `files:`,
73179
- filesList,
73180
- `reasoning: ${extension.reasoning}`
73181
- ];
73182
- return lines.join("\n");
73183
- }).join("\n\n");
73184
- }
73185
- var formatIterationPlanExtension = ({ ext, id, outputPath }) => {
73186
- const lines = [
73187
- `**ID: ${id}**`,
73188
- `- Name: ${ext.extension.name}`,
73189
- `- Type: ${ext.extension.type}`,
73190
- `- Description: ${ext.extension.description}`
73191
- ];
73192
- const relevantFilesContent = (0, utils_1.loadRelevantFilesAsString)(ext.paths || [], outputPath);
73193
- if (relevantFilesContent && relevantFilesContent !== "None") {
73194
- lines.push(`- Relevant Files Content:
73195
- ${relevantFilesContent}`);
73196
- }
73197
- if (ext.extension.relatedSpis && ext.extension.relatedSpis.length > 0) {
73198
- lines.push(`- Current SPIs: ${ext.extension.relatedSpis.map((spi) => spi.name).join(", ")}`);
73199
- }
73200
- lines.push("");
73201
- return lines;
73307
+ var popupWithDashboardExample = {
73308
+ currentExtensions: [],
73309
+ additionalExtensions: [
73310
+ {
73311
+ extensionType: types_1.ExtensionType.EMBEDDED_SCRIPT,
73312
+ name: "Promotional Popup",
73313
+ relevantUserRequest: "Display a promotional popup overlay on the site"
73314
+ },
73315
+ {
73316
+ extensionType: types_1.ExtensionType.DASHBOARD_PAGE,
73317
+ name: "Popup Manager",
73318
+ relevantUserRequest: "Admin interface to configure popup content, timing, and activation settings"
73319
+ }
73320
+ ],
73321
+ summary: "User wants a promotional popup. EMBEDDED_SCRIPT requires a DASHBOARD_PAGE for configuration."
73202
73322
  };
73203
- exports2.formatIterationPlanExtension = formatIterationPlanExtension;
73204
- function formatContextExtensions(extensions) {
73205
- if (!extensions || extensions.length === 0)
73206
- return "None";
73207
- return extensions.map((extension, index) => {
73208
- const lines = [
73209
- `#${index + 1}`,
73210
- `type: ${extension.type ?? "UNKNOWN"}`,
73211
- `reasoning: ${extension.reasoning}`
73212
- ];
73213
- return lines.join("\n");
73214
- }).join("\n\n");
73215
- }
73216
- function formatScannedExtensions(extensions, outputPath) {
73217
- return extensions.map((extension, index) => {
73218
- const relevantFilesContent = extension.files ? (0, utils_1.loadRelevantFilesAsString)(extension.files, outputPath) : "None";
73219
- const lines = [
73220
- `Extension ${index + 1}:`,
73221
- `Type: ${extension.type}`,
73222
- `ComponentPath: ${extension.componentPath}`,
73223
- `Relevant Files Content: ${relevantFilesContent}`
73224
- ];
73225
- return lines.join("\n");
73226
- }).join("\n\n");
73227
- }
73228
- }
73229
- });
73230
-
73231
- // dist/agents/Iteration/utils/contextBuilders.js
73232
- var require_contextBuilders = __commonJS({
73233
- "dist/agents/Iteration/utils/contextBuilders.js"(exports2) {
73234
- "use strict";
73235
- Object.defineProperty(exports2, "__esModule", { value: true });
73236
- exports2.buildContextSections = buildContextSections;
73237
- function formatChatHistory(chatHistory) {
73238
- return (chatHistory || []).map((message) => `${message.role.toUpperCase()}: ${message.text}`).join("\n\n");
73239
- }
73240
- function buildContextSections(chatHistory, currentUserRequest, previousResources) {
73241
- const historyStr = formatChatHistory(chatHistory);
73242
- const sections = [
73243
- `
73244
- Full Chat History:
73245
- ${historyStr}`,
73246
- `
73247
- Current User Request: ${currentUserRequest}`
73248
- ];
73249
- if (previousResources.collections.length > 0) {
73250
- sections.push(`
73251
- Existing Collections:
73252
- ${JSON.stringify(previousResources.collections, null, 2)}`);
73253
- }
73254
- if (previousResources.embeddedScriptParameters.length > 0) {
73255
- sections.push(`
73256
- Embedded Script Parameters:
73257
- ${JSON.stringify(previousResources.embeddedScriptParameters, null, 2)}`);
73258
- }
73259
- return sections;
73260
- }
73261
- }
73262
- });
73263
-
73264
- // dist/agents/Iteration/IterationAgent.js
73265
- var require_IterationAgent = __commonJS({
73266
- "dist/agents/Iteration/IterationAgent.js"(exports2) {
73267
- "use strict";
73268
- Object.defineProperty(exports2, "__esModule", { value: true });
73269
- exports2.IterationAgent = void 0;
73270
- var zod_1 = require_zod();
73271
- var ai_1 = require_dist8();
73272
- var iteration_agent_prompt_1 = require_iteration_agent_prompt();
73273
- var AgentsRegistry_1 = require_AgentsRegistry();
73274
- var codegen_common_logic_1 = require_dist9();
73275
- var ditto_codegen_types_12 = require_dist();
73276
- var constants_1 = require_constants();
73277
- var codeGenerationService_12 = require_codeGenerationService();
73278
- var extensionFormatters_1 = require_extensionFormatters();
73279
- var contextBuilders_1 = require_contextBuilders();
73280
- var MAX_NAME_LENGTH = 30;
73281
- var CurrentExtensionSchema = zod_1.z.object({
73282
- extensionType: zod_1.z.enum(codegen_common_logic_1.codeGenerationExtensionTypes).describe("The extension kind to trigger"),
73283
- name: zod_1.z.string().min(2).max(MAX_NAME_LENGTH).describe(`Short, human-readable name for the extension. Less than ${MAX_NAME_LENGTH} chars.`),
73284
- relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
73285
- paths: zod_1.z.array(zod_1.z.string()).describe("Paths relevant for this extension"),
73286
- relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
73287
- });
73288
- var AdditionalExtensionSchema = zod_1.z.object({
73289
- extensionType: zod_1.z.enum(codegen_common_logic_1.codeGenerationExtensionTypes).describe("The extension kind to add"),
73290
- name: zod_1.z.string().min(2).max(MAX_NAME_LENGTH).describe(`Short, human-readable name for the extension. Less than ${MAX_NAME_LENGTH} chars.`),
73291
- relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
73292
- relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
73293
- });
73294
- var IterationPlanSchema = zod_1.z.object({
73295
- currentExtensions: zod_1.z.array(CurrentExtensionSchema).describe("Existing extensions to be triggered, return [] if no existing extensions are needed"),
73296
- additionalExtensions: zod_1.z.array(AdditionalExtensionSchema).describe("New extensions to be created, return [] if no new extensions are needed"),
73297
- summary: zod_1.z.string().describe("Summary of the chat with the user request")
73298
- });
73299
- var IterationAgent = class {
73300
- constructor() {
73301
- this.name = "IterationAgent";
73302
- }
73303
- buildSystemPrompt() {
73304
- return (0, iteration_agent_prompt_1.iterationAgentPrompt)();
73305
- }
73306
- mapExtensionType(extensionType) {
73307
- const supportedExtensionTypes = (0, AgentsRegistry_1.getSupportedExtensionTypes)();
73308
- if (supportedExtensionTypes.includes(extensionType)) {
73309
- return extensionType;
73323
+ var modifyExistingExample = {
73324
+ currentExtensions: [
73325
+ {
73326
+ extensionType: types_1.ExtensionType.SERVICE_PLUGIN,
73327
+ name: "Handling Fees Calculator",
73328
+ paths: ["src/backend/service-plugins/fees/plugin.ts"],
73329
+ relevantUserRequest: "Update the fee amount from $5 to $10"
73310
73330
  }
73311
- throw new ditto_codegen_types_12.UnsupportedExtensionTypeError(`Unsupported extension type: ${extensionType}. Supported types: ${supportedExtensionTypes.join(", ")}`, {
73312
- extensionType: extensionType || "UNKNOWN",
73313
- origin: ditto_codegen_types_12.ErrorOrigin.ITERATION
73314
- });
73315
- }
73316
- generateExtensionObject(extensionType, name, relevantUserRequest, relatedSpis) {
73317
- return {
73318
- type: this.mapExtensionType(extensionType),
73319
- name,
73320
- description: relevantUserRequest,
73321
- relatedSpis: relatedSpis?.map((spi) => ({
73322
- name: spi,
73323
- purpose: ""
73324
- })) || []
73325
- };
73326
- }
73327
- async repairNameTooLong({ text, error }) {
73328
- if (!ai_1.TypeValidationError.isInstance(error)) {
73329
- return text;
73331
+ ],
73332
+ additionalExtensions: [],
73333
+ summary: "User wants to update the existing fee amount in the service plugin."
73334
+ };
73335
+ var eventTriggerExample = {
73336
+ currentExtensions: [],
73337
+ additionalExtensions: [
73338
+ {
73339
+ extensionType: types_1.ExtensionType.BACKEND_EVENT,
73340
+ name: "Contact Creation Logger",
73341
+ relevantUserRequest: "Listen for contact creation events and log new contacts automatically"
73330
73342
  }
73331
- const cause = error.cause;
73332
- const hasNameTooLongIssue = cause?.issues?.some((issue) => issue.code === "too_big" && issue.path?.at(-1) === "name");
73333
- if (!hasNameTooLongIssue) {
73334
- return text;
73343
+ ],
73344
+ summary: "User wants automatic logging when contacts are created."
73345
+ };
73346
+ var widgetWithDashboardExample = {
73347
+ currentExtensions: [],
73348
+ additionalExtensions: [
73349
+ {
73350
+ extensionType: types_1.ExtensionType.SITE_WIDGET,
73351
+ name: "Product Showcase",
73352
+ relevantUserRequest: "Display featured products in a widget on the site"
73353
+ },
73354
+ {
73355
+ extensionType: types_1.ExtensionType.DASHBOARD_PAGE,
73356
+ name: "Featured Products Manager",
73357
+ relevantUserRequest: "Admin interface to select and manage which products are featured"
73335
73358
  }
73336
- const parsed = JSON.parse(text);
73337
- const hasCurrentExtensionsIssue = parsed.currentExtensions && cause?.issues?.some((issue) => issue.path?.includes("currentExtensions"));
73338
- const hasAdditionalExtensionsIssue = parsed.additionalExtensions && cause?.issues?.some((issue) => issue.path?.includes("additionalExtensions"));
73339
- if (hasCurrentExtensionsIssue) {
73340
- for (const ext of parsed.currentExtensions) {
73341
- if (ext.name && ext.name.length > MAX_NAME_LENGTH) {
73342
- ext.name = ext.name.slice(0, MAX_NAME_LENGTH);
73343
- }
73344
- }
73359
+ ],
73360
+ summary: "User wants a product showcase widget with a dashboard for managing featured products."
73361
+ };
73362
+ var modifyAndCreateExample = {
73363
+ currentExtensions: [
73364
+ {
73365
+ extensionType: types_1.ExtensionType.DASHBOARD_PAGE,
73366
+ name: "Settings Dashboard",
73367
+ paths: ["src/dashboard/pages/settings/page.tsx"],
73368
+ relevantUserRequest: "Add a color picker input to the settings form"
73345
73369
  }
73346
- if (hasAdditionalExtensionsIssue) {
73347
- for (const ext of parsed.additionalExtensions) {
73348
- if (ext.name && ext.name.length > MAX_NAME_LENGTH) {
73349
- ext.name = ext.name.slice(0, MAX_NAME_LENGTH);
73350
- }
73351
- }
73370
+ ],
73371
+ additionalExtensions: [
73372
+ {
73373
+ extensionType: types_1.ExtensionType.DASHBOARD_PAGE,
73374
+ name: "Analytics Dashboard",
73375
+ relevantUserRequest: "Create a new dashboard page for viewing analytics data"
73352
73376
  }
73353
- return JSON.stringify(parsed);
73354
- }
73355
- buildUserPrompt({ chatHistory, currentUserRequest, previousResources, extensionSelectorResult }) {
73356
- const sections = (0, contextBuilders_1.buildContextSections)(chatHistory, currentUserRequest, previousResources);
73357
- sections.push(`
73358
- Relevant Existing Extensions:
73359
- ${(0, extensionFormatters_1.formatEvaluationResultsExtensions)(extensionSelectorResult.extensionsToModify)}`);
73360
- sections.push(`
73361
- Context Extensions (already exist, don't need changes):
73362
- ${(0, extensionFormatters_1.formatContextExtensions)(extensionSelectorResult.contextExtensions)}`);
73363
- return sections.join("\n\n");
73364
- }
73365
- async generate({ currentUserRequest, chatHistory, extensionSelectorResult, previousResources }) {
73366
- const userMessage = this.buildUserPrompt({
73367
- chatHistory,
73368
- currentUserRequest,
73369
- extensionSelectorResult,
73370
- previousResources
73371
- });
73372
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
73373
- userMessage,
73374
- systemPrompt: this.buildSystemPrompt(),
73375
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
73376
- model: constants_1.LLM_MODELS.CLAUDE_3_5_HAIKU_LATEST,
73377
- schema: IterationPlanSchema,
73378
- agentName: this.name,
73379
- experimental_repairText: this.repairNameTooLong
73380
- });
73381
- const resultObject = {
73382
- currentExtensions: result.object.currentExtensions.map((ext) => ({
73383
- paths: ext.paths,
73384
- extension: this.generateExtensionObject(ext.extensionType, ext.name, ext.relevantUserRequest, ext.relatedSpis)
73385
- })),
73386
- additionalExtensions: result.object.additionalExtensions.map((ext) => ({
73387
- extension: this.generateExtensionObject(ext.extensionType, ext.name, ext.relevantUserRequest, ext.relatedSpis)
73388
- })),
73389
- summary: result.object.summary
73390
- };
73391
- console.log("IterationAgent result:", JSON.stringify(resultObject, null, 2));
73392
- return resultObject;
73393
- }
73377
+ ],
73378
+ summary: "User wants to modify existing settings dashboard and create a new analytics dashboard."
73394
73379
  };
73395
- exports2.IterationAgent = IterationAgent;
73396
- }
73397
- });
73398
-
73399
- // dist/agents/DashboardDecisionAgent.js
73400
- var require_DashboardDecisionAgent = __commonJS({
73401
- "dist/agents/DashboardDecisionAgent.js"(exports2) {
73402
- "use strict";
73403
- Object.defineProperty(exports2, "__esModule", { value: true });
73404
- exports2.DashboardDecisionAgent = void 0;
73405
- var zod_1 = require_zod();
73406
- var codegen_dashboard_agents_1 = require_dist11();
73407
- var prompt_selectors_1 = require_prompt_selectors();
73408
- var types_1 = require_types_impl();
73409
- var userPrompt_1 = require_userPrompt();
73410
- var codeGenerationService_12 = require_codeGenerationService();
73411
- var constants_1 = require_constants();
73412
- var autoPatternsLlmConfig = zod_1.z.object({
73413
- useAutoPatterns: zod_1.z.boolean(),
73414
- schema: zod_1.z.object({
73415
- content: zod_1.z.object({
73416
- collectionRouteId: zod_1.z.string(),
73417
- singularEntityName: zod_1.z.string(),
73418
- pageTitle: zod_1.z.string(),
73419
- pageSubtitle: zod_1.z.string(),
73420
- actionButtonLabel: zod_1.z.string(),
73421
- toolbarTitle: zod_1.z.string(),
73422
- toolbarSubtitle: zod_1.z.string(),
73423
- emptyStateTitle: zod_1.z.string(),
73424
- emptyStateSubtitle: zod_1.z.string(),
73425
- emptyStateButtonText: zod_1.z.string(),
73426
- deleteModalTitle: zod_1.z.string(),
73427
- deleteModalDescription: zod_1.z.string(),
73428
- deleteSuccessToast: zod_1.z.string(),
73429
- deleteErrorToast: zod_1.z.string(),
73430
- bulkDeleteModalTitle: zod_1.z.string(),
73431
- bulkDeleteModalDescription: zod_1.z.string(),
73432
- bulkDeleteSuccessToast: zod_1.z.string(),
73433
- bulkDeleteErrorToast: zod_1.z.string(),
73434
- entityPageTitle: zod_1.z.string(),
73435
- entityPageSubtitle: zod_1.z.string()
73436
- }),
73437
- layout: zod_1.z.object({
73438
- main: zod_1.z.array(zod_1.z.object({
73439
- title: zod_1.z.string(),
73440
- subtitle: zod_1.z.string(),
73441
- fields: zod_1.z.array(zod_1.z.string())
73442
- })),
73443
- sidebar: zod_1.z.array(zod_1.z.object({
73444
- title: zod_1.z.string(),
73445
- subtitle: zod_1.z.string(),
73446
- fields: zod_1.z.array(zod_1.z.string())
73447
- }))
73448
- }),
73449
- columns: zod_1.z.array(zod_1.z.object({
73450
- id: zod_1.z.string(),
73451
- displayName: zod_1.z.string()
73452
- })),
73453
- gridItem: zod_1.z.object({
73454
- titleFieldId: zod_1.z.string(),
73455
- subtitleFieldId: zod_1.z.string().optional(),
73456
- imageFieldId: zod_1.z.string().optional()
73457
- }).optional().nullable()
73458
- }).optional(),
73459
- relevantCollectionId: zod_1.z.string().optional()
73460
- });
73461
- var DashboardDecisionAgent = class {
73462
- constructor() {
73463
- this.name = "DashboardDecisionAgent";
73464
- }
73465
- buildSystemPrompt() {
73466
- return (0, codegen_dashboard_agents_1.autoPatternsDecisionPrompt)();
73467
- }
73468
- shouldNotUseAutoPatterns(params) {
73469
- const { blueprint } = params;
73470
- const hasEmbeddedScriptExtension = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.EMBEDDED_SCRIPT) ?? false;
73471
- const hasOneDashboardPageExtension = blueprint?.extensions?.filter((ext) => ext.type === types_1.ExtensionType.DASHBOARD_PAGE).length === 1;
73472
- const shouldImplementEmbeddedScriptParameters = hasOneDashboardPageExtension && hasEmbeddedScriptExtension;
73473
- const hasCollections = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
73474
- const hasUnsupportedCollectionFieldsTypes = (0, prompt_selectors_1.hasUnsupportedCollectionTypes)(params);
73475
- if (!hasCollections || shouldImplementEmbeddedScriptParameters || hasUnsupportedCollectionFieldsTypes) {
73476
- return true;
73380
+ var servicePluginExample = {
73381
+ currentExtensions: [],
73382
+ additionalExtensions: [
73383
+ {
73384
+ extensionType: types_1.ExtensionType.SERVICE_PLUGIN,
73385
+ name: "Custom Shipping Rates",
73386
+ relatedSpis: ["ecom.shippingRates.getShippingRates"],
73387
+ relevantUserRequest: "Calculate custom shipping rates based on destination region"
73477
73388
  }
73478
- return false;
73479
- }
73480
- async generate(params) {
73481
- if (this.shouldNotUseAutoPatterns(params)) {
73482
- return {
73483
- useAutoPatterns: false
73484
- };
73389
+ ],
73390
+ summary: "User wants custom shipping rate calculations at checkout."
73391
+ };
73392
+ var fixedFeesWithDashboardExample = {
73393
+ currentExtensions: [],
73394
+ additionalExtensions: [
73395
+ {
73396
+ extensionType: types_1.ExtensionType.SERVICE_PLUGIN,
73397
+ name: "Fixed Shipping Fees",
73398
+ relatedSpis: ["ecom.additionalFees.calculateAdditionalFees"],
73399
+ relevantUserRequest: "Apply fixed-cost shipping fees at checkout by reading fee configuration from database"
73400
+ },
73401
+ {
73402
+ extensionType: types_1.ExtensionType.DASHBOARD_PAGE,
73403
+ name: "Shipping Fees Manager",
73404
+ relevantUserRequest: "Admin interface to create, edit, and delete fixed shipping fees stored in a database collection"
73485
73405
  }
73486
- const systemPrompt = this.buildSystemPrompt();
73487
- const primaryAction = "Decide whether to use auto patterns for the dashboard page";
73488
- const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
73489
- const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
73490
- userMessage,
73491
- systemPrompt,
73492
- provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
73493
- model: constants_1.LLM_MODELS.CLAUDE_3_5_HAIKU_LATEST,
73494
- schema: autoPatternsLlmConfig,
73495
- agentName: this.name
73496
- });
73497
- console.log("\u{1F3AF} Decision and schema result:", JSON.stringify(result.object, null, 2));
73498
- return result.object;
73499
- }
73406
+ ],
73407
+ summary: "User wants a fixed-cost shipping fees system with Additional Fees SPI and a dashboard to manage fee configurations stored in a database."
73500
73408
  };
73501
- exports2.DashboardDecisionAgent = DashboardDecisionAgent;
73502
- }
73503
- });
73409
+ exports2.iterationAgentExamples = `### Example 1: Simple Widget Request (NO extra extensions)
73410
+ **User Request:** "I want to add a countdown timer to my site"
73411
+ **Existing Extensions:** None
73504
73412
 
73505
- // ../scaffolding/dist/tools.js
73506
- var require_tools = __commonJS({
73507
- "../scaffolding/dist/tools.js"(exports2) {
73508
- "use strict";
73509
- var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
73510
- return mod && mod.__esModule ? mod : { "default": mod };
73511
- };
73512
- Object.defineProperty(exports2, "__esModule", { value: true });
73513
- exports2.copyRecursive = copyRecursive;
73514
- exports2.copyScaffolding = copyScaffolding;
73515
- var fs_1 = __importDefault2(require("fs"));
73516
- var path_1 = __importDefault2(require("path"));
73517
- var scaffoldingBasePath = path_1.default.join(__dirname, "wix-cli-templates");
73518
- function copyRecursive(sourcePath, destPath) {
73519
- if (!fs_1.default.existsSync(sourcePath)) {
73520
- throw new Error(`Source path does not exist: ${sourcePath}`);
73521
- }
73522
- const stat = fs_1.default.statSync(sourcePath);
73523
- if (stat.isDirectory()) {
73524
- const copiedFiles = [];
73525
- if (!fs_1.default.existsSync(destPath)) {
73526
- fs_1.default.mkdirSync(destPath, { recursive: true });
73527
- }
73528
- const items = fs_1.default.readdirSync(sourcePath);
73529
- for (const item of items) {
73530
- const sourceItemPath = path_1.default.join(sourcePath, item);
73531
- const destItemPath = path_1.default.join(destPath, item);
73532
- const results = copyRecursive(sourceItemPath, destItemPath);
73533
- copiedFiles.push(...results);
73534
- }
73535
- return copiedFiles;
73536
- } else {
73537
- const destDir = path_1.default.dirname(destPath);
73538
- if (!fs_1.default.existsSync(destDir)) {
73539
- fs_1.default.mkdirSync(destDir, { recursive: true });
73540
- }
73541
- fs_1.default.copyFileSync(sourcePath, destPath);
73542
- console.log(`\u{1F4CB} Copied: ${sourcePath} \u2192 ${destPath}`);
73543
- return [destPath];
73544
- }
73545
- }
73546
- function copyScaffolding(scaffoldingSubPath, outputRootPath, outputRelativePath) {
73547
- const sourcePath = path_1.default.join(scaffoldingBasePath, scaffoldingSubPath);
73548
- const destPath = path_1.default.join(outputRootPath, outputRelativePath);
73549
- console.log(`\u{1F4E6} Copying scaffolding from: ${scaffoldingSubPath}`);
73550
- return copyRecursive(sourcePath, destPath);
73551
- }
73552
- }
73553
- });
73413
+ **Expected Output:**
73414
+ ${JSON.stringify(simpleWidgetExample, null, 2)}
73415
+ **Why:** User asked for a widget only. Do NOT add a dashboard - SITE_WIDGET has built-in settings panel.
73554
73416
 
73555
- // ../scaffolding/dist/constants.js
73556
- var require_constants2 = __commonJS({
73557
- "../scaffolding/dist/constants.js"(exports2) {
73558
- "use strict";
73559
- Object.defineProperty(exports2, "__esModule", { value: true });
73560
- exports2.spiToSubPath = void 0;
73561
- exports2.spiToSubPath = {
73562
- "ecom.shippingRates.getShippingRates": "ecom-shipping-rates",
73563
- "ecom.additionalFees.calculateAdditionalFees": "ecom-additional-fees",
73564
- "ecom.paymentSettings.getPaymentSettings": "ecom-payment-settings",
73565
- "ecom.validations.getValidationViolations": "ecom-validations",
73566
- "ecom.customTriggers.getEligibleTriggers": "ecom-discount-triggers",
73567
- "ecom.customTriggers.listTriggers": "ecom-discount-triggers",
73568
- "ecom.giftCardsProvider.redeem": "ecom-gift-cards",
73569
- "ecom.giftCardsProvider._void": "ecom-gift-cards",
73570
- "ecom.giftCardsProvider.getBalance": "ecom-gift-cards"
73571
- };
73572
- }
73573
- });
73417
+ ---
73574
73418
 
73575
- // ../scaffolding/dist/scaffolding.js
73576
- var require_scaffolding = __commonJS({
73577
- "../scaffolding/dist/scaffolding.js"(exports2) {
73578
- "use strict";
73579
- var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
73580
- return mod && mod.__esModule ? mod : { "default": mod };
73581
- };
73582
- Object.defineProperty(exports2, "__esModule", { value: true });
73583
- exports2.copyScaffoldingTemplate = copyScaffoldingTemplate;
73584
- exports2.toKebabCase = toKebabCase;
73585
- var tools_1 = require_tools();
73586
- var constants_1 = require_constants2();
73587
- var types_1 = require_types_impl();
73588
- var fs_1 = __importDefault2(require("fs"));
73589
- var path_1 = __importDefault2(require("path"));
73590
- async function copyScaffoldingTemplate(extension, outputPath) {
73591
- const copiedPaths = await _copyScaffoldingTemplate(extension, outputPath);
73592
- const uniquePaths = Array.from(new Set(copiedPaths));
73593
- return uniquePaths.map((filePath) => {
73594
- const relativePath = path_1.default.relative(outputPath, filePath);
73595
- const content = fs_1.default.readFileSync(filePath, "utf8");
73596
- return { path: relativePath, content };
73597
- });
73598
- }
73599
- async function _copyScaffoldingTemplate(extension, outputPath) {
73600
- switch (extension.type) {
73601
- case types_1.ExtensionType.SERVICE_PLUGIN:
73602
- return copyServicePluginScaffolding(extension, outputPath);
73603
- case types_1.ExtensionType.DASHBOARD_PAGE:
73604
- return copyDashboardPageScaffolding(extension, outputPath);
73605
- case types_1.ExtensionType.DASHBOARD_MODAL:
73606
- return copyDashboardModalScaffolding(extension, outputPath);
73607
- case types_1.ExtensionType.SITE_WIDGET:
73608
- return copyCustomElementScaffolding(extension, outputPath);
73609
- case types_1.ExtensionType.EMBEDDED_SCRIPT:
73610
- return copyEmbeddedScriptScaffolding(extension, outputPath);
73611
- case types_1.ExtensionType.BACKEND_API:
73612
- return copyBackendApiScaffolding(extension, outputPath);
73613
- case types_1.ExtensionType.BACKEND_EVENT:
73614
- return copyBackendEventScaffolding(extension, outputPath);
73615
- case types_1.ExtensionType.SITE_COMPONENT:
73616
- return copySiteComponentScaffolding(extension, outputPath);
73617
- default:
73618
- console.log(` \u26A0\uFE0F Unsupported extension type: ${extension.type}`);
73619
- return [];
73620
- }
73621
- }
73622
- async function copySiteComponentScaffolding(extension, outputPath) {
73623
- const componentName = extension.name ?? "my-component";
73624
- const scaffoldingSubPath = `src/site/components/my-component`;
73625
- const componentSubPath = `src/site/components/${toKebabCase(componentName)}`;
73626
- console.log(` \u{1F3A8} Copying site component scaffolding from: ${scaffoldingSubPath} to ${componentSubPath}`);
73627
- return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, componentSubPath);
73628
- }
73629
- async function copyServicePluginScaffolding(extension, outputPath) {
73630
- if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
73631
- throw new Error("Service plugin extension must have related SPIs");
73632
- }
73633
- const allCopiedFiles = [];
73634
- const uniqueFolderName = toKebabCase(extension.name || "my-service-plugin");
73635
- for (const spi of extension.relatedSpis) {
73636
- console.log(` \u{1F4CB} Copying service plugin scaffolding for related SPI: ${spi.name}`);
73637
- const mapped = constants_1.spiToSubPath[spi.name || ""];
73638
- if (mapped) {
73639
- const scaffoldingPath = `src/backend/service-plugins/${mapped}/my-service-plugin`;
73640
- const outputFolder = `src/backend/service-plugins/${mapped}/${uniqueFolderName}`;
73641
- const copiedFiles = await (0, tools_1.copyScaffolding)(scaffoldingPath, outputPath, outputFolder);
73642
- allCopiedFiles.push(...copiedFiles);
73643
- } else {
73644
- console.warn(` \u26A0\uFE0F No scaffolding template found for SPI: ${spi.name}`);
73645
- }
73646
- }
73647
- return allCopiedFiles;
73648
- }
73649
- async function copyDashboardPageScaffolding(extension, outputPath) {
73650
- const scaffoldingSubPath = "src/dashboard/pages";
73651
- const uniqueFolderName = toKebabCase(extension.name || "page");
73652
- const outputFolder = `src/dashboard/pages/${uniqueFolderName}`;
73653
- console.log(` \u{1F4CA} Copying dashboard page scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
73654
- return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
73655
- }
73656
- async function copyDashboardModalScaffolding(extension, outputPath) {
73657
- const scaffoldingSubPath = "src/dashboard/modals/my-modal";
73658
- const uniqueFolderName = toKebabCase(extension.name || "my-modal");
73659
- const outputFolder = `src/dashboard/modals/${uniqueFolderName}`;
73660
- console.log(` \u{1F532} Copying dashboard modal scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
73661
- return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
73662
- }
73663
- async function copyCustomElementScaffolding(extension, outputPath) {
73664
- const scaffoldingSubPath = "src/site/widgets/custom-elements/my-widget";
73665
- const uniqueFolderName = toKebabCase(extension.name || "my-widget");
73666
- const outputFolder = `src/site/widgets/custom-elements/${uniqueFolderName}`;
73667
- console.log(` \u{1F3A8} Copying site widget scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
73668
- return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
73669
- }
73670
- async function copyEmbeddedScriptScaffolding(extension, outputPath) {
73671
- const scaffoldingSubPath = "src/site/embedded-scripts/my-script";
73672
- const uniqueFolderName = toKebabCase(extension.name || "my-script");
73673
- const outputFolder = `src/site/embedded-scripts/${uniqueFolderName}`;
73674
- console.log(` \u{1F4DC} Copying embedded script scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
73675
- return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
73676
- }
73677
- async function copyBackendApiScaffolding(extension, outputPath) {
73678
- const uniqueFolderName = toKebabCase(extension.name || "my-api");
73679
- const apiScaffoldingFile = "src/pages/api/my-api.ts";
73680
- const apiOutputFile = `src/pages/api/${uniqueFolderName}.ts`;
73681
- console.log(` \u{1F50C} Copying backend API scaffolding from: ${apiScaffoldingFile} to ${apiOutputFile}`);
73682
- const apiFiles = (0, tools_1.copyScaffolding)(apiScaffoldingFile, outputPath, apiOutputFile);
73683
- return apiFiles;
73684
- }
73685
- async function copyBackendEventScaffolding(extension, outputPath) {
73686
- const scaffoldingSubPath = "src/backend/events/my-event";
73687
- const uniqueFolderName = toKebabCase(extension.name || "my-event");
73688
- const outputFolder = `src/backend/events/${uniqueFolderName}`;
73689
- console.log(` \u26A1 Copying backend event scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
73690
- return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
73691
- }
73692
- function toKebabCase(name) {
73693
- return name.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/-+/g, "-").toLowerCase();
73694
- }
73695
- }
73696
- });
73419
+ ### Example 2: Widget with Explicit React Request
73420
+ **User Request:** "Create a countdown timer React component for my site"
73421
+ **Existing Extensions:** None
73697
73422
 
73698
- // ../scaffolding/dist/index.js
73699
- var require_dist12 = __commonJS({
73700
- "../scaffolding/dist/index.js"(exports2) {
73701
- "use strict";
73702
- Object.defineProperty(exports2, "__esModule", { value: true });
73703
- exports2.spiToSubPath = exports2.copyRecursive = exports2.copyScaffolding = exports2.toKebabCase = exports2.copyScaffoldingTemplate = void 0;
73704
- var scaffolding_1 = require_scaffolding();
73705
- Object.defineProperty(exports2, "copyScaffoldingTemplate", { enumerable: true, get: function() {
73706
- return scaffolding_1.copyScaffoldingTemplate;
73707
- } });
73708
- Object.defineProperty(exports2, "toKebabCase", { enumerable: true, get: function() {
73709
- return scaffolding_1.toKebabCase;
73710
- } });
73711
- var tools_1 = require_tools();
73712
- Object.defineProperty(exports2, "copyScaffolding", { enumerable: true, get: function() {
73713
- return tools_1.copyScaffolding;
73714
- } });
73715
- Object.defineProperty(exports2, "copyRecursive", { enumerable: true, get: function() {
73716
- return tools_1.copyRecursive;
73717
- } });
73718
- var constants_1 = require_constants2();
73719
- Object.defineProperty(exports2, "spiToSubPath", { enumerable: true, get: function() {
73720
- return constants_1.spiToSubPath;
73721
- } });
73423
+ **Expected Output:**
73424
+ ${JSON.stringify(reactComponentExample, null, 2)}
73425
+ **Why:** User explicitly said "React", so use SITE_COMPONENT instead of SITE_WIDGET.
73426
+
73427
+ ---
73428
+
73429
+ ### Example 3: Popup Request (MANDATORY Dashboard Pairing)
73430
+ **User Request:** "I want a promotional popup on my site"
73431
+ **Existing Extensions:** None
73432
+
73433
+ **Expected Output:**
73434
+ ${JSON.stringify(popupWithDashboardExample, null, 2)}
73435
+ **Why:** EMBEDDED_SCRIPT MUST always be paired with DASHBOARD_PAGE - this is a technical requirement.
73436
+
73437
+ ---
73438
+
73439
+ ### Example 4: Modify Existing Extension
73440
+ **User Request:** "Change the fee from $5 to $10"
73441
+ **Existing Extensions:** SERVICE_PLUGIN "Handling Fees Calculator" at src/backend/service-plugins/fees/
73442
+
73443
+ **Expected Output:**
73444
+ ${JSON.stringify(modifyExistingExample, null, 2)}
73445
+ **Why:** Modify existing extension instead of creating new one. User didn't ask for anything new.
73446
+
73447
+ ---
73448
+
73449
+ ### Example 5: Event Trigger Pattern
73450
+ **User Request:** "When a new contact is created, log it automatically"
73451
+ **Existing Extensions:** None
73452
+
73453
+ **Expected Output:**
73454
+ ${JSON.stringify(eventTriggerExample, null, 2)}
73455
+ **Why:** Trigger pattern "when...created" indicates BACKEND_EVENT. No dashboard needed unless requested.
73456
+
73457
+ ---
73458
+
73459
+ ### Example 6: Explicit Dashboard Request with Widget
73460
+ **User Request:** "Create a product showcase widget AND a dashboard to manage featured products"
73461
+ **Existing Extensions:** None
73462
+
73463
+ **Expected Output:**
73464
+ ${JSON.stringify(widgetWithDashboardExample, null, 2)}
73465
+ **Why:** User explicitly asked for BOTH a widget AND a dashboard - honor both requests.
73466
+
73467
+ ---
73468
+
73469
+ ### Example 7: Add Feature to Existing + Create New
73470
+ **User Request:** "Add a color picker to the existing dashboard, and create a new analytics dashboard"
73471
+ **Existing Extensions:** DASHBOARD_PAGE "Settings Dashboard" at src/dashboard/pages/settings/
73472
+
73473
+ **Expected Output:**
73474
+ ${JSON.stringify(modifyAndCreateExample, null, 2)}
73475
+ **Why:** User said "add to existing" (modify) AND "create a new" (additional). Honor both.
73476
+
73477
+ ---
73478
+
73479
+ ### Example 8: Service Plugin for eCommerce
73480
+ **User Request:** "I need custom shipping rates based on destination"
73481
+ **Existing Extensions:** None
73482
+
73483
+ **Expected Output:**
73484
+ ${JSON.stringify(servicePluginExample, null, 2)}
73485
+ **Why:** User asked for shipping rates logic only. Do NOT add dashboard unless explicitly requested.
73486
+
73487
+ ---
73488
+
73489
+ ### Example 9: Full eCommerce Solution with SPI + Dashboard + Database
73490
+ **User Request:** "Build an app that adds fixed-cost shipping fees at checkout using the Additional Fees SPI. The app should save the fee description text and amount in a dedicated database collection. Also provide the user with a dashboard to manage these fixed fees."
73491
+ **Existing Extensions:** None
73492
+
73493
+ **Expected Output:**
73494
+ ${JSON.stringify(fixedFeesWithDashboardExample, null, 2)}
73495
+ **Why:** User explicitly requested BOTH a SERVICE_PLUGIN (Additional Fees SPI) AND a DASHBOARD_PAGE to manage fees. The database collection is handled by the Planner agent - no separate extension needed for CMS.`;
73722
73496
  }
73723
73497
  });
73724
73498
 
73725
- // dist/agents/AutoPatternsGenerator.js
73726
- var require_AutoPatternsGenerator = __commonJS({
73727
- "dist/agents/AutoPatternsGenerator.js"(exports2) {
73499
+ // dist/system-prompts/iterationAgent/iteration-agent-prompt.js
73500
+ var require_iteration_agent_prompt = __commonJS({
73501
+ "dist/system-prompts/iterationAgent/iteration-agent-prompt.js"(exports2) {
73728
73502
  "use strict";
73729
73503
  Object.defineProperty(exports2, "__esModule", { value: true });
73730
- exports2.AutoPatternsGenerator = void 0;
73731
- var ditto_scaffolding_1 = require_dist12();
73732
- var ditto_codegen_types_12 = require_dist();
73733
- var AutoPatternsGenerator = class {
73734
- constructor() {
73735
- this.name = "AutoPatternsGenerator";
73736
- }
73737
- generate({ collection, decision, extensionName }) {
73738
- const name = (0, ditto_scaffolding_1.toKebabCase)(extensionName);
73739
- const path2 = `src/dashboard/pages/${name}`;
73740
- const patternsConfig = this.generatePatternsConfig(collection, decision);
73741
- const pageTsx = this.generatePageTsx();
73742
- return [
73743
- {
73744
- path: `${path2}/patterns.json`,
73745
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
73746
- content: JSON.stringify(patternsConfig, null, 2)
73747
- },
73748
- {
73749
- path: `${path2}/page.tsx`,
73750
- operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
73751
- content: pageTsx
73752
- }
73753
- ];
73754
- }
73755
- generatePatternsConfig(collection, contentResult) {
73756
- const collectionRouteId = contentResult.schema?.content?.collectionRouteId;
73757
- const singularEntityName = contentResult.schema?.content?.singularEntityName;
73758
- const fieldMap = new Map(collection.fields?.filter((field) => field.key && field.displayName).map((field) => [field.key, field]) || []);
73759
- const sortableFieldTypes = ["TEXT", "DATE", "NUMBER", "BOOLEAN", "URL"];
73760
- const columns = contentResult.schema?.columns?.map((columnConfig) => {
73761
- const field = fieldMap.get(columnConfig.id);
73762
- if (!field || !field.key || !field.type)
73763
- return null;
73764
- let width = "200px";
73765
- if (["BOOLEAN", "IMAGE", "NUMBER"].includes(field.type))
73766
- width = "100px";
73767
- if (field.type === "URL")
73768
- width = "300px";
73769
- return {
73770
- id: field.key,
73771
- name: columnConfig.displayName || field.displayName || "Field",
73772
- width,
73773
- sortable: sortableFieldTypes.includes(field.type || "")
73774
- };
73775
- }).filter((item) => item != null) || [];
73776
- const filterableFieldTypes = ["DATE", "NUMBER", "BOOLEAN"];
73777
- const filters = columns.map((column) => {
73778
- const field = fieldMap.get(column.id);
73779
- if (!field || !field.key || !filterableFieldTypes.includes(field.type || ""))
73780
- return null;
73781
- const baseFilter = {
73782
- id: `${field.key}-filter`,
73783
- fieldId: field.key,
73784
- displayName: field.displayName || "",
73785
- tagLabel: field.displayName || ""
73786
- };
73787
- if (field.type === "DATE") {
73788
- return {
73789
- ...baseFilter,
73790
- dateConfig: {
73791
- mode: "COMBINE",
73792
- presets: [
73793
- "TODAY",
73794
- "SEVEN_DAYS",
73795
- "MONTH",
73796
- "NEXT_SEVEN_DAYS",
73797
- "NEXT_THIRTY_DAYS"
73798
- ],
73799
- includeTime: false
73800
- }
73801
- };
73802
- }
73803
- if (field.type === "NUMBER") {
73804
- return {
73805
- ...baseFilter,
73806
- numberConfig: { allowedDecimals: true }
73807
- };
73808
- }
73809
- if (field.type === "BOOLEAN") {
73810
- return baseFilter;
73811
- }
73812
- return null;
73813
- }).filter((item) => item != null);
73814
- const layout = [
73815
- {
73816
- type: "Table",
73817
- table: {
73818
- columns,
73819
- customColumns: {
73820
- enabled: true
73821
- }
73822
- }
73823
- }
73824
- ];
73825
- if (contentResult.schema?.gridItem) {
73826
- layout.push({
73827
- type: "Grid",
73828
- grid: {
73829
- item: {
73830
- titleFieldId: contentResult.schema?.gridItem?.titleFieldId,
73831
- subtitleFieldId: contentResult.schema?.gridItem?.subtitleFieldId,
73832
- imageFieldId: contentResult.schema?.gridItem?.imageFieldId,
73833
- cardContentMode: contentResult.schema?.gridItem?.subtitleFieldId ? "full" : "title"
73834
- }
73835
- }
73836
- });
73837
- }
73838
- return {
73839
- pages: [
73840
- {
73841
- id: `${collectionRouteId}-collection`,
73842
- type: "collectionPage",
73843
- appMainPage: true,
73844
- collectionPage: {
73845
- route: {
73846
- path: "/"
73847
- },
73848
- title: {
73849
- text: contentResult.schema?.content.pageTitle || "",
73850
- hideTotal: false
73851
- },
73852
- subtitle: {
73853
- text: contentResult.schema?.content.pageSubtitle || ""
73854
- },
73855
- actions: {
73856
- primaryActions: {
73857
- type: "action",
73858
- action: {
73859
- item: {
73860
- id: `create-${collectionRouteId}`,
73861
- type: "create",
73862
- label: contentResult.schema?.content.actionButtonLabel,
73863
- collection: {
73864
- collectionId: collection.idSuffix,
73865
- entityTypeSource: "cms"
73866
- },
73867
- create: {
73868
- mode: "page",
73869
- page: {
73870
- id: `${collectionRouteId}-entity`
73871
- }
73872
- }
73873
- }
73874
- }
73875
- }
73876
- },
73877
- components: [
73878
- {
73879
- type: "collection",
73880
- layout,
73881
- entityPageId: `${collectionRouteId}-entity`,
73882
- collection: {
73883
- collectionId: collection.idSuffix,
73884
- entityTypeSource: "cms"
73885
- },
73886
- toolbarTitle: {
73887
- title: contentResult.schema?.content.toolbarTitle || "",
73888
- subtitle: {
73889
- text: contentResult.schema?.content.toolbarSubtitle || ""
73890
- },
73891
- showTotal: true
73892
- },
73893
- filters: {
73894
- items: filters
73895
- },
73896
- emptyState: {
73897
- title: contentResult.schema?.content.emptyStateTitle,
73898
- subtitle: contentResult.schema?.content.emptyStateSubtitle,
73899
- addNewCta: {
73900
- id: `create-${collectionRouteId}`,
73901
- text: contentResult.schema?.content.emptyStateButtonText
73902
- }
73903
- },
73904
- actionCell: {
73905
- primaryAction: {
73906
- item: {
73907
- id: `edit-${collectionRouteId}`,
73908
- type: "update",
73909
- update: {
73910
- mode: "page",
73911
- page: {
73912
- id: `${collectionRouteId}-entity`
73913
- }
73914
- }
73915
- }
73916
- },
73917
- secondaryActions: {
73918
- items: [
73919
- {
73920
- id: `delete-${collectionRouteId}`,
73921
- type: "delete",
73922
- label: "Delete",
73923
- delete: {
73924
- mode: "modal",
73925
- modal: {
73926
- title: {
73927
- text: contentResult.schema?.content.deleteModalTitle || ""
73928
- },
73929
- description: {
73930
- text: contentResult.schema?.content.deleteModalDescription || ""
73931
- },
73932
- feedback: {
73933
- successToast: {
73934
- text: contentResult.schema?.content.deleteSuccessToast || ""
73935
- },
73936
- errorToast: {
73937
- text: contentResult.schema?.content.deleteErrorToast || ""
73938
- }
73939
- }
73940
- }
73941
- }
73942
- }
73943
- ]
73944
- }
73945
- },
73946
- bulkActionToolbar: {
73947
- primaryActions: [
73948
- {
73949
- type: "action",
73950
- action: {
73951
- item: {
73952
- id: `bulk-delete-${collectionRouteId}`,
73953
- type: "bulkDelete",
73954
- bulkDelete: {
73955
- mode: "modal",
73956
- modal: {
73957
- title: {
73958
- text: contentResult.schema?.content.bulkDeleteModalTitle || ""
73959
- },
73960
- description: {
73961
- text: contentResult.schema?.content.bulkDeleteModalDescription || ""
73962
- },
73963
- feedback: {
73964
- successToast: {
73965
- text: contentResult.schema?.content.bulkDeleteSuccessToast || ""
73966
- },
73967
- errorToast: {
73968
- text: contentResult.schema?.content.bulkDeleteErrorToast || ""
73969
- }
73970
- }
73971
- }
73972
- }
73973
- }
73974
- }
73975
- }
73976
- ]
73977
- }
73978
- }
73979
- ]
73980
- }
73981
- },
73982
- {
73983
- id: `${collectionRouteId}-entity`,
73984
- type: "entityPage",
73985
- entityPage: {
73986
- route: {
73987
- path: `/${singularEntityName}/:entityId`,
73988
- params: { id: "entityId" }
73989
- },
73990
- title: {
73991
- text: contentResult.schema?.content.entityPageTitle || ""
73992
- },
73993
- subtitle: {
73994
- text: contentResult.schema?.content.entityPageSubtitle
73995
- },
73996
- parentPageId: `${collectionRouteId}-collection`,
73997
- layout: this.generateEntityPageLayout(contentResult.schema?.layout),
73998
- collectionId: collection.idSuffix,
73999
- entityTypeSource: "cms"
74000
- }
74001
- }
74002
- ]
74003
- };
74004
- }
74005
- generateEntityPageLayout(layout) {
74006
- if (!layout)
74007
- return { main: [] };
74008
- const main2 = layout.main.map((section) => ({
74009
- type: "card",
74010
- card: {
74011
- title: { text: section.title },
74012
- subtitle: { text: section.subtitle },
74013
- children: section.fields.map((fieldKey) => ({
74014
- type: "field",
74015
- field: { span: 12, fieldId: fieldKey }
74016
- }))
74017
- }
74018
- }));
74019
- const sidebar = layout.sidebar.map((section) => ({
74020
- type: "card",
74021
- card: {
74022
- title: { text: section.title },
74023
- subtitle: { text: section.subtitle },
74024
- children: section.fields.map((fieldKey) => ({
74025
- type: "field",
74026
- field: { span: 12, fieldId: fieldKey }
74027
- }))
74028
- }
74029
- }));
74030
- return {
74031
- main: main2,
74032
- ...sidebar.length > 0 ? { sidebar } : {}
74033
- };
74034
- }
74035
- generatePageTsx() {
74036
- return `import React, { type FC } from 'react';
74037
- import { WixDesignSystemProvider } from '@wix/design-system';
74038
- import '@wix/design-system/styles.global.css';
74039
- import { WixPatternsProvider } from '@wix/patterns/provider';
74040
- import { PatternsWizardOverridesProvider, AutoPatternsApp } from '@wix/auto-patterns';
74041
- import type { AppConfig } from '@wix/auto-patterns';
74042
- import { withDashboard } from '@wix/patterns';
74043
- import config from './patterns.json';
74044
-
74045
- const CollectionPage: FC = () => {
74046
- return (
74047
- <WixDesignSystemProvider features={{ newColorsBranding: true }}>
74048
- <WixPatternsProvider>
74049
- <PatternsWizardOverridesProvider value={{}}>
74050
- <AutoPatternsApp configuration={config as AppConfig} />
74051
- </PatternsWizardOverridesProvider>
74052
- </WixPatternsProvider>
74053
- </WixDesignSystemProvider>
74054
- );
74055
- };
74056
-
74057
- export default withDashboard(CollectionPage);
74058
- `;
74059
- }
73504
+ exports2.iterationAgentPrompt = void 0;
73505
+ var codegen_common_logic_1 = require_dist9();
73506
+ var iterartion_agent_instructions_1 = require_iterartion_agent_instructions();
73507
+ var AgentsRegistry_1 = require_AgentsRegistry();
73508
+ var iteration_examples_1 = require_iteration_examples();
73509
+ var iterationAgentPrompt = () => {
73510
+ const supportedTypes = (0, AgentsRegistry_1.getSupportedExtensionTypes)().join(", ");
73511
+ const supportedExtensions = (0, AgentsRegistry_1.generateSupportedExtensionsSection)();
73512
+ const constraints = (0, iterartion_agent_instructions_1.getIterationAgentConstraints)(supportedTypes);
73513
+ const keyPoints = (0, iterartion_agent_instructions_1.getIterationAgentKeyPoints)(supportedTypes);
73514
+ const systemPrompt = new codegen_common_logic_1.SystemPromptBuilder({
73515
+ agentType: codegen_common_logic_1.GeneralAgentType.ITERATION_AGENT
73516
+ }).withRole(iterartion_agent_instructions_1.iterationAgentRole).withSection("project_structure_guide", iterartion_agent_instructions_1.iterationAgentProjectStructureGuide).withSection("data_extensions_guide", iterartion_agent_instructions_1.iterationAgentDataExtensionsGuide).withSection("chat_history_context", iterartion_agent_instructions_1.iterationAgentChatHistoryContext).withSection("common_iteration_scenarios", iterartion_agent_instructions_1.iterationAgentCommonScenariosDocumentation).withSection("quick_decision_guide", iterartion_agent_instructions_1.iterationAgentQuickDecisionGuide).withSection("common_use_cases_guide", iterartion_agent_instructions_1.iterationAgentCommonUseCasesGuide).withSection("available_tools", iterartion_agent_instructions_1.iterationAgentAvailableTools).withSection("extension_evaluation", iterartion_agent_instructions_1.iterationAgentExtensionEvaluation).withSection("supported_extension_types", supportedExtensions).withSection("extension_selection_logic", iterartion_agent_instructions_1.iterationAgentExtensionSelectionLogic).withSection("constraints", constraints).withSection("key_points", keyPoints).withExamples(iteration_examples_1.iterationAgentExamples);
73517
+ return systemPrompt.compose();
74060
73518
  };
74061
- exports2.AutoPatternsGenerator = AutoPatternsGenerator;
73519
+ exports2.iterationAgentPrompt = iterationAgentPrompt;
74062
73520
  }
74063
73521
  });
74064
73522
 
@@ -74339,148 +73797,76 @@ var require_src = __commonJS({
74339
73797
  }
74340
73798
  });
74341
73799
 
74342
- // dist/system-prompts/extension-selector/extension-selector-instructions.js
74343
- var require_extension_selector_instructions = __commonJS({
74344
- "dist/system-prompts/extension-selector/extension-selector-instructions.js"(exports2) {
73800
+ // dist/agents/Iteration/utils/contextBuilders.js
73801
+ var require_contextBuilders = __commonJS({
73802
+ "dist/agents/Iteration/utils/contextBuilders.js"(exports2) {
74345
73803
  "use strict";
73804
+ var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
73805
+ return mod && mod.__esModule ? mod : { "default": mod };
73806
+ };
74346
73807
  Object.defineProperty(exports2, "__esModule", { value: true });
74347
- exports2.extensionSelectorInstructions = void 0;
74348
- var AgentsRegistry_1 = require_AgentsRegistry();
74349
- var iterationScenarios_1 = require_iterationScenarios();
74350
- var extensionSelectorRole = `You evaluate ALL provided extensions for relevance to a user request and return only the relevant ones.`;
74351
- var extensionSelectorCommonScenariosDocumentation = (0, iterationScenarios_1.getCommonScenariosDocumentation)();
74352
- var extensionSelectorQuickDecisionGuide = (0, iterationScenarios_1.getQuickDecisionGuide)();
74353
- var extensionSelectorChatHistoryContext = (0, iterationScenarios_1.getChatHistoryContext)();
74354
- var extensionSelectorAvailableTools = `You have access to the following tools:
74355
- - **read_file**: Read the contents of any file in the project
74356
- - Use this to examine extension files, imported dependencies, and related files
74357
- - You can call this tool multiple times to understand the full context
74358
-
74359
- - **submit_evaluation**: Submit your final relevance evaluation for all extensions (REQUIRED)
74360
- - You MUST call this tool at the end with your final decision
74361
- - Only include extensions in extensionsToModify if they NEED CODE CHANGES
74362
- - Include existing relevant extensions in contextExtensions so the Iteration Agent knows they exist
74363
- `;
74364
- var extensionSelectorProjectStructure = (srcFolderStructure) => `The project src/ folder structure:
73808
+ exports2.generateSrcFolderStructure = generateSrcFolderStructure;
73809
+ exports2.buildContextSections = buildContextSections;
73810
+ var fs_1 = __importDefault2(require("fs"));
73811
+ var path_1 = __importDefault2(require("path"));
73812
+ var tree_node_cli_1 = __importDefault2(require_src());
73813
+ function generateSrcFolderStructure(basePath) {
73814
+ const srcPath = path_1.default.join(basePath, "src");
73815
+ if (!fs_1.default.existsSync(srcPath)) {
73816
+ return "";
73817
+ }
73818
+ try {
73819
+ return (0, tree_node_cli_1.default)(srcPath, {
73820
+ allFiles: true,
73821
+ maxDepth: 10
73822
+ });
73823
+ } catch (error) {
73824
+ console.error("Error generating src folder structure:", error);
73825
+ return "";
73826
+ }
73827
+ }
73828
+ function formatChatHistory(chatHistory) {
73829
+ return (chatHistory || []).map((message) => `${message.role.toUpperCase()}: ${message.text}`).join("\n\n");
73830
+ }
73831
+ function formatProjectStructure(srcFolderStructure) {
73832
+ if (!srcFolderStructure) {
73833
+ return "";
73834
+ }
73835
+ return `## Project Structure
73836
+
73837
+ The project src/ folder structure:
74365
73838
  \`\`\`
74366
73839
  ${srcFolderStructure}
74367
73840
  \`\`\`
74368
73841
 
74369
- Use this structure to navigate and locate relevant files.`;
74370
- var extensionSelectorExtensionTypeDocumentation = (extensionTypes) => {
74371
- const uniqueExtensionTypes = [...new Set(extensionTypes)];
74372
- const extensionDocs = uniqueExtensionTypes.map((type) => (0, AgentsRegistry_1.getAgentDocumentation)(type)).join("\n\n");
74373
- return extensionDocs;
74374
- };
74375
- var extensionSelectorInstructionsContent = `
74376
- 1. **Review all extensions**:
74377
- - Read the current user request (this is the PRIMARY directive)
74378
- - Review ALL provided extensions: their types, component paths, files lists, and config keys
74379
- - Use chat history only for additional context if needed
74380
-
74381
- 2. **Use the read_file tool strategically**:
74382
- - Examine extension files to understand their functionality
74383
- - Read imported files if they're relevant to understanding the extensions
74384
- - Use the project structure above to locate files efficiently
74385
- - For SERVICE_PLUGIN extensions: Look for which SPI is being used to understand its domain
74386
-
74387
- 3. **Evaluate and submit**:
74388
- - For EACH extension, decide if it needs CODE CHANGES to its EXISTING files based on the user's request
74389
- - ONLY return extensions that need to be MODIFIED in their existing code. DO NOT return extensions if:
74390
- * You're suggesting to CREATE new features that don't exist yet
74391
- * You're suggesting to ADD new functionality (that's handled by the Iteration Agent separately)
74392
- * The extension is used for validation or verification purposes only
74393
- * The extension is referenced for information but doesn't need code changes
74394
- * The extension is read for context but remains unchanged
74395
- * Your reasoning suggests "creating" or "adding" something new
74396
- - Deletion Operations**: If the user wants to DELETE an extension, include it in extensionsToModify (not contextExtensions)
74397
- * Example: "delete the dashboard" \u2192 Put DASHBOARD_PAGE in extensionsToModify with reasoning about deletion
74398
- * Example: "remove the widget" \u2192 Put SITE_WIDGET in extensionsToModify
74399
- - Adding New Features**: When the user wants to ADD something entirely new (e.g., "add shipping rates", "add a new widget", "display fees for visitors"):
74400
- * Ask yourself: "Does this extension ALREADY have code that needs to be CHANGED?"
74401
- * If the answer is NO (you're suggesting to create something new) \u2192 DO NOT return this extension
74402
- * If NO EXISTING extensions need modifications \u2192 Return EMPTY extensionsToModify []
74403
- * DO NOT invent file paths for extensions that don't exist yet
74404
- * The Iteration Agent will handle creating new extensions in additionalExtensions
74405
- * **Example**: User says "add shipping rates" but only additional fees exist \u2192 Return [] (empty array)
74406
- * **Example**: User says "display fees on site" but only dashboard page exists \u2192 Return [] (no existing site widget to modify)
74407
- - For extensions that need changes, identify the specific files that need to be modified
74408
- - relevantFiles array**: The \`relevantFiles\` array should ONLY contain files that NEED TO BE CHANGED:
74409
- * If you read a file for understanding/context but it doesn't need changes \u2192 DO NOT include it in relevantFiles
74410
- * If no files need changes for an extension \u2192 DO NOT return that extension at all
74411
- * **Example**: Reading patterns.json to understand schema but no code changes needed \u2192 relevantFiles should be empty \u2192 don't return the extension
74412
- * **For deletions**: Include all files of the extension that will be deleted
74413
- - Not all files you read will be relevant - filter to only what needs modification
74414
- - Only return files that are part of each extension, never mix files from different extensions
74415
- - Only return EXISTING extensions from the "Extensions to Evaluate" list - never invent new extensions
74416
- - Use the extension types documentation above to understand what each extension type does
74417
- - **Ensure each extension's \`reasoning\` field includes**:
74418
- * **What the extension CURRENTLY does**: What functionality does it already provide?
74419
- * **What CODE CHANGES it needs**: Specifically what needs to be modified/deleted in the existing code?`;
74420
- var extensionSelectorConstraints = `
74421
- - **TWO CATEGORIES OF EXTENSIONS**:
74422
- 1. **extensionsToModify**: Include extensions that need CODE CHANGES, MODIFICATIONS, or DELETION
74423
- * DO include if extension needs to be modified or deleted
74424
- * DO NOT include if you're suggesting to CREATE or ADD new features
74425
- * DO NOT include if your reasoning says "we need to create" or "add a new"
74426
- * DO NOT include if they're just used for reference/validation
74427
- 2. **contextExtensions**: Include extensions that are RELEVANT but DON'T need any code changes or deletion
74428
- * DO include if they already exist and relate to the user's request
74429
- * This helps the Iteration Agent know what exists to avoid creating duplicates
74430
- * Example: User wants to "add a widget", dashboard exists and doesn't need changes \u2192 include dashboard in contextExtensions
74431
- * DO NOT include if extension needs to be deleted \u2192 that goes in extensionsToModify
74432
- - **ASK YOURSELF for extensionsToModify**: "Does this extension need to be CHANGED or DELETED?" If YES \u2192 Put it in extensionsToModify
74433
- - **ASK YOURSELF for contextExtensions**: "Does this extension already exist, relate to the request, but needs NO changes?" If YES \u2192 Put it in contextExtensions
74434
- - **DO NOT INVENT FILE PATHS**: Only return file paths that exist in the "Extensions to Evaluate" list
74435
- * If user wants to ADD a new feature that doesn't exist \u2192 return EMPTY ARRAY []
74436
- * **Example**: User says "add shipping rates", only additional fees exists \u2192 return []
74437
- * DO NOT invent paths like "src/backend/service-plugins/ecom-shipping-rates/..." if they don't exist
74438
- - **relevantFiles MUST be non-empty AND must exist**: If you can't identify specific files that need changes, don't return the extension
74439
- - **Precision over recall**: Avoid false positives - only include extensions if you're confident they need changes
74440
- - **File scope**: Only consider files under src/ directory
74441
- - **Efficiency**: Be strategic with tool calls - don't read unnecessary files
74442
- - **Uncertainty**: If you're unsure about an extension, omit it from the results
74443
- - **Output filtering**: For each extension, return only files that:
74444
- * Belong to that specific extension (never mix files from different extensions)
74445
- * Directly relate to the user's request
74446
- * Actually need modification (not all files you read)
74447
- * **EXIST in the provided extensions list** - never invent file paths
74448
- - **SPI Matching (for SERVICE_PLUGIN extensions)**: If an extension uses a specific SPI (Service Provider Interface), understand that:
74449
- * Each SPI handles a specific business domain (e.g., additional fees, shipping rates, product validation)
74450
- * Different SPIs are NOT interchangeable - they serve different purposes
74451
- * Only include an SPI extension if the user's request matches that specific SPI's domain
74452
- * Example: If user wants to add fees using ecom.additionalFees.calculateAdditionalFees, don't include ecom.shippingRates.getShippingRates even if both mention "shipping"
74453
- * Example: If user wants to add shipping rates using ecom.shippingRates.getShippingRates, don't include ecom.additionalFees.calculateAdditionalFees
74454
- * Look at the actual SPI being used in the extension code to determine if it matches the user's intent`;
74455
- exports2.extensionSelectorInstructions = {
74456
- role: extensionSelectorRole,
74457
- chatHistoryContext: extensionSelectorChatHistoryContext,
74458
- commonScenariosDocumentation: extensionSelectorCommonScenariosDocumentation,
74459
- quickDecisionGuide: extensionSelectorQuickDecisionGuide,
74460
- availableTools: extensionSelectorAvailableTools,
74461
- projectStructure: extensionSelectorProjectStructure,
74462
- extensionTypeDocumentation: extensionSelectorExtensionTypeDocumentation,
74463
- instructions: extensionSelectorInstructionsContent,
74464
- constraints: extensionSelectorConstraints
74465
- };
74466
- }
74467
- });
74468
-
74469
- // dist/system-prompts/extension-selector/extension-selector-prompt.js
74470
- var require_extension_selector_prompt = __commonJS({
74471
- "dist/system-prompts/extension-selector/extension-selector-prompt.js"(exports2) {
74472
- "use strict";
74473
- Object.defineProperty(exports2, "__esModule", { value: true });
74474
- exports2.extensionSelectorPrompt = void 0;
74475
- var codegen_common_logic_1 = require_dist9();
74476
- var extension_selector_instructions_1 = require_extension_selector_instructions();
74477
- var extensionSelectorPrompt = (extensionTypes, srcFolderStructure) => {
74478
- const systemPrompt = (0, codegen_common_logic_1.systemPromptBuilder)({
74479
- agentType: codegen_common_logic_1.GeneralAgentType.EXTENSION_SELECTOR
74480
- }).withRole(extension_selector_instructions_1.extensionSelectorInstructions.role).withSection("chat_history_context", extension_selector_instructions_1.extensionSelectorInstructions.chatHistoryContext).withSection("common_iteration_scenarios", extension_selector_instructions_1.extensionSelectorInstructions.commonScenariosDocumentation).withSection("quick_decision_guide", extension_selector_instructions_1.extensionSelectorInstructions.quickDecisionGuide).withSection("available_tools", extension_selector_instructions_1.extensionSelectorInstructions.availableTools).withSection("project_structure", extension_selector_instructions_1.extensionSelectorInstructions.projectStructure(srcFolderStructure)).withSection("extension_type_documentation", extension_selector_instructions_1.extensionSelectorInstructions.extensionTypeDocumentation(extensionTypes)).withSection("instructions", extension_selector_instructions_1.extensionSelectorInstructions.instructions).withSection("constraints", extension_selector_instructions_1.extensionSelectorInstructions.constraints);
74481
- return systemPrompt.compose();
74482
- };
74483
- exports2.extensionSelectorPrompt = extensionSelectorPrompt;
73842
+ Use this structure along with **glob** and **grep** tools to navigate and locate relevant files.`;
73843
+ }
73844
+ function buildContextSections(chatHistory, currentUserRequest, previousResources, srcFolderStructure) {
73845
+ const historyStr = formatChatHistory(chatHistory);
73846
+ const sections = [
73847
+ `
73848
+ Full Chat History:
73849
+ ${historyStr}`,
73850
+ `
73851
+ Current User Request: ${currentUserRequest}`
73852
+ ];
73853
+ const projectStructure = formatProjectStructure(srcFolderStructure);
73854
+ if (projectStructure) {
73855
+ sections.push(`
73856
+ ${projectStructure}`);
73857
+ }
73858
+ if (previousResources.collections.length > 0) {
73859
+ sections.push(`
73860
+ Existing Collections:
73861
+ ${JSON.stringify(previousResources.collections, null, 2)}`);
73862
+ }
73863
+ if (previousResources.embeddedScriptParameters.length > 0) {
73864
+ sections.push(`
73865
+ Embedded Script Parameters:
73866
+ ${JSON.stringify(previousResources.embeddedScriptParameters, null, 2)}`);
73867
+ }
73868
+ return sections;
73869
+ }
74484
73870
  }
74485
73871
  });
74486
73872
 
@@ -75045,7 +74431,7 @@ var require_glob_parent = __commonJS({
75045
74431
  });
75046
74432
 
75047
74433
  // ../../node_modules/braces/lib/utils.js
75048
- var require_utils2 = __commonJS({
74434
+ var require_utils = __commonJS({
75049
74435
  "../../node_modules/braces/lib/utils.js"(exports2) {
75050
74436
  "use strict";
75051
74437
  exports2.isInteger = (num) => {
@@ -75130,7 +74516,7 @@ var require_utils2 = __commonJS({
75130
74516
  var require_stringify = __commonJS({
75131
74517
  "../../node_modules/braces/lib/stringify.js"(exports2, module2) {
75132
74518
  "use strict";
75133
- var utils = require_utils2();
74519
+ var utils = require_utils();
75134
74520
  module2.exports = (ast, options = {}) => {
75135
74521
  const stringify = (node, parent = {}) => {
75136
74522
  const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
@@ -75583,7 +74969,7 @@ var require_compile = __commonJS({
75583
74969
  "../../node_modules/braces/lib/compile.js"(exports2, module2) {
75584
74970
  "use strict";
75585
74971
  var fill = require_fill_range();
75586
- var utils = require_utils2();
74972
+ var utils = require_utils();
75587
74973
  var compile = (ast, options = {}) => {
75588
74974
  const walk = (node, parent = {}) => {
75589
74975
  const invalidBlock = utils.isInvalidBrace(parent);
@@ -75636,7 +75022,7 @@ var require_expand = __commonJS({
75636
75022
  "use strict";
75637
75023
  var fill = require_fill_range();
75638
75024
  var stringify = require_stringify();
75639
- var utils = require_utils2();
75025
+ var utils = require_utils();
75640
75026
  var append = (queue = "", stash = "", enclose = false) => {
75641
75027
  const result = [];
75642
75028
  queue = [].concat(queue);
@@ -75725,7 +75111,7 @@ var require_expand = __commonJS({
75725
75111
  });
75726
75112
 
75727
75113
  // ../../node_modules/braces/lib/constants.js
75728
- var require_constants3 = __commonJS({
75114
+ var require_constants2 = __commonJS({
75729
75115
  "../../node_modules/braces/lib/constants.js"(exports2, module2) {
75730
75116
  "use strict";
75731
75117
  module2.exports = {
@@ -75858,7 +75244,7 @@ var require_parse3 = __commonJS({
75858
75244
  /* ' */
75859
75245
  CHAR_NO_BREAK_SPACE,
75860
75246
  CHAR_ZERO_WIDTH_NOBREAK_SPACE
75861
- } = require_constants3();
75247
+ } = require_constants2();
75862
75248
  var parse = (input, options = {}) => {
75863
75249
  if (typeof input !== "string") {
75864
75250
  throw new TypeError("Expected a string");
@@ -76127,7 +75513,7 @@ var require_braces = __commonJS({
76127
75513
  });
76128
75514
 
76129
75515
  // ../../node_modules/picomatch/lib/constants.js
76130
- var require_constants4 = __commonJS({
75516
+ var require_constants3 = __commonJS({
76131
75517
  "../../node_modules/picomatch/lib/constants.js"(exports2, module2) {
76132
75518
  "use strict";
76133
75519
  var path2 = require("path");
@@ -76324,7 +75710,7 @@ var require_constants4 = __commonJS({
76324
75710
  });
76325
75711
 
76326
75712
  // ../../node_modules/picomatch/lib/utils.js
76327
- var require_utils3 = __commonJS({
75713
+ var require_utils2 = __commonJS({
76328
75714
  "../../node_modules/picomatch/lib/utils.js"(exports2) {
76329
75715
  "use strict";
76330
75716
  var path2 = require("path");
@@ -76334,7 +75720,7 @@ var require_utils3 = __commonJS({
76334
75720
  REGEX_REMOVE_BACKSLASH,
76335
75721
  REGEX_SPECIAL_CHARS,
76336
75722
  REGEX_SPECIAL_CHARS_GLOBAL
76337
- } = require_constants4();
75723
+ } = require_constants3();
76338
75724
  exports2.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
76339
75725
  exports2.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
76340
75726
  exports2.isRegexChar = (str) => str.length === 1 && exports2.hasRegexChars(str);
@@ -76388,7 +75774,7 @@ var require_utils3 = __commonJS({
76388
75774
  var require_scan = __commonJS({
76389
75775
  "../../node_modules/picomatch/lib/scan.js"(exports2, module2) {
76390
75776
  "use strict";
76391
- var utils = require_utils3();
75777
+ var utils = require_utils2();
76392
75778
  var {
76393
75779
  CHAR_ASTERISK,
76394
75780
  /* * */
@@ -76420,7 +75806,7 @@ var require_scan = __commonJS({
76420
75806
  /* ) */
76421
75807
  CHAR_RIGHT_SQUARE_BRACKET
76422
75808
  /* ] */
76423
- } = require_constants4();
75809
+ } = require_constants3();
76424
75810
  var isPathSeparator = (code) => {
76425
75811
  return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
76426
75812
  };
@@ -76718,8 +76104,8 @@ var require_scan = __commonJS({
76718
76104
  var require_parse4 = __commonJS({
76719
76105
  "../../node_modules/picomatch/lib/parse.js"(exports2, module2) {
76720
76106
  "use strict";
76721
- var constants = require_constants4();
76722
- var utils = require_utils3();
76107
+ var constants = require_constants3();
76108
+ var utils = require_utils2();
76723
76109
  var {
76724
76110
  MAX_LENGTH,
76725
76111
  POSIX_REGEX_SOURCE,
@@ -77494,8 +76880,8 @@ var require_picomatch = __commonJS({
77494
76880
  var path2 = require("path");
77495
76881
  var scan = require_scan();
77496
76882
  var parse = require_parse4();
77497
- var utils = require_utils3();
77498
- var constants = require_constants4();
76883
+ var utils = require_utils2();
76884
+ var constants = require_constants3();
77499
76885
  var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
77500
76886
  var picomatch = (glob, options, returnState = false) => {
77501
76887
  if (Array.isArray(glob)) {
@@ -77643,7 +77029,7 @@ var require_micromatch = __commonJS({
77643
77029
  var util = require("util");
77644
77030
  var braces = require_braces();
77645
77031
  var picomatch = require_picomatch2();
77646
- var utils = require_utils3();
77032
+ var utils = require_utils2();
77647
77033
  var isEmptyString = (v) => v === "" || v === "./";
77648
77034
  var hasBraces = (v) => {
77649
77035
  const index = v.indexOf("{");
@@ -78122,7 +77508,7 @@ var require_string = __commonJS({
78122
77508
  });
78123
77509
 
78124
77510
  // ../../node_modules/fast-glob/out/utils/index.js
78125
- var require_utils4 = __commonJS({
77511
+ var require_utils3 = __commonJS({
78126
77512
  "../../node_modules/fast-glob/out/utils/index.js"(exports2) {
78127
77513
  "use strict";
78128
77514
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -78150,7 +77536,7 @@ var require_tasks = __commonJS({
78150
77536
  "use strict";
78151
77537
  Object.defineProperty(exports2, "__esModule", { value: true });
78152
77538
  exports2.convertPatternGroupToTask = exports2.convertPatternGroupsToTasks = exports2.groupPatternsByBaseDirectory = exports2.getNegativePatternsAsPositive = exports2.getPositivePatterns = exports2.convertPatternsToTasks = exports2.generate = void 0;
78153
- var utils = require_utils4();
77539
+ var utils = require_utils3();
78154
77540
  function generate(input, settings) {
78155
77541
  const patterns = processPatterns(input, settings);
78156
77542
  const ignore = processPatterns(settings.ignore, settings);
@@ -78448,7 +77834,7 @@ var require_run_parallel = __commonJS({
78448
77834
  });
78449
77835
 
78450
77836
  // ../../node_modules/@nodelib/fs.scandir/out/constants.js
78451
- var require_constants5 = __commonJS({
77837
+ var require_constants4 = __commonJS({
78452
77838
  "../../node_modules/@nodelib/fs.scandir/out/constants.js"(exports2) {
78453
77839
  "use strict";
78454
77840
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -78493,7 +77879,7 @@ var require_fs3 = __commonJS({
78493
77879
  });
78494
77880
 
78495
77881
  // ../../node_modules/@nodelib/fs.scandir/out/utils/index.js
78496
- var require_utils5 = __commonJS({
77882
+ var require_utils4 = __commonJS({
78497
77883
  "../../node_modules/@nodelib/fs.scandir/out/utils/index.js"(exports2) {
78498
77884
  "use strict";
78499
77885
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -78527,8 +77913,8 @@ var require_async2 = __commonJS({
78527
77913
  exports2.readdir = exports2.readdirWithFileTypes = exports2.read = void 0;
78528
77914
  var fsStat = require_out();
78529
77915
  var rpl = require_run_parallel();
78530
- var constants_1 = require_constants5();
78531
- var utils = require_utils5();
77916
+ var constants_1 = require_constants4();
77917
+ var utils = require_utils4();
78532
77918
  var common = require_common();
78533
77919
  function read(directory, settings, callback) {
78534
77920
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
@@ -78636,8 +78022,8 @@ var require_sync3 = __commonJS({
78636
78022
  Object.defineProperty(exports2, "__esModule", { value: true });
78637
78023
  exports2.readdir = exports2.readdirWithFileTypes = exports2.read = void 0;
78638
78024
  var fsStat = require_out();
78639
- var constants_1 = require_constants5();
78640
- var utils = require_utils5();
78025
+ var constants_1 = require_constants4();
78026
+ var utils = require_utils4();
78641
78027
  var common = require_common();
78642
78028
  function read(directory, settings) {
78643
78029
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
@@ -79461,7 +78847,7 @@ var require_reader2 = __commonJS({
79461
78847
  Object.defineProperty(exports2, "__esModule", { value: true });
79462
78848
  var path2 = require("path");
79463
78849
  var fsStat = require_out();
79464
- var utils = require_utils4();
78850
+ var utils = require_utils3();
79465
78851
  var Reader = class {
79466
78852
  constructor(_settings) {
79467
78853
  this._settings = _settings;
@@ -79594,7 +78980,7 @@ var require_matcher = __commonJS({
79594
78980
  "../../node_modules/fast-glob/out/providers/matchers/matcher.js"(exports2) {
79595
78981
  "use strict";
79596
78982
  Object.defineProperty(exports2, "__esModule", { value: true });
79597
- var utils = require_utils4();
78983
+ var utils = require_utils3();
79598
78984
  var Matcher = class {
79599
78985
  constructor(_patterns, _settings, _micromatchOptions) {
79600
78986
  this._patterns = _patterns;
@@ -79682,7 +79068,7 @@ var require_deep = __commonJS({
79682
79068
  "../../node_modules/fast-glob/out/providers/filters/deep.js"(exports2) {
79683
79069
  "use strict";
79684
79070
  Object.defineProperty(exports2, "__esModule", { value: true });
79685
- var utils = require_utils4();
79071
+ var utils = require_utils3();
79686
79072
  var partial_1 = require_partial();
79687
79073
  var DeepFilter = class {
79688
79074
  constructor(_settings, _micromatchOptions) {
@@ -79747,7 +79133,7 @@ var require_entry = __commonJS({
79747
79133
  "../../node_modules/fast-glob/out/providers/filters/entry.js"(exports2) {
79748
79134
  "use strict";
79749
79135
  Object.defineProperty(exports2, "__esModule", { value: true });
79750
- var utils = require_utils4();
79136
+ var utils = require_utils3();
79751
79137
  var EntryFilter = class {
79752
79138
  constructor(_settings, _micromatchOptions) {
79753
79139
  this._settings = _settings;
@@ -79835,7 +79221,7 @@ var require_error = __commonJS({
79835
79221
  "../../node_modules/fast-glob/out/providers/filters/error.js"(exports2) {
79836
79222
  "use strict";
79837
79223
  Object.defineProperty(exports2, "__esModule", { value: true });
79838
- var utils = require_utils4();
79224
+ var utils = require_utils3();
79839
79225
  var ErrorFilter = class {
79840
79226
  constructor(_settings) {
79841
79227
  this._settings = _settings;
@@ -79856,7 +79242,7 @@ var require_entry2 = __commonJS({
79856
79242
  "../../node_modules/fast-glob/out/providers/transformers/entry.js"(exports2) {
79857
79243
  "use strict";
79858
79244
  Object.defineProperty(exports2, "__esModule", { value: true });
79859
- var utils = require_utils4();
79245
+ var utils = require_utils3();
79860
79246
  var EntryTransformer = class {
79861
79247
  constructor(_settings) {
79862
79248
  this._settings = _settings;
@@ -80146,7 +79532,7 @@ var require_out4 = __commonJS({
80146
79532
  var stream_1 = require_stream5();
80147
79533
  var sync_1 = require_sync7();
80148
79534
  var settings_1 = require_settings4();
80149
- var utils = require_utils4();
79535
+ var utils = require_utils3();
80150
79536
  async function FastGlob(source, options) {
80151
79537
  assertPatternsInput2(source);
80152
79538
  const works = getWorks(source, async_1.default, options);
@@ -81440,12 +80826,49 @@ var require_editFile = __commonJS({
81440
80826
  }
81441
80827
  });
81442
80828
 
80829
+ // dist/tools/submitPlanIteration.js
80830
+ var require_submitPlanIteration = __commonJS({
80831
+ "dist/tools/submitPlanIteration.js"(exports2) {
80832
+ "use strict";
80833
+ Object.defineProperty(exports2, "__esModule", { value: true });
80834
+ exports2.createSubmitIterationPlanTool = createSubmitIterationPlanTool;
80835
+ var zod_1 = require_zod();
80836
+ var codegen_common_logic_1 = require_dist9();
80837
+ var MAX_NAME_LENGTH = 30;
80838
+ var CurrentExtensionSchema = zod_1.z.object({
80839
+ extensionType: zod_1.z.enum(codegen_common_logic_1.codeGenerationExtensionTypes).describe("The extension kind to trigger"),
80840
+ name: zod_1.z.string().min(2).max(MAX_NAME_LENGTH).describe(`Short, human-readable name for the extension. Less than ${MAX_NAME_LENGTH} chars.`),
80841
+ relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
80842
+ paths: zod_1.z.array(zod_1.z.string()).describe("Paths relevant for this extension"),
80843
+ relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
80844
+ });
80845
+ var AdditionalExtensionSchema = zod_1.z.object({
80846
+ extensionType: zod_1.z.enum(codegen_common_logic_1.codeGenerationExtensionTypes).describe("The extension kind to add"),
80847
+ name: zod_1.z.string().min(2).max(MAX_NAME_LENGTH).describe(`Short, human-readable name for the extension. Less than ${MAX_NAME_LENGTH} chars.`),
80848
+ relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
80849
+ relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
80850
+ });
80851
+ var IterationPlanSchema = zod_1.z.object({
80852
+ currentExtensions: zod_1.z.array(CurrentExtensionSchema).describe("Existing extensions to be triggered, return [] if no existing extensions are needed"),
80853
+ additionalExtensions: zod_1.z.array(AdditionalExtensionSchema).describe("New extensions to be created, return [] if no new extensions are needed"),
80854
+ summary: zod_1.z.string().describe("Summary of the chat with the user request")
80855
+ });
80856
+ function createSubmitIterationPlanTool() {
80857
+ return {
80858
+ description: "Submit your final iteration plan with structured data. Call this when you have determined which extensions to modify and create.",
80859
+ inputSchema: IterationPlanSchema,
80860
+ execute: async (params) => params
80861
+ };
80862
+ }
80863
+ }
80864
+ });
80865
+
81443
80866
  // dist/tools/index.js
81444
- var require_tools2 = __commonJS({
80867
+ var require_tools = __commonJS({
81445
80868
  "dist/tools/index.js"(exports2) {
81446
80869
  "use strict";
81447
80870
  Object.defineProperty(exports2, "__esModule", { value: true });
81448
- exports2.TOOL_NAMES = exports2.createEditFileTool = exports2.createCreateFileTool = exports2.createGlobTool = exports2.createGrepTool = exports2.createReadFileTool = void 0;
80871
+ exports2.TOOL_NAMES = exports2.createSubmitPlanTool = exports2.createEditFileTool = exports2.createCreateFileTool = exports2.createGlobTool = exports2.createGrepTool = exports2.createReadFileTool = void 0;
81449
80872
  var readFile_1 = require_readFile();
81450
80873
  Object.defineProperty(exports2, "createReadFileTool", { enumerable: true, get: function() {
81451
80874
  return readFile_1.createReadFileTool;
@@ -81466,6 +80889,10 @@ var require_tools2 = __commonJS({
81466
80889
  Object.defineProperty(exports2, "createEditFileTool", { enumerable: true, get: function() {
81467
80890
  return editFile_1.createEditFileTool;
81468
80891
  } });
80892
+ var submitPlanIteration_1 = require_submitPlanIteration();
80893
+ Object.defineProperty(exports2, "createSubmitPlanTool", { enumerable: true, get: function() {
80894
+ return submitPlanIteration_1.createSubmitIterationPlanTool;
80895
+ } });
81469
80896
  var TOOL_NAMES;
81470
80897
  (function(TOOL_NAMES2) {
81471
80898
  TOOL_NAMES2["READ_FILE"] = "read_file";
@@ -81477,145 +80904,781 @@ var require_tools2 = __commonJS({
81477
80904
  }
81478
80905
  });
81479
80906
 
81480
- // dist/agents/Iteration/ExtensionSelectorAgent.js
81481
- var require_ExtensionSelectorAgent = __commonJS({
81482
- "dist/agents/Iteration/ExtensionSelectorAgent.js"(exports2) {
80907
+ // dist/agents/Iteration/IterationAgent.js
80908
+ var require_IterationAgent = __commonJS({
80909
+ "dist/agents/Iteration/IterationAgent.js"(exports2) {
81483
80910
  "use strict";
81484
- var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
81485
- return mod && mod.__esModule ? mod : { "default": mod };
81486
- };
81487
80911
  Object.defineProperty(exports2, "__esModule", { value: true });
81488
- exports2.ExtensionSelectorAgent = void 0;
80912
+ exports2.IterationAgent = void 0;
81489
80913
  var ai_1 = require_dist8();
81490
- var zod_1 = require_zod();
81491
- var fs_1 = __importDefault2(require("fs"));
81492
- var path_1 = __importDefault2(require("path"));
81493
- var tree_node_cli_1 = __importDefault2(require_src());
80914
+ var iteration_agent_prompt_1 = require_iteration_agent_prompt();
80915
+ var AgentsRegistry_1 = require_AgentsRegistry();
81494
80916
  var ditto_codegen_types_12 = require_dist();
81495
- var extension_selector_prompt_1 = require_extension_selector_prompt();
81496
- var ditto_codegen_types_2 = require_dist();
80917
+ var constants_1 = require_constants();
81497
80918
  var contextBuilders_1 = require_contextBuilders();
81498
- var extensionFormatters_1 = require_extensionFormatters();
81499
- var dedent_1 = __importDefault2(require_dedent());
81500
80919
  var customAnthropicProvider_1 = require_customAnthropicProvider();
81501
- var constants_1 = require_constants();
81502
- var tools_1 = require_tools2();
81503
- var TOOL_NAMES = {
81504
- READ_FILE: "read_file",
81505
- SUBMIT_EVALUATION: "submit_evaluation"
81506
- };
81507
- var ExtensionSelectorAgent = class {
80920
+ var tools_1 = require_tools();
80921
+ var SUBMIT_PLAN_TOOL_NAME = "submit_plan";
80922
+ var IterationAgent = class {
81508
80923
  constructor() {
81509
- this.name = "ExtensionSelectorAgent";
80924
+ this.name = "IterationAgent";
81510
80925
  }
81511
- buildSystemPrompt({ extensionTypes, srcStructure }) {
81512
- return (0, dedent_1.default)`${(0, extension_selector_prompt_1.extensionSelectorPrompt)(extensionTypes, srcStructure)}`;
80926
+ buildSystemPrompt() {
80927
+ return (0, iteration_agent_prompt_1.iterationAgentPrompt)();
81513
80928
  }
81514
- generateSrcFolderStructure(basePath) {
81515
- const srcPath = path_1.default.join(basePath, "src");
81516
- if (!fs_1.default.existsSync(srcPath)) {
81517
- return "";
81518
- }
81519
- try {
81520
- return (0, tree_node_cli_1.default)(srcPath, {
81521
- allFiles: true,
81522
- maxDepth: 10
81523
- });
81524
- } catch (error) {
81525
- console.error("Error generating src folder structure:", error);
81526
- return "";
80929
+ extractPlanResult(toolCalls) {
80930
+ const submitCall = toolCalls.find((call) => call.toolName === SUBMIT_PLAN_TOOL_NAME);
80931
+ if (!submitCall) {
80932
+ throw new Error("Failed to generate iteration plan");
81527
80933
  }
80934
+ return submitCall.input;
81528
80935
  }
81529
- createSubmitEvaluationSchema(allowedExtensionTypes) {
81530
- return zod_1.z.object({
81531
- extensionsToModify: zod_1.z.array(zod_1.z.object({
81532
- type: zod_1.z.enum(allowedExtensionTypes).describe("Extension type"),
81533
- reasoning: zod_1.z.string().describe("What code changes are needed"),
81534
- relevantFiles: zod_1.z.array(zod_1.z.string()).describe("File paths that need changes")
81535
- })).default([]).describe("Extensions that need code modifications to existing files"),
81536
- contextExtensions: zod_1.z.array(zod_1.z.object({
81537
- type: zod_1.z.enum(allowedExtensionTypes).describe("Extension type"),
81538
- reasoning: zod_1.z.string().describe("Why this is relevant for context")
81539
- })).default([]).describe("Extensions that exist and relate to request but don't need changes")
80936
+ mapExtensionType(extensionType) {
80937
+ const supportedExtensionTypes = (0, AgentsRegistry_1.getSupportedExtensionTypes)();
80938
+ if (supportedExtensionTypes.includes(extensionType)) {
80939
+ return extensionType;
80940
+ }
80941
+ throw new ditto_codegen_types_12.UnsupportedExtensionTypeError(`Unsupported extension type: ${extensionType}. Supported types: ${supportedExtensionTypes.join(", ")}`, {
80942
+ extensionType: extensionType || "UNKNOWN",
80943
+ origin: ditto_codegen_types_12.ErrorOrigin.ITERATION
81540
80944
  });
81541
80945
  }
81542
- createSubmitEvaluationTool(allowedExtensionTypes) {
80946
+ generateExtensionObject(extensionType, name, relevantUserRequest, relatedSpis) {
81543
80947
  return {
81544
- description: "Submit your final relevance evaluation decision with structured data.",
81545
- inputSchema: this.createSubmitEvaluationSchema(allowedExtensionTypes),
81546
- execute: async (params) => params
80948
+ type: this.mapExtensionType(extensionType),
80949
+ name,
80950
+ description: relevantUserRequest,
80951
+ relatedSpis: relatedSpis?.map((spi) => ({
80952
+ name: spi,
80953
+ purpose: ""
80954
+ })) || []
81547
80955
  };
81548
80956
  }
81549
- extractEvaluationResult(toolCalls) {
81550
- const submitCall = toolCalls.find((call) => call.toolName === TOOL_NAMES.SUBMIT_EVALUATION);
81551
- if (!submitCall) {
81552
- console.error("No submit_evaluation tool call found");
81553
- return null;
81554
- }
81555
- return submitCall.input;
81556
- }
81557
- buildUserPrompt({ chatHistory, currentUserRequest, previousResources, extensions, outputPath }) {
81558
- const sections = (0, contextBuilders_1.buildContextSections)(chatHistory, currentUserRequest, previousResources);
81559
- sections.push(`
81560
- Extensions to Evaluate:
81561
- ${(0, extensionFormatters_1.formatScannedExtensions)(extensions, outputPath)}`);
80957
+ buildUserPrompt({ chatHistory, currentUserRequest, previousResources, srcFolderStructure }) {
80958
+ const sections = (0, contextBuilders_1.buildContextSections)(chatHistory, currentUserRequest, previousResources, srcFolderStructure);
81562
80959
  return sections.join("\n\n");
81563
80960
  }
81564
- async generate({ outputPath, extensions, chatHistory, currentUserRequest, previousResources }) {
81565
- const srcStructure = this.generateSrcFolderStructure(outputPath);
80961
+ async generate({ currentUserRequest, chatHistory, previousResources, outputPath }) {
80962
+ const srcFolderStructure = (0, contextBuilders_1.generateSrcFolderStructure)(outputPath);
80963
+ const userMessage = this.buildUserPrompt({
80964
+ chatHistory,
80965
+ currentUserRequest,
80966
+ previousResources,
80967
+ srcFolderStructure
80968
+ });
81566
80969
  try {
81567
- const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.CLAUDE_3_5_HAIKU_LATEST, {
80970
+ const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929, {
81568
80971
  agentName: this.name
81569
80972
  });
81570
- const userContent = this.buildUserPrompt({
81571
- chatHistory,
81572
- currentUserRequest,
81573
- previousResources,
81574
- extensions,
81575
- outputPath
81576
- });
81577
- const extensionTypes = extensions.map((extension) => extension.type);
81578
- if (extensionTypes.length === 0) {
81579
- return { extensionsToModify: [], contextExtensions: [] };
81580
- }
81581
- const systemPrompt = this.buildSystemPrompt({
81582
- extensionTypes,
81583
- srcStructure
81584
- });
81585
80973
  const result = await (0, ai_1.generateText)({
81586
80974
  model,
81587
80975
  tools: {
81588
- [TOOL_NAMES.READ_FILE]: (0, tools_1.createReadFileTool)(outputPath),
81589
- [TOOL_NAMES.SUBMIT_EVALUATION]: this.createSubmitEvaluationTool(extensionTypes)
80976
+ [tools_1.TOOL_NAMES.READ_FILE]: (0, tools_1.createReadFileTool)(outputPath),
80977
+ [tools_1.TOOL_NAMES.GREP]: (0, tools_1.createGrepTool)(outputPath),
80978
+ [tools_1.TOOL_NAMES.GLOB]: (0, tools_1.createGlobTool)(outputPath),
80979
+ [SUBMIT_PLAN_TOOL_NAME]: (0, tools_1.createSubmitPlanTool)()
81590
80980
  },
81591
80981
  stopWhen: ({ steps }) => {
81592
80982
  const lastStep = steps[steps.length - 1];
81593
- return lastStep?.toolCalls.some((toolCall) => toolCall.toolName === TOOL_NAMES.SUBMIT_EVALUATION) ?? false;
80983
+ return lastStep?.toolCalls.some((toolCall) => toolCall.toolName === SUBMIT_PLAN_TOOL_NAME && !("invalid" in toolCall) && !("error" in toolCall)) ?? false;
81594
80984
  },
81595
80985
  messages: [
81596
80986
  {
81597
80987
  role: "system",
81598
- content: systemPrompt,
80988
+ content: this.buildSystemPrompt(),
81599
80989
  providerOptions: (0, ditto_codegen_types_12.withCaching)("1h")
81600
80990
  },
81601
- { role: "user", content: userContent }
80991
+ { role: "user", content: userMessage }
81602
80992
  ],
81603
80993
  maxRetries: 3,
81604
80994
  temperature: 0,
81605
80995
  experimental_telemetry: { isEnabled: true, functionId: this.name }
81606
80996
  });
81607
- const evaluationResult = this.extractEvaluationResult(result.toolCalls);
81608
- console.log("evaluationResult", JSON.stringify(evaluationResult, null, 2));
81609
- if (!evaluationResult) {
81610
- return { extensionsToModify: [], contextExtensions: [] };
81611
- }
81612
- return evaluationResult;
80997
+ const planResult = this.extractPlanResult(result.toolCalls);
80998
+ console.log("IterationAgent planResult:", JSON.stringify(planResult, null, 2));
80999
+ const resultObject = {
81000
+ currentExtensions: planResult.currentExtensions.map((ext) => ({
81001
+ paths: ext.paths,
81002
+ extension: this.generateExtensionObject(ext.extensionType, ext.name, ext.relevantUserRequest, ext.relatedSpis)
81003
+ })),
81004
+ additionalExtensions: planResult.additionalExtensions.map((ext) => ({
81005
+ extension: this.generateExtensionObject(ext.extensionType, ext.name, ext.relevantUserRequest, ext.relatedSpis)
81006
+ })),
81007
+ summary: planResult.summary
81008
+ };
81009
+ return resultObject;
81613
81010
  } catch (error) {
81614
- throw (0, ditto_codegen_types_2.toCodegenError)(error);
81011
+ throw (0, ditto_codegen_types_12.toCodegenError)(error);
81012
+ }
81013
+ }
81014
+ };
81015
+ exports2.IterationAgent = IterationAgent;
81016
+ }
81017
+ });
81018
+
81019
+ // dist/agents/DashboardDecisionAgent.js
81020
+ var require_DashboardDecisionAgent = __commonJS({
81021
+ "dist/agents/DashboardDecisionAgent.js"(exports2) {
81022
+ "use strict";
81023
+ Object.defineProperty(exports2, "__esModule", { value: true });
81024
+ exports2.DashboardDecisionAgent = void 0;
81025
+ var zod_1 = require_zod();
81026
+ var codegen_dashboard_agents_1 = require_dist11();
81027
+ var prompt_selectors_1 = require_prompt_selectors();
81028
+ var types_1 = require_types_impl();
81029
+ var userPrompt_1 = require_userPrompt();
81030
+ var codeGenerationService_12 = require_codeGenerationService();
81031
+ var constants_1 = require_constants();
81032
+ var autoPatternsLlmConfig = zod_1.z.object({
81033
+ useAutoPatterns: zod_1.z.boolean(),
81034
+ schema: zod_1.z.object({
81035
+ content: zod_1.z.object({
81036
+ collectionRouteId: zod_1.z.string(),
81037
+ singularEntityName: zod_1.z.string(),
81038
+ pageTitle: zod_1.z.string(),
81039
+ pageSubtitle: zod_1.z.string(),
81040
+ actionButtonLabel: zod_1.z.string(),
81041
+ toolbarTitle: zod_1.z.string(),
81042
+ toolbarSubtitle: zod_1.z.string(),
81043
+ emptyStateTitle: zod_1.z.string(),
81044
+ emptyStateSubtitle: zod_1.z.string(),
81045
+ emptyStateButtonText: zod_1.z.string(),
81046
+ deleteModalTitle: zod_1.z.string(),
81047
+ deleteModalDescription: zod_1.z.string(),
81048
+ deleteSuccessToast: zod_1.z.string(),
81049
+ deleteErrorToast: zod_1.z.string(),
81050
+ bulkDeleteModalTitle: zod_1.z.string(),
81051
+ bulkDeleteModalDescription: zod_1.z.string(),
81052
+ bulkDeleteSuccessToast: zod_1.z.string(),
81053
+ bulkDeleteErrorToast: zod_1.z.string(),
81054
+ entityPageTitle: zod_1.z.string(),
81055
+ entityPageSubtitle: zod_1.z.string()
81056
+ }),
81057
+ layout: zod_1.z.object({
81058
+ main: zod_1.z.array(zod_1.z.object({
81059
+ title: zod_1.z.string(),
81060
+ subtitle: zod_1.z.string(),
81061
+ fields: zod_1.z.array(zod_1.z.string())
81062
+ })),
81063
+ sidebar: zod_1.z.array(zod_1.z.object({
81064
+ title: zod_1.z.string(),
81065
+ subtitle: zod_1.z.string(),
81066
+ fields: zod_1.z.array(zod_1.z.string())
81067
+ }))
81068
+ }),
81069
+ columns: zod_1.z.array(zod_1.z.object({
81070
+ id: zod_1.z.string(),
81071
+ displayName: zod_1.z.string()
81072
+ })),
81073
+ gridItem: zod_1.z.object({
81074
+ titleFieldId: zod_1.z.string(),
81075
+ subtitleFieldId: zod_1.z.string().optional(),
81076
+ imageFieldId: zod_1.z.string().optional()
81077
+ }).optional().nullable()
81078
+ }).optional(),
81079
+ relevantCollectionId: zod_1.z.string().optional()
81080
+ });
81081
+ var DashboardDecisionAgent = class {
81082
+ constructor() {
81083
+ this.name = "DashboardDecisionAgent";
81084
+ }
81085
+ buildSystemPrompt() {
81086
+ return (0, codegen_dashboard_agents_1.autoPatternsDecisionPrompt)();
81087
+ }
81088
+ shouldNotUseAutoPatterns(params) {
81089
+ const { blueprint } = params;
81090
+ const hasEmbeddedScriptExtension = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.EMBEDDED_SCRIPT) ?? false;
81091
+ const hasOneDashboardPageExtension = blueprint?.extensions?.filter((ext) => ext.type === types_1.ExtensionType.DASHBOARD_PAGE).length === 1;
81092
+ const shouldImplementEmbeddedScriptParameters = hasOneDashboardPageExtension && hasEmbeddedScriptExtension;
81093
+ const hasCollections = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
81094
+ const hasUnsupportedCollectionFieldsTypes = (0, prompt_selectors_1.hasUnsupportedCollectionTypes)(params);
81095
+ if (!hasCollections || shouldImplementEmbeddedScriptParameters || hasUnsupportedCollectionFieldsTypes) {
81096
+ return true;
81097
+ }
81098
+ return false;
81099
+ }
81100
+ async generate(params) {
81101
+ if (this.shouldNotUseAutoPatterns(params)) {
81102
+ return {
81103
+ useAutoPatterns: false
81104
+ };
81105
+ }
81106
+ const systemPrompt = this.buildSystemPrompt();
81107
+ const primaryAction = "Decide whether to use auto patterns for the dashboard page";
81108
+ const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
81109
+ const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
81110
+ userMessage,
81111
+ systemPrompt,
81112
+ provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
81113
+ model: constants_1.LLM_MODELS.CLAUDE_3_5_HAIKU_LATEST,
81114
+ schema: autoPatternsLlmConfig,
81115
+ agentName: this.name
81116
+ });
81117
+ console.log("\u{1F3AF} Decision and schema result:", JSON.stringify(result.object, null, 2));
81118
+ return result.object;
81119
+ }
81120
+ };
81121
+ exports2.DashboardDecisionAgent = DashboardDecisionAgent;
81122
+ }
81123
+ });
81124
+
81125
+ // ../scaffolding/dist/tools.js
81126
+ var require_tools2 = __commonJS({
81127
+ "../scaffolding/dist/tools.js"(exports2) {
81128
+ "use strict";
81129
+ var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
81130
+ return mod && mod.__esModule ? mod : { "default": mod };
81131
+ };
81132
+ Object.defineProperty(exports2, "__esModule", { value: true });
81133
+ exports2.copyRecursive = copyRecursive;
81134
+ exports2.copyScaffolding = copyScaffolding;
81135
+ var fs_1 = __importDefault2(require("fs"));
81136
+ var path_1 = __importDefault2(require("path"));
81137
+ var scaffoldingBasePath = path_1.default.join(__dirname, "wix-cli-templates");
81138
+ function copyRecursive(sourcePath, destPath) {
81139
+ if (!fs_1.default.existsSync(sourcePath)) {
81140
+ throw new Error(`Source path does not exist: ${sourcePath}`);
81141
+ }
81142
+ const stat = fs_1.default.statSync(sourcePath);
81143
+ if (stat.isDirectory()) {
81144
+ const copiedFiles = [];
81145
+ if (!fs_1.default.existsSync(destPath)) {
81146
+ fs_1.default.mkdirSync(destPath, { recursive: true });
81147
+ }
81148
+ const items = fs_1.default.readdirSync(sourcePath);
81149
+ for (const item of items) {
81150
+ const sourceItemPath = path_1.default.join(sourcePath, item);
81151
+ const destItemPath = path_1.default.join(destPath, item);
81152
+ const results = copyRecursive(sourceItemPath, destItemPath);
81153
+ copiedFiles.push(...results);
81154
+ }
81155
+ return copiedFiles;
81156
+ } else {
81157
+ const destDir = path_1.default.dirname(destPath);
81158
+ if (!fs_1.default.existsSync(destDir)) {
81159
+ fs_1.default.mkdirSync(destDir, { recursive: true });
81160
+ }
81161
+ fs_1.default.copyFileSync(sourcePath, destPath);
81162
+ console.log(`\u{1F4CB} Copied: ${sourcePath} \u2192 ${destPath}`);
81163
+ return [destPath];
81164
+ }
81165
+ }
81166
+ function copyScaffolding(scaffoldingSubPath, outputRootPath, outputRelativePath) {
81167
+ const sourcePath = path_1.default.join(scaffoldingBasePath, scaffoldingSubPath);
81168
+ const destPath = path_1.default.join(outputRootPath, outputRelativePath);
81169
+ console.log(`\u{1F4E6} Copying scaffolding from: ${scaffoldingSubPath}`);
81170
+ return copyRecursive(sourcePath, destPath);
81171
+ }
81172
+ }
81173
+ });
81174
+
81175
+ // ../scaffolding/dist/constants.js
81176
+ var require_constants5 = __commonJS({
81177
+ "../scaffolding/dist/constants.js"(exports2) {
81178
+ "use strict";
81179
+ Object.defineProperty(exports2, "__esModule", { value: true });
81180
+ exports2.spiToSubPath = void 0;
81181
+ exports2.spiToSubPath = {
81182
+ "ecom.shippingRates.getShippingRates": "ecom-shipping-rates",
81183
+ "ecom.additionalFees.calculateAdditionalFees": "ecom-additional-fees",
81184
+ "ecom.paymentSettings.getPaymentSettings": "ecom-payment-settings",
81185
+ "ecom.validations.getValidationViolations": "ecom-validations",
81186
+ "ecom.customTriggers.getEligibleTriggers": "ecom-discount-triggers",
81187
+ "ecom.customTriggers.listTriggers": "ecom-discount-triggers",
81188
+ "ecom.giftCardsProvider.redeem": "ecom-gift-cards",
81189
+ "ecom.giftCardsProvider._void": "ecom-gift-cards",
81190
+ "ecom.giftCardsProvider.getBalance": "ecom-gift-cards"
81191
+ };
81192
+ }
81193
+ });
81194
+
81195
+ // ../scaffolding/dist/scaffolding.js
81196
+ var require_scaffolding = __commonJS({
81197
+ "../scaffolding/dist/scaffolding.js"(exports2) {
81198
+ "use strict";
81199
+ var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
81200
+ return mod && mod.__esModule ? mod : { "default": mod };
81201
+ };
81202
+ Object.defineProperty(exports2, "__esModule", { value: true });
81203
+ exports2.copyScaffoldingTemplate = copyScaffoldingTemplate;
81204
+ exports2.toKebabCase = toKebabCase;
81205
+ var tools_1 = require_tools2();
81206
+ var constants_1 = require_constants5();
81207
+ var types_1 = require_types_impl();
81208
+ var fs_1 = __importDefault2(require("fs"));
81209
+ var path_1 = __importDefault2(require("path"));
81210
+ async function copyScaffoldingTemplate(extension, outputPath) {
81211
+ const copiedPaths = await _copyScaffoldingTemplate(extension, outputPath);
81212
+ const uniquePaths = Array.from(new Set(copiedPaths));
81213
+ return uniquePaths.map((filePath) => {
81214
+ const relativePath = path_1.default.relative(outputPath, filePath);
81215
+ const content = fs_1.default.readFileSync(filePath, "utf8");
81216
+ return { path: relativePath, content };
81217
+ });
81218
+ }
81219
+ async function _copyScaffoldingTemplate(extension, outputPath) {
81220
+ switch (extension.type) {
81221
+ case types_1.ExtensionType.SERVICE_PLUGIN:
81222
+ return copyServicePluginScaffolding(extension, outputPath);
81223
+ case types_1.ExtensionType.DASHBOARD_PAGE:
81224
+ return copyDashboardPageScaffolding(extension, outputPath);
81225
+ case types_1.ExtensionType.DASHBOARD_MODAL:
81226
+ return copyDashboardModalScaffolding(extension, outputPath);
81227
+ case types_1.ExtensionType.SITE_WIDGET:
81228
+ return copyCustomElementScaffolding(extension, outputPath);
81229
+ case types_1.ExtensionType.EMBEDDED_SCRIPT:
81230
+ return copyEmbeddedScriptScaffolding(extension, outputPath);
81231
+ case types_1.ExtensionType.BACKEND_API:
81232
+ return copyBackendApiScaffolding(extension, outputPath);
81233
+ case types_1.ExtensionType.BACKEND_EVENT:
81234
+ return copyBackendEventScaffolding(extension, outputPath);
81235
+ case types_1.ExtensionType.SITE_COMPONENT:
81236
+ return copySiteComponentScaffolding(extension, outputPath);
81237
+ default:
81238
+ console.log(` \u26A0\uFE0F Unsupported extension type: ${extension.type}`);
81239
+ return [];
81240
+ }
81241
+ }
81242
+ async function copySiteComponentScaffolding(extension, outputPath) {
81243
+ const componentName = extension.name ?? "my-component";
81244
+ const scaffoldingSubPath = `src/site/components/my-component`;
81245
+ const componentSubPath = `src/site/components/${toKebabCase(componentName)}`;
81246
+ console.log(` \u{1F3A8} Copying site component scaffolding from: ${scaffoldingSubPath} to ${componentSubPath}`);
81247
+ return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, componentSubPath);
81248
+ }
81249
+ async function copyServicePluginScaffolding(extension, outputPath) {
81250
+ if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
81251
+ throw new Error("Service plugin extension must have related SPIs");
81252
+ }
81253
+ const allCopiedFiles = [];
81254
+ const uniqueFolderName = toKebabCase(extension.name || "my-service-plugin");
81255
+ for (const spi of extension.relatedSpis) {
81256
+ console.log(` \u{1F4CB} Copying service plugin scaffolding for related SPI: ${spi.name}`);
81257
+ const mapped = constants_1.spiToSubPath[spi.name || ""];
81258
+ if (mapped) {
81259
+ const scaffoldingPath = `src/backend/service-plugins/${mapped}/my-service-plugin`;
81260
+ const outputFolder = `src/backend/service-plugins/${mapped}/${uniqueFolderName}`;
81261
+ const copiedFiles = await (0, tools_1.copyScaffolding)(scaffoldingPath, outputPath, outputFolder);
81262
+ allCopiedFiles.push(...copiedFiles);
81263
+ } else {
81264
+ console.warn(` \u26A0\uFE0F No scaffolding template found for SPI: ${spi.name}`);
81265
+ }
81266
+ }
81267
+ return allCopiedFiles;
81268
+ }
81269
+ async function copyDashboardPageScaffolding(extension, outputPath) {
81270
+ const scaffoldingSubPath = "src/dashboard/pages";
81271
+ const uniqueFolderName = toKebabCase(extension.name || "page");
81272
+ const outputFolder = `src/dashboard/pages/${uniqueFolderName}`;
81273
+ console.log(` \u{1F4CA} Copying dashboard page scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
81274
+ return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
81275
+ }
81276
+ async function copyDashboardModalScaffolding(extension, outputPath) {
81277
+ const scaffoldingSubPath = "src/dashboard/modals/my-modal";
81278
+ const uniqueFolderName = toKebabCase(extension.name || "my-modal");
81279
+ const outputFolder = `src/dashboard/modals/${uniqueFolderName}`;
81280
+ console.log(` \u{1F532} Copying dashboard modal scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
81281
+ return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
81282
+ }
81283
+ async function copyCustomElementScaffolding(extension, outputPath) {
81284
+ const scaffoldingSubPath = "src/site/widgets/custom-elements/my-widget";
81285
+ const uniqueFolderName = toKebabCase(extension.name || "my-widget");
81286
+ const outputFolder = `src/site/widgets/custom-elements/${uniqueFolderName}`;
81287
+ console.log(` \u{1F3A8} Copying site widget scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
81288
+ return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
81289
+ }
81290
+ async function copyEmbeddedScriptScaffolding(extension, outputPath) {
81291
+ const scaffoldingSubPath = "src/site/embedded-scripts/my-script";
81292
+ const uniqueFolderName = toKebabCase(extension.name || "my-script");
81293
+ const outputFolder = `src/site/embedded-scripts/${uniqueFolderName}`;
81294
+ console.log(` \u{1F4DC} Copying embedded script scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
81295
+ return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
81296
+ }
81297
+ async function copyBackendApiScaffolding(extension, outputPath) {
81298
+ const uniqueFolderName = toKebabCase(extension.name || "my-api");
81299
+ const apiScaffoldingFile = "src/pages/api/my-api.ts";
81300
+ const apiOutputFile = `src/pages/api/${uniqueFolderName}.ts`;
81301
+ console.log(` \u{1F50C} Copying backend API scaffolding from: ${apiScaffoldingFile} to ${apiOutputFile}`);
81302
+ const apiFiles = (0, tools_1.copyScaffolding)(apiScaffoldingFile, outputPath, apiOutputFile);
81303
+ return apiFiles;
81304
+ }
81305
+ async function copyBackendEventScaffolding(extension, outputPath) {
81306
+ const scaffoldingSubPath = "src/backend/events/my-event";
81307
+ const uniqueFolderName = toKebabCase(extension.name || "my-event");
81308
+ const outputFolder = `src/backend/events/${uniqueFolderName}`;
81309
+ console.log(` \u26A1 Copying backend event scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
81310
+ return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
81311
+ }
81312
+ function toKebabCase(name) {
81313
+ return name.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/-+/g, "-").toLowerCase();
81314
+ }
81315
+ }
81316
+ });
81317
+
81318
+ // ../scaffolding/dist/index.js
81319
+ var require_dist12 = __commonJS({
81320
+ "../scaffolding/dist/index.js"(exports2) {
81321
+ "use strict";
81322
+ Object.defineProperty(exports2, "__esModule", { value: true });
81323
+ exports2.spiToSubPath = exports2.copyRecursive = exports2.copyScaffolding = exports2.toKebabCase = exports2.copyScaffoldingTemplate = void 0;
81324
+ var scaffolding_1 = require_scaffolding();
81325
+ Object.defineProperty(exports2, "copyScaffoldingTemplate", { enumerable: true, get: function() {
81326
+ return scaffolding_1.copyScaffoldingTemplate;
81327
+ } });
81328
+ Object.defineProperty(exports2, "toKebabCase", { enumerable: true, get: function() {
81329
+ return scaffolding_1.toKebabCase;
81330
+ } });
81331
+ var tools_1 = require_tools2();
81332
+ Object.defineProperty(exports2, "copyScaffolding", { enumerable: true, get: function() {
81333
+ return tools_1.copyScaffolding;
81334
+ } });
81335
+ Object.defineProperty(exports2, "copyRecursive", { enumerable: true, get: function() {
81336
+ return tools_1.copyRecursive;
81337
+ } });
81338
+ var constants_1 = require_constants5();
81339
+ Object.defineProperty(exports2, "spiToSubPath", { enumerable: true, get: function() {
81340
+ return constants_1.spiToSubPath;
81341
+ } });
81342
+ }
81343
+ });
81344
+
81345
+ // dist/agents/AutoPatternsGenerator.js
81346
+ var require_AutoPatternsGenerator = __commonJS({
81347
+ "dist/agents/AutoPatternsGenerator.js"(exports2) {
81348
+ "use strict";
81349
+ Object.defineProperty(exports2, "__esModule", { value: true });
81350
+ exports2.AutoPatternsGenerator = void 0;
81351
+ var ditto_scaffolding_1 = require_dist12();
81352
+ var ditto_codegen_types_12 = require_dist();
81353
+ var AutoPatternsGenerator = class {
81354
+ constructor() {
81355
+ this.name = "AutoPatternsGenerator";
81356
+ }
81357
+ generate({ collection, decision, extensionName }) {
81358
+ const name = (0, ditto_scaffolding_1.toKebabCase)(extensionName);
81359
+ const path2 = `src/dashboard/pages/${name}`;
81360
+ const patternsConfig = this.generatePatternsConfig(collection, decision);
81361
+ const pageTsx = this.generatePageTsx();
81362
+ return [
81363
+ {
81364
+ path: `${path2}/patterns.json`,
81365
+ operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
81366
+ content: JSON.stringify(patternsConfig, null, 2)
81367
+ },
81368
+ {
81369
+ path: `${path2}/page.tsx`,
81370
+ operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
81371
+ content: pageTsx
81372
+ }
81373
+ ];
81374
+ }
81375
+ generatePatternsConfig(collection, contentResult) {
81376
+ const collectionRouteId = contentResult.schema?.content?.collectionRouteId;
81377
+ const singularEntityName = contentResult.schema?.content?.singularEntityName;
81378
+ const fieldMap = new Map(collection.fields?.filter((field) => field.key && field.displayName).map((field) => [field.key, field]) || []);
81379
+ const sortableFieldTypes = ["TEXT", "DATE", "NUMBER", "BOOLEAN", "URL"];
81380
+ const columns = contentResult.schema?.columns?.map((columnConfig) => {
81381
+ const field = fieldMap.get(columnConfig.id);
81382
+ if (!field || !field.key || !field.type)
81383
+ return null;
81384
+ let width = "200px";
81385
+ if (["BOOLEAN", "IMAGE", "NUMBER"].includes(field.type))
81386
+ width = "100px";
81387
+ if (field.type === "URL")
81388
+ width = "300px";
81389
+ return {
81390
+ id: field.key,
81391
+ name: columnConfig.displayName || field.displayName || "Field",
81392
+ width,
81393
+ sortable: sortableFieldTypes.includes(field.type || "")
81394
+ };
81395
+ }).filter((item) => item != null) || [];
81396
+ const filterableFieldTypes = ["DATE", "NUMBER", "BOOLEAN"];
81397
+ const filters = columns.map((column) => {
81398
+ const field = fieldMap.get(column.id);
81399
+ if (!field || !field.key || !filterableFieldTypes.includes(field.type || ""))
81400
+ return null;
81401
+ const baseFilter = {
81402
+ id: `${field.key}-filter`,
81403
+ fieldId: field.key,
81404
+ displayName: field.displayName || "",
81405
+ tagLabel: field.displayName || ""
81406
+ };
81407
+ if (field.type === "DATE") {
81408
+ return {
81409
+ ...baseFilter,
81410
+ dateConfig: {
81411
+ mode: "COMBINE",
81412
+ presets: [
81413
+ "TODAY",
81414
+ "SEVEN_DAYS",
81415
+ "MONTH",
81416
+ "NEXT_SEVEN_DAYS",
81417
+ "NEXT_THIRTY_DAYS"
81418
+ ],
81419
+ includeTime: false
81420
+ }
81421
+ };
81422
+ }
81423
+ if (field.type === "NUMBER") {
81424
+ return {
81425
+ ...baseFilter,
81426
+ numberConfig: { allowedDecimals: true }
81427
+ };
81428
+ }
81429
+ if (field.type === "BOOLEAN") {
81430
+ return baseFilter;
81431
+ }
81432
+ return null;
81433
+ }).filter((item) => item != null);
81434
+ const layout = [
81435
+ {
81436
+ type: "Table",
81437
+ table: {
81438
+ columns,
81439
+ customColumns: {
81440
+ enabled: true
81441
+ }
81442
+ }
81443
+ }
81444
+ ];
81445
+ if (contentResult.schema?.gridItem) {
81446
+ layout.push({
81447
+ type: "Grid",
81448
+ grid: {
81449
+ item: {
81450
+ titleFieldId: contentResult.schema?.gridItem?.titleFieldId,
81451
+ subtitleFieldId: contentResult.schema?.gridItem?.subtitleFieldId,
81452
+ imageFieldId: contentResult.schema?.gridItem?.imageFieldId,
81453
+ cardContentMode: contentResult.schema?.gridItem?.subtitleFieldId ? "full" : "title"
81454
+ }
81455
+ }
81456
+ });
81615
81457
  }
81458
+ return {
81459
+ pages: [
81460
+ {
81461
+ id: `${collectionRouteId}-collection`,
81462
+ type: "collectionPage",
81463
+ appMainPage: true,
81464
+ collectionPage: {
81465
+ route: {
81466
+ path: "/"
81467
+ },
81468
+ title: {
81469
+ text: contentResult.schema?.content.pageTitle || "",
81470
+ hideTotal: false
81471
+ },
81472
+ subtitle: {
81473
+ text: contentResult.schema?.content.pageSubtitle || ""
81474
+ },
81475
+ actions: {
81476
+ primaryActions: {
81477
+ type: "action",
81478
+ action: {
81479
+ item: {
81480
+ id: `create-${collectionRouteId}`,
81481
+ type: "create",
81482
+ label: contentResult.schema?.content.actionButtonLabel,
81483
+ collection: {
81484
+ collectionId: collection.idSuffix,
81485
+ entityTypeSource: "cms"
81486
+ },
81487
+ create: {
81488
+ mode: "page",
81489
+ page: {
81490
+ id: `${collectionRouteId}-entity`
81491
+ }
81492
+ }
81493
+ }
81494
+ }
81495
+ }
81496
+ },
81497
+ components: [
81498
+ {
81499
+ type: "collection",
81500
+ layout,
81501
+ entityPageId: `${collectionRouteId}-entity`,
81502
+ collection: {
81503
+ collectionId: collection.idSuffix,
81504
+ entityTypeSource: "cms"
81505
+ },
81506
+ toolbarTitle: {
81507
+ title: contentResult.schema?.content.toolbarTitle || "",
81508
+ subtitle: {
81509
+ text: contentResult.schema?.content.toolbarSubtitle || ""
81510
+ },
81511
+ showTotal: true
81512
+ },
81513
+ filters: {
81514
+ items: filters
81515
+ },
81516
+ emptyState: {
81517
+ title: contentResult.schema?.content.emptyStateTitle,
81518
+ subtitle: contentResult.schema?.content.emptyStateSubtitle,
81519
+ addNewCta: {
81520
+ id: `create-${collectionRouteId}`,
81521
+ text: contentResult.schema?.content.emptyStateButtonText
81522
+ }
81523
+ },
81524
+ actionCell: {
81525
+ primaryAction: {
81526
+ item: {
81527
+ id: `edit-${collectionRouteId}`,
81528
+ type: "update",
81529
+ update: {
81530
+ mode: "page",
81531
+ page: {
81532
+ id: `${collectionRouteId}-entity`
81533
+ }
81534
+ }
81535
+ }
81536
+ },
81537
+ secondaryActions: {
81538
+ items: [
81539
+ {
81540
+ id: `delete-${collectionRouteId}`,
81541
+ type: "delete",
81542
+ label: "Delete",
81543
+ delete: {
81544
+ mode: "modal",
81545
+ modal: {
81546
+ title: {
81547
+ text: contentResult.schema?.content.deleteModalTitle || ""
81548
+ },
81549
+ description: {
81550
+ text: contentResult.schema?.content.deleteModalDescription || ""
81551
+ },
81552
+ feedback: {
81553
+ successToast: {
81554
+ text: contentResult.schema?.content.deleteSuccessToast || ""
81555
+ },
81556
+ errorToast: {
81557
+ text: contentResult.schema?.content.deleteErrorToast || ""
81558
+ }
81559
+ }
81560
+ }
81561
+ }
81562
+ }
81563
+ ]
81564
+ }
81565
+ },
81566
+ bulkActionToolbar: {
81567
+ primaryActions: [
81568
+ {
81569
+ type: "action",
81570
+ action: {
81571
+ item: {
81572
+ id: `bulk-delete-${collectionRouteId}`,
81573
+ type: "bulkDelete",
81574
+ bulkDelete: {
81575
+ mode: "modal",
81576
+ modal: {
81577
+ title: {
81578
+ text: contentResult.schema?.content.bulkDeleteModalTitle || ""
81579
+ },
81580
+ description: {
81581
+ text: contentResult.schema?.content.bulkDeleteModalDescription || ""
81582
+ },
81583
+ feedback: {
81584
+ successToast: {
81585
+ text: contentResult.schema?.content.bulkDeleteSuccessToast || ""
81586
+ },
81587
+ errorToast: {
81588
+ text: contentResult.schema?.content.bulkDeleteErrorToast || ""
81589
+ }
81590
+ }
81591
+ }
81592
+ }
81593
+ }
81594
+ }
81595
+ }
81596
+ ]
81597
+ }
81598
+ }
81599
+ ]
81600
+ }
81601
+ },
81602
+ {
81603
+ id: `${collectionRouteId}-entity`,
81604
+ type: "entityPage",
81605
+ entityPage: {
81606
+ route: {
81607
+ path: `/${singularEntityName}/:entityId`,
81608
+ params: { id: "entityId" }
81609
+ },
81610
+ title: {
81611
+ text: contentResult.schema?.content.entityPageTitle || ""
81612
+ },
81613
+ subtitle: {
81614
+ text: contentResult.schema?.content.entityPageSubtitle
81615
+ },
81616
+ parentPageId: `${collectionRouteId}-collection`,
81617
+ layout: this.generateEntityPageLayout(contentResult.schema?.layout),
81618
+ collectionId: collection.idSuffix,
81619
+ entityTypeSource: "cms"
81620
+ }
81621
+ }
81622
+ ]
81623
+ };
81624
+ }
81625
+ generateEntityPageLayout(layout) {
81626
+ if (!layout)
81627
+ return { main: [] };
81628
+ const main2 = layout.main.map((section) => ({
81629
+ type: "card",
81630
+ card: {
81631
+ title: { text: section.title },
81632
+ subtitle: { text: section.subtitle },
81633
+ children: section.fields.map((fieldKey) => ({
81634
+ type: "field",
81635
+ field: { span: 12, fieldId: fieldKey }
81636
+ }))
81637
+ }
81638
+ }));
81639
+ const sidebar = layout.sidebar.map((section) => ({
81640
+ type: "card",
81641
+ card: {
81642
+ title: { text: section.title },
81643
+ subtitle: { text: section.subtitle },
81644
+ children: section.fields.map((fieldKey) => ({
81645
+ type: "field",
81646
+ field: { span: 12, fieldId: fieldKey }
81647
+ }))
81648
+ }
81649
+ }));
81650
+ return {
81651
+ main: main2,
81652
+ ...sidebar.length > 0 ? { sidebar } : {}
81653
+ };
81654
+ }
81655
+ generatePageTsx() {
81656
+ return `import React, { type FC } from 'react';
81657
+ import { WixDesignSystemProvider } from '@wix/design-system';
81658
+ import '@wix/design-system/styles.global.css';
81659
+ import { WixPatternsProvider } from '@wix/patterns/provider';
81660
+ import { PatternsWizardOverridesProvider, AutoPatternsApp } from '@wix/auto-patterns';
81661
+ import type { AppConfig } from '@wix/auto-patterns';
81662
+ import { withDashboard } from '@wix/patterns';
81663
+ import config from './patterns.json';
81664
+
81665
+ const CollectionPage: FC = () => {
81666
+ return (
81667
+ <WixDesignSystemProvider features={{ newColorsBranding: true }}>
81668
+ <WixPatternsProvider>
81669
+ <PatternsWizardOverridesProvider value={{}}>
81670
+ <AutoPatternsApp configuration={config as AppConfig} />
81671
+ </PatternsWizardOverridesProvider>
81672
+ </WixPatternsProvider>
81673
+ </WixDesignSystemProvider>
81674
+ );
81675
+ };
81676
+
81677
+ export default withDashboard(CollectionPage);
81678
+ `;
81616
81679
  }
81617
81680
  };
81618
- exports2.ExtensionSelectorAgent = ExtensionSelectorAgent;
81681
+ exports2.AutoPatternsGenerator = AutoPatternsGenerator;
81619
81682
  }
81620
81683
  });
81621
81684
 
@@ -90532,7 +90595,7 @@ var require_data2 = __commonJS({
90532
90595
  });
90533
90596
 
90534
90597
  // ../../node_modules/fast-uri/lib/utils.js
90535
- var require_utils6 = __commonJS({
90598
+ var require_utils5 = __commonJS({
90536
90599
  "../../node_modules/fast-uri/lib/utils.js"(exports2, module2) {
90537
90600
  "use strict";
90538
90601
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
@@ -90792,7 +90855,7 @@ var require_utils6 = __commonJS({
90792
90855
  var require_schemes = __commonJS({
90793
90856
  "../../node_modules/fast-uri/lib/schemes.js"(exports2, module2) {
90794
90857
  "use strict";
90795
- var { isUUID } = require_utils6();
90858
+ var { isUUID } = require_utils5();
90796
90859
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
90797
90860
  var supportedSchemeNames = (
90798
90861
  /** @type {const} */
@@ -91002,7 +91065,7 @@ var require_schemes = __commonJS({
91002
91065
  var require_fast_uri = __commonJS({
91003
91066
  "../../node_modules/fast-uri/index.js"(exports2, module2) {
91004
91067
  "use strict";
91005
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils6();
91068
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils5();
91006
91069
  var { SCHEMES, getSchemeHandler } = require_schemes();
91007
91070
  function normalize(uri, options) {
91008
91071
  if (typeof uri === "string") {
@@ -96331,6 +96394,107 @@ var require_dist14 = __commonJS({
96331
96394
  }
96332
96395
  });
96333
96396
 
96397
+ // dist/agents/utils.js
96398
+ var require_utils6 = __commonJS({
96399
+ "dist/agents/utils.js"(exports2) {
96400
+ "use strict";
96401
+ var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
96402
+ return mod && mod.__esModule ? mod : { "default": mod };
96403
+ };
96404
+ Object.defineProperty(exports2, "__esModule", { value: true });
96405
+ exports2.extractApiNames = exports2.getErrorMessage = void 0;
96406
+ exports2.shouldUseDataPrompt = shouldUseDataPrompt;
96407
+ exports2.shouldUseDynamicParametersPrompt = shouldUseDynamicParametersPrompt;
96408
+ exports2.loadRelevantFilesAsString = loadRelevantFilesAsString;
96409
+ var fs_1 = __importDefault2(require("fs"));
96410
+ var path_1 = __importDefault2(require("path"));
96411
+ function shouldUseDataPrompt(params) {
96412
+ const { plan, previousResources } = params;
96413
+ return Boolean(plan?.collections?.length || previousResources?.collections?.length);
96414
+ }
96415
+ function shouldUseDynamicParametersPrompt(params) {
96416
+ const { plan, previousResources } = params;
96417
+ return Boolean(plan?.embeddedScriptParameters?.length || previousResources?.embeddedScriptParameters?.length);
96418
+ }
96419
+ function loadRelevantFiles(relevantFilePaths = [], basePath) {
96420
+ return relevantFilePaths.map((filePath) => {
96421
+ const fullPath = path_1.default.isAbsolute(basePath) ? path_1.default.join(basePath, filePath) : path_1.default.join(process.cwd(), basePath, filePath);
96422
+ try {
96423
+ if (!fs_1.default.existsSync(fullPath)) {
96424
+ return `Path: ${filePath}
96425
+
96426
+ [File does not exist]`;
96427
+ }
96428
+ const stats = fs_1.default.statSync(fullPath);
96429
+ if (stats.isDirectory()) {
96430
+ return `Path: ${filePath}
96431
+
96432
+ [Path is a directory, not a file]`;
96433
+ }
96434
+ const content = fs_1.default.readFileSync(fullPath, "utf8");
96435
+ return `Path: ${filePath}
96436
+
96437
+ ${content}`;
96438
+ } catch (error) {
96439
+ return `Path: ${filePath}
96440
+
96441
+ [Could not read file: ${error instanceof Error ? error.message : "Unknown error"}]`;
96442
+ }
96443
+ });
96444
+ }
96445
+ function loadRelevantFilesAsString(relevantFilePaths = [], basePath) {
96446
+ const srcOnlyPaths = relevantFilePaths.filter((p) => {
96447
+ const normalized = path_1.default.normalize(p);
96448
+ return normalized.startsWith("src" + path_1.default.sep);
96449
+ });
96450
+ return loadRelevantFiles(srcOnlyPaths, basePath).join("\n\n---\n\n");
96451
+ }
96452
+ var getErrorMessage = (error) => {
96453
+ if (error?.response?.data && error?.response?.data?.message.length > 0) {
96454
+ return JSON.stringify(error.response.data);
96455
+ } else if (error?.message && error?.message.length > 0) {
96456
+ return JSON.stringify(error.message);
96457
+ } else {
96458
+ return JSON.stringify(error);
96459
+ }
96460
+ };
96461
+ exports2.getErrorMessage = getErrorMessage;
96462
+ var extractApiNames = (extension) => {
96463
+ return extension.relatedApis?.map((api) => api.name).filter((name) => !!name) || [];
96464
+ };
96465
+ exports2.extractApiNames = extractApiNames;
96466
+ }
96467
+ });
96468
+
96469
+ // dist/agents/Iteration/utils/extensionFormatters.js
96470
+ var require_extensionFormatters = __commonJS({
96471
+ "dist/agents/Iteration/utils/extensionFormatters.js"(exports2) {
96472
+ "use strict";
96473
+ Object.defineProperty(exports2, "__esModule", { value: true });
96474
+ exports2.formatIterationPlanExtension = void 0;
96475
+ var utils_1 = require_utils6();
96476
+ var formatIterationPlanExtension = ({ ext, id, outputPath }) => {
96477
+ const lines = [
96478
+ `**ID: ${id}**`,
96479
+ `- Name: ${ext.extension.name}`,
96480
+ `- Type: ${ext.extension.type}`,
96481
+ `- Description: ${ext.extension.description}`
96482
+ ];
96483
+ const relevantFilesContent = (0, utils_1.loadRelevantFilesAsString)(ext.paths || [], outputPath);
96484
+ if (relevantFilesContent && relevantFilesContent !== "None") {
96485
+ lines.push(`- Relevant Files Content:
96486
+ ${relevantFilesContent}`);
96487
+ }
96488
+ if (ext.extension.relatedSpis && ext.extension.relatedSpis.length > 0) {
96489
+ lines.push(`- Current SPIs: ${ext.extension.relatedSpis.map((spi) => spi.name).join(", ")}`);
96490
+ }
96491
+ lines.push("");
96492
+ return lines;
96493
+ };
96494
+ exports2.formatIterationPlanExtension = formatIterationPlanExtension;
96495
+ }
96496
+ });
96497
+
96334
96498
  // dist/agents/Iteration/SDKPicker/SDKPickerAgent.js
96335
96499
  var require_SDKPickerAgent2 = __commonJS({
96336
96500
  "dist/agents/Iteration/SDKPicker/SDKPickerAgent.js"(exports2) {
@@ -96582,7 +96746,7 @@ var require_ExtensionIndexerAgent = __commonJS({
96582
96746
  var ditto_codegen_types_12 = require_dist();
96583
96747
  var constants_1 = require_constants();
96584
96748
  var customAnthropicProvider_1 = require_customAnthropicProvider();
96585
- var tools_1 = require_tools2();
96749
+ var tools_1 = require_tools();
96586
96750
  var tree_node_cli_1 = __importDefault2(require_src());
96587
96751
  var path_1 = __importDefault2(require("path"));
96588
96752
  var fs_1 = __importDefault2(require("fs"));
@@ -96668,7 +96832,6 @@ var require_AgentsFactory = __commonJS({
96668
96832
  var IterationAgent_1 = require_IterationAgent();
96669
96833
  var DashboardDecisionAgent_1 = require_DashboardDecisionAgent();
96670
96834
  var AutoPatternsGenerator_1 = require_AutoPatternsGenerator();
96671
- var ExtensionSelectorAgent_1 = require_ExtensionSelectorAgent();
96672
96835
  var AgentsRegistry_1 = require_AgentsRegistry();
96673
96836
  var ditto_codegen_types_12 = require_dist();
96674
96837
  var SDKPickerAgent_1 = require_SDKPickerAgent2();
@@ -96702,8 +96865,6 @@ var require_AgentsFactory = __commonJS({
96702
96865
  return new DashboardDecisionAgent_1.DashboardDecisionAgent();
96703
96866
  case "AUTO_PATTERNS_GENERATOR":
96704
96867
  return new AutoPatternsGenerator_1.AutoPatternsGenerator();
96705
- case "EXTENSION_SELECTOR":
96706
- return new ExtensionSelectorAgent_1.ExtensionSelectorAgent();
96707
96868
  case "SDK_PICKER":
96708
96869
  return new SDKPickerAgent_1.SDKPickerAgent();
96709
96870
  case "EXTENSION_INDEXER":
@@ -320479,6 +320640,7 @@ var require_extension = __commonJS({
320479
320640
  var fs_1 = __importDefault2(require("fs"));
320480
320641
  var extensionAst_1 = require_extensionAst();
320481
320642
  var EXTENSIONS_FILENAME = "extensions.ts";
320643
+ var EXTENSION_FILE_PATTERN = "*.extension.ts";
320482
320644
  function getSrcDir(outputPath) {
320483
320645
  return path_1.default.join(outputPath, "src");
320484
320646
  }
@@ -320493,7 +320655,10 @@ var require_extension = __commonJS({
320493
320655
  async function findExtensionFiles(srcDir) {
320494
320656
  const { globby: globby2 } = await Promise.resolve().then(() => (init_globby(), globby_exports));
320495
320657
  const aggregatorFilePath = path_1.default.join(srcDir, EXTENSIONS_FILENAME);
320496
- const allExtensionFiles = await globby2(`${srcDir}/**/${EXTENSIONS_FILENAME}`, {
320658
+ const allExtensionFiles = await globby2([
320659
+ `${srcDir}/**/${EXTENSIONS_FILENAME}`,
320660
+ `${srcDir}/**/${EXTENSION_FILE_PATTERN}`
320661
+ ], {
320497
320662
  ignore: ["**/node_modules/**", "**/dist/**"]
320498
320663
  });
320499
320664
  return allExtensionFiles.filter((f) => path_1.default.resolve(f) !== path_1.default.resolve(aggregatorFilePath));
@@ -320815,21 +320980,11 @@ var require_IterationOrchestrator = __commonJS({
320815
320980
  type: "ITERATION_AGENT"
320816
320981
  });
320817
320982
  const { currentUserRequest, filteredChatHistory } = this.extractUserRequestAndFilteredHistory(chatHistory);
320818
- const extensionSelectorAgent = this.agentsFactory.getAgent({
320819
- type: "EXTENSION_SELECTOR"
320820
- });
320821
- const extensionSelectorResult = await extensionSelectorAgent.generate({
320822
- outputPath,
320823
- extensions,
320824
- chatHistory: filteredChatHistory,
320825
- currentUserRequest,
320826
- previousResources
320827
- });
320828
320983
  const iterationPlan = await iterationAgent.generate({
320829
320984
  currentUserRequest,
320830
320985
  chatHistory: filteredChatHistory,
320831
- extensionSelectorResult,
320832
- previousResources
320986
+ previousResources,
320987
+ outputPath
320833
320988
  });
320834
320989
  this.validateEmbeddedScriptConstraint(extensions, iterationPlan);
320835
320990
  const sdkPickerAgent = this.agentsFactory.getAgent({ type: "SDK_PICKER" });