@wix/ditto-codegen-public 1.0.256 → 1.0.258
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 +431 -139
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -48388,17 +48388,81 @@ var require_DittoEventEmitter = __commonJS({
|
|
|
48388
48388
|
}
|
|
48389
48389
|
});
|
|
48390
48390
|
|
|
48391
|
-
// dist/opencode-integration/
|
|
48392
|
-
var
|
|
48393
|
-
"dist/opencode-integration/
|
|
48391
|
+
// dist/opencode-integration/types.js
|
|
48392
|
+
var require_types5 = __commonJS({
|
|
48393
|
+
"dist/opencode-integration/types.js"(exports2) {
|
|
48394
|
+
"use strict";
|
|
48395
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
48396
|
+
exports2.ASK_MODE = void 0;
|
|
48397
|
+
exports2.tryParseJson = tryParseJson;
|
|
48398
|
+
exports2.ASK_MODE = "ask";
|
|
48399
|
+
function tryParseJson(text) {
|
|
48400
|
+
try {
|
|
48401
|
+
return JSON.parse(text);
|
|
48402
|
+
} catch {
|
|
48403
|
+
return null;
|
|
48404
|
+
}
|
|
48405
|
+
}
|
|
48406
|
+
}
|
|
48407
|
+
});
|
|
48408
|
+
|
|
48409
|
+
// dist/opencode-integration/prompts/prompt-utils.js
|
|
48410
|
+
var require_prompt_utils = __commonJS({
|
|
48411
|
+
"dist/opencode-integration/prompts/prompt-utils.js"(exports2) {
|
|
48394
48412
|
"use strict";
|
|
48395
48413
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
48396
48414
|
exports2.buildAppContext = buildAppContext;
|
|
48397
48415
|
exports2.extractUserRequestAndFilteredHistory = extractUserRequestAndFilteredHistory;
|
|
48416
|
+
exports2.formatChatHistory = formatChatHistory;
|
|
48417
|
+
exports2.formatFilesList = formatFilesList;
|
|
48418
|
+
function buildAppContext() {
|
|
48419
|
+
const appNamespace = process.env.APP_NAMESPACE;
|
|
48420
|
+
const codeIdentifier = process.env.CODE_IDENTIFIER;
|
|
48421
|
+
const parts = [];
|
|
48422
|
+
if (appNamespace) {
|
|
48423
|
+
parts.push(`APP_NAMESPACE: ${appNamespace}
|
|
48424
|
+
Use this namespace when creating data collections (for idSuffix scoping).`);
|
|
48425
|
+
}
|
|
48426
|
+
if (codeIdentifier) {
|
|
48427
|
+
parts.push(`CODE_IDENTIFIER: ${codeIdentifier}
|
|
48428
|
+
If generating site component extensions, use this identifier as the type prefix (e.g. type: '${codeIdentifier}.ComponentName').`);
|
|
48429
|
+
}
|
|
48430
|
+
return parts.join("\n\n");
|
|
48431
|
+
}
|
|
48432
|
+
function extractUserRequestAndFilteredHistory(chatHistory) {
|
|
48433
|
+
const lastUserMessage = [...chatHistory].reverse().find((msg) => msg.role === "USER");
|
|
48434
|
+
return {
|
|
48435
|
+
currentUserRequest: lastUserMessage?.text || "",
|
|
48436
|
+
filteredChatHistory: chatHistory.filter((msg) => msg.text.length > 0)
|
|
48437
|
+
};
|
|
48438
|
+
}
|
|
48439
|
+
function formatChatHistory(history, label) {
|
|
48440
|
+
if (!history || history.length === 0) {
|
|
48441
|
+
return "";
|
|
48442
|
+
}
|
|
48443
|
+
const lines = history.map((msg) => `${msg.role.toUpperCase()}: ${msg.text}`).join("\n\n");
|
|
48444
|
+
return `${label}:
|
|
48445
|
+
${lines}`;
|
|
48446
|
+
}
|
|
48447
|
+
function formatFilesList(filesChanged) {
|
|
48448
|
+
if (filesChanged.length === 0) {
|
|
48449
|
+
return "No files were tracked as changed.";
|
|
48450
|
+
}
|
|
48451
|
+
return filesChanged.map((f) => `- ${f.path} (${f.operation})`).join("\n");
|
|
48452
|
+
}
|
|
48453
|
+
}
|
|
48454
|
+
});
|
|
48455
|
+
|
|
48456
|
+
// dist/opencode-integration/prompts/codegen-prompt.js
|
|
48457
|
+
var require_codegen_prompt = __commonJS({
|
|
48458
|
+
"dist/opencode-integration/prompts/codegen-prompt.js"(exports2) {
|
|
48459
|
+
"use strict";
|
|
48460
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
48398
48461
|
exports2.buildInitPrompt = buildInitPrompt;
|
|
48399
48462
|
exports2.buildIterationBasePrompt = buildIterationBasePrompt;
|
|
48400
48463
|
exports2.buildIterationPrompt = buildIterationPrompt;
|
|
48401
48464
|
exports2.buildRecoveryPrompt = buildRecoveryPrompt;
|
|
48465
|
+
var prompt_utils_1 = require_prompt_utils();
|
|
48402
48466
|
var BASE_PROMPT_INSTRUCTIONS = `CORE PRINCIPLES:
|
|
48403
48467
|
- Do NOT invent or assume new types, modules, functions, props, events, or imports
|
|
48404
48468
|
- NEVER use mocks, placeholders, debugging, or TODOs in any code
|
|
@@ -48447,52 +48511,17 @@ If no permissions are required, output an empty array:
|
|
|
48447
48511
|
\`\`\`json:required-permissions
|
|
48448
48512
|
[]
|
|
48449
48513
|
\`\`\``;
|
|
48450
|
-
function buildAppContext() {
|
|
48451
|
-
const appNamespace = process.env.APP_NAMESPACE;
|
|
48452
|
-
const codeIdentifier = process.env.CODE_IDENTIFIER;
|
|
48453
|
-
const parts = [];
|
|
48454
|
-
if (appNamespace) {
|
|
48455
|
-
parts.push(`APP_NAMESPACE: ${appNamespace}
|
|
48456
|
-
Use this namespace when creating data collections (for idSuffix scoping).`);
|
|
48457
|
-
}
|
|
48458
|
-
if (codeIdentifier) {
|
|
48459
|
-
parts.push(`CODE_IDENTIFIER: ${codeIdentifier}
|
|
48460
|
-
If generating site component extensions, use this identifier as the type prefix (e.g. type: '${codeIdentifier}.ComponentName').`);
|
|
48461
|
-
}
|
|
48462
|
-
return parts.join("\n\n");
|
|
48463
|
-
}
|
|
48464
48514
|
function buildPrompt(...sections) {
|
|
48465
|
-
return [...sections, buildAppContext(), BASE_PROMPT_INSTRUCTIONS].filter(Boolean).join("\n\n");
|
|
48466
|
-
}
|
|
48467
|
-
function extractUserRequestAndFilteredHistory(chatHistory) {
|
|
48468
|
-
const lastUserMessage = [...chatHistory].reverse().find((msg) => msg.role === "USER");
|
|
48469
|
-
return {
|
|
48470
|
-
currentUserRequest: lastUserMessage?.text || "",
|
|
48471
|
-
filteredChatHistory: chatHistory.filter((msg) => msg.text.length > 0)
|
|
48472
|
-
};
|
|
48473
|
-
}
|
|
48474
|
-
function formatChatHistory(history, label) {
|
|
48475
|
-
if (!history || history.length === 0) {
|
|
48476
|
-
return "";
|
|
48477
|
-
}
|
|
48478
|
-
const lines = history.map((msg) => `${msg.role.toUpperCase()}: ${msg.text}`).join("\n\n");
|
|
48479
|
-
return `${label}:
|
|
48480
|
-
${lines}`;
|
|
48481
|
-
}
|
|
48482
|
-
function formatFilesList(filesChanged) {
|
|
48483
|
-
if (filesChanged.length === 0) {
|
|
48484
|
-
return "No files were tracked as changed.";
|
|
48485
|
-
}
|
|
48486
|
-
return filesChanged.map((f) => `- ${f.path} (${f.operation})`).join("\n");
|
|
48515
|
+
return [...sections, (0, prompt_utils_1.buildAppContext)(), BASE_PROMPT_INSTRUCTIONS].filter(Boolean).join("\n\n");
|
|
48487
48516
|
}
|
|
48488
48517
|
function buildInitPrompt(blueprint, history) {
|
|
48489
48518
|
const blueprintJson = JSON.stringify({ blueprint }, null, 2);
|
|
48490
48519
|
return buildPrompt(`Generate the extensions from this blueprint.
|
|
48491
48520
|
|
|
48492
|
-
${blueprintJson}`, formatChatHistory(history, "CONVERSATION HISTORY"));
|
|
48521
|
+
${blueprintJson}`, (0, prompt_utils_1.formatChatHistory)(history, "CONVERSATION HISTORY"));
|
|
48493
48522
|
}
|
|
48494
48523
|
function buildIterationBasePrompt(chatHistory) {
|
|
48495
|
-
const { currentUserRequest } = extractUserRequestAndFilteredHistory(chatHistory);
|
|
48524
|
+
const { currentUserRequest } = (0, prompt_utils_1.extractUserRequestAndFilteredHistory)(chatHistory);
|
|
48496
48525
|
if (!currentUserRequest) {
|
|
48497
48526
|
return "Continue iterating on the existing code.";
|
|
48498
48527
|
}
|
|
@@ -48501,7 +48530,7 @@ ${blueprintJson}`, formatChatHistory(history, "CONVERSATION HISTORY"));
|
|
|
48501
48530
|
|
|
48502
48531
|
You MUST fulfill the latest user request above. If the user is asking to CREATE something new (like a new page, widget, or extension), you must CREATE it - do not just modify existing code.
|
|
48503
48532
|
|
|
48504
|
-
${formatChatHistory(recentHistory, "CONVERSATION CONTEXT")}
|
|
48533
|
+
${(0, prompt_utils_1.formatChatHistory)(recentHistory, "CONVERSATION CONTEXT")}
|
|
48505
48534
|
|
|
48506
48535
|
INSTRUCTIONS:
|
|
48507
48536
|
1. Read the latest user request carefully
|
|
@@ -48519,7 +48548,7 @@ ORIGINAL TASK:
|
|
|
48519
48548
|
${originalPrompt}
|
|
48520
48549
|
|
|
48521
48550
|
FILES ALREADY CHANGED IN THE PREVIOUS SESSION:
|
|
48522
|
-
${formatFilesList(filesChanged)}
|
|
48551
|
+
${(0, prompt_utils_1.formatFilesList)(filesChanged)}
|
|
48523
48552
|
|
|
48524
48553
|
PREVIOUS SESSION ERROR:
|
|
48525
48554
|
${error48}
|
|
@@ -48533,6 +48562,67 @@ INSTRUCTIONS:
|
|
|
48533
48562
|
}
|
|
48534
48563
|
});
|
|
48535
48564
|
|
|
48565
|
+
// dist/opencode-integration/prompts/ask-prompt.js
|
|
48566
|
+
var require_ask_prompt = __commonJS({
|
|
48567
|
+
"dist/opencode-integration/prompts/ask-prompt.js"(exports2) {
|
|
48568
|
+
"use strict";
|
|
48569
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
48570
|
+
exports2.buildAskPrompt = buildAskPrompt;
|
|
48571
|
+
var prompt_utils_1 = require_prompt_utils();
|
|
48572
|
+
var ASK_PROMPT_INSTRUCTIONS = `CORE PRINCIPLES:
|
|
48573
|
+
- You are a READ-ONLY assistant. You MUST NOT modify, create, or delete any files.
|
|
48574
|
+
- Your job is to answer questions about the codebase and Wix platform by reading code and fetching documentation.
|
|
48575
|
+
- Use the read tool to explore the codebase and find relevant code.
|
|
48576
|
+
- Use the wix-mcp tools to fetch Wix SDK/API documentation when needed.
|
|
48577
|
+
- Provide clear, accurate, and well-structured answers.
|
|
48578
|
+
|
|
48579
|
+
IMPORTANT INSTRUCTIONS:
|
|
48580
|
+
1. Do NOT edit, write, or create any files.
|
|
48581
|
+
2. Do NOT run any bash commands.
|
|
48582
|
+
3. READ the codebase to understand the code structure and find answers.
|
|
48583
|
+
4. Use MCP tools to look up Wix documentation when the question involves Wix APIs, SDKs, or platform features.
|
|
48584
|
+
5. If you cannot find a definitive answer, say so clearly and explain what you found.`;
|
|
48585
|
+
function buildAskPrompt(chatHistory) {
|
|
48586
|
+
const { currentUserRequest } = (0, prompt_utils_1.extractUserRequestAndFilteredHistory)(chatHistory);
|
|
48587
|
+
if (!currentUserRequest) {
|
|
48588
|
+
return [ASK_PROMPT_INSTRUCTIONS, (0, prompt_utils_1.buildAppContext)()].filter(Boolean).join("\n\n");
|
|
48589
|
+
}
|
|
48590
|
+
const recentHistory = chatHistory.slice(-5);
|
|
48591
|
+
const sections = [
|
|
48592
|
+
`QUESTION: "${currentUserRequest}"`,
|
|
48593
|
+
(0, prompt_utils_1.formatChatHistory)(recentHistory, "CONVERSATION CONTEXT"),
|
|
48594
|
+
ASK_PROMPT_INSTRUCTIONS,
|
|
48595
|
+
(0, prompt_utils_1.buildAppContext)()
|
|
48596
|
+
];
|
|
48597
|
+
return sections.filter(Boolean).join("\n\n");
|
|
48598
|
+
}
|
|
48599
|
+
}
|
|
48600
|
+
});
|
|
48601
|
+
|
|
48602
|
+
// dist/opencode-integration/prompts/index.js
|
|
48603
|
+
var require_prompts = __commonJS({
|
|
48604
|
+
"dist/opencode-integration/prompts/index.js"(exports2) {
|
|
48605
|
+
"use strict";
|
|
48606
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
48607
|
+
exports2.buildAskPrompt = exports2.buildIterationPrompt = exports2.buildRecoveryPrompt = exports2.buildInitPrompt = void 0;
|
|
48608
|
+
var codegen_prompt_1 = require_codegen_prompt();
|
|
48609
|
+
Object.defineProperty(exports2, "buildInitPrompt", { enumerable: true, get: function() {
|
|
48610
|
+
return codegen_prompt_1.buildInitPrompt;
|
|
48611
|
+
} });
|
|
48612
|
+
Object.defineProperty(exports2, "buildRecoveryPrompt", { enumerable: true, get: function() {
|
|
48613
|
+
return codegen_prompt_1.buildRecoveryPrompt;
|
|
48614
|
+
} });
|
|
48615
|
+
var codegen_prompt_2 = require_codegen_prompt();
|
|
48616
|
+
Object.defineProperty(exports2, "buildIterationPrompt", { enumerable: true, get: function() {
|
|
48617
|
+
return codegen_prompt_2.buildIterationPrompt;
|
|
48618
|
+
} });
|
|
48619
|
+
var ask_prompt_1 = require_ask_prompt();
|
|
48620
|
+
Object.defineProperty(exports2, "buildAskPrompt", { enumerable: true, get: function() {
|
|
48621
|
+
return ask_prompt_1.buildAskPrompt;
|
|
48622
|
+
} });
|
|
48623
|
+
}
|
|
48624
|
+
});
|
|
48625
|
+
|
|
48536
48626
|
// dist/opencode-integration/config.js
|
|
48537
48627
|
var require_config = __commonJS({
|
|
48538
48628
|
"dist/opencode-integration/config.js"(exports2) {
|
|
@@ -48541,6 +48631,7 @@ var require_config = __commonJS({
|
|
|
48541
48631
|
exports2.DEFAULT_MODEL = exports2.DEFAULT_TIMEOUT_MS = void 0;
|
|
48542
48632
|
exports2.getAnthropicBaseUrl = getAnthropicBaseUrl;
|
|
48543
48633
|
exports2.getOpenCodeEnv = getOpenCodeEnv;
|
|
48634
|
+
exports2.getOpenCodeAskEnv = getOpenCodeAskEnv;
|
|
48544
48635
|
var os_1 = require("os");
|
|
48545
48636
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
48546
48637
|
exports2.DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
@@ -48548,18 +48639,36 @@ var require_config = __commonJS({
|
|
|
48548
48639
|
function getAnthropicBaseUrl(projectId) {
|
|
48549
48640
|
return `${codeGenerationService_12.aiProxyBaseUrl}/projects/${projectId}/anthropic`;
|
|
48550
48641
|
}
|
|
48551
|
-
function
|
|
48642
|
+
function getProviderConfig() {
|
|
48643
|
+
const accessToken = process.env.WIX_ACCESS_TOKEN;
|
|
48644
|
+
const headers = accessToken ? { Authorization: `Bearer ${accessToken}` } : {};
|
|
48552
48645
|
return {
|
|
48553
|
-
|
|
48554
|
-
|
|
48555
|
-
|
|
48556
|
-
|
|
48557
|
-
|
|
48558
|
-
cacheControl: true,
|
|
48559
|
-
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
|
|
48560
|
-
}
|
|
48646
|
+
anthropic: {
|
|
48647
|
+
options: {
|
|
48648
|
+
apiKey: "proxy-handled",
|
|
48649
|
+
cacheControl: true,
|
|
48650
|
+
headers
|
|
48561
48651
|
}
|
|
48562
|
-
}
|
|
48652
|
+
}
|
|
48653
|
+
};
|
|
48654
|
+
}
|
|
48655
|
+
var WIX_MCP_CONFIG = {
|
|
48656
|
+
"wix-mcp": {
|
|
48657
|
+
type: "local",
|
|
48658
|
+
command: [
|
|
48659
|
+
"npx",
|
|
48660
|
+
"-y",
|
|
48661
|
+
"@wix/mcp@1.0.22",
|
|
48662
|
+
"--experimental",
|
|
48663
|
+
"GET_TO_KNOW_WIX,WIX_API_THROUGH_FS"
|
|
48664
|
+
],
|
|
48665
|
+
enabled: true
|
|
48666
|
+
}
|
|
48667
|
+
};
|
|
48668
|
+
function getOpenCodeConfig() {
|
|
48669
|
+
return {
|
|
48670
|
+
model: exports2.DEFAULT_MODEL,
|
|
48671
|
+
provider: getProviderConfig(),
|
|
48563
48672
|
permission: {
|
|
48564
48673
|
edit: "allow",
|
|
48565
48674
|
bash: "allow",
|
|
@@ -48573,19 +48682,20 @@ var require_config = __commonJS({
|
|
|
48573
48682
|
}
|
|
48574
48683
|
},
|
|
48575
48684
|
lsp: false,
|
|
48576
|
-
mcp:
|
|
48577
|
-
|
|
48578
|
-
|
|
48579
|
-
|
|
48580
|
-
|
|
48581
|
-
|
|
48582
|
-
|
|
48583
|
-
|
|
48584
|
-
|
|
48585
|
-
|
|
48586
|
-
|
|
48587
|
-
|
|
48588
|
-
|
|
48685
|
+
mcp: WIX_MCP_CONFIG
|
|
48686
|
+
};
|
|
48687
|
+
}
|
|
48688
|
+
function getOpenCodeAskConfig() {
|
|
48689
|
+
return {
|
|
48690
|
+
model: exports2.DEFAULT_MODEL,
|
|
48691
|
+
provider: getProviderConfig(),
|
|
48692
|
+
permission: {
|
|
48693
|
+
edit: "deny",
|
|
48694
|
+
bash: "deny",
|
|
48695
|
+
task: "deny"
|
|
48696
|
+
},
|
|
48697
|
+
lsp: false,
|
|
48698
|
+
mcp: WIX_MCP_CONFIG
|
|
48589
48699
|
};
|
|
48590
48700
|
}
|
|
48591
48701
|
function ensureOpenCodeInPath() {
|
|
@@ -48596,10 +48706,8 @@ var require_config = __commonJS({
|
|
|
48596
48706
|
}
|
|
48597
48707
|
return `${opencodeBin}:${currentPath}`;
|
|
48598
48708
|
}
|
|
48599
|
-
function
|
|
48709
|
+
function buildOpenCodeEnv(projectId, config2) {
|
|
48600
48710
|
const anthropicBaseUrl = getAnthropicBaseUrl(projectId);
|
|
48601
|
-
const accessToken = process.env.WIX_ACCESS_TOKEN;
|
|
48602
|
-
const config2 = getOpenCodeConfig(accessToken);
|
|
48603
48711
|
return {
|
|
48604
48712
|
...process.env,
|
|
48605
48713
|
PATH: ensureOpenCodeInPath(),
|
|
@@ -48609,21 +48717,11 @@ var require_config = __commonJS({
|
|
|
48609
48717
|
OPENCODE_DISABLE_LSP_DOWNLOAD: "true"
|
|
48610
48718
|
};
|
|
48611
48719
|
}
|
|
48612
|
-
|
|
48613
|
-
|
|
48614
|
-
|
|
48615
|
-
|
|
48616
|
-
|
|
48617
|
-
"dist/opencode-integration/types.js"(exports2) {
|
|
48618
|
-
"use strict";
|
|
48619
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
48620
|
-
exports2.tryParseJson = tryParseJson;
|
|
48621
|
-
function tryParseJson(text) {
|
|
48622
|
-
try {
|
|
48623
|
-
return JSON.parse(text);
|
|
48624
|
-
} catch {
|
|
48625
|
-
return null;
|
|
48626
|
-
}
|
|
48720
|
+
function getOpenCodeEnv(projectId) {
|
|
48721
|
+
return buildOpenCodeEnv(projectId, getOpenCodeConfig());
|
|
48722
|
+
}
|
|
48723
|
+
function getOpenCodeAskEnv(projectId) {
|
|
48724
|
+
return buildOpenCodeEnv(projectId, getOpenCodeAskConfig());
|
|
48627
48725
|
}
|
|
48628
48726
|
}
|
|
48629
48727
|
});
|
|
@@ -48635,6 +48733,7 @@ var require_parser = __commonJS({
|
|
|
48635
48733
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
48636
48734
|
exports2.parseRequiredPermissions = parseRequiredPermissions;
|
|
48637
48735
|
exports2.parseFilesChanged = parseFilesChanged;
|
|
48736
|
+
exports2.parseAnswerText = parseAnswerText;
|
|
48638
48737
|
exports2.createEmptyUsageStats = createEmptyUsageStats;
|
|
48639
48738
|
exports2.parseUsageStats = parseUsageStats;
|
|
48640
48739
|
exports2.mergeUsageStats = mergeUsageStats;
|
|
@@ -48645,6 +48744,9 @@ var require_parser = __commonJS({
|
|
|
48645
48744
|
write: ditto_codegen_types_12.ExtensionGenerationOperation.INSERT,
|
|
48646
48745
|
edit: ditto_codegen_types_12.ExtensionGenerationOperation.EDIT
|
|
48647
48746
|
};
|
|
48747
|
+
function parseEvents(output, type) {
|
|
48748
|
+
return output.split("\n").filter((line) => line.trim()).map((line) => (0, types_1.tryParseJson)(line)).filter((event) => event !== null && event.type === type);
|
|
48749
|
+
}
|
|
48648
48750
|
function parseRequiredPermissions(output) {
|
|
48649
48751
|
const lines = output.split("\n");
|
|
48650
48752
|
for (const line of lines) {
|
|
@@ -48715,6 +48817,9 @@ var require_parser = __commonJS({
|
|
|
48715
48817
|
}
|
|
48716
48818
|
return filesChanged;
|
|
48717
48819
|
}
|
|
48820
|
+
function parseAnswerText(output) {
|
|
48821
|
+
return parseEvents(output, "text").map((event) => event.part?.text).filter(Boolean).join("").trim();
|
|
48822
|
+
}
|
|
48718
48823
|
function createEmptyUsageStats() {
|
|
48719
48824
|
return {
|
|
48720
48825
|
cost: 0,
|
|
@@ -48795,10 +48900,17 @@ var require_task_tracker = __commonJS({
|
|
|
48795
48900
|
var ditto_codegen_types_12 = require_dist4();
|
|
48796
48901
|
var types_1 = require_types5();
|
|
48797
48902
|
var logger_12 = require_logger();
|
|
48903
|
+
var CODE_SEARCH_TOOLS = /* @__PURE__ */ new Set(["read", "grep", "glob", "list"]);
|
|
48904
|
+
function isMcpTool(tool2) {
|
|
48905
|
+
return tool2.startsWith("wix-mcp_");
|
|
48906
|
+
}
|
|
48798
48907
|
var OpenCodeTaskTracker = class {
|
|
48799
|
-
constructor() {
|
|
48908
|
+
constructor(options) {
|
|
48800
48909
|
this.trackedTasks = /* @__PURE__ */ new Map();
|
|
48801
48910
|
this.taskCounter = 0;
|
|
48911
|
+
this.codeSearchTaskCreated = false;
|
|
48912
|
+
this.docSearchTaskCreated = false;
|
|
48913
|
+
this.trackToolCategories = options?.trackToolCategories ?? false;
|
|
48802
48914
|
}
|
|
48803
48915
|
getJobContext() {
|
|
48804
48916
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
@@ -48827,6 +48939,9 @@ var require_task_tracker = __commonJS({
|
|
|
48827
48939
|
if (tool2 === "skill" && state.status === "completed") {
|
|
48828
48940
|
await this.handleSkillEvent(state);
|
|
48829
48941
|
}
|
|
48942
|
+
if (this.trackToolCategories) {
|
|
48943
|
+
await this.handleToolCategoryEvent(tool2);
|
|
48944
|
+
}
|
|
48830
48945
|
}
|
|
48831
48946
|
async handleTaskEvent(callID, state) {
|
|
48832
48947
|
const jobContext = this.getJobContext();
|
|
@@ -48893,6 +49008,42 @@ var require_task_tracker = __commonJS({
|
|
|
48893
49008
|
const skillName = state.title?.replace("Loaded skill: ", "") || "unknown";
|
|
48894
49009
|
logger_12.logger.info("[OpenCode] Loaded skill", { skillName });
|
|
48895
49010
|
}
|
|
49011
|
+
async handleToolCategoryEvent(tool2) {
|
|
49012
|
+
const jobContext = this.getJobContext();
|
|
49013
|
+
if (!jobContext)
|
|
49014
|
+
return;
|
|
49015
|
+
if (CODE_SEARCH_TOOLS.has(tool2) && !this.codeSearchTaskCreated) {
|
|
49016
|
+
this.codeSearchTaskCreated = true;
|
|
49017
|
+
await this.createCategoryTask(jobContext, "code-search", "Searching in code");
|
|
49018
|
+
}
|
|
49019
|
+
if (isMcpTool(tool2) && !this.docSearchTaskCreated) {
|
|
49020
|
+
this.docSearchTaskCreated = true;
|
|
49021
|
+
await this.createCategoryTask(jobContext, "doc-search", "Searching in docs");
|
|
49022
|
+
}
|
|
49023
|
+
}
|
|
49024
|
+
async createCategoryTask(jobContext, suffix, description) {
|
|
49025
|
+
const taskId = `${jobContext.taskId}-${suffix}`;
|
|
49026
|
+
this.trackedTasks.set(suffix, {
|
|
49027
|
+
taskId,
|
|
49028
|
+
description,
|
|
49029
|
+
status: ditto_codegen_types_12.Status.RUNNING
|
|
49030
|
+
});
|
|
49031
|
+
try {
|
|
49032
|
+
await codeGenerationService_12.codeGenerationService.addTask(jobContext.jobId, {
|
|
49033
|
+
id: taskId,
|
|
49034
|
+
kind: ditto_codegen_types_12.TaskKind.RUN_AGENT,
|
|
49035
|
+
status: ditto_codegen_types_12.Status.RUNNING,
|
|
49036
|
+
name: "run_agent",
|
|
49037
|
+
description,
|
|
49038
|
+
agentName: ""
|
|
49039
|
+
});
|
|
49040
|
+
logger_12.logger.info("[OpenCode] Created category task", { description });
|
|
49041
|
+
} catch (error48) {
|
|
49042
|
+
logger_12.logger.error("[OpenCode] Failed to create category task", {
|
|
49043
|
+
error: error48 instanceof Error ? error48.message : String(error48)
|
|
49044
|
+
});
|
|
49045
|
+
}
|
|
49046
|
+
}
|
|
48896
49047
|
async completeRemainingTasks() {
|
|
48897
49048
|
const jobContext = this.getJobContext();
|
|
48898
49049
|
if (!jobContext)
|
|
@@ -49143,9 +49294,10 @@ var require_executor = __commonJS({
|
|
|
49143
49294
|
exports2.executeOpenCode = executeOpenCode;
|
|
49144
49295
|
var child_process_1 = require("child_process");
|
|
49145
49296
|
var ditto_codegen_types_12 = require_dist4();
|
|
49297
|
+
var types_1 = require_types5();
|
|
49146
49298
|
var config_1 = require_config();
|
|
49147
49299
|
var parser_1 = require_parser();
|
|
49148
|
-
var
|
|
49300
|
+
var prompts_1 = require_prompts();
|
|
49149
49301
|
var task_tracker_1 = require_task_tracker();
|
|
49150
49302
|
var process_manager_1 = require_process_manager();
|
|
49151
49303
|
var process_handlers_1 = require_process_handlers();
|
|
@@ -49160,7 +49312,7 @@ var require_executor = __commonJS({
|
|
|
49160
49312
|
if (attempt > 1) {
|
|
49161
49313
|
logger_12.logger.info(`[OpenCode] Retry attempt ${attempt}/${MAX_RETRIES} - starting fresh session with recovery context`);
|
|
49162
49314
|
const filesChanged = (0, parser_1.parseFilesChanged)(accumulatedStdout);
|
|
49163
|
-
currentPrompt = (0,
|
|
49315
|
+
currentPrompt = (0, prompts_1.buildRecoveryPrompt)(options.prompt, filesChanged, lastResult?.error?.message || lastResult?.stderr || "Process timed out");
|
|
49164
49316
|
}
|
|
49165
49317
|
const result = await executeOpenCodeOnce({ ...options, prompt: currentPrompt }, attempt);
|
|
49166
49318
|
accumulatedStdout += result.stdout;
|
|
@@ -49197,9 +49349,11 @@ var require_executor = __commonJS({
|
|
|
49197
49349
|
return ["run", "--format", "json", prompt];
|
|
49198
49350
|
}
|
|
49199
49351
|
async function executeOpenCodeOnce(options, attempt) {
|
|
49200
|
-
const { prompt, outputPath, projectId, onStdout, onStderr } = options;
|
|
49352
|
+
const { prompt, outputPath, projectId, mode, onStdout, onStderr } = options;
|
|
49201
49353
|
const startTime = Date.now();
|
|
49202
|
-
const taskTracker = new task_tracker_1.OpenCodeTaskTracker(
|
|
49354
|
+
const taskTracker = new task_tracker_1.OpenCodeTaskTracker({
|
|
49355
|
+
trackToolCategories: mode === types_1.ASK_MODE
|
|
49356
|
+
});
|
|
49203
49357
|
return new Promise((resolve3) => {
|
|
49204
49358
|
const state = {
|
|
49205
49359
|
stdout: "",
|
|
@@ -49239,9 +49393,10 @@ var require_executor = __commonJS({
|
|
|
49239
49393
|
maxRetries: MAX_RETRIES,
|
|
49240
49394
|
workingDirectory: outputPath
|
|
49241
49395
|
});
|
|
49396
|
+
const env = mode === types_1.ASK_MODE ? (0, config_1.getOpenCodeAskEnv)(projectId) : (0, config_1.getOpenCodeEnv)(projectId);
|
|
49242
49397
|
ctx.child = (0, child_process_1.spawn)("opencode", args, {
|
|
49243
49398
|
cwd: outputPath,
|
|
49244
|
-
env
|
|
49399
|
+
env,
|
|
49245
49400
|
stdio: ["ignore", "pipe", "pipe"],
|
|
49246
49401
|
detached: true
|
|
49247
49402
|
});
|
|
@@ -49277,20 +49432,41 @@ var require_opencode_runner = __commonJS({
|
|
|
49277
49432
|
"dist/opencode-integration/opencode-runner.js"(exports2) {
|
|
49278
49433
|
"use strict";
|
|
49279
49434
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
49280
|
-
exports2.
|
|
49435
|
+
exports2.runOpenCodeInit = runOpenCodeInit;
|
|
49281
49436
|
exports2.runOpenCodeIteration = runOpenCodeIteration;
|
|
49282
|
-
|
|
49437
|
+
exports2.runOpenCodeAsk = runOpenCodeAsk;
|
|
49438
|
+
var types_1 = require_types5();
|
|
49439
|
+
var prompts_1 = require_prompts();
|
|
49283
49440
|
var executor_1 = require_executor();
|
|
49284
|
-
|
|
49285
|
-
|
|
49286
|
-
const
|
|
49441
|
+
var parser_1 = require_parser();
|
|
49442
|
+
async function runOpenCodeInit(options) {
|
|
49443
|
+
const { blueprint, outputPath, projectId, chatHistory, onStdout, onStderr } = options;
|
|
49444
|
+
const prompt = (0, prompts_1.buildInitPrompt)(blueprint, chatHistory);
|
|
49287
49445
|
return (0, executor_1.executeOpenCode)({ prompt, outputPath, projectId, onStdout, onStderr });
|
|
49288
49446
|
}
|
|
49289
49447
|
async function runOpenCodeIteration(options) {
|
|
49290
49448
|
const { outputPath, projectId, chatHistory, onStdout, onStderr } = options;
|
|
49291
|
-
const prompt = (0,
|
|
49449
|
+
const prompt = (0, prompts_1.buildIterationPrompt)(chatHistory);
|
|
49292
49450
|
return (0, executor_1.executeOpenCode)({ prompt, outputPath, projectId, onStdout, onStderr });
|
|
49293
49451
|
}
|
|
49452
|
+
async function runOpenCodeAsk(options) {
|
|
49453
|
+
const { outputPath, projectId, chatHistory, onStdout, onStderr } = options;
|
|
49454
|
+
const prompt = (0, prompts_1.buildAskPrompt)(chatHistory);
|
|
49455
|
+
const result = await (0, executor_1.executeOpenCode)({
|
|
49456
|
+
prompt,
|
|
49457
|
+
outputPath,
|
|
49458
|
+
projectId,
|
|
49459
|
+
mode: types_1.ASK_MODE,
|
|
49460
|
+
onStdout,
|
|
49461
|
+
onStderr
|
|
49462
|
+
});
|
|
49463
|
+
return {
|
|
49464
|
+
success: result.success,
|
|
49465
|
+
answer: (0, parser_1.parseAnswerText)(result.stdout),
|
|
49466
|
+
usage: result.usage,
|
|
49467
|
+
error: result.error
|
|
49468
|
+
};
|
|
49469
|
+
}
|
|
49294
49470
|
}
|
|
49295
49471
|
});
|
|
49296
49472
|
|
|
@@ -49299,14 +49475,17 @@ var require_opencode_integration = __commonJS({
|
|
|
49299
49475
|
"dist/opencode-integration/index.js"(exports2) {
|
|
49300
49476
|
"use strict";
|
|
49301
49477
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
49302
|
-
exports2.formatUsageStats = exports2.OpenCodeTaskTracker = exports2.runOpenCodeIteration = exports2.
|
|
49478
|
+
exports2.formatUsageStats = exports2.OpenCodeTaskTracker = exports2.runOpenCodeAsk = exports2.runOpenCodeIteration = exports2.runOpenCodeInit = void 0;
|
|
49303
49479
|
var opencode_runner_1 = require_opencode_runner();
|
|
49304
|
-
Object.defineProperty(exports2, "
|
|
49305
|
-
return opencode_runner_1.
|
|
49480
|
+
Object.defineProperty(exports2, "runOpenCodeInit", { enumerable: true, get: function() {
|
|
49481
|
+
return opencode_runner_1.runOpenCodeInit;
|
|
49306
49482
|
} });
|
|
49307
49483
|
Object.defineProperty(exports2, "runOpenCodeIteration", { enumerable: true, get: function() {
|
|
49308
49484
|
return opencode_runner_1.runOpenCodeIteration;
|
|
49309
49485
|
} });
|
|
49486
|
+
Object.defineProperty(exports2, "runOpenCodeAsk", { enumerable: true, get: function() {
|
|
49487
|
+
return opencode_runner_1.runOpenCodeAsk;
|
|
49488
|
+
} });
|
|
49310
49489
|
var task_tracker_1 = require_task_tracker();
|
|
49311
49490
|
Object.defineProperty(exports2, "OpenCodeTaskTracker", { enumerable: true, get: function() {
|
|
49312
49491
|
return task_tracker_1.OpenCodeTaskTracker;
|
|
@@ -49333,7 +49512,7 @@ var require_OpenCodeOrchestrator = __commonJS({
|
|
|
49333
49512
|
super();
|
|
49334
49513
|
}
|
|
49335
49514
|
async generateCode(request) {
|
|
49336
|
-
const { blueprint, outputPath, projectId,
|
|
49515
|
+
const { blueprint, outputPath, projectId, chatHistory } = request;
|
|
49337
49516
|
this.emitEvent("start", {
|
|
49338
49517
|
appName: blueprint.appName ?? "",
|
|
49339
49518
|
summary: blueprint.summary ?? "",
|
|
@@ -49342,11 +49521,11 @@ var require_OpenCodeOrchestrator = __commonJS({
|
|
|
49342
49521
|
});
|
|
49343
49522
|
const start = Date.now();
|
|
49344
49523
|
this.emitEvent("opencode:start", { outputPath });
|
|
49345
|
-
const result = await (0, opencode_integration_1.
|
|
49524
|
+
const result = await (0, opencode_integration_1.runOpenCodeInit)({
|
|
49346
49525
|
blueprint,
|
|
49347
49526
|
outputPath,
|
|
49348
49527
|
projectId,
|
|
49349
|
-
|
|
49528
|
+
chatHistory,
|
|
49350
49529
|
onStdout: (data) => {
|
|
49351
49530
|
this.emitEvent("opencode:output", { data });
|
|
49352
49531
|
},
|
|
@@ -74142,6 +74321,37 @@ var require_DashboardPlugins = __commonJS({
|
|
|
74142
74321
|
}
|
|
74143
74322
|
});
|
|
74144
74323
|
|
|
74324
|
+
// ../codegen-common-logic/dist/extensions/DashboardMenuPlugins.js
|
|
74325
|
+
var require_DashboardMenuPlugins = __commonJS({
|
|
74326
|
+
"../codegen-common-logic/dist/extensions/DashboardMenuPlugins.js"(exports2) {
|
|
74327
|
+
"use strict";
|
|
74328
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
74329
|
+
exports2.getDashboardMenuPluginsDecisionGuide = exports2.getDashboardMenuPluginsAgentDocumentation = void 0;
|
|
74330
|
+
var getDashboardMenuPluginsAgentDocumentation = () => {
|
|
74331
|
+
return `<dashboard_menu_plugins>
|
|
74332
|
+
#### Dashboard Menu Plugins
|
|
74333
|
+
|
|
74334
|
+
- **Description**: Menu items added to dashboard page menus that can navigate to pages or open modals
|
|
74335
|
+
- **Use Cases**:
|
|
74336
|
+
- Quick access to app features
|
|
74337
|
+
- Navigation shortcuts
|
|
74338
|
+
- Context-specific actions
|
|
74339
|
+
- **When to Choose**: When you need to add navigation items or quick actions to existing dashboard menus
|
|
74340
|
+
</dashboard_menu_plugins>`;
|
|
74341
|
+
};
|
|
74342
|
+
exports2.getDashboardMenuPluginsAgentDocumentation = getDashboardMenuPluginsAgentDocumentation;
|
|
74343
|
+
var getDashboardMenuPluginsDecisionGuide = () => {
|
|
74344
|
+
return `### Choose Dashboard Menu Plugins when:
|
|
74345
|
+
|
|
74346
|
+
- \u2705 Need to add custom navigation items to the dashboard sidebar
|
|
74347
|
+
- \u2705 Want quick-access shortcuts to app features from the dashboard menu
|
|
74348
|
+
- \u2705 Need context-specific actions accessible from dashboard navigation
|
|
74349
|
+
- \u2705 Want to link dashboard menu items to Dashboard Pages`;
|
|
74350
|
+
};
|
|
74351
|
+
exports2.getDashboardMenuPluginsDecisionGuide = getDashboardMenuPluginsDecisionGuide;
|
|
74352
|
+
}
|
|
74353
|
+
});
|
|
74354
|
+
|
|
74145
74355
|
// ../codegen-common-logic/dist/extensions/DashboardExtensions.js
|
|
74146
74356
|
var require_DashboardExtensions = __commonJS({
|
|
74147
74357
|
"../codegen-common-logic/dist/extensions/DashboardExtensions.js"(exports2) {
|
|
@@ -74150,12 +74360,15 @@ var require_DashboardExtensions = __commonJS({
|
|
|
74150
74360
|
exports2.getDashboardExtensionsDocumentation = void 0;
|
|
74151
74361
|
var DashboardPageAgent_1 = require_DashboardPageAgent();
|
|
74152
74362
|
var DashboardPlugins_1 = require_DashboardPlugins();
|
|
74363
|
+
var DashboardMenuPlugins_1 = require_DashboardMenuPlugins();
|
|
74153
74364
|
var getDashboardExtensionsDocumentation = (options) => {
|
|
74154
74365
|
return `### Dashboard Extensions
|
|
74155
74366
|
Dashboard extensions add functionality to the Wix Dashboard for site administrators. They are not visible on live sites.
|
|
74156
74367
|
${(0, DashboardPageAgent_1.getDashboardPageAgentDocumentation)()}${options?.enableNewExtensions ? `
|
|
74157
74368
|
|
|
74158
|
-
${(0, DashboardPlugins_1.getDashboardPluginsAgentDocumentation)()}
|
|
74369
|
+
${(0, DashboardPlugins_1.getDashboardPluginsAgentDocumentation)()}
|
|
74370
|
+
|
|
74371
|
+
${(0, DashboardMenuPlugins_1.getDashboardMenuPluginsAgentDocumentation)()}` : ""}`;
|
|
74159
74372
|
};
|
|
74160
74373
|
exports2.getDashboardExtensionsDocumentation = getDashboardExtensionsDocumentation;
|
|
74161
74374
|
}
|
|
@@ -74330,37 +74543,6 @@ ${(0, SitePluginAgent_1.getSitePluginAgentDocumentation)()}` : ""}`;
|
|
|
74330
74543
|
}
|
|
74331
74544
|
});
|
|
74332
74545
|
|
|
74333
|
-
// ../codegen-common-logic/dist/extensions/DashboardMenuPlugins.js
|
|
74334
|
-
var require_DashboardMenuPlugins = __commonJS({
|
|
74335
|
-
"../codegen-common-logic/dist/extensions/DashboardMenuPlugins.js"(exports2) {
|
|
74336
|
-
"use strict";
|
|
74337
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
74338
|
-
exports2.getDashboardMenuPluginsDecisionGuide = exports2.getDashboardMenuPluginsAgentDocumentation = void 0;
|
|
74339
|
-
var getDashboardMenuPluginsAgentDocumentation = () => {
|
|
74340
|
-
return `<dashboard_menu_plugins>
|
|
74341
|
-
#### Dashboard Menu Plugins
|
|
74342
|
-
|
|
74343
|
-
- **Description**: Menu items added to dashboard page menus that can navigate to pages or open modals
|
|
74344
|
-
- **Use Cases**:
|
|
74345
|
-
- Quick access to app features
|
|
74346
|
-
- Navigation shortcuts
|
|
74347
|
-
- Context-specific actions
|
|
74348
|
-
- **When to Choose**: When you need to add navigation items or quick actions to existing dashboard menus
|
|
74349
|
-
</dashboard_menu_plugins>`;
|
|
74350
|
-
};
|
|
74351
|
-
exports2.getDashboardMenuPluginsAgentDocumentation = getDashboardMenuPluginsAgentDocumentation;
|
|
74352
|
-
var getDashboardMenuPluginsDecisionGuide = () => {
|
|
74353
|
-
return `### Choose Dashboard Menu Plugins when:
|
|
74354
|
-
|
|
74355
|
-
- \u2705 Need to add custom navigation items to the dashboard sidebar
|
|
74356
|
-
- \u2705 Want quick-access shortcuts to app features from the dashboard menu
|
|
74357
|
-
- \u2705 Need context-specific actions accessible from dashboard navigation
|
|
74358
|
-
- \u2705 Want to link dashboard menu items to Dashboard Pages`;
|
|
74359
|
-
};
|
|
74360
|
-
exports2.getDashboardMenuPluginsDecisionGuide = getDashboardMenuPluginsDecisionGuide;
|
|
74361
|
-
}
|
|
74362
|
-
});
|
|
74363
|
-
|
|
74364
74546
|
// ../codegen-common-logic/dist/extensions/DashboardModals.js
|
|
74365
74547
|
var require_DashboardModals = __commonJS({
|
|
74366
74548
|
"../codegen-common-logic/dist/extensions/DashboardModals.js"(exports2) {
|
|
@@ -74401,6 +74583,7 @@ var require_extensionsDecisionGuide = __commonJS({
|
|
|
74401
74583
|
exports2.getExtensionDecisionMatrix = void 0;
|
|
74402
74584
|
var DashboardPageAgent_1 = require_DashboardPageAgent();
|
|
74403
74585
|
var DashboardPlugins_1 = require_DashboardPlugins();
|
|
74586
|
+
var DashboardMenuPlugins_1 = require_DashboardMenuPlugins();
|
|
74404
74587
|
var EmbeddedScriptAgent_1 = require_EmbeddedScriptAgent();
|
|
74405
74588
|
var CustomElementAgent_1 = require_CustomElementAgent();
|
|
74406
74589
|
var SiteComponentAgent_1 = require_SiteComponentAgent();
|
|
@@ -74413,7 +74596,9 @@ var require_extensionsDecisionGuide = __commonJS({
|
|
|
74413
74596
|
return `## Decision Matrix
|
|
74414
74597
|
${(0, DashboardPageAgent_1.getDashboardPageDecisionGuide)()}${options?.enableNewExtensions ? `
|
|
74415
74598
|
|
|
74416
|
-
${(0, DashboardPlugins_1.getDashboardPluginsDecisionGuide)()}
|
|
74599
|
+
${(0, DashboardPlugins_1.getDashboardPluginsDecisionGuide)()}
|
|
74600
|
+
|
|
74601
|
+
${(0, DashboardMenuPlugins_1.getDashboardMenuPluginsDecisionGuide)()}` : ""}
|
|
74417
74602
|
|
|
74418
74603
|
${(0, EmbeddedScriptAgent_1.getEmbeddedScriptDecisionGuide)()}
|
|
74419
74604
|
|
|
@@ -94668,7 +94853,7 @@ var require_opencode_init = __commonJS({
|
|
|
94668
94853
|
blueprint,
|
|
94669
94854
|
outputPath,
|
|
94670
94855
|
projectId: context_12.ctx.projectId,
|
|
94671
|
-
history
|
|
94856
|
+
chatHistory: history
|
|
94672
94857
|
});
|
|
94673
94858
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
94674
94859
|
requiredPermissions: result.requiredPermissions,
|
|
@@ -94817,6 +95002,109 @@ var require_opencode_iterate = __commonJS({
|
|
|
94817
95002
|
}
|
|
94818
95003
|
});
|
|
94819
95004
|
|
|
95005
|
+
// dist/OpenCodeAskOrchestrator.js
|
|
95006
|
+
var require_OpenCodeAskOrchestrator = __commonJS({
|
|
95007
|
+
"dist/OpenCodeAskOrchestrator.js"(exports2) {
|
|
95008
|
+
"use strict";
|
|
95009
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
95010
|
+
exports2.OpenCodeAskOrchestrator = void 0;
|
|
95011
|
+
var ditto_codegen_types_12 = require_dist4();
|
|
95012
|
+
var DittoEventEmitter_1 = require_DittoEventEmitter();
|
|
95013
|
+
var opencode_integration_1 = require_opencode_integration();
|
|
95014
|
+
var logger_12 = require_logger();
|
|
95015
|
+
var OpenCodeAskOrchestrator = class extends DittoEventEmitter_1.DittoEventEmitter {
|
|
95016
|
+
constructor() {
|
|
95017
|
+
super();
|
|
95018
|
+
}
|
|
95019
|
+
async ask(request) {
|
|
95020
|
+
const { outputPath, projectId, chatHistory } = request;
|
|
95021
|
+
this.emitEvent("opencode:start", { outputPath });
|
|
95022
|
+
const start = Date.now();
|
|
95023
|
+
const result = await (0, opencode_integration_1.runOpenCodeAsk)({
|
|
95024
|
+
outputPath,
|
|
95025
|
+
projectId,
|
|
95026
|
+
chatHistory,
|
|
95027
|
+
onStdout: (data) => {
|
|
95028
|
+
this.emitEvent("opencode:output", { data });
|
|
95029
|
+
},
|
|
95030
|
+
onStderr: (data) => {
|
|
95031
|
+
logger_12.logger.error("[OpenCode Ask] stderr", { output: data });
|
|
95032
|
+
}
|
|
95033
|
+
});
|
|
95034
|
+
const durationMs = Date.now() - start;
|
|
95035
|
+
if (!result.success) {
|
|
95036
|
+
this.emitEvent("opencode:error", {
|
|
95037
|
+
error: result.error?.message,
|
|
95038
|
+
exitCode: null,
|
|
95039
|
+
durationMs
|
|
95040
|
+
});
|
|
95041
|
+
throw result.error ?? new ditto_codegen_types_12.ProcessExecutionError("Ask flow failed", {
|
|
95042
|
+
processType: ditto_codegen_types_12.ProcessType.EXECUTION
|
|
95043
|
+
});
|
|
95044
|
+
}
|
|
95045
|
+
this.emitEvent("opencode:done", { durationMs });
|
|
95046
|
+
return result;
|
|
95047
|
+
}
|
|
95048
|
+
};
|
|
95049
|
+
exports2.OpenCodeAskOrchestrator = OpenCodeAskOrchestrator;
|
|
95050
|
+
}
|
|
95051
|
+
});
|
|
95052
|
+
|
|
95053
|
+
// dist/flows/opencode-ask.js
|
|
95054
|
+
var require_opencode_ask = __commonJS({
|
|
95055
|
+
"dist/flows/opencode-ask.js"(exports2) {
|
|
95056
|
+
"use strict";
|
|
95057
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
95058
|
+
exports2.runOpencodeAskFlow = void 0;
|
|
95059
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
95060
|
+
var cli_listeners_1 = require_cli_listeners();
|
|
95061
|
+
var job_context_storage_12 = require_job_context_storage();
|
|
95062
|
+
var ditto_codegen_types_12 = require_dist4();
|
|
95063
|
+
var OpenCodeAskOrchestrator_1 = require_OpenCodeAskOrchestrator();
|
|
95064
|
+
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
95065
|
+
var ditto_codegen_types_2 = require_dist4();
|
|
95066
|
+
var context_12 = require_context();
|
|
95067
|
+
var logger_12 = require_logger();
|
|
95068
|
+
var runOpencodeAskFlow = async (chatHistory) => {
|
|
95069
|
+
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
95070
|
+
if (!store?.jobId || !store?.taskId) {
|
|
95071
|
+
throw new Error("Job context not available - jobId and taskId are required");
|
|
95072
|
+
}
|
|
95073
|
+
const localJobContext = {
|
|
95074
|
+
jobId: store.jobId,
|
|
95075
|
+
taskId: store.taskId
|
|
95076
|
+
};
|
|
95077
|
+
const jobLog = (0, logger_12.getJobLogger)(localJobContext.jobId, localJobContext.taskId);
|
|
95078
|
+
jobLog.info(`[OpenCode Ask] Starting opencode ask task: jobId=${localJobContext?.jobId}, taskId=${localJobContext?.taskId}`);
|
|
95079
|
+
await codeGenerationService_12.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
95080
|
+
jobLog.info(`[OpenCode Ask] Marked task RUNNING: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`);
|
|
95081
|
+
try {
|
|
95082
|
+
const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
|
|
95083
|
+
const askOrchestrator = new OpenCodeAskOrchestrator_1.OpenCodeAskOrchestrator();
|
|
95084
|
+
(0, cli_listeners_1.attachOrchestratorListeners)(askOrchestrator);
|
|
95085
|
+
const result = await askOrchestrator.ask({
|
|
95086
|
+
outputPath,
|
|
95087
|
+
projectId: context_12.ctx.projectId,
|
|
95088
|
+
chatHistory
|
|
95089
|
+
});
|
|
95090
|
+
await codeGenerationService_12.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, ditto_codegen_types_12.Status.COMPLETED, {
|
|
95091
|
+
taskOutput: {
|
|
95092
|
+
answer: result.answer
|
|
95093
|
+
}
|
|
95094
|
+
});
|
|
95095
|
+
jobLog.info("[OpenCode Ask] Completed task");
|
|
95096
|
+
} catch (error48) {
|
|
95097
|
+
const codegenError = (0, ditto_codegen_types_2.toCodegenError)(error48);
|
|
95098
|
+
await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
|
|
95099
|
+
jobLog.error("[OpenCode Ask] Failed task", {
|
|
95100
|
+
error: error48 instanceof Error ? error48.message : String(error48)
|
|
95101
|
+
});
|
|
95102
|
+
}
|
|
95103
|
+
};
|
|
95104
|
+
exports2.runOpencodeAskFlow = runOpencodeAskFlow;
|
|
95105
|
+
}
|
|
95106
|
+
});
|
|
95107
|
+
|
|
94820
95108
|
// dist/system-prompts/common/iterationScenarios.js
|
|
94821
95109
|
var require_iterationScenarios = __commonJS({
|
|
94822
95110
|
"dist/system-prompts/common/iterationScenarios.js"(exports2) {
|
|
@@ -342047,7 +342335,6 @@ var require_IterationOrchestrator = __commonJS({
|
|
|
342047
342335
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
342048
342336
|
exports2.IterationOrchestrator = void 0;
|
|
342049
342337
|
var types_1 = require_types_impl2();
|
|
342050
|
-
var prompt_builder_1 = require_prompt_builder();
|
|
342051
342338
|
var sdkEnricher_1 = require_sdkEnricher2();
|
|
342052
342339
|
var orchestrator_error_helpers_1 = require_orchestrator_error_helpers();
|
|
342053
342340
|
var fixFlow_1 = require_fixFlow();
|
|
@@ -342063,6 +342350,7 @@ var require_IterationOrchestrator = __commonJS({
|
|
|
342063
342350
|
var projectContext_1 = require_projectContext();
|
|
342064
342351
|
var ditto_codegen_types_12 = require_dist4();
|
|
342065
342352
|
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
342353
|
+
var prompt_utils_1 = require_prompt_utils();
|
|
342066
342354
|
var IterationOrchestrator = class extends DittoEventEmitter_1.DittoEventEmitter {
|
|
342067
342355
|
constructor(agentsFactory) {
|
|
342068
342356
|
super();
|
|
@@ -342187,7 +342475,7 @@ var require_IterationOrchestrator = __commonJS({
|
|
|
342187
342475
|
const iterationAgent = this.agentsFactory.getAgent({
|
|
342188
342476
|
type: "ITERATION_AGENT"
|
|
342189
342477
|
});
|
|
342190
|
-
const { currentUserRequest, filteredChatHistory } = (0,
|
|
342478
|
+
const { currentUserRequest, filteredChatHistory } = (0, prompt_utils_1.extractUserRequestAndFilteredHistory)(chatHistory);
|
|
342191
342479
|
const iterationPlan = await iterationAgent.generate({
|
|
342192
342480
|
currentUserRequest,
|
|
342193
342481
|
chatHistory: filteredChatHistory,
|
|
@@ -342515,6 +342803,7 @@ var CodeGenService_1 = require_CodeGenService();
|
|
|
342515
342803
|
var job_context_storage_1 = require_job_context_storage();
|
|
342516
342804
|
var opencode_init_1 = require_opencode_init();
|
|
342517
342805
|
var opencode_iterate_1 = require_opencode_iterate();
|
|
342806
|
+
var opencode_ask_1 = require_opencode_ask();
|
|
342518
342807
|
var init_codegen_1 = require_init_codegen();
|
|
342519
342808
|
var iterate_codegen_1 = require_iterate_codegen();
|
|
342520
342809
|
var codegen_flow_helpers_1 = require_codegen_flow_helpers();
|
|
@@ -342622,7 +342911,10 @@ async function processJob(job) {
|
|
|
342622
342911
|
const payload = task.payload ?? {};
|
|
342623
342912
|
const history = payload.history ?? [];
|
|
342624
342913
|
const blueprint = payload.blueprint;
|
|
342625
|
-
|
|
342914
|
+
const taskKind = task.kind;
|
|
342915
|
+
if (taskKind === "ASK_CODEGEN") {
|
|
342916
|
+
await (0, opencode_ask_1.runOpencodeAskFlow)(history);
|
|
342917
|
+
} else if (task.kind === "ITERATE_CODEGEN") {
|
|
342626
342918
|
await handleIteration(history);
|
|
342627
342919
|
} else if (task.kind === "INIT_CODEGEN" && blueprint) {
|
|
342628
342920
|
await handleInit(blueprint, history);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/ditto-codegen-public",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.258",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"@wix/ditto-codegen": "1.0.0",
|
|
29
29
|
"esbuild": "^0.27.2"
|
|
30
30
|
},
|
|
31
|
-
"falconPackageHash": "
|
|
31
|
+
"falconPackageHash": "1b8f88b2662cd17c34a091e6efc4d0ee2ac0259b1edc73bc784055d0"
|
|
32
32
|
}
|