@wix/ditto-codegen-public 1.0.197 → 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.
- package/dist/out.js +1183 -1275
- 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.
|
|
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
|
-
|
|
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
|
|
@@ -39906,6 +39906,30 @@ Given the full chat history, current user request, and all project files:
|
|
|
39906
39906
|
|
|
39907
39907
|
**#7 - If an extension already exists AND user doesn't use "new/create/add" keywords, MODIFY IT instead**
|
|
39908
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
|
+
|
|
39909
39933
|
**EXTENSION TYPE RULES & USAGE NOTES:**
|
|
39910
39934
|
- Use **SITE_COMPONENT** ONLY when React is EXPLICITLY requested by the user. If React is not explicitly mentioned, use **SITE_WIDGET** instead.
|
|
39911
39935
|
- Use **DASHBOARD_PAGE** for admin tasks and configuration - but ONLY if the user requests admin/management capabilities.
|
|
@@ -39921,10 +39945,85 @@ Given the full chat history, current user request, and all project files:
|
|
|
39921
39945
|
- Include the extension in currentExtensions with its paths
|
|
39922
39946
|
- Set relevantUserRequest to clearly state "Delete this extension" or similar
|
|
39923
39947
|
- The code generation agent will handle removing the files`;
|
|
39924
|
-
|
|
39925
|
-
|
|
39926
|
-
|
|
39927
|
-
|
|
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>
|
|
39928
40027
|
1. **For UI/Admin interfaces**: Use DASHBOARD_PAGE
|
|
39929
40028
|
2. **For site frontend components**: Use SITE_COMPONENT or SITE_WIDGET
|
|
39930
40029
|
3. **For eCommerce business logic**: Use SERVICE_PLUGIN
|
|
@@ -39952,12 +40051,7 @@ When relevant existing extensions are identified:
|
|
|
39952
40051
|
</critical_rule_for_existing_extensions>
|
|
39953
40052
|
|
|
39954
40053
|
${(0, codegen_common_logic_1.getExtensionDecisionMatrix)()}`;
|
|
39955
|
-
exports2.iterationAgentRole = iterationAgentRoleConst;
|
|
39956
|
-
exports2.iterationAgentCommonScenariosDocumentation = iterationAgentCommonScenariosDocumentationConst;
|
|
39957
|
-
exports2.iterationAgentQuickDecisionGuide = iterationAgentQuickDecisionGuideConst;
|
|
39958
|
-
exports2.iterationAgentCommonUseCasesGuide = iterationAgentCommonUseCasesGuideConst;
|
|
39959
40054
|
exports2.iterationAgentChatHistoryContext = (0, iterationScenarios_1.getChatHistoryContext)();
|
|
39960
|
-
exports2.iterationAgentExtensionSelectionLogic = iterationAgentExtensionSelectionLogicConst;
|
|
39961
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.
|
|
39962
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.
|
|
39963
40057
|
- **SMART DUPLICATION DETECTION**: When deciding between modifying vs creating:
|
|
@@ -40000,6 +40094,100 @@ ${(0, codegen_common_logic_1.getExtensionDecisionMatrix)()}`;
|
|
|
40000
40094
|
- "paths" field: For ALL extension types - specify relevant file paths to modify
|
|
40001
40095
|
- For currentExtensions, always include paths; for additionalExtensions, paths are not needed`;
|
|
40002
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`;
|
|
40003
40191
|
}
|
|
40004
40192
|
});
|
|
40005
40193
|
|
|
@@ -73325,990 +73513,13 @@ var require_iteration_agent_prompt = __commonJS({
|
|
|
73325
73513
|
const keyPoints = (0, iterartion_agent_instructions_1.getIterationAgentKeyPoints)(supportedTypes);
|
|
73326
73514
|
const systemPrompt = new codegen_common_logic_1.SystemPromptBuilder({
|
|
73327
73515
|
agentType: codegen_common_logic_1.GeneralAgentType.ITERATION_AGENT
|
|
73328
|
-
}).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).withExamples(iteration_examples_1.iterationAgentExamples);
|
|
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);
|
|
73329
73517
|
return systemPrompt.compose();
|
|
73330
73518
|
};
|
|
73331
73519
|
exports2.iterationAgentPrompt = iterationAgentPrompt;
|
|
73332
73520
|
}
|
|
73333
73521
|
});
|
|
73334
73522
|
|
|
73335
|
-
// dist/agents/utils.js
|
|
73336
|
-
var require_utils = __commonJS({
|
|
73337
|
-
"dist/agents/utils.js"(exports2) {
|
|
73338
|
-
"use strict";
|
|
73339
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
73340
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
73341
|
-
};
|
|
73342
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73343
|
-
exports2.extractApiNames = exports2.getErrorMessage = void 0;
|
|
73344
|
-
exports2.shouldUseDataPrompt = shouldUseDataPrompt;
|
|
73345
|
-
exports2.shouldUseDynamicParametersPrompt = shouldUseDynamicParametersPrompt;
|
|
73346
|
-
exports2.loadRelevantFilesAsString = loadRelevantFilesAsString;
|
|
73347
|
-
var fs_1 = __importDefault2(require("fs"));
|
|
73348
|
-
var path_1 = __importDefault2(require("path"));
|
|
73349
|
-
function shouldUseDataPrompt(params) {
|
|
73350
|
-
const { plan, previousResources } = params;
|
|
73351
|
-
return Boolean(plan?.collections?.length || previousResources?.collections?.length);
|
|
73352
|
-
}
|
|
73353
|
-
function shouldUseDynamicParametersPrompt(params) {
|
|
73354
|
-
const { plan, previousResources } = params;
|
|
73355
|
-
return Boolean(plan?.embeddedScriptParameters?.length || previousResources?.embeddedScriptParameters?.length);
|
|
73356
|
-
}
|
|
73357
|
-
function loadRelevantFiles(relevantFilePaths = [], basePath) {
|
|
73358
|
-
return relevantFilePaths.map((filePath) => {
|
|
73359
|
-
const fullPath = path_1.default.isAbsolute(basePath) ? path_1.default.join(basePath, filePath) : path_1.default.join(process.cwd(), basePath, filePath);
|
|
73360
|
-
try {
|
|
73361
|
-
if (!fs_1.default.existsSync(fullPath)) {
|
|
73362
|
-
return `Path: ${filePath}
|
|
73363
|
-
|
|
73364
|
-
[File does not exist]`;
|
|
73365
|
-
}
|
|
73366
|
-
const stats = fs_1.default.statSync(fullPath);
|
|
73367
|
-
if (stats.isDirectory()) {
|
|
73368
|
-
return `Path: ${filePath}
|
|
73369
|
-
|
|
73370
|
-
[Path is a directory, not a file]`;
|
|
73371
|
-
}
|
|
73372
|
-
const content = fs_1.default.readFileSync(fullPath, "utf8");
|
|
73373
|
-
return `Path: ${filePath}
|
|
73374
|
-
|
|
73375
|
-
${content}`;
|
|
73376
|
-
} catch (error) {
|
|
73377
|
-
return `Path: ${filePath}
|
|
73378
|
-
|
|
73379
|
-
[Could not read file: ${error instanceof Error ? error.message : "Unknown error"}]`;
|
|
73380
|
-
}
|
|
73381
|
-
});
|
|
73382
|
-
}
|
|
73383
|
-
function loadRelevantFilesAsString(relevantFilePaths = [], basePath) {
|
|
73384
|
-
const srcOnlyPaths = relevantFilePaths.filter((p) => {
|
|
73385
|
-
const normalized = path_1.default.normalize(p);
|
|
73386
|
-
return normalized.startsWith("src" + path_1.default.sep);
|
|
73387
|
-
});
|
|
73388
|
-
return loadRelevantFiles(srcOnlyPaths, basePath).join("\n\n---\n\n");
|
|
73389
|
-
}
|
|
73390
|
-
var getErrorMessage = (error) => {
|
|
73391
|
-
if (error?.response?.data && error?.response?.data?.message.length > 0) {
|
|
73392
|
-
return JSON.stringify(error.response.data);
|
|
73393
|
-
} else if (error?.message && error?.message.length > 0) {
|
|
73394
|
-
return JSON.stringify(error.message);
|
|
73395
|
-
} else {
|
|
73396
|
-
return JSON.stringify(error);
|
|
73397
|
-
}
|
|
73398
|
-
};
|
|
73399
|
-
exports2.getErrorMessage = getErrorMessage;
|
|
73400
|
-
var extractApiNames = (extension) => {
|
|
73401
|
-
return extension.relatedApis?.map((api) => api.name).filter((name) => !!name) || [];
|
|
73402
|
-
};
|
|
73403
|
-
exports2.extractApiNames = extractApiNames;
|
|
73404
|
-
}
|
|
73405
|
-
});
|
|
73406
|
-
|
|
73407
|
-
// dist/agents/Iteration/utils/extensionFormatters.js
|
|
73408
|
-
var require_extensionFormatters = __commonJS({
|
|
73409
|
-
"dist/agents/Iteration/utils/extensionFormatters.js"(exports2) {
|
|
73410
|
-
"use strict";
|
|
73411
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73412
|
-
exports2.formatIterationPlanExtension = void 0;
|
|
73413
|
-
exports2.formatEvaluationResultsExtensions = formatEvaluationResultsExtensions;
|
|
73414
|
-
exports2.formatContextExtensions = formatContextExtensions;
|
|
73415
|
-
exports2.formatScannedExtensions = formatScannedExtensions;
|
|
73416
|
-
var utils_1 = require_utils();
|
|
73417
|
-
function formatEvaluationResultsExtensions(extensions) {
|
|
73418
|
-
if (!extensions || extensions.length === 0)
|
|
73419
|
-
return "None";
|
|
73420
|
-
return extensions.map((extension, index) => {
|
|
73421
|
-
const filesList = extension.relevantFiles.map((file) => `- ${file}`).join("\n");
|
|
73422
|
-
const lines = [
|
|
73423
|
-
`#${index + 1}`,
|
|
73424
|
-
`type: ${extension.type ?? "UNKNOWN"}`,
|
|
73425
|
-
`files:`,
|
|
73426
|
-
filesList,
|
|
73427
|
-
`reasoning: ${extension.reasoning}`
|
|
73428
|
-
];
|
|
73429
|
-
return lines.join("\n");
|
|
73430
|
-
}).join("\n\n");
|
|
73431
|
-
}
|
|
73432
|
-
var formatIterationPlanExtension = ({ ext, id, outputPath }) => {
|
|
73433
|
-
const lines = [
|
|
73434
|
-
`**ID: ${id}**`,
|
|
73435
|
-
`- Name: ${ext.extension.name}`,
|
|
73436
|
-
`- Type: ${ext.extension.type}`,
|
|
73437
|
-
`- Description: ${ext.extension.description}`
|
|
73438
|
-
];
|
|
73439
|
-
const relevantFilesContent = (0, utils_1.loadRelevantFilesAsString)(ext.paths || [], outputPath);
|
|
73440
|
-
if (relevantFilesContent && relevantFilesContent !== "None") {
|
|
73441
|
-
lines.push(`- Relevant Files Content:
|
|
73442
|
-
${relevantFilesContent}`);
|
|
73443
|
-
}
|
|
73444
|
-
if (ext.extension.relatedSpis && ext.extension.relatedSpis.length > 0) {
|
|
73445
|
-
lines.push(`- Current SPIs: ${ext.extension.relatedSpis.map((spi) => spi.name).join(", ")}`);
|
|
73446
|
-
}
|
|
73447
|
-
lines.push("");
|
|
73448
|
-
return lines;
|
|
73449
|
-
};
|
|
73450
|
-
exports2.formatIterationPlanExtension = formatIterationPlanExtension;
|
|
73451
|
-
function formatContextExtensions(extensions) {
|
|
73452
|
-
if (!extensions || extensions.length === 0)
|
|
73453
|
-
return "None";
|
|
73454
|
-
return extensions.map((extension, index) => {
|
|
73455
|
-
const lines = [
|
|
73456
|
-
`#${index + 1}`,
|
|
73457
|
-
`type: ${extension.type ?? "UNKNOWN"}`,
|
|
73458
|
-
`reasoning: ${extension.reasoning}`
|
|
73459
|
-
];
|
|
73460
|
-
return lines.join("\n");
|
|
73461
|
-
}).join("\n\n");
|
|
73462
|
-
}
|
|
73463
|
-
function formatScannedExtensions(extensions, outputPath) {
|
|
73464
|
-
return extensions.map((extension, index) => {
|
|
73465
|
-
const relevantFilesContent = extension.files ? (0, utils_1.loadRelevantFilesAsString)(extension.files, outputPath) : "None";
|
|
73466
|
-
const lines = [
|
|
73467
|
-
`Extension ${index + 1}:`,
|
|
73468
|
-
`Type: ${extension.type}`,
|
|
73469
|
-
`ComponentPath: ${extension.componentPath}`,
|
|
73470
|
-
`Relevant Files Content: ${relevantFilesContent}`
|
|
73471
|
-
];
|
|
73472
|
-
return lines.join("\n");
|
|
73473
|
-
}).join("\n\n");
|
|
73474
|
-
}
|
|
73475
|
-
}
|
|
73476
|
-
});
|
|
73477
|
-
|
|
73478
|
-
// dist/agents/Iteration/utils/contextBuilders.js
|
|
73479
|
-
var require_contextBuilders = __commonJS({
|
|
73480
|
-
"dist/agents/Iteration/utils/contextBuilders.js"(exports2) {
|
|
73481
|
-
"use strict";
|
|
73482
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73483
|
-
exports2.buildContextSections = buildContextSections;
|
|
73484
|
-
function formatChatHistory(chatHistory) {
|
|
73485
|
-
return (chatHistory || []).map((message) => `${message.role.toUpperCase()}: ${message.text}`).join("\n\n");
|
|
73486
|
-
}
|
|
73487
|
-
function buildContextSections(chatHistory, currentUserRequest, previousResources) {
|
|
73488
|
-
const historyStr = formatChatHistory(chatHistory);
|
|
73489
|
-
const sections = [
|
|
73490
|
-
`
|
|
73491
|
-
Full Chat History:
|
|
73492
|
-
${historyStr}`,
|
|
73493
|
-
`
|
|
73494
|
-
Current User Request: ${currentUserRequest}`
|
|
73495
|
-
];
|
|
73496
|
-
if (previousResources.collections.length > 0) {
|
|
73497
|
-
sections.push(`
|
|
73498
|
-
Existing Collections:
|
|
73499
|
-
${JSON.stringify(previousResources.collections, null, 2)}`);
|
|
73500
|
-
}
|
|
73501
|
-
if (previousResources.embeddedScriptParameters.length > 0) {
|
|
73502
|
-
sections.push(`
|
|
73503
|
-
Embedded Script Parameters:
|
|
73504
|
-
${JSON.stringify(previousResources.embeddedScriptParameters, null, 2)}`);
|
|
73505
|
-
}
|
|
73506
|
-
return sections;
|
|
73507
|
-
}
|
|
73508
|
-
}
|
|
73509
|
-
});
|
|
73510
|
-
|
|
73511
|
-
// dist/agents/Iteration/IterationAgent.js
|
|
73512
|
-
var require_IterationAgent = __commonJS({
|
|
73513
|
-
"dist/agents/Iteration/IterationAgent.js"(exports2) {
|
|
73514
|
-
"use strict";
|
|
73515
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73516
|
-
exports2.IterationAgent = exports2.IterationPlanSchema = void 0;
|
|
73517
|
-
var zod_1 = require_zod();
|
|
73518
|
-
var ai_1 = require_dist8();
|
|
73519
|
-
var iteration_agent_prompt_1 = require_iteration_agent_prompt();
|
|
73520
|
-
var AgentsRegistry_1 = require_AgentsRegistry();
|
|
73521
|
-
var codegen_common_logic_1 = require_dist9();
|
|
73522
|
-
var ditto_codegen_types_12 = require_dist();
|
|
73523
|
-
var constants_1 = require_constants();
|
|
73524
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
73525
|
-
var extensionFormatters_1 = require_extensionFormatters();
|
|
73526
|
-
var contextBuilders_1 = require_contextBuilders();
|
|
73527
|
-
var MAX_NAME_LENGTH = 30;
|
|
73528
|
-
var CurrentExtensionSchema = zod_1.z.object({
|
|
73529
|
-
extensionType: zod_1.z.enum(codegen_common_logic_1.codeGenerationExtensionTypes).describe("The extension kind to trigger"),
|
|
73530
|
-
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.`),
|
|
73531
|
-
relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
|
|
73532
|
-
paths: zod_1.z.array(zod_1.z.string()).describe("Paths relevant for this extension"),
|
|
73533
|
-
relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
|
|
73534
|
-
});
|
|
73535
|
-
var AdditionalExtensionSchema = zod_1.z.object({
|
|
73536
|
-
extensionType: zod_1.z.enum(codegen_common_logic_1.codeGenerationExtensionTypes).describe("The extension kind to add"),
|
|
73537
|
-
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.`),
|
|
73538
|
-
relatedSpis: zod_1.z.array(zod_1.z.string()).optional().describe("Optional value, only for SPI extensions - specify the SPI types"),
|
|
73539
|
-
relevantUserRequest: zod_1.z.string().describe("What part of the user request this extension should do, do not reference other extensions.")
|
|
73540
|
-
});
|
|
73541
|
-
exports2.IterationPlanSchema = zod_1.z.object({
|
|
73542
|
-
currentExtensions: zod_1.z.array(CurrentExtensionSchema).describe("Existing extensions to be triggered, return [] if no existing extensions are needed"),
|
|
73543
|
-
additionalExtensions: zod_1.z.array(AdditionalExtensionSchema).describe("New extensions to be created, return [] if no new extensions are needed"),
|
|
73544
|
-
summary: zod_1.z.string().describe("Summary of the chat with the user request")
|
|
73545
|
-
});
|
|
73546
|
-
var IterationAgent = class {
|
|
73547
|
-
constructor() {
|
|
73548
|
-
this.name = "IterationAgent";
|
|
73549
|
-
}
|
|
73550
|
-
buildSystemPrompt() {
|
|
73551
|
-
return (0, iteration_agent_prompt_1.iterationAgentPrompt)();
|
|
73552
|
-
}
|
|
73553
|
-
mapExtensionType(extensionType) {
|
|
73554
|
-
const supportedExtensionTypes = (0, AgentsRegistry_1.getSupportedExtensionTypes)();
|
|
73555
|
-
if (supportedExtensionTypes.includes(extensionType)) {
|
|
73556
|
-
return extensionType;
|
|
73557
|
-
}
|
|
73558
|
-
throw new ditto_codegen_types_12.UnsupportedExtensionTypeError(`Unsupported extension type: ${extensionType}. Supported types: ${supportedExtensionTypes.join(", ")}`, {
|
|
73559
|
-
extensionType: extensionType || "UNKNOWN",
|
|
73560
|
-
origin: ditto_codegen_types_12.ErrorOrigin.ITERATION
|
|
73561
|
-
});
|
|
73562
|
-
}
|
|
73563
|
-
generateExtensionObject(extensionType, name, relevantUserRequest, relatedSpis) {
|
|
73564
|
-
return {
|
|
73565
|
-
type: this.mapExtensionType(extensionType),
|
|
73566
|
-
name,
|
|
73567
|
-
description: relevantUserRequest,
|
|
73568
|
-
relatedSpis: relatedSpis?.map((spi) => ({
|
|
73569
|
-
name: spi,
|
|
73570
|
-
purpose: ""
|
|
73571
|
-
})) || []
|
|
73572
|
-
};
|
|
73573
|
-
}
|
|
73574
|
-
async repairNameTooLong({ text, error }) {
|
|
73575
|
-
if (!ai_1.TypeValidationError.isInstance(error)) {
|
|
73576
|
-
return text;
|
|
73577
|
-
}
|
|
73578
|
-
const cause = error.cause;
|
|
73579
|
-
const hasNameTooLongIssue = cause?.issues?.some((issue) => issue.code === "too_big" && issue.path?.at(-1) === "name");
|
|
73580
|
-
if (!hasNameTooLongIssue) {
|
|
73581
|
-
return text;
|
|
73582
|
-
}
|
|
73583
|
-
const parsed = JSON.parse(text);
|
|
73584
|
-
const hasCurrentExtensionsIssue = parsed.currentExtensions && cause?.issues?.some((issue) => issue.path?.includes("currentExtensions"));
|
|
73585
|
-
const hasAdditionalExtensionsIssue = parsed.additionalExtensions && cause?.issues?.some((issue) => issue.path?.includes("additionalExtensions"));
|
|
73586
|
-
if (hasCurrentExtensionsIssue) {
|
|
73587
|
-
for (const ext of parsed.currentExtensions) {
|
|
73588
|
-
if (ext.name && ext.name.length > MAX_NAME_LENGTH) {
|
|
73589
|
-
ext.name = ext.name.slice(0, MAX_NAME_LENGTH);
|
|
73590
|
-
}
|
|
73591
|
-
}
|
|
73592
|
-
}
|
|
73593
|
-
if (hasAdditionalExtensionsIssue) {
|
|
73594
|
-
for (const ext of parsed.additionalExtensions) {
|
|
73595
|
-
if (ext.name && ext.name.length > MAX_NAME_LENGTH) {
|
|
73596
|
-
ext.name = ext.name.slice(0, MAX_NAME_LENGTH);
|
|
73597
|
-
}
|
|
73598
|
-
}
|
|
73599
|
-
}
|
|
73600
|
-
return JSON.stringify(parsed);
|
|
73601
|
-
}
|
|
73602
|
-
buildUserPrompt({ chatHistory, currentUserRequest, previousResources, extensionSelectorResult }) {
|
|
73603
|
-
const sections = (0, contextBuilders_1.buildContextSections)(chatHistory, currentUserRequest, previousResources);
|
|
73604
|
-
sections.push(`
|
|
73605
|
-
Relevant Existing Extensions:
|
|
73606
|
-
${(0, extensionFormatters_1.formatEvaluationResultsExtensions)(extensionSelectorResult.extensionsToModify)}`);
|
|
73607
|
-
sections.push(`
|
|
73608
|
-
Context Extensions (already exist, don't need changes):
|
|
73609
|
-
${(0, extensionFormatters_1.formatContextExtensions)(extensionSelectorResult.contextExtensions)}`);
|
|
73610
|
-
return sections.join("\n\n");
|
|
73611
|
-
}
|
|
73612
|
-
async generate({ currentUserRequest, chatHistory, extensionSelectorResult, previousResources }) {
|
|
73613
|
-
const userMessage = this.buildUserPrompt({
|
|
73614
|
-
chatHistory,
|
|
73615
|
-
currentUserRequest,
|
|
73616
|
-
extensionSelectorResult,
|
|
73617
|
-
previousResources
|
|
73618
|
-
});
|
|
73619
|
-
const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
|
|
73620
|
-
userMessage,
|
|
73621
|
-
systemPrompt: this.buildSystemPrompt(),
|
|
73622
|
-
provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
|
|
73623
|
-
model: constants_1.LLM_MODELS.CLAUDE_3_5_HAIKU_LATEST,
|
|
73624
|
-
schema: exports2.IterationPlanSchema,
|
|
73625
|
-
agentName: this.name,
|
|
73626
|
-
experimental_repairText: this.repairNameTooLong
|
|
73627
|
-
});
|
|
73628
|
-
const resultObject = {
|
|
73629
|
-
currentExtensions: result.object.currentExtensions.map((ext) => ({
|
|
73630
|
-
paths: ext.paths,
|
|
73631
|
-
extension: this.generateExtensionObject(ext.extensionType, ext.name, ext.relevantUserRequest, ext.relatedSpis)
|
|
73632
|
-
})),
|
|
73633
|
-
additionalExtensions: result.object.additionalExtensions.map((ext) => ({
|
|
73634
|
-
extension: this.generateExtensionObject(ext.extensionType, ext.name, ext.relevantUserRequest, ext.relatedSpis)
|
|
73635
|
-
})),
|
|
73636
|
-
summary: result.object.summary
|
|
73637
|
-
};
|
|
73638
|
-
console.log("IterationAgent result:", JSON.stringify(resultObject, null, 2));
|
|
73639
|
-
return resultObject;
|
|
73640
|
-
}
|
|
73641
|
-
};
|
|
73642
|
-
exports2.IterationAgent = IterationAgent;
|
|
73643
|
-
}
|
|
73644
|
-
});
|
|
73645
|
-
|
|
73646
|
-
// dist/agents/DashboardDecisionAgent.js
|
|
73647
|
-
var require_DashboardDecisionAgent = __commonJS({
|
|
73648
|
-
"dist/agents/DashboardDecisionAgent.js"(exports2) {
|
|
73649
|
-
"use strict";
|
|
73650
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73651
|
-
exports2.DashboardDecisionAgent = void 0;
|
|
73652
|
-
var zod_1 = require_zod();
|
|
73653
|
-
var codegen_dashboard_agents_1 = require_dist11();
|
|
73654
|
-
var prompt_selectors_1 = require_prompt_selectors();
|
|
73655
|
-
var types_1 = require_types_impl();
|
|
73656
|
-
var userPrompt_1 = require_userPrompt();
|
|
73657
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
73658
|
-
var constants_1 = require_constants();
|
|
73659
|
-
var autoPatternsLlmConfig = zod_1.z.object({
|
|
73660
|
-
useAutoPatterns: zod_1.z.boolean(),
|
|
73661
|
-
schema: zod_1.z.object({
|
|
73662
|
-
content: zod_1.z.object({
|
|
73663
|
-
collectionRouteId: zod_1.z.string(),
|
|
73664
|
-
singularEntityName: zod_1.z.string(),
|
|
73665
|
-
pageTitle: zod_1.z.string(),
|
|
73666
|
-
pageSubtitle: zod_1.z.string(),
|
|
73667
|
-
actionButtonLabel: zod_1.z.string(),
|
|
73668
|
-
toolbarTitle: zod_1.z.string(),
|
|
73669
|
-
toolbarSubtitle: zod_1.z.string(),
|
|
73670
|
-
emptyStateTitle: zod_1.z.string(),
|
|
73671
|
-
emptyStateSubtitle: zod_1.z.string(),
|
|
73672
|
-
emptyStateButtonText: zod_1.z.string(),
|
|
73673
|
-
deleteModalTitle: zod_1.z.string(),
|
|
73674
|
-
deleteModalDescription: zod_1.z.string(),
|
|
73675
|
-
deleteSuccessToast: zod_1.z.string(),
|
|
73676
|
-
deleteErrorToast: zod_1.z.string(),
|
|
73677
|
-
bulkDeleteModalTitle: zod_1.z.string(),
|
|
73678
|
-
bulkDeleteModalDescription: zod_1.z.string(),
|
|
73679
|
-
bulkDeleteSuccessToast: zod_1.z.string(),
|
|
73680
|
-
bulkDeleteErrorToast: zod_1.z.string(),
|
|
73681
|
-
entityPageTitle: zod_1.z.string(),
|
|
73682
|
-
entityPageSubtitle: zod_1.z.string()
|
|
73683
|
-
}),
|
|
73684
|
-
layout: zod_1.z.object({
|
|
73685
|
-
main: zod_1.z.array(zod_1.z.object({
|
|
73686
|
-
title: zod_1.z.string(),
|
|
73687
|
-
subtitle: zod_1.z.string(),
|
|
73688
|
-
fields: zod_1.z.array(zod_1.z.string())
|
|
73689
|
-
})),
|
|
73690
|
-
sidebar: zod_1.z.array(zod_1.z.object({
|
|
73691
|
-
title: zod_1.z.string(),
|
|
73692
|
-
subtitle: zod_1.z.string(),
|
|
73693
|
-
fields: zod_1.z.array(zod_1.z.string())
|
|
73694
|
-
}))
|
|
73695
|
-
}),
|
|
73696
|
-
columns: zod_1.z.array(zod_1.z.object({
|
|
73697
|
-
id: zod_1.z.string(),
|
|
73698
|
-
displayName: zod_1.z.string()
|
|
73699
|
-
})),
|
|
73700
|
-
gridItem: zod_1.z.object({
|
|
73701
|
-
titleFieldId: zod_1.z.string(),
|
|
73702
|
-
subtitleFieldId: zod_1.z.string().optional(),
|
|
73703
|
-
imageFieldId: zod_1.z.string().optional()
|
|
73704
|
-
}).optional().nullable()
|
|
73705
|
-
}).optional(),
|
|
73706
|
-
relevantCollectionId: zod_1.z.string().optional()
|
|
73707
|
-
});
|
|
73708
|
-
var DashboardDecisionAgent = class {
|
|
73709
|
-
constructor() {
|
|
73710
|
-
this.name = "DashboardDecisionAgent";
|
|
73711
|
-
}
|
|
73712
|
-
buildSystemPrompt() {
|
|
73713
|
-
return (0, codegen_dashboard_agents_1.autoPatternsDecisionPrompt)();
|
|
73714
|
-
}
|
|
73715
|
-
shouldNotUseAutoPatterns(params) {
|
|
73716
|
-
const { blueprint } = params;
|
|
73717
|
-
const hasEmbeddedScriptExtension = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.EMBEDDED_SCRIPT) ?? false;
|
|
73718
|
-
const hasOneDashboardPageExtension = blueprint?.extensions?.filter((ext) => ext.type === types_1.ExtensionType.DASHBOARD_PAGE).length === 1;
|
|
73719
|
-
const shouldImplementEmbeddedScriptParameters = hasOneDashboardPageExtension && hasEmbeddedScriptExtension;
|
|
73720
|
-
const hasCollections = (0, prompt_selectors_1.shouldUseDataPrompt)(params);
|
|
73721
|
-
const hasUnsupportedCollectionFieldsTypes = (0, prompt_selectors_1.hasUnsupportedCollectionTypes)(params);
|
|
73722
|
-
if (!hasCollections || shouldImplementEmbeddedScriptParameters || hasUnsupportedCollectionFieldsTypes) {
|
|
73723
|
-
return true;
|
|
73724
|
-
}
|
|
73725
|
-
return false;
|
|
73726
|
-
}
|
|
73727
|
-
async generate(params) {
|
|
73728
|
-
if (this.shouldNotUseAutoPatterns(params)) {
|
|
73729
|
-
return {
|
|
73730
|
-
useAutoPatterns: false
|
|
73731
|
-
};
|
|
73732
|
-
}
|
|
73733
|
-
const systemPrompt = this.buildSystemPrompt();
|
|
73734
|
-
const primaryAction = "Decide whether to use auto patterns for the dashboard page";
|
|
73735
|
-
const userMessage = (0, userPrompt_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
|
|
73736
|
-
const result = await codeGenerationService_12.codegenAIProxyService.generateCodegenObject({
|
|
73737
|
-
userMessage,
|
|
73738
|
-
systemPrompt,
|
|
73739
|
-
provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
|
|
73740
|
-
model: constants_1.LLM_MODELS.CLAUDE_3_5_HAIKU_LATEST,
|
|
73741
|
-
schema: autoPatternsLlmConfig,
|
|
73742
|
-
agentName: this.name
|
|
73743
|
-
});
|
|
73744
|
-
console.log("\u{1F3AF} Decision and schema result:", JSON.stringify(result.object, null, 2));
|
|
73745
|
-
return result.object;
|
|
73746
|
-
}
|
|
73747
|
-
};
|
|
73748
|
-
exports2.DashboardDecisionAgent = DashboardDecisionAgent;
|
|
73749
|
-
}
|
|
73750
|
-
});
|
|
73751
|
-
|
|
73752
|
-
// ../scaffolding/dist/tools.js
|
|
73753
|
-
var require_tools = __commonJS({
|
|
73754
|
-
"../scaffolding/dist/tools.js"(exports2) {
|
|
73755
|
-
"use strict";
|
|
73756
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
73757
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
73758
|
-
};
|
|
73759
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73760
|
-
exports2.copyRecursive = copyRecursive;
|
|
73761
|
-
exports2.copyScaffolding = copyScaffolding;
|
|
73762
|
-
var fs_1 = __importDefault2(require("fs"));
|
|
73763
|
-
var path_1 = __importDefault2(require("path"));
|
|
73764
|
-
var scaffoldingBasePath = path_1.default.join(__dirname, "wix-cli-templates");
|
|
73765
|
-
function copyRecursive(sourcePath, destPath) {
|
|
73766
|
-
if (!fs_1.default.existsSync(sourcePath)) {
|
|
73767
|
-
throw new Error(`Source path does not exist: ${sourcePath}`);
|
|
73768
|
-
}
|
|
73769
|
-
const stat = fs_1.default.statSync(sourcePath);
|
|
73770
|
-
if (stat.isDirectory()) {
|
|
73771
|
-
const copiedFiles = [];
|
|
73772
|
-
if (!fs_1.default.existsSync(destPath)) {
|
|
73773
|
-
fs_1.default.mkdirSync(destPath, { recursive: true });
|
|
73774
|
-
}
|
|
73775
|
-
const items = fs_1.default.readdirSync(sourcePath);
|
|
73776
|
-
for (const item of items) {
|
|
73777
|
-
const sourceItemPath = path_1.default.join(sourcePath, item);
|
|
73778
|
-
const destItemPath = path_1.default.join(destPath, item);
|
|
73779
|
-
const results = copyRecursive(sourceItemPath, destItemPath);
|
|
73780
|
-
copiedFiles.push(...results);
|
|
73781
|
-
}
|
|
73782
|
-
return copiedFiles;
|
|
73783
|
-
} else {
|
|
73784
|
-
const destDir = path_1.default.dirname(destPath);
|
|
73785
|
-
if (!fs_1.default.existsSync(destDir)) {
|
|
73786
|
-
fs_1.default.mkdirSync(destDir, { recursive: true });
|
|
73787
|
-
}
|
|
73788
|
-
fs_1.default.copyFileSync(sourcePath, destPath);
|
|
73789
|
-
console.log(`\u{1F4CB} Copied: ${sourcePath} \u2192 ${destPath}`);
|
|
73790
|
-
return [destPath];
|
|
73791
|
-
}
|
|
73792
|
-
}
|
|
73793
|
-
function copyScaffolding(scaffoldingSubPath, outputRootPath, outputRelativePath) {
|
|
73794
|
-
const sourcePath = path_1.default.join(scaffoldingBasePath, scaffoldingSubPath);
|
|
73795
|
-
const destPath = path_1.default.join(outputRootPath, outputRelativePath);
|
|
73796
|
-
console.log(`\u{1F4E6} Copying scaffolding from: ${scaffoldingSubPath}`);
|
|
73797
|
-
return copyRecursive(sourcePath, destPath);
|
|
73798
|
-
}
|
|
73799
|
-
}
|
|
73800
|
-
});
|
|
73801
|
-
|
|
73802
|
-
// ../scaffolding/dist/constants.js
|
|
73803
|
-
var require_constants2 = __commonJS({
|
|
73804
|
-
"../scaffolding/dist/constants.js"(exports2) {
|
|
73805
|
-
"use strict";
|
|
73806
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73807
|
-
exports2.spiToSubPath = void 0;
|
|
73808
|
-
exports2.spiToSubPath = {
|
|
73809
|
-
"ecom.shippingRates.getShippingRates": "ecom-shipping-rates",
|
|
73810
|
-
"ecom.additionalFees.calculateAdditionalFees": "ecom-additional-fees",
|
|
73811
|
-
"ecom.paymentSettings.getPaymentSettings": "ecom-payment-settings",
|
|
73812
|
-
"ecom.validations.getValidationViolations": "ecom-validations",
|
|
73813
|
-
"ecom.customTriggers.getEligibleTriggers": "ecom-discount-triggers",
|
|
73814
|
-
"ecom.customTriggers.listTriggers": "ecom-discount-triggers",
|
|
73815
|
-
"ecom.giftCardsProvider.redeem": "ecom-gift-cards",
|
|
73816
|
-
"ecom.giftCardsProvider._void": "ecom-gift-cards",
|
|
73817
|
-
"ecom.giftCardsProvider.getBalance": "ecom-gift-cards"
|
|
73818
|
-
};
|
|
73819
|
-
}
|
|
73820
|
-
});
|
|
73821
|
-
|
|
73822
|
-
// ../scaffolding/dist/scaffolding.js
|
|
73823
|
-
var require_scaffolding = __commonJS({
|
|
73824
|
-
"../scaffolding/dist/scaffolding.js"(exports2) {
|
|
73825
|
-
"use strict";
|
|
73826
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
73827
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
73828
|
-
};
|
|
73829
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73830
|
-
exports2.copyScaffoldingTemplate = copyScaffoldingTemplate;
|
|
73831
|
-
exports2.toKebabCase = toKebabCase;
|
|
73832
|
-
var tools_1 = require_tools();
|
|
73833
|
-
var constants_1 = require_constants2();
|
|
73834
|
-
var types_1 = require_types_impl();
|
|
73835
|
-
var fs_1 = __importDefault2(require("fs"));
|
|
73836
|
-
var path_1 = __importDefault2(require("path"));
|
|
73837
|
-
async function copyScaffoldingTemplate(extension, outputPath) {
|
|
73838
|
-
const copiedPaths = await _copyScaffoldingTemplate(extension, outputPath);
|
|
73839
|
-
const uniquePaths = Array.from(new Set(copiedPaths));
|
|
73840
|
-
return uniquePaths.map((filePath) => {
|
|
73841
|
-
const relativePath = path_1.default.relative(outputPath, filePath);
|
|
73842
|
-
const content = fs_1.default.readFileSync(filePath, "utf8");
|
|
73843
|
-
return { path: relativePath, content };
|
|
73844
|
-
});
|
|
73845
|
-
}
|
|
73846
|
-
async function _copyScaffoldingTemplate(extension, outputPath) {
|
|
73847
|
-
switch (extension.type) {
|
|
73848
|
-
case types_1.ExtensionType.SERVICE_PLUGIN:
|
|
73849
|
-
return copyServicePluginScaffolding(extension, outputPath);
|
|
73850
|
-
case types_1.ExtensionType.DASHBOARD_PAGE:
|
|
73851
|
-
return copyDashboardPageScaffolding(extension, outputPath);
|
|
73852
|
-
case types_1.ExtensionType.DASHBOARD_MODAL:
|
|
73853
|
-
return copyDashboardModalScaffolding(extension, outputPath);
|
|
73854
|
-
case types_1.ExtensionType.SITE_WIDGET:
|
|
73855
|
-
return copyCustomElementScaffolding(extension, outputPath);
|
|
73856
|
-
case types_1.ExtensionType.EMBEDDED_SCRIPT:
|
|
73857
|
-
return copyEmbeddedScriptScaffolding(extension, outputPath);
|
|
73858
|
-
case types_1.ExtensionType.BACKEND_API:
|
|
73859
|
-
return copyBackendApiScaffolding(extension, outputPath);
|
|
73860
|
-
case types_1.ExtensionType.BACKEND_EVENT:
|
|
73861
|
-
return copyBackendEventScaffolding(extension, outputPath);
|
|
73862
|
-
case types_1.ExtensionType.SITE_COMPONENT:
|
|
73863
|
-
return copySiteComponentScaffolding(extension, outputPath);
|
|
73864
|
-
default:
|
|
73865
|
-
console.log(` \u26A0\uFE0F Unsupported extension type: ${extension.type}`);
|
|
73866
|
-
return [];
|
|
73867
|
-
}
|
|
73868
|
-
}
|
|
73869
|
-
async function copySiteComponentScaffolding(extension, outputPath) {
|
|
73870
|
-
const componentName = extension.name ?? "my-component";
|
|
73871
|
-
const scaffoldingSubPath = `src/site/components/my-component`;
|
|
73872
|
-
const componentSubPath = `src/site/components/${toKebabCase(componentName)}`;
|
|
73873
|
-
console.log(` \u{1F3A8} Copying site component scaffolding from: ${scaffoldingSubPath} to ${componentSubPath}`);
|
|
73874
|
-
return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, componentSubPath);
|
|
73875
|
-
}
|
|
73876
|
-
async function copyServicePluginScaffolding(extension, outputPath) {
|
|
73877
|
-
if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
|
|
73878
|
-
throw new Error("Service plugin extension must have related SPIs");
|
|
73879
|
-
}
|
|
73880
|
-
const allCopiedFiles = [];
|
|
73881
|
-
const uniqueFolderName = toKebabCase(extension.name || "my-service-plugin");
|
|
73882
|
-
for (const spi of extension.relatedSpis) {
|
|
73883
|
-
console.log(` \u{1F4CB} Copying service plugin scaffolding for related SPI: ${spi.name}`);
|
|
73884
|
-
const mapped = constants_1.spiToSubPath[spi.name || ""];
|
|
73885
|
-
if (mapped) {
|
|
73886
|
-
const scaffoldingPath = `src/backend/service-plugins/${mapped}/my-service-plugin`;
|
|
73887
|
-
const outputFolder = `src/backend/service-plugins/${mapped}/${uniqueFolderName}`;
|
|
73888
|
-
const copiedFiles = await (0, tools_1.copyScaffolding)(scaffoldingPath, outputPath, outputFolder);
|
|
73889
|
-
allCopiedFiles.push(...copiedFiles);
|
|
73890
|
-
} else {
|
|
73891
|
-
console.warn(` \u26A0\uFE0F No scaffolding template found for SPI: ${spi.name}`);
|
|
73892
|
-
}
|
|
73893
|
-
}
|
|
73894
|
-
return allCopiedFiles;
|
|
73895
|
-
}
|
|
73896
|
-
async function copyDashboardPageScaffolding(extension, outputPath) {
|
|
73897
|
-
const scaffoldingSubPath = "src/dashboard/pages";
|
|
73898
|
-
const uniqueFolderName = toKebabCase(extension.name || "page");
|
|
73899
|
-
const outputFolder = `src/dashboard/pages/${uniqueFolderName}`;
|
|
73900
|
-
console.log(` \u{1F4CA} Copying dashboard page scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
|
|
73901
|
-
return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
|
|
73902
|
-
}
|
|
73903
|
-
async function copyDashboardModalScaffolding(extension, outputPath) {
|
|
73904
|
-
const scaffoldingSubPath = "src/dashboard/modals/my-modal";
|
|
73905
|
-
const uniqueFolderName = toKebabCase(extension.name || "my-modal");
|
|
73906
|
-
const outputFolder = `src/dashboard/modals/${uniqueFolderName}`;
|
|
73907
|
-
console.log(` \u{1F532} Copying dashboard modal scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
|
|
73908
|
-
return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
|
|
73909
|
-
}
|
|
73910
|
-
async function copyCustomElementScaffolding(extension, outputPath) {
|
|
73911
|
-
const scaffoldingSubPath = "src/site/widgets/custom-elements/my-widget";
|
|
73912
|
-
const uniqueFolderName = toKebabCase(extension.name || "my-widget");
|
|
73913
|
-
const outputFolder = `src/site/widgets/custom-elements/${uniqueFolderName}`;
|
|
73914
|
-
console.log(` \u{1F3A8} Copying site widget scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
|
|
73915
|
-
return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
|
|
73916
|
-
}
|
|
73917
|
-
async function copyEmbeddedScriptScaffolding(extension, outputPath) {
|
|
73918
|
-
const scaffoldingSubPath = "src/site/embedded-scripts/my-script";
|
|
73919
|
-
const uniqueFolderName = toKebabCase(extension.name || "my-script");
|
|
73920
|
-
const outputFolder = `src/site/embedded-scripts/${uniqueFolderName}`;
|
|
73921
|
-
console.log(` \u{1F4DC} Copying embedded script scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
|
|
73922
|
-
return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
|
|
73923
|
-
}
|
|
73924
|
-
async function copyBackendApiScaffolding(extension, outputPath) {
|
|
73925
|
-
const uniqueFolderName = toKebabCase(extension.name || "my-api");
|
|
73926
|
-
const apiScaffoldingFile = "src/pages/api/my-api.ts";
|
|
73927
|
-
const apiOutputFile = `src/pages/api/${uniqueFolderName}.ts`;
|
|
73928
|
-
console.log(` \u{1F50C} Copying backend API scaffolding from: ${apiScaffoldingFile} to ${apiOutputFile}`);
|
|
73929
|
-
const apiFiles = (0, tools_1.copyScaffolding)(apiScaffoldingFile, outputPath, apiOutputFile);
|
|
73930
|
-
return apiFiles;
|
|
73931
|
-
}
|
|
73932
|
-
async function copyBackendEventScaffolding(extension, outputPath) {
|
|
73933
|
-
const scaffoldingSubPath = "src/backend/events/my-event";
|
|
73934
|
-
const uniqueFolderName = toKebabCase(extension.name || "my-event");
|
|
73935
|
-
const outputFolder = `src/backend/events/${uniqueFolderName}`;
|
|
73936
|
-
console.log(` \u26A1 Copying backend event scaffolding from: ${scaffoldingSubPath} to ${outputFolder}`);
|
|
73937
|
-
return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, outputFolder);
|
|
73938
|
-
}
|
|
73939
|
-
function toKebabCase(name) {
|
|
73940
|
-
return name.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/-+/g, "-").toLowerCase();
|
|
73941
|
-
}
|
|
73942
|
-
}
|
|
73943
|
-
});
|
|
73944
|
-
|
|
73945
|
-
// ../scaffolding/dist/index.js
|
|
73946
|
-
var require_dist12 = __commonJS({
|
|
73947
|
-
"../scaffolding/dist/index.js"(exports2) {
|
|
73948
|
-
"use strict";
|
|
73949
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73950
|
-
exports2.spiToSubPath = exports2.copyRecursive = exports2.copyScaffolding = exports2.toKebabCase = exports2.copyScaffoldingTemplate = void 0;
|
|
73951
|
-
var scaffolding_1 = require_scaffolding();
|
|
73952
|
-
Object.defineProperty(exports2, "copyScaffoldingTemplate", { enumerable: true, get: function() {
|
|
73953
|
-
return scaffolding_1.copyScaffoldingTemplate;
|
|
73954
|
-
} });
|
|
73955
|
-
Object.defineProperty(exports2, "toKebabCase", { enumerable: true, get: function() {
|
|
73956
|
-
return scaffolding_1.toKebabCase;
|
|
73957
|
-
} });
|
|
73958
|
-
var tools_1 = require_tools();
|
|
73959
|
-
Object.defineProperty(exports2, "copyScaffolding", { enumerable: true, get: function() {
|
|
73960
|
-
return tools_1.copyScaffolding;
|
|
73961
|
-
} });
|
|
73962
|
-
Object.defineProperty(exports2, "copyRecursive", { enumerable: true, get: function() {
|
|
73963
|
-
return tools_1.copyRecursive;
|
|
73964
|
-
} });
|
|
73965
|
-
var constants_1 = require_constants2();
|
|
73966
|
-
Object.defineProperty(exports2, "spiToSubPath", { enumerable: true, get: function() {
|
|
73967
|
-
return constants_1.spiToSubPath;
|
|
73968
|
-
} });
|
|
73969
|
-
}
|
|
73970
|
-
});
|
|
73971
|
-
|
|
73972
|
-
// dist/agents/AutoPatternsGenerator.js
|
|
73973
|
-
var require_AutoPatternsGenerator = __commonJS({
|
|
73974
|
-
"dist/agents/AutoPatternsGenerator.js"(exports2) {
|
|
73975
|
-
"use strict";
|
|
73976
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
73977
|
-
exports2.AutoPatternsGenerator = void 0;
|
|
73978
|
-
var ditto_scaffolding_1 = require_dist12();
|
|
73979
|
-
var ditto_codegen_types_12 = require_dist();
|
|
73980
|
-
var AutoPatternsGenerator = class {
|
|
73981
|
-
constructor() {
|
|
73982
|
-
this.name = "AutoPatternsGenerator";
|
|
73983
|
-
}
|
|
73984
|
-
generate({ collection, decision, extensionName }) {
|
|
73985
|
-
const name = (0, ditto_scaffolding_1.toKebabCase)(extensionName);
|
|
73986
|
-
const path2 = `src/dashboard/pages/${name}`;
|
|
73987
|
-
const patternsConfig = this.generatePatternsConfig(collection, decision);
|
|
73988
|
-
const pageTsx = this.generatePageTsx();
|
|
73989
|
-
return [
|
|
73990
|
-
{
|
|
73991
|
-
path: `${path2}/patterns.json`,
|
|
73992
|
-
operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
|
|
73993
|
-
content: JSON.stringify(patternsConfig, null, 2)
|
|
73994
|
-
},
|
|
73995
|
-
{
|
|
73996
|
-
path: `${path2}/page.tsx`,
|
|
73997
|
-
operation: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
|
|
73998
|
-
content: pageTsx
|
|
73999
|
-
}
|
|
74000
|
-
];
|
|
74001
|
-
}
|
|
74002
|
-
generatePatternsConfig(collection, contentResult) {
|
|
74003
|
-
const collectionRouteId = contentResult.schema?.content?.collectionRouteId;
|
|
74004
|
-
const singularEntityName = contentResult.schema?.content?.singularEntityName;
|
|
74005
|
-
const fieldMap = new Map(collection.fields?.filter((field) => field.key && field.displayName).map((field) => [field.key, field]) || []);
|
|
74006
|
-
const sortableFieldTypes = ["TEXT", "DATE", "NUMBER", "BOOLEAN", "URL"];
|
|
74007
|
-
const columns = contentResult.schema?.columns?.map((columnConfig) => {
|
|
74008
|
-
const field = fieldMap.get(columnConfig.id);
|
|
74009
|
-
if (!field || !field.key || !field.type)
|
|
74010
|
-
return null;
|
|
74011
|
-
let width = "200px";
|
|
74012
|
-
if (["BOOLEAN", "IMAGE", "NUMBER"].includes(field.type))
|
|
74013
|
-
width = "100px";
|
|
74014
|
-
if (field.type === "URL")
|
|
74015
|
-
width = "300px";
|
|
74016
|
-
return {
|
|
74017
|
-
id: field.key,
|
|
74018
|
-
name: columnConfig.displayName || field.displayName || "Field",
|
|
74019
|
-
width,
|
|
74020
|
-
sortable: sortableFieldTypes.includes(field.type || "")
|
|
74021
|
-
};
|
|
74022
|
-
}).filter((item) => item != null) || [];
|
|
74023
|
-
const filterableFieldTypes = ["DATE", "NUMBER", "BOOLEAN"];
|
|
74024
|
-
const filters = columns.map((column) => {
|
|
74025
|
-
const field = fieldMap.get(column.id);
|
|
74026
|
-
if (!field || !field.key || !filterableFieldTypes.includes(field.type || ""))
|
|
74027
|
-
return null;
|
|
74028
|
-
const baseFilter = {
|
|
74029
|
-
id: `${field.key}-filter`,
|
|
74030
|
-
fieldId: field.key,
|
|
74031
|
-
displayName: field.displayName || "",
|
|
74032
|
-
tagLabel: field.displayName || ""
|
|
74033
|
-
};
|
|
74034
|
-
if (field.type === "DATE") {
|
|
74035
|
-
return {
|
|
74036
|
-
...baseFilter,
|
|
74037
|
-
dateConfig: {
|
|
74038
|
-
mode: "COMBINE",
|
|
74039
|
-
presets: [
|
|
74040
|
-
"TODAY",
|
|
74041
|
-
"SEVEN_DAYS",
|
|
74042
|
-
"MONTH",
|
|
74043
|
-
"NEXT_SEVEN_DAYS",
|
|
74044
|
-
"NEXT_THIRTY_DAYS"
|
|
74045
|
-
],
|
|
74046
|
-
includeTime: false
|
|
74047
|
-
}
|
|
74048
|
-
};
|
|
74049
|
-
}
|
|
74050
|
-
if (field.type === "NUMBER") {
|
|
74051
|
-
return {
|
|
74052
|
-
...baseFilter,
|
|
74053
|
-
numberConfig: { allowedDecimals: true }
|
|
74054
|
-
};
|
|
74055
|
-
}
|
|
74056
|
-
if (field.type === "BOOLEAN") {
|
|
74057
|
-
return baseFilter;
|
|
74058
|
-
}
|
|
74059
|
-
return null;
|
|
74060
|
-
}).filter((item) => item != null);
|
|
74061
|
-
const layout = [
|
|
74062
|
-
{
|
|
74063
|
-
type: "Table",
|
|
74064
|
-
table: {
|
|
74065
|
-
columns,
|
|
74066
|
-
customColumns: {
|
|
74067
|
-
enabled: true
|
|
74068
|
-
}
|
|
74069
|
-
}
|
|
74070
|
-
}
|
|
74071
|
-
];
|
|
74072
|
-
if (contentResult.schema?.gridItem) {
|
|
74073
|
-
layout.push({
|
|
74074
|
-
type: "Grid",
|
|
74075
|
-
grid: {
|
|
74076
|
-
item: {
|
|
74077
|
-
titleFieldId: contentResult.schema?.gridItem?.titleFieldId,
|
|
74078
|
-
subtitleFieldId: contentResult.schema?.gridItem?.subtitleFieldId,
|
|
74079
|
-
imageFieldId: contentResult.schema?.gridItem?.imageFieldId,
|
|
74080
|
-
cardContentMode: contentResult.schema?.gridItem?.subtitleFieldId ? "full" : "title"
|
|
74081
|
-
}
|
|
74082
|
-
}
|
|
74083
|
-
});
|
|
74084
|
-
}
|
|
74085
|
-
return {
|
|
74086
|
-
pages: [
|
|
74087
|
-
{
|
|
74088
|
-
id: `${collectionRouteId}-collection`,
|
|
74089
|
-
type: "collectionPage",
|
|
74090
|
-
appMainPage: true,
|
|
74091
|
-
collectionPage: {
|
|
74092
|
-
route: {
|
|
74093
|
-
path: "/"
|
|
74094
|
-
},
|
|
74095
|
-
title: {
|
|
74096
|
-
text: contentResult.schema?.content.pageTitle || "",
|
|
74097
|
-
hideTotal: false
|
|
74098
|
-
},
|
|
74099
|
-
subtitle: {
|
|
74100
|
-
text: contentResult.schema?.content.pageSubtitle || ""
|
|
74101
|
-
},
|
|
74102
|
-
actions: {
|
|
74103
|
-
primaryActions: {
|
|
74104
|
-
type: "action",
|
|
74105
|
-
action: {
|
|
74106
|
-
item: {
|
|
74107
|
-
id: `create-${collectionRouteId}`,
|
|
74108
|
-
type: "create",
|
|
74109
|
-
label: contentResult.schema?.content.actionButtonLabel,
|
|
74110
|
-
collection: {
|
|
74111
|
-
collectionId: collection.idSuffix,
|
|
74112
|
-
entityTypeSource: "cms"
|
|
74113
|
-
},
|
|
74114
|
-
create: {
|
|
74115
|
-
mode: "page",
|
|
74116
|
-
page: {
|
|
74117
|
-
id: `${collectionRouteId}-entity`
|
|
74118
|
-
}
|
|
74119
|
-
}
|
|
74120
|
-
}
|
|
74121
|
-
}
|
|
74122
|
-
}
|
|
74123
|
-
},
|
|
74124
|
-
components: [
|
|
74125
|
-
{
|
|
74126
|
-
type: "collection",
|
|
74127
|
-
layout,
|
|
74128
|
-
entityPageId: `${collectionRouteId}-entity`,
|
|
74129
|
-
collection: {
|
|
74130
|
-
collectionId: collection.idSuffix,
|
|
74131
|
-
entityTypeSource: "cms"
|
|
74132
|
-
},
|
|
74133
|
-
toolbarTitle: {
|
|
74134
|
-
title: contentResult.schema?.content.toolbarTitle || "",
|
|
74135
|
-
subtitle: {
|
|
74136
|
-
text: contentResult.schema?.content.toolbarSubtitle || ""
|
|
74137
|
-
},
|
|
74138
|
-
showTotal: true
|
|
74139
|
-
},
|
|
74140
|
-
filters: {
|
|
74141
|
-
items: filters
|
|
74142
|
-
},
|
|
74143
|
-
emptyState: {
|
|
74144
|
-
title: contentResult.schema?.content.emptyStateTitle,
|
|
74145
|
-
subtitle: contentResult.schema?.content.emptyStateSubtitle,
|
|
74146
|
-
addNewCta: {
|
|
74147
|
-
id: `create-${collectionRouteId}`,
|
|
74148
|
-
text: contentResult.schema?.content.emptyStateButtonText
|
|
74149
|
-
}
|
|
74150
|
-
},
|
|
74151
|
-
actionCell: {
|
|
74152
|
-
primaryAction: {
|
|
74153
|
-
item: {
|
|
74154
|
-
id: `edit-${collectionRouteId}`,
|
|
74155
|
-
type: "update",
|
|
74156
|
-
update: {
|
|
74157
|
-
mode: "page",
|
|
74158
|
-
page: {
|
|
74159
|
-
id: `${collectionRouteId}-entity`
|
|
74160
|
-
}
|
|
74161
|
-
}
|
|
74162
|
-
}
|
|
74163
|
-
},
|
|
74164
|
-
secondaryActions: {
|
|
74165
|
-
items: [
|
|
74166
|
-
{
|
|
74167
|
-
id: `delete-${collectionRouteId}`,
|
|
74168
|
-
type: "delete",
|
|
74169
|
-
label: "Delete",
|
|
74170
|
-
delete: {
|
|
74171
|
-
mode: "modal",
|
|
74172
|
-
modal: {
|
|
74173
|
-
title: {
|
|
74174
|
-
text: contentResult.schema?.content.deleteModalTitle || ""
|
|
74175
|
-
},
|
|
74176
|
-
description: {
|
|
74177
|
-
text: contentResult.schema?.content.deleteModalDescription || ""
|
|
74178
|
-
},
|
|
74179
|
-
feedback: {
|
|
74180
|
-
successToast: {
|
|
74181
|
-
text: contentResult.schema?.content.deleteSuccessToast || ""
|
|
74182
|
-
},
|
|
74183
|
-
errorToast: {
|
|
74184
|
-
text: contentResult.schema?.content.deleteErrorToast || ""
|
|
74185
|
-
}
|
|
74186
|
-
}
|
|
74187
|
-
}
|
|
74188
|
-
}
|
|
74189
|
-
}
|
|
74190
|
-
]
|
|
74191
|
-
}
|
|
74192
|
-
},
|
|
74193
|
-
bulkActionToolbar: {
|
|
74194
|
-
primaryActions: [
|
|
74195
|
-
{
|
|
74196
|
-
type: "action",
|
|
74197
|
-
action: {
|
|
74198
|
-
item: {
|
|
74199
|
-
id: `bulk-delete-${collectionRouteId}`,
|
|
74200
|
-
type: "bulkDelete",
|
|
74201
|
-
bulkDelete: {
|
|
74202
|
-
mode: "modal",
|
|
74203
|
-
modal: {
|
|
74204
|
-
title: {
|
|
74205
|
-
text: contentResult.schema?.content.bulkDeleteModalTitle || ""
|
|
74206
|
-
},
|
|
74207
|
-
description: {
|
|
74208
|
-
text: contentResult.schema?.content.bulkDeleteModalDescription || ""
|
|
74209
|
-
},
|
|
74210
|
-
feedback: {
|
|
74211
|
-
successToast: {
|
|
74212
|
-
text: contentResult.schema?.content.bulkDeleteSuccessToast || ""
|
|
74213
|
-
},
|
|
74214
|
-
errorToast: {
|
|
74215
|
-
text: contentResult.schema?.content.bulkDeleteErrorToast || ""
|
|
74216
|
-
}
|
|
74217
|
-
}
|
|
74218
|
-
}
|
|
74219
|
-
}
|
|
74220
|
-
}
|
|
74221
|
-
}
|
|
74222
|
-
}
|
|
74223
|
-
]
|
|
74224
|
-
}
|
|
74225
|
-
}
|
|
74226
|
-
]
|
|
74227
|
-
}
|
|
74228
|
-
},
|
|
74229
|
-
{
|
|
74230
|
-
id: `${collectionRouteId}-entity`,
|
|
74231
|
-
type: "entityPage",
|
|
74232
|
-
entityPage: {
|
|
74233
|
-
route: {
|
|
74234
|
-
path: `/${singularEntityName}/:entityId`,
|
|
74235
|
-
params: { id: "entityId" }
|
|
74236
|
-
},
|
|
74237
|
-
title: {
|
|
74238
|
-
text: contentResult.schema?.content.entityPageTitle || ""
|
|
74239
|
-
},
|
|
74240
|
-
subtitle: {
|
|
74241
|
-
text: contentResult.schema?.content.entityPageSubtitle
|
|
74242
|
-
},
|
|
74243
|
-
parentPageId: `${collectionRouteId}-collection`,
|
|
74244
|
-
layout: this.generateEntityPageLayout(contentResult.schema?.layout),
|
|
74245
|
-
collectionId: collection.idSuffix,
|
|
74246
|
-
entityTypeSource: "cms"
|
|
74247
|
-
}
|
|
74248
|
-
}
|
|
74249
|
-
]
|
|
74250
|
-
};
|
|
74251
|
-
}
|
|
74252
|
-
generateEntityPageLayout(layout) {
|
|
74253
|
-
if (!layout)
|
|
74254
|
-
return { main: [] };
|
|
74255
|
-
const main2 = layout.main.map((section) => ({
|
|
74256
|
-
type: "card",
|
|
74257
|
-
card: {
|
|
74258
|
-
title: { text: section.title },
|
|
74259
|
-
subtitle: { text: section.subtitle },
|
|
74260
|
-
children: section.fields.map((fieldKey) => ({
|
|
74261
|
-
type: "field",
|
|
74262
|
-
field: { span: 12, fieldId: fieldKey }
|
|
74263
|
-
}))
|
|
74264
|
-
}
|
|
74265
|
-
}));
|
|
74266
|
-
const sidebar = layout.sidebar.map((section) => ({
|
|
74267
|
-
type: "card",
|
|
74268
|
-
card: {
|
|
74269
|
-
title: { text: section.title },
|
|
74270
|
-
subtitle: { text: section.subtitle },
|
|
74271
|
-
children: section.fields.map((fieldKey) => ({
|
|
74272
|
-
type: "field",
|
|
74273
|
-
field: { span: 12, fieldId: fieldKey }
|
|
74274
|
-
}))
|
|
74275
|
-
}
|
|
74276
|
-
}));
|
|
74277
|
-
return {
|
|
74278
|
-
main: main2,
|
|
74279
|
-
...sidebar.length > 0 ? { sidebar } : {}
|
|
74280
|
-
};
|
|
74281
|
-
}
|
|
74282
|
-
generatePageTsx() {
|
|
74283
|
-
return `import React, { type FC } from 'react';
|
|
74284
|
-
import { WixDesignSystemProvider } from '@wix/design-system';
|
|
74285
|
-
import '@wix/design-system/styles.global.css';
|
|
74286
|
-
import { WixPatternsProvider } from '@wix/patterns/provider';
|
|
74287
|
-
import { PatternsWizardOverridesProvider, AutoPatternsApp } from '@wix/auto-patterns';
|
|
74288
|
-
import type { AppConfig } from '@wix/auto-patterns';
|
|
74289
|
-
import { withDashboard } from '@wix/patterns';
|
|
74290
|
-
import config from './patterns.json';
|
|
74291
|
-
|
|
74292
|
-
const CollectionPage: FC = () => {
|
|
74293
|
-
return (
|
|
74294
|
-
<WixDesignSystemProvider features={{ newColorsBranding: true }}>
|
|
74295
|
-
<WixPatternsProvider>
|
|
74296
|
-
<PatternsWizardOverridesProvider value={{}}>
|
|
74297
|
-
<AutoPatternsApp configuration={config as AppConfig} />
|
|
74298
|
-
</PatternsWizardOverridesProvider>
|
|
74299
|
-
</WixPatternsProvider>
|
|
74300
|
-
</WixDesignSystemProvider>
|
|
74301
|
-
);
|
|
74302
|
-
};
|
|
74303
|
-
|
|
74304
|
-
export default withDashboard(CollectionPage);
|
|
74305
|
-
`;
|
|
74306
|
-
}
|
|
74307
|
-
};
|
|
74308
|
-
exports2.AutoPatternsGenerator = AutoPatternsGenerator;
|
|
74309
|
-
}
|
|
74310
|
-
});
|
|
74311
|
-
|
|
74312
73523
|
// ../../node_modules/pretty-bytes/index.js
|
|
74313
73524
|
var require_pretty_bytes = __commonJS({
|
|
74314
73525
|
"../../node_modules/pretty-bytes/index.js"(exports2, module2) {
|
|
@@ -74586,148 +73797,76 @@ var require_src = __commonJS({
|
|
|
74586
73797
|
}
|
|
74587
73798
|
});
|
|
74588
73799
|
|
|
74589
|
-
// dist/
|
|
74590
|
-
var
|
|
74591
|
-
"dist/
|
|
73800
|
+
// dist/agents/Iteration/utils/contextBuilders.js
|
|
73801
|
+
var require_contextBuilders = __commonJS({
|
|
73802
|
+
"dist/agents/Iteration/utils/contextBuilders.js"(exports2) {
|
|
74592
73803
|
"use strict";
|
|
73804
|
+
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
73805
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
73806
|
+
};
|
|
74593
73807
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
74594
|
-
exports2.
|
|
74595
|
-
|
|
74596
|
-
var
|
|
74597
|
-
var
|
|
74598
|
-
var
|
|
74599
|
-
|
|
74600
|
-
|
|
74601
|
-
|
|
74602
|
-
|
|
74603
|
-
|
|
74604
|
-
|
|
74605
|
-
|
|
74606
|
-
|
|
74607
|
-
|
|
74608
|
-
|
|
74609
|
-
|
|
74610
|
-
|
|
74611
|
-
|
|
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:
|
|
74612
73838
|
\`\`\`
|
|
74613
73839
|
${srcFolderStructure}
|
|
74614
73840
|
\`\`\`
|
|
74615
73841
|
|
|
74616
|
-
Use this structure to navigate and locate relevant files.`;
|
|
74617
|
-
|
|
74618
|
-
|
|
74619
|
-
const
|
|
74620
|
-
|
|
74621
|
-
|
|
74622
|
-
|
|
74623
|
-
|
|
74624
|
-
|
|
74625
|
-
|
|
74626
|
-
|
|
74627
|
-
|
|
74628
|
-
|
|
74629
|
-
|
|
74630
|
-
|
|
74631
|
-
|
|
74632
|
-
|
|
74633
|
-
|
|
74634
|
-
|
|
74635
|
-
|
|
74636
|
-
|
|
74637
|
-
|
|
74638
|
-
|
|
74639
|
-
|
|
74640
|
-
|
|
74641
|
-
|
|
74642
|
-
|
|
74643
|
-
|
|
74644
|
-
* Example: "delete the dashboard" \u2192 Put DASHBOARD_PAGE in extensionsToModify with reasoning about deletion
|
|
74645
|
-
* Example: "remove the widget" \u2192 Put SITE_WIDGET in extensionsToModify
|
|
74646
|
-
- 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"):
|
|
74647
|
-
* Ask yourself: "Does this extension ALREADY have code that needs to be CHANGED?"
|
|
74648
|
-
* If the answer is NO (you're suggesting to create something new) \u2192 DO NOT return this extension
|
|
74649
|
-
* If NO EXISTING extensions need modifications \u2192 Return EMPTY extensionsToModify []
|
|
74650
|
-
* DO NOT invent file paths for extensions that don't exist yet
|
|
74651
|
-
* The Iteration Agent will handle creating new extensions in additionalExtensions
|
|
74652
|
-
* **Example**: User says "add shipping rates" but only additional fees exist \u2192 Return [] (empty array)
|
|
74653
|
-
* **Example**: User says "display fees on site" but only dashboard page exists \u2192 Return [] (no existing site widget to modify)
|
|
74654
|
-
- For extensions that need changes, identify the specific files that need to be modified
|
|
74655
|
-
- relevantFiles array**: The \`relevantFiles\` array should ONLY contain files that NEED TO BE CHANGED:
|
|
74656
|
-
* If you read a file for understanding/context but it doesn't need changes \u2192 DO NOT include it in relevantFiles
|
|
74657
|
-
* If no files need changes for an extension \u2192 DO NOT return that extension at all
|
|
74658
|
-
* **Example**: Reading patterns.json to understand schema but no code changes needed \u2192 relevantFiles should be empty \u2192 don't return the extension
|
|
74659
|
-
* **For deletions**: Include all files of the extension that will be deleted
|
|
74660
|
-
- Not all files you read will be relevant - filter to only what needs modification
|
|
74661
|
-
- Only return files that are part of each extension, never mix files from different extensions
|
|
74662
|
-
- Only return EXISTING extensions from the "Extensions to Evaluate" list - never invent new extensions
|
|
74663
|
-
- Use the extension types documentation above to understand what each extension type does
|
|
74664
|
-
- **Ensure each extension's \`reasoning\` field includes**:
|
|
74665
|
-
* **What the extension CURRENTLY does**: What functionality does it already provide?
|
|
74666
|
-
* **What CODE CHANGES it needs**: Specifically what needs to be modified/deleted in the existing code?`;
|
|
74667
|
-
var extensionSelectorConstraints = `
|
|
74668
|
-
- **TWO CATEGORIES OF EXTENSIONS**:
|
|
74669
|
-
1. **extensionsToModify**: Include extensions that need CODE CHANGES, MODIFICATIONS, or DELETION
|
|
74670
|
-
* DO include if extension needs to be modified or deleted
|
|
74671
|
-
* DO NOT include if you're suggesting to CREATE or ADD new features
|
|
74672
|
-
* DO NOT include if your reasoning says "we need to create" or "add a new"
|
|
74673
|
-
* DO NOT include if they're just used for reference/validation
|
|
74674
|
-
2. **contextExtensions**: Include extensions that are RELEVANT but DON'T need any code changes or deletion
|
|
74675
|
-
* DO include if they already exist and relate to the user's request
|
|
74676
|
-
* This helps the Iteration Agent know what exists to avoid creating duplicates
|
|
74677
|
-
* Example: User wants to "add a widget", dashboard exists and doesn't need changes \u2192 include dashboard in contextExtensions
|
|
74678
|
-
* DO NOT include if extension needs to be deleted \u2192 that goes in extensionsToModify
|
|
74679
|
-
- **ASK YOURSELF for extensionsToModify**: "Does this extension need to be CHANGED or DELETED?" If YES \u2192 Put it in extensionsToModify
|
|
74680
|
-
- **ASK YOURSELF for contextExtensions**: "Does this extension already exist, relate to the request, but needs NO changes?" If YES \u2192 Put it in contextExtensions
|
|
74681
|
-
- **DO NOT INVENT FILE PATHS**: Only return file paths that exist in the "Extensions to Evaluate" list
|
|
74682
|
-
* If user wants to ADD a new feature that doesn't exist \u2192 return EMPTY ARRAY []
|
|
74683
|
-
* **Example**: User says "add shipping rates", only additional fees exists \u2192 return []
|
|
74684
|
-
* DO NOT invent paths like "src/backend/service-plugins/ecom-shipping-rates/..." if they don't exist
|
|
74685
|
-
- **relevantFiles MUST be non-empty AND must exist**: If you can't identify specific files that need changes, don't return the extension
|
|
74686
|
-
- **Precision over recall**: Avoid false positives - only include extensions if you're confident they need changes
|
|
74687
|
-
- **File scope**: Only consider files under src/ directory
|
|
74688
|
-
- **Efficiency**: Be strategic with tool calls - don't read unnecessary files
|
|
74689
|
-
- **Uncertainty**: If you're unsure about an extension, omit it from the results
|
|
74690
|
-
- **Output filtering**: For each extension, return only files that:
|
|
74691
|
-
* Belong to that specific extension (never mix files from different extensions)
|
|
74692
|
-
* Directly relate to the user's request
|
|
74693
|
-
* Actually need modification (not all files you read)
|
|
74694
|
-
* **EXIST in the provided extensions list** - never invent file paths
|
|
74695
|
-
- **SPI Matching (for SERVICE_PLUGIN extensions)**: If an extension uses a specific SPI (Service Provider Interface), understand that:
|
|
74696
|
-
* Each SPI handles a specific business domain (e.g., additional fees, shipping rates, product validation)
|
|
74697
|
-
* Different SPIs are NOT interchangeable - they serve different purposes
|
|
74698
|
-
* Only include an SPI extension if the user's request matches that specific SPI's domain
|
|
74699
|
-
* Example: If user wants to add fees using ecom.additionalFees.calculateAdditionalFees, don't include ecom.shippingRates.getShippingRates even if both mention "shipping"
|
|
74700
|
-
* Example: If user wants to add shipping rates using ecom.shippingRates.getShippingRates, don't include ecom.additionalFees.calculateAdditionalFees
|
|
74701
|
-
* Look at the actual SPI being used in the extension code to determine if it matches the user's intent`;
|
|
74702
|
-
exports2.extensionSelectorInstructions = {
|
|
74703
|
-
role: extensionSelectorRole,
|
|
74704
|
-
chatHistoryContext: extensionSelectorChatHistoryContext,
|
|
74705
|
-
commonScenariosDocumentation: extensionSelectorCommonScenariosDocumentation,
|
|
74706
|
-
quickDecisionGuide: extensionSelectorQuickDecisionGuide,
|
|
74707
|
-
availableTools: extensionSelectorAvailableTools,
|
|
74708
|
-
projectStructure: extensionSelectorProjectStructure,
|
|
74709
|
-
extensionTypeDocumentation: extensionSelectorExtensionTypeDocumentation,
|
|
74710
|
-
instructions: extensionSelectorInstructionsContent,
|
|
74711
|
-
constraints: extensionSelectorConstraints
|
|
74712
|
-
};
|
|
74713
|
-
}
|
|
74714
|
-
});
|
|
74715
|
-
|
|
74716
|
-
// dist/system-prompts/extension-selector/extension-selector-prompt.js
|
|
74717
|
-
var require_extension_selector_prompt = __commonJS({
|
|
74718
|
-
"dist/system-prompts/extension-selector/extension-selector-prompt.js"(exports2) {
|
|
74719
|
-
"use strict";
|
|
74720
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
74721
|
-
exports2.extensionSelectorPrompt = void 0;
|
|
74722
|
-
var codegen_common_logic_1 = require_dist9();
|
|
74723
|
-
var extension_selector_instructions_1 = require_extension_selector_instructions();
|
|
74724
|
-
var extensionSelectorPrompt = (extensionTypes, srcFolderStructure) => {
|
|
74725
|
-
const systemPrompt = (0, codegen_common_logic_1.systemPromptBuilder)({
|
|
74726
|
-
agentType: codegen_common_logic_1.GeneralAgentType.EXTENSION_SELECTOR
|
|
74727
|
-
}).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);
|
|
74728
|
-
return systemPrompt.compose();
|
|
74729
|
-
};
|
|
74730
|
-
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
|
+
}
|
|
74731
73870
|
}
|
|
74732
73871
|
});
|
|
74733
73872
|
|
|
@@ -75292,7 +74431,7 @@ var require_glob_parent = __commonJS({
|
|
|
75292
74431
|
});
|
|
75293
74432
|
|
|
75294
74433
|
// ../../node_modules/braces/lib/utils.js
|
|
75295
|
-
var
|
|
74434
|
+
var require_utils = __commonJS({
|
|
75296
74435
|
"../../node_modules/braces/lib/utils.js"(exports2) {
|
|
75297
74436
|
"use strict";
|
|
75298
74437
|
exports2.isInteger = (num) => {
|
|
@@ -75377,7 +74516,7 @@ var require_utils2 = __commonJS({
|
|
|
75377
74516
|
var require_stringify = __commonJS({
|
|
75378
74517
|
"../../node_modules/braces/lib/stringify.js"(exports2, module2) {
|
|
75379
74518
|
"use strict";
|
|
75380
|
-
var utils =
|
|
74519
|
+
var utils = require_utils();
|
|
75381
74520
|
module2.exports = (ast, options = {}) => {
|
|
75382
74521
|
const stringify = (node, parent = {}) => {
|
|
75383
74522
|
const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
|
@@ -75830,7 +74969,7 @@ var require_compile = __commonJS({
|
|
|
75830
74969
|
"../../node_modules/braces/lib/compile.js"(exports2, module2) {
|
|
75831
74970
|
"use strict";
|
|
75832
74971
|
var fill = require_fill_range();
|
|
75833
|
-
var utils =
|
|
74972
|
+
var utils = require_utils();
|
|
75834
74973
|
var compile = (ast, options = {}) => {
|
|
75835
74974
|
const walk = (node, parent = {}) => {
|
|
75836
74975
|
const invalidBlock = utils.isInvalidBrace(parent);
|
|
@@ -75883,7 +75022,7 @@ var require_expand = __commonJS({
|
|
|
75883
75022
|
"use strict";
|
|
75884
75023
|
var fill = require_fill_range();
|
|
75885
75024
|
var stringify = require_stringify();
|
|
75886
|
-
var utils =
|
|
75025
|
+
var utils = require_utils();
|
|
75887
75026
|
var append = (queue = "", stash = "", enclose = false) => {
|
|
75888
75027
|
const result = [];
|
|
75889
75028
|
queue = [].concat(queue);
|
|
@@ -75972,7 +75111,7 @@ var require_expand = __commonJS({
|
|
|
75972
75111
|
});
|
|
75973
75112
|
|
|
75974
75113
|
// ../../node_modules/braces/lib/constants.js
|
|
75975
|
-
var
|
|
75114
|
+
var require_constants2 = __commonJS({
|
|
75976
75115
|
"../../node_modules/braces/lib/constants.js"(exports2, module2) {
|
|
75977
75116
|
"use strict";
|
|
75978
75117
|
module2.exports = {
|
|
@@ -76105,7 +75244,7 @@ var require_parse3 = __commonJS({
|
|
|
76105
75244
|
/* ' */
|
|
76106
75245
|
CHAR_NO_BREAK_SPACE,
|
|
76107
75246
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
|
76108
|
-
} =
|
|
75247
|
+
} = require_constants2();
|
|
76109
75248
|
var parse = (input, options = {}) => {
|
|
76110
75249
|
if (typeof input !== "string") {
|
|
76111
75250
|
throw new TypeError("Expected a string");
|
|
@@ -76374,7 +75513,7 @@ var require_braces = __commonJS({
|
|
|
76374
75513
|
});
|
|
76375
75514
|
|
|
76376
75515
|
// ../../node_modules/picomatch/lib/constants.js
|
|
76377
|
-
var
|
|
75516
|
+
var require_constants3 = __commonJS({
|
|
76378
75517
|
"../../node_modules/picomatch/lib/constants.js"(exports2, module2) {
|
|
76379
75518
|
"use strict";
|
|
76380
75519
|
var path2 = require("path");
|
|
@@ -76571,7 +75710,7 @@ var require_constants4 = __commonJS({
|
|
|
76571
75710
|
});
|
|
76572
75711
|
|
|
76573
75712
|
// ../../node_modules/picomatch/lib/utils.js
|
|
76574
|
-
var
|
|
75713
|
+
var require_utils2 = __commonJS({
|
|
76575
75714
|
"../../node_modules/picomatch/lib/utils.js"(exports2) {
|
|
76576
75715
|
"use strict";
|
|
76577
75716
|
var path2 = require("path");
|
|
@@ -76581,7 +75720,7 @@ var require_utils3 = __commonJS({
|
|
|
76581
75720
|
REGEX_REMOVE_BACKSLASH,
|
|
76582
75721
|
REGEX_SPECIAL_CHARS,
|
|
76583
75722
|
REGEX_SPECIAL_CHARS_GLOBAL
|
|
76584
|
-
} =
|
|
75723
|
+
} = require_constants3();
|
|
76585
75724
|
exports2.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
76586
75725
|
exports2.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
76587
75726
|
exports2.isRegexChar = (str) => str.length === 1 && exports2.hasRegexChars(str);
|
|
@@ -76635,7 +75774,7 @@ var require_utils3 = __commonJS({
|
|
|
76635
75774
|
var require_scan = __commonJS({
|
|
76636
75775
|
"../../node_modules/picomatch/lib/scan.js"(exports2, module2) {
|
|
76637
75776
|
"use strict";
|
|
76638
|
-
var utils =
|
|
75777
|
+
var utils = require_utils2();
|
|
76639
75778
|
var {
|
|
76640
75779
|
CHAR_ASTERISK,
|
|
76641
75780
|
/* * */
|
|
@@ -76667,7 +75806,7 @@ var require_scan = __commonJS({
|
|
|
76667
75806
|
/* ) */
|
|
76668
75807
|
CHAR_RIGHT_SQUARE_BRACKET
|
|
76669
75808
|
/* ] */
|
|
76670
|
-
} =
|
|
75809
|
+
} = require_constants3();
|
|
76671
75810
|
var isPathSeparator = (code) => {
|
|
76672
75811
|
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
76673
75812
|
};
|
|
@@ -76965,8 +76104,8 @@ var require_scan = __commonJS({
|
|
|
76965
76104
|
var require_parse4 = __commonJS({
|
|
76966
76105
|
"../../node_modules/picomatch/lib/parse.js"(exports2, module2) {
|
|
76967
76106
|
"use strict";
|
|
76968
|
-
var constants =
|
|
76969
|
-
var utils =
|
|
76107
|
+
var constants = require_constants3();
|
|
76108
|
+
var utils = require_utils2();
|
|
76970
76109
|
var {
|
|
76971
76110
|
MAX_LENGTH,
|
|
76972
76111
|
POSIX_REGEX_SOURCE,
|
|
@@ -77741,8 +76880,8 @@ var require_picomatch = __commonJS({
|
|
|
77741
76880
|
var path2 = require("path");
|
|
77742
76881
|
var scan = require_scan();
|
|
77743
76882
|
var parse = require_parse4();
|
|
77744
|
-
var utils =
|
|
77745
|
-
var constants =
|
|
76883
|
+
var utils = require_utils2();
|
|
76884
|
+
var constants = require_constants3();
|
|
77746
76885
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
77747
76886
|
var picomatch = (glob, options, returnState = false) => {
|
|
77748
76887
|
if (Array.isArray(glob)) {
|
|
@@ -77890,7 +77029,7 @@ var require_micromatch = __commonJS({
|
|
|
77890
77029
|
var util = require("util");
|
|
77891
77030
|
var braces = require_braces();
|
|
77892
77031
|
var picomatch = require_picomatch2();
|
|
77893
|
-
var utils =
|
|
77032
|
+
var utils = require_utils2();
|
|
77894
77033
|
var isEmptyString = (v) => v === "" || v === "./";
|
|
77895
77034
|
var hasBraces = (v) => {
|
|
77896
77035
|
const index = v.indexOf("{");
|
|
@@ -78369,7 +77508,7 @@ var require_string = __commonJS({
|
|
|
78369
77508
|
});
|
|
78370
77509
|
|
|
78371
77510
|
// ../../node_modules/fast-glob/out/utils/index.js
|
|
78372
|
-
var
|
|
77511
|
+
var require_utils3 = __commonJS({
|
|
78373
77512
|
"../../node_modules/fast-glob/out/utils/index.js"(exports2) {
|
|
78374
77513
|
"use strict";
|
|
78375
77514
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -78397,7 +77536,7 @@ var require_tasks = __commonJS({
|
|
|
78397
77536
|
"use strict";
|
|
78398
77537
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
78399
77538
|
exports2.convertPatternGroupToTask = exports2.convertPatternGroupsToTasks = exports2.groupPatternsByBaseDirectory = exports2.getNegativePatternsAsPositive = exports2.getPositivePatterns = exports2.convertPatternsToTasks = exports2.generate = void 0;
|
|
78400
|
-
var utils =
|
|
77539
|
+
var utils = require_utils3();
|
|
78401
77540
|
function generate(input, settings) {
|
|
78402
77541
|
const patterns = processPatterns(input, settings);
|
|
78403
77542
|
const ignore = processPatterns(settings.ignore, settings);
|
|
@@ -78695,7 +77834,7 @@ var require_run_parallel = __commonJS({
|
|
|
78695
77834
|
});
|
|
78696
77835
|
|
|
78697
77836
|
// ../../node_modules/@nodelib/fs.scandir/out/constants.js
|
|
78698
|
-
var
|
|
77837
|
+
var require_constants4 = __commonJS({
|
|
78699
77838
|
"../../node_modules/@nodelib/fs.scandir/out/constants.js"(exports2) {
|
|
78700
77839
|
"use strict";
|
|
78701
77840
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -78740,7 +77879,7 @@ var require_fs3 = __commonJS({
|
|
|
78740
77879
|
});
|
|
78741
77880
|
|
|
78742
77881
|
// ../../node_modules/@nodelib/fs.scandir/out/utils/index.js
|
|
78743
|
-
var
|
|
77882
|
+
var require_utils4 = __commonJS({
|
|
78744
77883
|
"../../node_modules/@nodelib/fs.scandir/out/utils/index.js"(exports2) {
|
|
78745
77884
|
"use strict";
|
|
78746
77885
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -78774,8 +77913,8 @@ var require_async2 = __commonJS({
|
|
|
78774
77913
|
exports2.readdir = exports2.readdirWithFileTypes = exports2.read = void 0;
|
|
78775
77914
|
var fsStat = require_out();
|
|
78776
77915
|
var rpl = require_run_parallel();
|
|
78777
|
-
var constants_1 =
|
|
78778
|
-
var utils =
|
|
77916
|
+
var constants_1 = require_constants4();
|
|
77917
|
+
var utils = require_utils4();
|
|
78779
77918
|
var common = require_common();
|
|
78780
77919
|
function read(directory, settings, callback) {
|
|
78781
77920
|
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
|
|
@@ -78883,8 +78022,8 @@ var require_sync3 = __commonJS({
|
|
|
78883
78022
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
78884
78023
|
exports2.readdir = exports2.readdirWithFileTypes = exports2.read = void 0;
|
|
78885
78024
|
var fsStat = require_out();
|
|
78886
|
-
var constants_1 =
|
|
78887
|
-
var utils =
|
|
78025
|
+
var constants_1 = require_constants4();
|
|
78026
|
+
var utils = require_utils4();
|
|
78888
78027
|
var common = require_common();
|
|
78889
78028
|
function read(directory, settings) {
|
|
78890
78029
|
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
|
|
@@ -79708,7 +78847,7 @@ var require_reader2 = __commonJS({
|
|
|
79708
78847
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
79709
78848
|
var path2 = require("path");
|
|
79710
78849
|
var fsStat = require_out();
|
|
79711
|
-
var utils =
|
|
78850
|
+
var utils = require_utils3();
|
|
79712
78851
|
var Reader = class {
|
|
79713
78852
|
constructor(_settings) {
|
|
79714
78853
|
this._settings = _settings;
|
|
@@ -79841,7 +78980,7 @@ var require_matcher = __commonJS({
|
|
|
79841
78980
|
"../../node_modules/fast-glob/out/providers/matchers/matcher.js"(exports2) {
|
|
79842
78981
|
"use strict";
|
|
79843
78982
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
79844
|
-
var utils =
|
|
78983
|
+
var utils = require_utils3();
|
|
79845
78984
|
var Matcher = class {
|
|
79846
78985
|
constructor(_patterns, _settings, _micromatchOptions) {
|
|
79847
78986
|
this._patterns = _patterns;
|
|
@@ -79929,7 +79068,7 @@ var require_deep = __commonJS({
|
|
|
79929
79068
|
"../../node_modules/fast-glob/out/providers/filters/deep.js"(exports2) {
|
|
79930
79069
|
"use strict";
|
|
79931
79070
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
79932
|
-
var utils =
|
|
79071
|
+
var utils = require_utils3();
|
|
79933
79072
|
var partial_1 = require_partial();
|
|
79934
79073
|
var DeepFilter = class {
|
|
79935
79074
|
constructor(_settings, _micromatchOptions) {
|
|
@@ -79994,7 +79133,7 @@ var require_entry = __commonJS({
|
|
|
79994
79133
|
"../../node_modules/fast-glob/out/providers/filters/entry.js"(exports2) {
|
|
79995
79134
|
"use strict";
|
|
79996
79135
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
79997
|
-
var utils =
|
|
79136
|
+
var utils = require_utils3();
|
|
79998
79137
|
var EntryFilter = class {
|
|
79999
79138
|
constructor(_settings, _micromatchOptions) {
|
|
80000
79139
|
this._settings = _settings;
|
|
@@ -80082,7 +79221,7 @@ var require_error = __commonJS({
|
|
|
80082
79221
|
"../../node_modules/fast-glob/out/providers/filters/error.js"(exports2) {
|
|
80083
79222
|
"use strict";
|
|
80084
79223
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
80085
|
-
var utils =
|
|
79224
|
+
var utils = require_utils3();
|
|
80086
79225
|
var ErrorFilter = class {
|
|
80087
79226
|
constructor(_settings) {
|
|
80088
79227
|
this._settings = _settings;
|
|
@@ -80103,7 +79242,7 @@ var require_entry2 = __commonJS({
|
|
|
80103
79242
|
"../../node_modules/fast-glob/out/providers/transformers/entry.js"(exports2) {
|
|
80104
79243
|
"use strict";
|
|
80105
79244
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
80106
|
-
var utils =
|
|
79245
|
+
var utils = require_utils3();
|
|
80107
79246
|
var EntryTransformer = class {
|
|
80108
79247
|
constructor(_settings) {
|
|
80109
79248
|
this._settings = _settings;
|
|
@@ -80393,7 +79532,7 @@ var require_out4 = __commonJS({
|
|
|
80393
79532
|
var stream_1 = require_stream5();
|
|
80394
79533
|
var sync_1 = require_sync7();
|
|
80395
79534
|
var settings_1 = require_settings4();
|
|
80396
|
-
var utils =
|
|
79535
|
+
var utils = require_utils3();
|
|
80397
79536
|
async function FastGlob(source, options) {
|
|
80398
79537
|
assertPatternsInput2(source);
|
|
80399
79538
|
const works = getWorks(source, async_1.default, options);
|
|
@@ -81687,12 +80826,49 @@ var require_editFile = __commonJS({
|
|
|
81687
80826
|
}
|
|
81688
80827
|
});
|
|
81689
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
|
+
|
|
81690
80866
|
// dist/tools/index.js
|
|
81691
|
-
var
|
|
80867
|
+
var require_tools = __commonJS({
|
|
81692
80868
|
"dist/tools/index.js"(exports2) {
|
|
81693
80869
|
"use strict";
|
|
81694
80870
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
81695
|
-
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;
|
|
81696
80872
|
var readFile_1 = require_readFile();
|
|
81697
80873
|
Object.defineProperty(exports2, "createReadFileTool", { enumerable: true, get: function() {
|
|
81698
80874
|
return readFile_1.createReadFileTool;
|
|
@@ -81713,6 +80889,10 @@ var require_tools2 = __commonJS({
|
|
|
81713
80889
|
Object.defineProperty(exports2, "createEditFileTool", { enumerable: true, get: function() {
|
|
81714
80890
|
return editFile_1.createEditFileTool;
|
|
81715
80891
|
} });
|
|
80892
|
+
var submitPlanIteration_1 = require_submitPlanIteration();
|
|
80893
|
+
Object.defineProperty(exports2, "createSubmitPlanTool", { enumerable: true, get: function() {
|
|
80894
|
+
return submitPlanIteration_1.createSubmitIterationPlanTool;
|
|
80895
|
+
} });
|
|
81716
80896
|
var TOOL_NAMES;
|
|
81717
80897
|
(function(TOOL_NAMES2) {
|
|
81718
80898
|
TOOL_NAMES2["READ_FILE"] = "read_file";
|
|
@@ -81724,145 +80904,781 @@ var require_tools2 = __commonJS({
|
|
|
81724
80904
|
}
|
|
81725
80905
|
});
|
|
81726
80906
|
|
|
81727
|
-
// dist/agents/Iteration/
|
|
81728
|
-
var
|
|
81729
|
-
"dist/agents/Iteration/
|
|
80907
|
+
// dist/agents/Iteration/IterationAgent.js
|
|
80908
|
+
var require_IterationAgent = __commonJS({
|
|
80909
|
+
"dist/agents/Iteration/IterationAgent.js"(exports2) {
|
|
81730
80910
|
"use strict";
|
|
81731
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
81732
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
81733
|
-
};
|
|
81734
80911
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
81735
|
-
exports2.
|
|
80912
|
+
exports2.IterationAgent = void 0;
|
|
81736
80913
|
var ai_1 = require_dist8();
|
|
81737
|
-
var
|
|
81738
|
-
var
|
|
81739
|
-
var path_1 = __importDefault2(require("path"));
|
|
81740
|
-
var tree_node_cli_1 = __importDefault2(require_src());
|
|
80914
|
+
var iteration_agent_prompt_1 = require_iteration_agent_prompt();
|
|
80915
|
+
var AgentsRegistry_1 = require_AgentsRegistry();
|
|
81741
80916
|
var ditto_codegen_types_12 = require_dist();
|
|
81742
|
-
var
|
|
81743
|
-
var ditto_codegen_types_2 = require_dist();
|
|
80917
|
+
var constants_1 = require_constants();
|
|
81744
80918
|
var contextBuilders_1 = require_contextBuilders();
|
|
81745
|
-
var extensionFormatters_1 = require_extensionFormatters();
|
|
81746
|
-
var dedent_1 = __importDefault2(require_dedent());
|
|
81747
80919
|
var customAnthropicProvider_1 = require_customAnthropicProvider();
|
|
81748
|
-
var
|
|
81749
|
-
var
|
|
81750
|
-
var
|
|
81751
|
-
READ_FILE: "read_file",
|
|
81752
|
-
SUBMIT_EVALUATION: "submit_evaluation"
|
|
81753
|
-
};
|
|
81754
|
-
var ExtensionSelectorAgent = class {
|
|
80920
|
+
var tools_1 = require_tools();
|
|
80921
|
+
var SUBMIT_PLAN_TOOL_NAME = "submit_plan";
|
|
80922
|
+
var IterationAgent = class {
|
|
81755
80923
|
constructor() {
|
|
81756
|
-
this.name = "
|
|
80924
|
+
this.name = "IterationAgent";
|
|
81757
80925
|
}
|
|
81758
|
-
buildSystemPrompt(
|
|
81759
|
-
return (0,
|
|
80926
|
+
buildSystemPrompt() {
|
|
80927
|
+
return (0, iteration_agent_prompt_1.iterationAgentPrompt)();
|
|
81760
80928
|
}
|
|
81761
|
-
|
|
81762
|
-
const
|
|
81763
|
-
if (!
|
|
81764
|
-
|
|
81765
|
-
}
|
|
81766
|
-
try {
|
|
81767
|
-
return (0, tree_node_cli_1.default)(srcPath, {
|
|
81768
|
-
allFiles: true,
|
|
81769
|
-
maxDepth: 10
|
|
81770
|
-
});
|
|
81771
|
-
} catch (error) {
|
|
81772
|
-
console.error("Error generating src folder structure:", error);
|
|
81773
|
-
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");
|
|
81774
80933
|
}
|
|
80934
|
+
return submitCall.input;
|
|
81775
80935
|
}
|
|
81776
|
-
|
|
81777
|
-
|
|
81778
|
-
|
|
81779
|
-
|
|
81780
|
-
|
|
81781
|
-
|
|
81782
|
-
|
|
81783
|
-
|
|
81784
|
-
type: zod_1.z.enum(allowedExtensionTypes).describe("Extension type"),
|
|
81785
|
-
reasoning: zod_1.z.string().describe("Why this is relevant for context")
|
|
81786
|
-
})).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
|
|
81787
80944
|
});
|
|
81788
80945
|
}
|
|
81789
|
-
|
|
80946
|
+
generateExtensionObject(extensionType, name, relevantUserRequest, relatedSpis) {
|
|
81790
80947
|
return {
|
|
81791
|
-
|
|
81792
|
-
|
|
81793
|
-
|
|
80948
|
+
type: this.mapExtensionType(extensionType),
|
|
80949
|
+
name,
|
|
80950
|
+
description: relevantUserRequest,
|
|
80951
|
+
relatedSpis: relatedSpis?.map((spi) => ({
|
|
80952
|
+
name: spi,
|
|
80953
|
+
purpose: ""
|
|
80954
|
+
})) || []
|
|
81794
80955
|
};
|
|
81795
80956
|
}
|
|
81796
|
-
|
|
81797
|
-
const
|
|
81798
|
-
if (!submitCall) {
|
|
81799
|
-
console.error("No submit_evaluation tool call found");
|
|
81800
|
-
return null;
|
|
81801
|
-
}
|
|
81802
|
-
return submitCall.input;
|
|
81803
|
-
}
|
|
81804
|
-
buildUserPrompt({ chatHistory, currentUserRequest, previousResources, extensions, outputPath }) {
|
|
81805
|
-
const sections = (0, contextBuilders_1.buildContextSections)(chatHistory, currentUserRequest, previousResources);
|
|
81806
|
-
sections.push(`
|
|
81807
|
-
Extensions to Evaluate:
|
|
81808
|
-
${(0, extensionFormatters_1.formatScannedExtensions)(extensions, outputPath)}`);
|
|
80957
|
+
buildUserPrompt({ chatHistory, currentUserRequest, previousResources, srcFolderStructure }) {
|
|
80958
|
+
const sections = (0, contextBuilders_1.buildContextSections)(chatHistory, currentUserRequest, previousResources, srcFolderStructure);
|
|
81809
80959
|
return sections.join("\n\n");
|
|
81810
80960
|
}
|
|
81811
|
-
async generate({
|
|
81812
|
-
const
|
|
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
|
+
});
|
|
81813
80969
|
try {
|
|
81814
|
-
const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.
|
|
80970
|
+
const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929, {
|
|
81815
80971
|
agentName: this.name
|
|
81816
80972
|
});
|
|
81817
|
-
const userContent = this.buildUserPrompt({
|
|
81818
|
-
chatHistory,
|
|
81819
|
-
currentUserRequest,
|
|
81820
|
-
previousResources,
|
|
81821
|
-
extensions,
|
|
81822
|
-
outputPath
|
|
81823
|
-
});
|
|
81824
|
-
const extensionTypes = extensions.map((extension) => extension.type);
|
|
81825
|
-
if (extensionTypes.length === 0) {
|
|
81826
|
-
return { extensionsToModify: [], contextExtensions: [] };
|
|
81827
|
-
}
|
|
81828
|
-
const systemPrompt = this.buildSystemPrompt({
|
|
81829
|
-
extensionTypes,
|
|
81830
|
-
srcStructure
|
|
81831
|
-
});
|
|
81832
80973
|
const result = await (0, ai_1.generateText)({
|
|
81833
80974
|
model,
|
|
81834
80975
|
tools: {
|
|
81835
|
-
[TOOL_NAMES.READ_FILE]: (0, tools_1.createReadFileTool)(outputPath),
|
|
81836
|
-
[TOOL_NAMES.
|
|
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)()
|
|
81837
80980
|
},
|
|
81838
80981
|
stopWhen: ({ steps }) => {
|
|
81839
80982
|
const lastStep = steps[steps.length - 1];
|
|
81840
|
-
return lastStep?.toolCalls.some((toolCall) => toolCall.toolName ===
|
|
80983
|
+
return lastStep?.toolCalls.some((toolCall) => toolCall.toolName === SUBMIT_PLAN_TOOL_NAME && !("invalid" in toolCall) && !("error" in toolCall)) ?? false;
|
|
81841
80984
|
},
|
|
81842
80985
|
messages: [
|
|
81843
80986
|
{
|
|
81844
80987
|
role: "system",
|
|
81845
|
-
content:
|
|
80988
|
+
content: this.buildSystemPrompt(),
|
|
81846
80989
|
providerOptions: (0, ditto_codegen_types_12.withCaching)("1h")
|
|
81847
80990
|
},
|
|
81848
|
-
{ role: "user", content:
|
|
80991
|
+
{ role: "user", content: userMessage }
|
|
81849
80992
|
],
|
|
81850
80993
|
maxRetries: 3,
|
|
81851
80994
|
temperature: 0,
|
|
81852
80995
|
experimental_telemetry: { isEnabled: true, functionId: this.name }
|
|
81853
80996
|
});
|
|
81854
|
-
const
|
|
81855
|
-
console.log("
|
|
81856
|
-
|
|
81857
|
-
|
|
81858
|
-
|
|
81859
|
-
|
|
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;
|
|
81860
81010
|
} catch (error) {
|
|
81861
|
-
throw (0,
|
|
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;
|
|
81862
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;
|
|
81863
81119
|
}
|
|
81864
81120
|
};
|
|
81865
|
-
exports2.
|
|
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
|
+
});
|
|
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
|
+
`;
|
|
81679
|
+
}
|
|
81680
|
+
};
|
|
81681
|
+
exports2.AutoPatternsGenerator = AutoPatternsGenerator;
|
|
81866
81682
|
}
|
|
81867
81683
|
});
|
|
81868
81684
|
|
|
@@ -90779,7 +90595,7 @@ var require_data2 = __commonJS({
|
|
|
90779
90595
|
});
|
|
90780
90596
|
|
|
90781
90597
|
// ../../node_modules/fast-uri/lib/utils.js
|
|
90782
|
-
var
|
|
90598
|
+
var require_utils5 = __commonJS({
|
|
90783
90599
|
"../../node_modules/fast-uri/lib/utils.js"(exports2, module2) {
|
|
90784
90600
|
"use strict";
|
|
90785
90601
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
@@ -91039,7 +90855,7 @@ var require_utils6 = __commonJS({
|
|
|
91039
90855
|
var require_schemes = __commonJS({
|
|
91040
90856
|
"../../node_modules/fast-uri/lib/schemes.js"(exports2, module2) {
|
|
91041
90857
|
"use strict";
|
|
91042
|
-
var { isUUID } =
|
|
90858
|
+
var { isUUID } = require_utils5();
|
|
91043
90859
|
var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
91044
90860
|
var supportedSchemeNames = (
|
|
91045
90861
|
/** @type {const} */
|
|
@@ -91249,7 +91065,7 @@ var require_schemes = __commonJS({
|
|
|
91249
91065
|
var require_fast_uri = __commonJS({
|
|
91250
91066
|
"../../node_modules/fast-uri/index.js"(exports2, module2) {
|
|
91251
91067
|
"use strict";
|
|
91252
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } =
|
|
91068
|
+
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils5();
|
|
91253
91069
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
91254
91070
|
function normalize(uri, options) {
|
|
91255
91071
|
if (typeof uri === "string") {
|
|
@@ -96578,6 +96394,107 @@ var require_dist14 = __commonJS({
|
|
|
96578
96394
|
}
|
|
96579
96395
|
});
|
|
96580
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
|
+
|
|
96581
96498
|
// dist/agents/Iteration/SDKPicker/SDKPickerAgent.js
|
|
96582
96499
|
var require_SDKPickerAgent2 = __commonJS({
|
|
96583
96500
|
"dist/agents/Iteration/SDKPicker/SDKPickerAgent.js"(exports2) {
|
|
@@ -96829,7 +96746,7 @@ var require_ExtensionIndexerAgent = __commonJS({
|
|
|
96829
96746
|
var ditto_codegen_types_12 = require_dist();
|
|
96830
96747
|
var constants_1 = require_constants();
|
|
96831
96748
|
var customAnthropicProvider_1 = require_customAnthropicProvider();
|
|
96832
|
-
var tools_1 =
|
|
96749
|
+
var tools_1 = require_tools();
|
|
96833
96750
|
var tree_node_cli_1 = __importDefault2(require_src());
|
|
96834
96751
|
var path_1 = __importDefault2(require("path"));
|
|
96835
96752
|
var fs_1 = __importDefault2(require("fs"));
|
|
@@ -96915,7 +96832,6 @@ var require_AgentsFactory = __commonJS({
|
|
|
96915
96832
|
var IterationAgent_1 = require_IterationAgent();
|
|
96916
96833
|
var DashboardDecisionAgent_1 = require_DashboardDecisionAgent();
|
|
96917
96834
|
var AutoPatternsGenerator_1 = require_AutoPatternsGenerator();
|
|
96918
|
-
var ExtensionSelectorAgent_1 = require_ExtensionSelectorAgent();
|
|
96919
96835
|
var AgentsRegistry_1 = require_AgentsRegistry();
|
|
96920
96836
|
var ditto_codegen_types_12 = require_dist();
|
|
96921
96837
|
var SDKPickerAgent_1 = require_SDKPickerAgent2();
|
|
@@ -96949,8 +96865,6 @@ var require_AgentsFactory = __commonJS({
|
|
|
96949
96865
|
return new DashboardDecisionAgent_1.DashboardDecisionAgent();
|
|
96950
96866
|
case "AUTO_PATTERNS_GENERATOR":
|
|
96951
96867
|
return new AutoPatternsGenerator_1.AutoPatternsGenerator();
|
|
96952
|
-
case "EXTENSION_SELECTOR":
|
|
96953
|
-
return new ExtensionSelectorAgent_1.ExtensionSelectorAgent();
|
|
96954
96868
|
case "SDK_PICKER":
|
|
96955
96869
|
return new SDKPickerAgent_1.SDKPickerAgent();
|
|
96956
96870
|
case "EXTENSION_INDEXER":
|
|
@@ -320726,6 +320640,7 @@ var require_extension = __commonJS({
|
|
|
320726
320640
|
var fs_1 = __importDefault2(require("fs"));
|
|
320727
320641
|
var extensionAst_1 = require_extensionAst();
|
|
320728
320642
|
var EXTENSIONS_FILENAME = "extensions.ts";
|
|
320643
|
+
var EXTENSION_FILE_PATTERN = "*.extension.ts";
|
|
320729
320644
|
function getSrcDir(outputPath) {
|
|
320730
320645
|
return path_1.default.join(outputPath, "src");
|
|
320731
320646
|
}
|
|
@@ -320740,7 +320655,10 @@ var require_extension = __commonJS({
|
|
|
320740
320655
|
async function findExtensionFiles(srcDir) {
|
|
320741
320656
|
const { globby: globby2 } = await Promise.resolve().then(() => (init_globby(), globby_exports));
|
|
320742
320657
|
const aggregatorFilePath = path_1.default.join(srcDir, EXTENSIONS_FILENAME);
|
|
320743
|
-
const allExtensionFiles = await globby2(
|
|
320658
|
+
const allExtensionFiles = await globby2([
|
|
320659
|
+
`${srcDir}/**/${EXTENSIONS_FILENAME}`,
|
|
320660
|
+
`${srcDir}/**/${EXTENSION_FILE_PATTERN}`
|
|
320661
|
+
], {
|
|
320744
320662
|
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
320745
320663
|
});
|
|
320746
320664
|
return allExtensionFiles.filter((f) => path_1.default.resolve(f) !== path_1.default.resolve(aggregatorFilePath));
|
|
@@ -321062,21 +320980,11 @@ var require_IterationOrchestrator = __commonJS({
|
|
|
321062
320980
|
type: "ITERATION_AGENT"
|
|
321063
320981
|
});
|
|
321064
320982
|
const { currentUserRequest, filteredChatHistory } = this.extractUserRequestAndFilteredHistory(chatHistory);
|
|
321065
|
-
const extensionSelectorAgent = this.agentsFactory.getAgent({
|
|
321066
|
-
type: "EXTENSION_SELECTOR"
|
|
321067
|
-
});
|
|
321068
|
-
const extensionSelectorResult = await extensionSelectorAgent.generate({
|
|
321069
|
-
outputPath,
|
|
321070
|
-
extensions,
|
|
321071
|
-
chatHistory: filteredChatHistory,
|
|
321072
|
-
currentUserRequest,
|
|
321073
|
-
previousResources
|
|
321074
|
-
});
|
|
321075
320983
|
const iterationPlan = await iterationAgent.generate({
|
|
321076
320984
|
currentUserRequest,
|
|
321077
320985
|
chatHistory: filteredChatHistory,
|
|
321078
|
-
|
|
321079
|
-
|
|
320986
|
+
previousResources,
|
|
320987
|
+
outputPath
|
|
321080
320988
|
});
|
|
321081
320989
|
this.validateEmbeddedScriptConstraint(extensions, iterationPlan);
|
|
321082
320990
|
const sdkPickerAgent = this.agentsFactory.getAgent({ type: "SDK_PICKER" });
|