@wix/ditto-codegen-public 1.0.346 → 1.0.348
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/assets/commit-message-rule.md +2 -0
- package/assets/set-commit-message.ts +23 -0
- package/dist/out.js +543 -529
- package/package.json +4 -3
package/dist/out.js
CHANGED
|
@@ -10930,9 +10930,9 @@ var require_generation = __commonJS({
|
|
|
10930
10930
|
}
|
|
10931
10931
|
});
|
|
10932
10932
|
|
|
10933
|
-
// ../codegen-types/dist/types/
|
|
10934
|
-
var
|
|
10935
|
-
"../codegen-types/dist/types/
|
|
10933
|
+
// ../codegen-types/dist/types/decision.js
|
|
10934
|
+
var require_decision = __commonJS({
|
|
10935
|
+
"../codegen-types/dist/types/decision.js"(exports2) {
|
|
10936
10936
|
"use strict";
|
|
10937
10937
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10938
10938
|
}
|
|
@@ -10946,9 +10946,9 @@ var require_environment = __commonJS({
|
|
|
10946
10946
|
}
|
|
10947
10947
|
});
|
|
10948
10948
|
|
|
10949
|
-
// ../codegen-types/dist/types/
|
|
10950
|
-
var
|
|
10951
|
-
"../codegen-types/dist/types/
|
|
10949
|
+
// ../codegen-types/dist/types/plugins.js
|
|
10950
|
+
var require_plugins2 = __commonJS({
|
|
10951
|
+
"../codegen-types/dist/types/plugins.js"(exports2) {
|
|
10952
10952
|
"use strict";
|
|
10953
10953
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10954
10954
|
}
|
|
@@ -11012,9 +11012,9 @@ var require_dist4 = __commonJS({
|
|
|
11012
11012
|
__exportStar2(require_status(), exports2);
|
|
11013
11013
|
__exportStar2(require_task(), exports2);
|
|
11014
11014
|
__exportStar2(require_generation(), exports2);
|
|
11015
|
-
__exportStar2(
|
|
11015
|
+
__exportStar2(require_decision(), exports2);
|
|
11016
11016
|
__exportStar2(require_environment(), exports2);
|
|
11017
|
-
__exportStar2(
|
|
11017
|
+
__exportStar2(require_plugins2(), exports2);
|
|
11018
11018
|
__exportStar2(require_job_payload(), exports2);
|
|
11019
11019
|
__exportStar2(require_logger2(), exports2);
|
|
11020
11020
|
__exportStar2(require_ai(), exports2);
|
|
@@ -11235,7 +11235,6 @@ var require_constants5 = __commonJS({
|
|
|
11235
11235
|
dashboardMenuPlugin: "dashboard menu plugin",
|
|
11236
11236
|
embeddedScript: "embedded script",
|
|
11237
11237
|
event: "backend event",
|
|
11238
|
-
genericExtension: "extension",
|
|
11239
11238
|
customElement: "custom element",
|
|
11240
11239
|
siteComponent: "editor react component",
|
|
11241
11240
|
editorReactComponent: "editor react component",
|
|
@@ -11248,7 +11247,8 @@ var require_constants5 = __commonJS({
|
|
|
11248
11247
|
ecomPaymentSettings: "service plugin",
|
|
11249
11248
|
bookingsStaffSortingProvider: "service plugin",
|
|
11250
11249
|
contextProvider: "context provider",
|
|
11251
|
-
functionLibrary: "function library"
|
|
11250
|
+
functionLibrary: "function library",
|
|
11251
|
+
dataCollections: "data collection"
|
|
11252
11252
|
};
|
|
11253
11253
|
function normalizeFilePath(filePath) {
|
|
11254
11254
|
return filePath.replace(exports2.CONTAINER_ROOT_PREFIX, "");
|
|
@@ -11257,9 +11257,6 @@ var require_constants5 = __commonJS({
|
|
|
11257
11257
|
return EXTENSION_FILE_PATTERN.test(filePath);
|
|
11258
11258
|
}
|
|
11259
11259
|
function detectExtension(content) {
|
|
11260
|
-
if (content.includes("genericExtension(") && content.includes("DATA_COMPONENT")) {
|
|
11261
|
-
return { extensionType: "dataCollection", label: "collection" };
|
|
11262
|
-
}
|
|
11263
11260
|
for (const [extensionType, label] of Object.entries(exports2.BUILDER_TO_EXTENSION_LABEL)) {
|
|
11264
11261
|
if (content.includes(`extensions.${extensionType}(`) || content.includes(`experimentalExtensions.${extensionType}(`)) {
|
|
11265
11262
|
return { extensionType, label };
|
|
@@ -11495,247 +11492,8 @@ var require_dist5 = __commonJS({
|
|
|
11495
11492
|
codegenRules: [],
|
|
11496
11493
|
askRules: [],
|
|
11497
11494
|
decisionCheckers: [],
|
|
11498
|
-
|
|
11499
|
-
};
|
|
11500
|
-
}
|
|
11501
|
-
});
|
|
11502
|
-
|
|
11503
|
-
// ../codegen-studio-2-config/dist/site-data-layer-rules.js
|
|
11504
|
-
var require_site_data_layer_rules = __commonJS({
|
|
11505
|
-
"../codegen-studio-2-config/dist/site-data-layer-rules.js"(exports2) {
|
|
11506
|
-
"use strict";
|
|
11507
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11508
|
-
exports2.SITE_DATA_LAYER_RULES = void 0;
|
|
11509
|
-
exports2.SITE_DATA_LAYER_RULES = `# Site Data Layer Rules
|
|
11510
|
-
|
|
11511
|
-
The agent operates on a live Wix site (METASITE_ID is in your prompt context).
|
|
11512
|
-
|
|
11513
|
-
For any persistent-data need \u2014 CMS collections, content tables, schemas, data models, or databases that store items \u2014 use the \`wix-site-data-collection\` skill.
|
|
11514
|
-
|
|
11515
|
-
The \`wix-app\` skill remains the right tool for surrounding extensions (dashboard pages, modals, widgets); only the data layer is overridden. A Wix CLI data collection extension will NOT work here \u2014 it only provisions on app install, but this is a live site that already exists. Use the \`wix-site-data-collection\` skill to discover the existing collections on the site and wire your code against them.
|
|
11516
|
-
|
|
11517
|
-
DO NOT write any code relating to Wix CLI data extensions \u2014 for example, do not generate \`src/extensions/data/extensions.ts\`.`;
|
|
11518
|
-
}
|
|
11519
|
-
});
|
|
11520
|
-
|
|
11521
|
-
// ../codegen-studio-2-config/dist/index.js
|
|
11522
|
-
var require_dist6 = __commonJS({
|
|
11523
|
-
"../codegen-studio-2-config/dist/index.js"(exports2) {
|
|
11524
|
-
"use strict";
|
|
11525
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11526
|
-
exports2.studio2CodegenConfig = void 0;
|
|
11527
|
-
var site_data_layer_rules_1 = require_site_data_layer_rules();
|
|
11528
|
-
exports2.studio2CodegenConfig = {
|
|
11529
|
-
codegenRules: [
|
|
11530
|
-
{ filename: "site-data-layer-rules.md", content: site_data_layer_rules_1.SITE_DATA_LAYER_RULES }
|
|
11531
|
-
],
|
|
11532
|
-
askRules: [],
|
|
11533
|
-
decisionCheckers: [],
|
|
11534
|
-
hooks: []
|
|
11535
|
-
};
|
|
11536
|
-
}
|
|
11537
|
-
});
|
|
11538
|
-
|
|
11539
|
-
// dist/opencode-integration/rules/codegen-rules.js
|
|
11540
|
-
var require_codegen_rules = __commonJS({
|
|
11541
|
-
"dist/opencode-integration/rules/codegen-rules.js"(exports2) {
|
|
11542
|
-
"use strict";
|
|
11543
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11544
|
-
exports2.CODEGEN_RULES = void 0;
|
|
11545
|
-
exports2.CODEGEN_RULES = `CORE PRINCIPLES:
|
|
11546
|
-
- Do NOT invent or assume new types, modules, functions, props, events, or imports.
|
|
11547
|
-
- NEVER use mocks, placeholders, debugging, or TODOs in any code.
|
|
11548
|
-
- ALWAYS implement complete, production-ready functionality.
|
|
11549
|
-
- Do NOT create test files or test code. Tests are out of scope for code generation.
|
|
11550
|
-
|
|
11551
|
-
MINIMIZE TEXT OUTPUT \u2014 CRITICAL:
|
|
11552
|
-
- Do NOT narrate your actions. No "Let me now...", "Perfect!", "Now I'll...", "Excellent!", "Great!".
|
|
11553
|
-
- Do NOT explain what you just did. The tool output speaks for itself.
|
|
11554
|
-
- Do NOT read back files you just wrote. Trust the write succeeded.
|
|
11555
|
-
- Every text token costs money. Use tools, not words.
|
|
11556
|
-
|
|
11557
|
-
TOOL USAGE:
|
|
11558
|
-
- \`progress\` to mark a step done. Call it ONCE per completed step, in the SAME response as the tool calls that did the work \u2014 never dedicate a separate turn to it. Report progress at EVERY meaningful milestone. Keep descriptions SHORT \u2014 mention the extension type but no file names, counts, namespaces, or other specifics. Examples:
|
|
11559
|
-
- "Planning extensions"
|
|
11560
|
-
- "Reading documentation"
|
|
11561
|
-
- "Creating dashboard page"
|
|
11562
|
-
- "Creating service plugin"
|
|
11563
|
-
- "Creating data collection"
|
|
11564
|
-
- "Registering extensions"
|
|
11565
|
-
- "Running type checks"
|
|
11566
|
-
- "Building project"
|
|
11567
|
-
- \`validate\` for all validation (tsc + build).
|
|
11568
|
-
- \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
|
|
11569
|
-
- File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
|
|
11570
|
-
- \`batch-write\` to create N new files in one call. NEVER call \`write\` more than once per turn \u2014 use batch-write instead. \`write\` is reserved for single-file creation.
|
|
11571
|
-
- \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
|
|
11572
|
-
- \`multi-edit\` to apply N find-and-replace edits across one or more files in one call. NEVER call \`edit\` more than once per turn \u2014 use multi-edit instead. \`edit\` is reserved for a single edit to one file.
|
|
11573
|
-
- For tools where no batch variant exists (e.g. \`grep\`, \`glob\`), still emit MULTIPLE \`tool_use\` blocks in a SINGLE response when the calls are independent. Sequential turns waste a model round-trip per call.
|
|
11574
|
-
- Before calling MCP tools, check if loaded skills already cover the API. Only use MCP for gaps.
|
|
11575
|
-
- When using MCP to look up a Wix SDK method, ALWAYS call \`ReadFullDocsMethodSchema\` (not just \`ReadFullDocsArticle\`). The schema is the source of truth for parameter shapes. Code examples in docs may use incorrect call signatures.
|
|
11576
|
-
- To discover API shapes, method signatures, or type definitions: ALWAYS try \`SearchWixSDKDocumentation\` or \`ReadFullDocsMethodSchema\` via wix-mcp first. ONLY fall back to grepping \`node_modules\` if the MCP tools return no useful results. Grepping \`node_modules\` as a first resort wastes turns, inflates context, and produces unreliable results \u2014 SDK internals are not a documentation source.
|
|
11577
|
-
- NEVER run preview, dev, release, or promote commands.
|
|
11578
|
-
|
|
11579
|
-
IMPLEMENTATION WORKFLOW:
|
|
11580
|
-
1. **Plan**: Determine extension types using the \`wix-app\` skill. Generate ALL UUIDs upfront. Include a \`progress\` call (e.g. "Planning extensions").
|
|
11581
|
-
2. **Research**: Load relevant SDK docs and skills for each extension type. Include a \`progress\` call (e.g. "Reading documentation").
|
|
11582
|
-
3. **Build**: Create every extension file in a SINGLE \`batch-write\` call. Build all extensions before registering. Include one \`progress\` call per extension type (e.g. "Creating dashboard page", "Creating service plugin").
|
|
11583
|
-
4. **Register**: Register all extensions in \`src/extensions.ts\`. Include a \`progress\` call (e.g. "Registering extensions").
|
|
11584
|
-
5. **Validate**: Run \`validate\` (typecheck only). Fix any errors and re-validate until tsc passes. Include a \`progress\` call (e.g. "Running type checks"). Then run \`validate({ runBuild: true })\` ONCE to verify the build. Pass \`installDeps: true\` ONLY when you added a new dependency to package.json in this iteration; otherwise omit it (node_modules is pre-installed). Include a \`progress\` call (e.g. "Building project").
|
|
11585
|
-
6. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
|
|
11586
|
-
|
|
11587
|
-
EFFICIENCY:
|
|
11588
|
-
- Always prefer the BATCH variant: \`batch-write\` over multiple \`write\`s, \`batch-read\` over multiple \`read\`s, \`multi-edit\` over multiple \`edit\`s.
|
|
11589
|
-
- When fixing type errors across N files, use ONE \`multi-edit\` call with all N edits.
|
|
11590
|
-
|
|
11591
|
-
FILE CREATION:
|
|
11592
|
-
- NEVER rewrite the same file twice. Once written, move on.
|
|
11593
|
-
- Keep each file under 200 lines. Split into types.ts, utils.ts if needed.
|
|
11594
|
-
- Do NOT output comments in code unless they explain non-obvious logic.
|
|
11595
|
-
|
|
11596
|
-
TYPESCRIPT:
|
|
11597
|
-
- The project enables \`verbatimModuleSyntax\`. Type-only imports MUST use \`import type\`.
|
|
11598
|
-
|
|
11599
|
-
PERMISSIONS:
|
|
11600
|
-
At the end of your response, output the required Wix app permissions as a JSON block.
|
|
11601
|
-
Use SCOPE ID format (not human-readable names). Examples:
|
|
11602
|
-
- \`@wix/data\` read \u2192 "SCOPE.DC-DATA.READ", write \u2192 "SCOPE.DC-DATA.WRITE"
|
|
11603
|
-
- Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
|
|
11604
|
-
|
|
11605
|
-
CRITICAL: Only include permissions that you have explicitly seen in the Wix SDK documentation (via MCP or loaded skills). NEVER guess or fabricate permission scope IDs. If you are unsure which permission a feature requires, look it up in the docs first. Omitting a permission is better than inventing one that does not exist.
|
|
11606
|
-
|
|
11607
|
-
\`\`\`json:required-permissions
|
|
11608
|
-
["SCOPE.DC-DATA.READ", "SCOPE.DC-DATA.WRITE"]
|
|
11609
|
-
\`\`\`
|
|
11610
|
-
|
|
11611
|
-
If no permissions are required, output an empty array:
|
|
11612
|
-
\`\`\`json:required-permissions
|
|
11613
|
-
[]
|
|
11614
|
-
\`\`\``;
|
|
11615
|
-
}
|
|
11616
|
-
});
|
|
11617
|
-
|
|
11618
|
-
// dist/opencode-integration/rules/ask-rules.js
|
|
11619
|
-
var require_ask_rules = __commonJS({
|
|
11620
|
-
"dist/opencode-integration/rules/ask-rules.js"(exports2) {
|
|
11621
|
-
"use strict";
|
|
11622
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11623
|
-
exports2.ASK_RULES = void 0;
|
|
11624
|
-
exports2.ASK_RULES = `CORE PRINCIPLES:
|
|
11625
|
-
- You are a READ-ONLY assistant. You MUST NOT modify, create, or delete any files.
|
|
11626
|
-
- Your job is to answer questions about the codebase and Wix platform by reading code and fetching documentation.
|
|
11627
|
-
- Use the read tool to explore the codebase and find relevant code.
|
|
11628
|
-
- Use the wix-mcp tools to fetch Wix SDK/API documentation when needed.
|
|
11629
|
-
- Provide clear, accurate, and well-structured answers.
|
|
11630
|
-
|
|
11631
|
-
TOOL USAGE:
|
|
11632
|
-
- \`progress\` to mark a step done. Call it ONCE per completed step, in the SAME response as the tool calls that did the work. Examples:
|
|
11633
|
-
- "Reading codebase"
|
|
11634
|
-
- "Looking up documentation"
|
|
11635
|
-
- "Analyzing code"
|
|
11636
|
-
|
|
11637
|
-
IMPORTANT INSTRUCTIONS:
|
|
11638
|
-
1. Do NOT edit, write, or create any files.
|
|
11639
|
-
2. Do NOT run any bash commands.
|
|
11640
|
-
3. READ the codebase to understand the code structure and find answers.
|
|
11641
|
-
4. Use MCP tools to look up Wix documentation when the question involves Wix APIs, SDKs, or platform features.
|
|
11642
|
-
5. If you cannot find a definitive answer, say so clearly and explain what you found.`;
|
|
11643
|
-
}
|
|
11644
|
-
});
|
|
11645
|
-
|
|
11646
|
-
// dist/job-decision-manager.js
|
|
11647
|
-
var require_job_decision_manager = __commonJS({
|
|
11648
|
-
"dist/job-decision-manager.js"(exports2) {
|
|
11649
|
-
"use strict";
|
|
11650
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11651
|
-
exports2.UserDecisionCancelledError = void 0;
|
|
11652
|
-
exports2.pauseForUserDecision = pauseForUserDecision;
|
|
11653
|
-
exports2.askJobChoice = askJobChoice;
|
|
11654
|
-
exports2.askJobConfirmation = askJobConfirmation;
|
|
11655
|
-
var types_1 = require_types_impl();
|
|
11656
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
11657
|
-
var CodeGenService_12 = require_CodeGenService();
|
|
11658
|
-
var logger_12 = require_logger();
|
|
11659
|
-
var DECISION_POLL_INTERVAL_MS = 2e3;
|
|
11660
|
-
var UserDecisionCancelledError = class extends Error {
|
|
11661
|
-
constructor(jobId, decisionId) {
|
|
11662
|
-
super(`User decision ${decisionId} cancelled for job ${jobId}`);
|
|
11663
|
-
this.jobId = jobId;
|
|
11664
|
-
this.decisionId = decisionId;
|
|
11665
|
-
this.name = "UserDecisionCancelledError";
|
|
11666
|
-
}
|
|
11495
|
+
plugins: []
|
|
11667
11496
|
};
|
|
11668
|
-
exports2.UserDecisionCancelledError = UserDecisionCancelledError;
|
|
11669
|
-
async function pauseForUserDecision(jobId, request) {
|
|
11670
|
-
const decisionId = crypto.randomUUID();
|
|
11671
|
-
const userDecision = {
|
|
11672
|
-
id: decisionId,
|
|
11673
|
-
request: {
|
|
11674
|
-
...request,
|
|
11675
|
-
requestedAt: /* @__PURE__ */ new Date()
|
|
11676
|
-
}
|
|
11677
|
-
};
|
|
11678
|
-
await codeGenerationService_12.codeGenerationService.updateJobWithPendingDecision(jobId, userDecision);
|
|
11679
|
-
logger_12.logger.info("[JobDecision] Paused for user input", {
|
|
11680
|
-
question: request.question
|
|
11681
|
-
});
|
|
11682
|
-
const startTime = Date.now();
|
|
11683
|
-
const response = await pollForJobDecisionResponse(jobId, decisionId);
|
|
11684
|
-
const durationMs = Date.now() - startTime;
|
|
11685
|
-
await codeGenerationService_12.codeGenerationService.resumeJobFromDecision(jobId);
|
|
11686
|
-
logger_12.logger.info("[JobDecision] Resumed after user decision", {
|
|
11687
|
-
selectedOptionId: response.selectedOptionId,
|
|
11688
|
-
durationMs
|
|
11689
|
-
});
|
|
11690
|
-
return response;
|
|
11691
|
-
}
|
|
11692
|
-
async function pollForJobDecisionResponse(jobId, decisionId) {
|
|
11693
|
-
logger_12.logger.info("[JobDecision] Polling for user decision response", {
|
|
11694
|
-
decisionId
|
|
11695
|
-
});
|
|
11696
|
-
while (true) {
|
|
11697
|
-
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
11698
|
-
if (!job) {
|
|
11699
|
-
throw new Error(`Job ${jobId} not found`);
|
|
11700
|
-
}
|
|
11701
|
-
if (job.status === CodeGenService_12.Status.CANCELLED || job.status === CodeGenService_12.Status.PENDING_CANCEL) {
|
|
11702
|
-
logger_12.logger.warn("[JobDecision] Job cancelled while waiting for user decision", { decisionId });
|
|
11703
|
-
throw new UserDecisionCancelledError(jobId, decisionId);
|
|
11704
|
-
}
|
|
11705
|
-
const decision = job.pendingUserDecisions?.find((d) => d.id === decisionId) ?? job.userDecisionHistory?.find((d) => d.id === decisionId);
|
|
11706
|
-
if (decision?.response?.selectedOptionId) {
|
|
11707
|
-
return {
|
|
11708
|
-
selectedOptionId: decision.response.selectedOptionId,
|
|
11709
|
-
respondedAt: decision.response.respondedAt ?? /* @__PURE__ */ new Date()
|
|
11710
|
-
};
|
|
11711
|
-
}
|
|
11712
|
-
await new Promise((resolve) => setTimeout(resolve, DECISION_POLL_INTERVAL_MS));
|
|
11713
|
-
}
|
|
11714
|
-
}
|
|
11715
|
-
async function askJobChoice(jobId, question, options, context) {
|
|
11716
|
-
const response = await pauseForUserDecision(jobId, {
|
|
11717
|
-
question,
|
|
11718
|
-
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
11719
|
-
options,
|
|
11720
|
-
context
|
|
11721
|
-
});
|
|
11722
|
-
if (!response.selectedOptionId) {
|
|
11723
|
-
throw new Error("No option selected in user decision response");
|
|
11724
|
-
}
|
|
11725
|
-
return response.selectedOptionId;
|
|
11726
|
-
}
|
|
11727
|
-
async function askJobConfirmation(jobId, question, context) {
|
|
11728
|
-
const response = await pauseForUserDecision(jobId, {
|
|
11729
|
-
question,
|
|
11730
|
-
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
11731
|
-
options: [
|
|
11732
|
-
{ id: "yes", label: "Yes" },
|
|
11733
|
-
{ id: "no", label: "No" }
|
|
11734
|
-
],
|
|
11735
|
-
context
|
|
11736
|
-
});
|
|
11737
|
-
return response.selectedOptionId === "yes";
|
|
11738
|
-
}
|
|
11739
11497
|
}
|
|
11740
11498
|
});
|
|
11741
11499
|
|
|
@@ -12095,165 +11853,47 @@ var require_http_impl2 = __commonJS({
|
|
|
12095
11853
|
}
|
|
12096
11854
|
});
|
|
12097
11855
|
|
|
12098
|
-
// dist/
|
|
12099
|
-
var require_utils9 = __commonJS({
|
|
12100
|
-
"dist/utils.js"(exports2) {
|
|
12101
|
-
"use strict";
|
|
12102
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12103
|
-
exports2.serializeError = serializeError;
|
|
12104
|
-
exports2.updateAllRunningTasks = updateAllRunningTasks;
|
|
12105
|
-
var types_1 = require_types_impl();
|
|
12106
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
12107
|
-
function serializeError(error) {
|
|
12108
|
-
if (error instanceof Error) {
|
|
12109
|
-
const base = {
|
|
12110
|
-
name: error.name,
|
|
12111
|
-
message: error.message,
|
|
12112
|
-
stack: error.stack
|
|
12113
|
-
};
|
|
12114
|
-
const anyErr = error;
|
|
12115
|
-
for (const key in anyErr) {
|
|
12116
|
-
if (!(key in base)) {
|
|
12117
|
-
try {
|
|
12118
|
-
base[key] = anyErr[key];
|
|
12119
|
-
} catch {
|
|
12120
|
-
}
|
|
12121
|
-
}
|
|
12122
|
-
}
|
|
12123
|
-
const withCause = error;
|
|
12124
|
-
if (withCause && "cause" in withCause) {
|
|
12125
|
-
base.cause = withCause.cause;
|
|
12126
|
-
}
|
|
12127
|
-
const maybeHttp = error;
|
|
12128
|
-
if (maybeHttp?.response?.data !== void 0)
|
|
12129
|
-
base.data = maybeHttp.response.data;
|
|
12130
|
-
if (maybeHttp?.code !== void 0)
|
|
12131
|
-
base.code = maybeHttp.code;
|
|
12132
|
-
if (maybeHttp?.details !== void 0)
|
|
12133
|
-
base.details = maybeHttp.details;
|
|
12134
|
-
return base;
|
|
12135
|
-
}
|
|
12136
|
-
if (typeof error === "object" && error !== null) {
|
|
12137
|
-
try {
|
|
12138
|
-
return JSON.parse(JSON.stringify(error));
|
|
12139
|
-
} catch {
|
|
12140
|
-
return { message: String(error) };
|
|
12141
|
-
}
|
|
12142
|
-
}
|
|
12143
|
-
return { message: String(error) };
|
|
12144
|
-
}
|
|
12145
|
-
async function updateAllRunningTasks(jobId, status, error) {
|
|
12146
|
-
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
12147
|
-
const tasks = (job?.tasks ?? []).filter((task) => task.status === types_1.Status.RUNNING || task.status === types_1.Status.PENDING) || [];
|
|
12148
|
-
for (const task of tasks) {
|
|
12149
|
-
if (!task.id)
|
|
12150
|
-
continue;
|
|
12151
|
-
await codeGenerationService_12.codeGenerationService.updateTask(jobId, task.id, status, error ? { error: serializeError(error) } : {});
|
|
12152
|
-
}
|
|
12153
|
-
}
|
|
12154
|
-
}
|
|
12155
|
-
});
|
|
12156
|
-
|
|
12157
|
-
// dist/flows/codegen-flow-helpers.js
|
|
12158
|
-
var require_codegen_flow_helpers = __commonJS({
|
|
12159
|
-
"dist/flows/codegen-flow-helpers.js"(exports2) {
|
|
12160
|
-
"use strict";
|
|
12161
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
12162
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12163
|
-
};
|
|
12164
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12165
|
-
exports2.updateJobPayload = updateJobPayload;
|
|
12166
|
-
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
12167
|
-
exports2.getOutputPath = getOutputPath;
|
|
12168
|
-
var path_1 = __importDefault2(require("path"));
|
|
12169
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
12170
|
-
var utils_1 = require_utils9();
|
|
12171
|
-
var DEFAULT_OUTPUT_PATH = "generated-app";
|
|
12172
|
-
async function updateJobPayload(jobContext, payload) {
|
|
12173
|
-
await codeGenerationService_12.codeGenerationService.updateJob(jobContext.jobId, payload);
|
|
12174
|
-
}
|
|
12175
|
-
async function updateParentTaskStatus(jobContext, status, error) {
|
|
12176
|
-
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, jobContext.taskId, status, error ? { error: (0, utils_1.serializeError)(error) } : {});
|
|
12177
|
-
}
|
|
12178
|
-
function getOutputPath() {
|
|
12179
|
-
const outputDir = process.env.OUTPUT_PATH || DEFAULT_OUTPUT_PATH;
|
|
12180
|
-
return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
12181
|
-
}
|
|
12182
|
-
}
|
|
12183
|
-
});
|
|
12184
|
-
|
|
12185
|
-
// dist/environments/hooks/checkpoint.js
|
|
11856
|
+
// ../codegen-checkpoint-plugin/dist/checkpoint.js
|
|
12186
11857
|
var require_checkpoint = __commonJS({
|
|
12187
|
-
"dist/
|
|
11858
|
+
"../codegen-checkpoint-plugin/dist/checkpoint.js"(exports2) {
|
|
12188
11859
|
"use strict";
|
|
12189
11860
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12190
|
-
exports2.
|
|
11861
|
+
exports2.checkpointPluginFactory = void 0;
|
|
11862
|
+
var fs_1 = require("fs");
|
|
11863
|
+
var path_1 = require("path");
|
|
12191
11864
|
var http_1 = require_http_impl2();
|
|
12192
11865
|
var http_client_1 = require_index_node();
|
|
12193
|
-
var logger_12 = require_logger();
|
|
12194
|
-
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
12195
|
-
var config_12 = require_config();
|
|
12196
|
-
var wixTokenRefresh_1 = require_wixTokenRefresh();
|
|
12197
11866
|
var FALLBACK_COMMIT_MESSAGE = "Auto-save";
|
|
12198
11867
|
var EML_MARKER = "generate-eml.ts";
|
|
12199
11868
|
var SET_COMMIT_MESSAGE_TOOL = "set-commit-message";
|
|
12200
11869
|
var MAX_COMMIT_MESSAGE_LENGTH = 1e3;
|
|
12201
11870
|
var TRUNCATION_SUFFIX = "\u2026";
|
|
11871
|
+
var ASSETS_DIR = (0, path_1.join)(__dirname, "..", "assets");
|
|
11872
|
+
var readAsset = (name) => (0, fs_1.readFileSync)((0, path_1.join)(ASSETS_DIR, name), "utf-8");
|
|
11873
|
+
var buildCheckpointRules = () => [
|
|
11874
|
+
{
|
|
11875
|
+
filename: "checkpoint-commit-message.md",
|
|
11876
|
+
content: readAsset("commit-message-rule.md")
|
|
11877
|
+
}
|
|
11878
|
+
];
|
|
11879
|
+
var buildCheckpointTools = () => [
|
|
11880
|
+
{
|
|
11881
|
+
filename: "set-commit-message.ts",
|
|
11882
|
+
source: readAsset("set-commit-message.ts")
|
|
11883
|
+
}
|
|
11884
|
+
];
|
|
12202
11885
|
var truncateCommitMessage = (message) => {
|
|
12203
11886
|
if (message.length <= MAX_COMMIT_MESSAGE_LENGTH)
|
|
12204
11887
|
return message;
|
|
12205
11888
|
return message.slice(0, MAX_COMMIT_MESSAGE_LENGTH - TRUNCATION_SUFFIX.length) + TRUNCATION_SUFFIX;
|
|
12206
11889
|
};
|
|
12207
|
-
var
|
|
12208
|
-
|
|
12209
|
-
});
|
|
12210
|
-
var withAuth = (req) => {
|
|
12211
|
-
const authHeader = {
|
|
12212
|
-
authorization: `Bearer ${process.env.WIX_ACCESS_TOKEN}`
|
|
12213
|
-
};
|
|
12214
|
-
if (typeof req === "function") {
|
|
12215
|
-
return (ctx) => {
|
|
12216
|
-
const r = req(ctx);
|
|
12217
|
-
return { ...r, headers: { ...r.headers ?? {}, ...authHeader } };
|
|
12218
|
-
};
|
|
12219
|
-
}
|
|
12220
|
-
return { ...req, headers: { ...req.headers ?? {}, ...authHeader } };
|
|
12221
|
-
};
|
|
12222
|
-
var isUnauthorized = (error) => {
|
|
12223
|
-
if (!http_client_1.HttpClient.isHttpError(error))
|
|
12224
|
-
return false;
|
|
12225
|
-
if (orchestratorHttpClient.isCancel(error))
|
|
12226
|
-
return false;
|
|
12227
|
-
return error.response?.status === 401;
|
|
12228
|
-
};
|
|
12229
|
-
var refreshAndPropagate = async () => {
|
|
12230
|
-
const token = await (0, wixTokenRefresh_1.refreshWixAccessToken)();
|
|
12231
|
-
(0, config_12.setCurrentAccessToken)(token);
|
|
12232
|
-
};
|
|
12233
|
-
var requestWithRefresh = async (req) => {
|
|
12234
|
-
try {
|
|
12235
|
-
return await orchestratorHttpClient.request(withAuth(req));
|
|
12236
|
-
} catch (err) {
|
|
12237
|
-
if (!isUnauthorized(err))
|
|
12238
|
-
throw err;
|
|
12239
|
-
logger_12.logger.warn("[Checkpoint] 401 received, refreshing token and retrying once");
|
|
12240
|
-
await refreshAndPropagate();
|
|
12241
|
-
return await orchestratorHttpClient.request(withAuth(req));
|
|
12242
|
-
}
|
|
12243
|
-
};
|
|
12244
|
-
var callCreateCheckpoint = async (appId, commitMessage) => {
|
|
12245
|
-
const resp = await requestWithRefresh((0, http_1.createCheckpoint)({
|
|
11890
|
+
var callCreateCheckpoint = async (client, appId, commitMessage) => {
|
|
11891
|
+
const resp = await client.request((0, http_1.createCheckpoint)({
|
|
12246
11892
|
appId,
|
|
12247
11893
|
commitMessage: truncateCommitMessage(commitMessage)
|
|
12248
11894
|
}));
|
|
12249
11895
|
return { checkpointId: resp.data?.checkpointId };
|
|
12250
11896
|
};
|
|
12251
|
-
var readBashCommand = (input) => {
|
|
12252
|
-
if (typeof input !== "object" || input === null)
|
|
12253
|
-
return void 0;
|
|
12254
|
-
const value = input.command;
|
|
12255
|
-
return typeof value === "string" ? value : void 0;
|
|
12256
|
-
};
|
|
12257
11897
|
var readToolCommitMessage = (input) => {
|
|
12258
11898
|
if (typeof input !== "object" || input === null)
|
|
12259
11899
|
return void 0;
|
|
@@ -12263,25 +11903,38 @@ var require_checkpoint = __commonJS({
|
|
|
12263
11903
|
const trimmed = value.trim();
|
|
12264
11904
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
12265
11905
|
};
|
|
12266
|
-
var
|
|
11906
|
+
var readBashCommand = (input) => {
|
|
11907
|
+
if (typeof input !== "object" || input === null)
|
|
11908
|
+
return void 0;
|
|
11909
|
+
const value = input.command;
|
|
11910
|
+
return typeof value === "string" ? value : void 0;
|
|
11911
|
+
};
|
|
11912
|
+
var checkpointPluginFactory = (ctx) => {
|
|
11913
|
+
const { host, job } = ctx;
|
|
11914
|
+
const orchestratorHttpClient = (0, http_client_1.createHttpClient)({
|
|
11915
|
+
baseURL: "https://editor.wix.com",
|
|
11916
|
+
headers: { Authorization: `Bearer ${host.auth.getAccessToken() ?? ""}` }
|
|
11917
|
+
});
|
|
12267
11918
|
let outcome;
|
|
12268
11919
|
let capturedCommitMessage;
|
|
12269
11920
|
const commitCheckpoint = async (commitMessage) => {
|
|
11921
|
+
if (!job)
|
|
11922
|
+
return;
|
|
12270
11923
|
try {
|
|
12271
|
-
const { checkpointId } = await callCreateCheckpoint(
|
|
11924
|
+
const { checkpointId } = await callCreateCheckpoint(orchestratorHttpClient, job.projectId, commitMessage);
|
|
12272
11925
|
outcome = { status: "created", checkpointId };
|
|
12273
11926
|
if (checkpointId) {
|
|
12274
|
-
await
|
|
11927
|
+
await host.jobs.updatePayload({ jobId: job.jobId, taskId: job.taskId }, { checkpointId });
|
|
12275
11928
|
}
|
|
12276
|
-
|
|
12277
|
-
projectId:
|
|
11929
|
+
host.logger.info("[Checkpoint] created", {
|
|
11930
|
+
projectId: job.projectId,
|
|
12278
11931
|
checkpointId,
|
|
12279
11932
|
commitMessage
|
|
12280
11933
|
});
|
|
12281
11934
|
} catch (error) {
|
|
12282
11935
|
outcome = { status: "failed", error };
|
|
12283
|
-
|
|
12284
|
-
projectId:
|
|
11936
|
+
host.logger.error("[Checkpoint] create failed", {
|
|
11937
|
+
projectId: job.projectId,
|
|
12285
11938
|
error: error instanceof Error ? error.message : String(error)
|
|
12286
11939
|
});
|
|
12287
11940
|
throw error;
|
|
@@ -12289,10 +11942,12 @@ var require_checkpoint = __commonJS({
|
|
|
12289
11942
|
};
|
|
12290
11943
|
return {
|
|
12291
11944
|
name: "checkpoint",
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
//
|
|
12295
|
-
// the
|
|
11945
|
+
rules: buildCheckpointRules(),
|
|
11946
|
+
tools: buildCheckpointTools(),
|
|
11947
|
+
// The agent calls `set-commit-message` (registered as a host tool from
|
|
11948
|
+
// the plugin's `tools` field) as the first thing it does. We capture
|
|
11949
|
+
// the value here. Then later, when the EML script runs (mid-flow), we
|
|
11950
|
+
// use the captured value for the early checkpoint.
|
|
12296
11951
|
async onToolUse({ tool, state }) {
|
|
12297
11952
|
if (state.status === "error")
|
|
12298
11953
|
return;
|
|
@@ -12317,97 +11972,272 @@ var require_checkpoint = __commonJS({
|
|
|
12317
11972
|
},
|
|
12318
11973
|
// Flow-end fallback: only fires if onToolUse didn't already create the
|
|
12319
11974
|
// checkpoint. Re-throws an earlier failure so the task is marked failed.
|
|
12320
|
-
async onFlowEnd({
|
|
11975
|
+
async onFlowEnd({ codegenFailed }) {
|
|
12321
11976
|
if (outcome?.status === "failed")
|
|
12322
11977
|
throw outcome.error;
|
|
12323
11978
|
if (outcome?.status === "created")
|
|
12324
11979
|
return;
|
|
12325
|
-
if (
|
|
11980
|
+
if (codegenFailed)
|
|
12326
11981
|
return;
|
|
12327
11982
|
const commitMessage = capturedCommitMessage ?? FALLBACK_COMMIT_MESSAGE;
|
|
12328
11983
|
await commitCheckpoint(commitMessage);
|
|
12329
11984
|
}
|
|
12330
11985
|
};
|
|
12331
11986
|
};
|
|
12332
|
-
exports2.
|
|
11987
|
+
exports2.checkpointPluginFactory = checkpointPluginFactory;
|
|
12333
11988
|
}
|
|
12334
11989
|
});
|
|
12335
11990
|
|
|
12336
|
-
// dist/
|
|
12337
|
-
var
|
|
12338
|
-
"dist/
|
|
11991
|
+
// ../codegen-checkpoint-plugin/dist/index.js
|
|
11992
|
+
var require_dist6 = __commonJS({
|
|
11993
|
+
"../codegen-checkpoint-plugin/dist/index.js"(exports2) {
|
|
12339
11994
|
"use strict";
|
|
12340
11995
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12341
|
-
exports2.
|
|
12342
|
-
|
|
12343
|
-
|
|
11996
|
+
exports2.checkpointPluginFactory = void 0;
|
|
11997
|
+
var checkpoint_1 = require_checkpoint();
|
|
11998
|
+
Object.defineProperty(exports2, "checkpointPluginFactory", { enumerable: true, get: function() {
|
|
11999
|
+
return checkpoint_1.checkpointPluginFactory;
|
|
12000
|
+
} });
|
|
12001
|
+
}
|
|
12002
|
+
});
|
|
12003
|
+
|
|
12004
|
+
// ../codegen-studio-2-config/dist/site-data-layer-rules.js
|
|
12005
|
+
var require_site_data_layer_rules = __commonJS({
|
|
12006
|
+
"../codegen-studio-2-config/dist/site-data-layer-rules.js"(exports2) {
|
|
12007
|
+
"use strict";
|
|
12008
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12009
|
+
exports2.SITE_DATA_LAYER_RULES = void 0;
|
|
12010
|
+
exports2.SITE_DATA_LAYER_RULES = `# Site Data Layer Rules
|
|
12011
|
+
|
|
12012
|
+
The agent operates on a live Wix site (METASITE_ID is in your prompt context).
|
|
12013
|
+
|
|
12014
|
+
For any persistent-data need \u2014 CMS collections, content tables, schemas, data models, or databases that store items \u2014 use the \`wix-site-data-collection\` skill.
|
|
12015
|
+
|
|
12016
|
+
The \`wix-app\` skill remains the right tool for surrounding extensions (dashboard pages, modals, widgets); only the data layer is overridden. A Wix CLI data collection extension will NOT work here \u2014 it only provisions on app install, but this is a live site that already exists. Use the \`wix-site-data-collection\` skill to discover the existing collections on the site and wire your code against them.
|
|
12017
|
+
|
|
12018
|
+
DO NOT write any code relating to Wix CLI data extensions \u2014 for example, do not generate \`src/extensions/data/extensions.ts\`.`;
|
|
12019
|
+
}
|
|
12020
|
+
});
|
|
12021
|
+
|
|
12022
|
+
// ../codegen-studio-2-config/dist/index.js
|
|
12023
|
+
var require_dist7 = __commonJS({
|
|
12024
|
+
"../codegen-studio-2-config/dist/index.js"(exports2) {
|
|
12025
|
+
"use strict";
|
|
12026
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12027
|
+
exports2.studio2CodegenConfig = void 0;
|
|
12028
|
+
var codegen_checkpoint_plugin_1 = require_dist6();
|
|
12029
|
+
var site_data_layer_rules_1 = require_site_data_layer_rules();
|
|
12030
|
+
exports2.studio2CodegenConfig = {
|
|
12031
|
+
codegenRules: [
|
|
12032
|
+
{ filename: "site-data-layer-rules.md", content: site_data_layer_rules_1.SITE_DATA_LAYER_RULES }
|
|
12033
|
+
],
|
|
12034
|
+
askRules: [],
|
|
12035
|
+
decisionCheckers: [],
|
|
12036
|
+
plugins: [codegen_checkpoint_plugin_1.checkpointPluginFactory]
|
|
12037
|
+
};
|
|
12038
|
+
}
|
|
12039
|
+
});
|
|
12040
|
+
|
|
12041
|
+
// dist/opencode-integration/rules/codegen-rules.js
|
|
12042
|
+
var require_codegen_rules = __commonJS({
|
|
12043
|
+
"dist/opencode-integration/rules/codegen-rules.js"(exports2) {
|
|
12044
|
+
"use strict";
|
|
12045
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12046
|
+
exports2.CODEGEN_RULES = void 0;
|
|
12047
|
+
exports2.CODEGEN_RULES = `CORE PRINCIPLES:
|
|
12048
|
+
- Do NOT invent or assume new types, modules, functions, props, events, or imports.
|
|
12049
|
+
- NEVER use mocks, placeholders, debugging, or TODOs in any code.
|
|
12050
|
+
- ALWAYS implement complete, production-ready functionality.
|
|
12051
|
+
- Do NOT create test files or test code. Tests are out of scope for code generation.
|
|
12052
|
+
|
|
12053
|
+
MINIMIZE TEXT OUTPUT \u2014 CRITICAL:
|
|
12054
|
+
- Do NOT narrate your actions. No "Let me now...", "Perfect!", "Now I'll...", "Excellent!", "Great!".
|
|
12055
|
+
- Do NOT explain what you just did. The tool output speaks for itself.
|
|
12056
|
+
- Do NOT read back files you just wrote. Trust the write succeeded.
|
|
12057
|
+
- Every text token costs money. Use tools, not words.
|
|
12058
|
+
|
|
12059
|
+
TOOL USAGE:
|
|
12060
|
+
- \`progress\` to mark a step done. Call it ONCE per completed step, in the SAME response as the tool calls that did the work \u2014 never dedicate a separate turn to it. Report progress at EVERY meaningful milestone. Keep descriptions SHORT \u2014 mention the extension type but no file names, counts, namespaces, or other specifics. Examples:
|
|
12061
|
+
- "Planning extensions"
|
|
12062
|
+
- "Reading documentation"
|
|
12063
|
+
- "Creating dashboard page"
|
|
12064
|
+
- "Creating service plugin"
|
|
12065
|
+
- "Creating data collection"
|
|
12066
|
+
- "Registering extensions"
|
|
12067
|
+
- "Running type checks"
|
|
12068
|
+
- "Building project"
|
|
12069
|
+
- \`validate\` for all validation (tsc + build).
|
|
12070
|
+
- \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
|
|
12071
|
+
- File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
|
|
12072
|
+
- \`batch-write\` to create N new files in one call. NEVER call \`write\` more than once per turn \u2014 use batch-write instead. \`write\` is reserved for single-file creation.
|
|
12073
|
+
- \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
|
|
12074
|
+
- \`multi-edit\` to apply N find-and-replace edits across one or more files in one call. NEVER call \`edit\` more than once per turn \u2014 use multi-edit instead. \`edit\` is reserved for a single edit to one file.
|
|
12075
|
+
- For tools where no batch variant exists (e.g. \`grep\`, \`glob\`), still emit MULTIPLE \`tool_use\` blocks in a SINGLE response when the calls are independent. Sequential turns waste a model round-trip per call.
|
|
12076
|
+
- Before calling MCP tools, check if loaded skills already cover the API. Only use MCP for gaps.
|
|
12077
|
+
- When using MCP to look up a Wix SDK method, ALWAYS call \`ReadFullDocsMethodSchema\` (not just \`ReadFullDocsArticle\`). The schema is the source of truth for parameter shapes. Code examples in docs may use incorrect call signatures.
|
|
12078
|
+
- To discover API shapes, method signatures, or type definitions: ALWAYS try \`SearchWixSDKDocumentation\` or \`ReadFullDocsMethodSchema\` via wix-mcp first. ONLY fall back to grepping \`node_modules\` if the MCP tools return no useful results. Grepping \`node_modules\` as a first resort wastes turns, inflates context, and produces unreliable results \u2014 SDK internals are not a documentation source.
|
|
12079
|
+
- NEVER run preview, dev, release, or promote commands.
|
|
12080
|
+
|
|
12081
|
+
IMPLEMENTATION WORKFLOW:
|
|
12082
|
+
1. **Plan**: Determine extension types using the \`wix-app\` skill. Generate ALL UUIDs upfront. Include a \`progress\` call (e.g. "Planning extensions").
|
|
12083
|
+
2. **Research**: Load relevant SDK docs and skills for each extension type. Include a \`progress\` call (e.g. "Reading documentation").
|
|
12084
|
+
3. **Build**: Create every extension file in a SINGLE \`batch-write\` call. Build all extensions before registering. Include one \`progress\` call per extension type (e.g. "Creating dashboard page", "Creating service plugin").
|
|
12085
|
+
4. **Register**: Register all extensions in \`src/extensions.ts\`. Include a \`progress\` call (e.g. "Registering extensions").
|
|
12086
|
+
5. **Validate**: Run \`validate\` (typecheck only). Fix any errors and re-validate until tsc passes. Include a \`progress\` call (e.g. "Running type checks"). Then run \`validate({ runBuild: true })\` ONCE to verify the build. Pass \`installDeps: true\` ONLY when you added a new dependency to package.json in this iteration; otherwise omit it (node_modules is pre-installed). Include a \`progress\` call (e.g. "Building project").
|
|
12087
|
+
6. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
|
|
12088
|
+
|
|
12089
|
+
EFFICIENCY:
|
|
12090
|
+
- Always prefer the BATCH variant: \`batch-write\` over multiple \`write\`s, \`batch-read\` over multiple \`read\`s, \`multi-edit\` over multiple \`edit\`s.
|
|
12091
|
+
- When fixing type errors across N files, use ONE \`multi-edit\` call with all N edits.
|
|
12092
|
+
|
|
12093
|
+
FILE CREATION:
|
|
12094
|
+
- NEVER rewrite the same file twice. Once written, move on.
|
|
12095
|
+
- Keep each file under 200 lines. Split into types.ts, utils.ts if needed.
|
|
12096
|
+
- Do NOT output comments in code unless they explain non-obvious logic.
|
|
12097
|
+
|
|
12098
|
+
TYPESCRIPT:
|
|
12099
|
+
- The project enables \`verbatimModuleSyntax\`. Type-only imports MUST use \`import type\`.
|
|
12100
|
+
|
|
12101
|
+
PERMISSIONS:
|
|
12102
|
+
At the end of your response, output the required Wix app permissions as a JSON block.
|
|
12103
|
+
Use SCOPE ID format (not human-readable names). Examples:
|
|
12104
|
+
- \`@wix/data\` read \u2192 "SCOPE.DC-DATA.READ", write \u2192 "SCOPE.DC-DATA.WRITE"
|
|
12105
|
+
- Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
|
|
12106
|
+
|
|
12107
|
+
CRITICAL: Only include permissions that you have explicitly seen in the Wix SDK documentation (via MCP or loaded skills). NEVER guess or fabricate permission scope IDs. If you are unsure which permission a feature requires, look it up in the docs first. Omitting a permission is better than inventing one that does not exist.
|
|
12108
|
+
|
|
12109
|
+
\`\`\`json:required-permissions
|
|
12110
|
+
["SCOPE.DC-DATA.READ", "SCOPE.DC-DATA.WRITE"]
|
|
12111
|
+
\`\`\`
|
|
12112
|
+
|
|
12113
|
+
If no permissions are required, output an empty array:
|
|
12114
|
+
\`\`\`json:required-permissions
|
|
12115
|
+
[]
|
|
12116
|
+
\`\`\``;
|
|
12117
|
+
}
|
|
12118
|
+
});
|
|
12119
|
+
|
|
12120
|
+
// dist/opencode-integration/rules/ask-rules.js
|
|
12121
|
+
var require_ask_rules = __commonJS({
|
|
12122
|
+
"dist/opencode-integration/rules/ask-rules.js"(exports2) {
|
|
12123
|
+
"use strict";
|
|
12124
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12125
|
+
exports2.ASK_RULES = void 0;
|
|
12126
|
+
exports2.ASK_RULES = `CORE PRINCIPLES:
|
|
12127
|
+
- You are a READ-ONLY assistant. You MUST NOT modify, create, or delete any files.
|
|
12128
|
+
- Your job is to answer questions about the codebase and Wix platform by reading code and fetching documentation.
|
|
12129
|
+
- Use the read tool to explore the codebase and find relevant code.
|
|
12130
|
+
- Use the wix-mcp tools to fetch Wix SDK/API documentation when needed.
|
|
12131
|
+
- Provide clear, accurate, and well-structured answers.
|
|
12132
|
+
|
|
12133
|
+
TOOL USAGE:
|
|
12134
|
+
- \`progress\` to mark a step done. Call it ONCE per completed step, in the SAME response as the tool calls that did the work. Examples:
|
|
12135
|
+
- "Reading codebase"
|
|
12136
|
+
- "Looking up documentation"
|
|
12137
|
+
- "Analyzing code"
|
|
12138
|
+
|
|
12139
|
+
IMPORTANT INSTRUCTIONS:
|
|
12140
|
+
1. Do NOT edit, write, or create any files.
|
|
12141
|
+
2. Do NOT run any bash commands.
|
|
12142
|
+
3. READ the codebase to understand the code structure and find answers.
|
|
12143
|
+
4. Use MCP tools to look up Wix documentation when the question involves Wix APIs, SDKs, or platform features.
|
|
12144
|
+
5. If you cannot find a definitive answer, say so clearly and explain what you found.`;
|
|
12344
12145
|
}
|
|
12345
12146
|
});
|
|
12346
12147
|
|
|
12347
|
-
// dist/
|
|
12348
|
-
var
|
|
12349
|
-
"dist/
|
|
12148
|
+
// dist/job-decision-manager.js
|
|
12149
|
+
var require_job_decision_manager = __commonJS({
|
|
12150
|
+
"dist/job-decision-manager.js"(exports2) {
|
|
12350
12151
|
"use strict";
|
|
12351
12152
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12352
|
-
exports2.
|
|
12353
|
-
exports2.
|
|
12354
|
-
exports2.
|
|
12153
|
+
exports2.UserDecisionCancelledError = void 0;
|
|
12154
|
+
exports2.pauseForUserDecision = pauseForUserDecision;
|
|
12155
|
+
exports2.askJobChoice = askJobChoice;
|
|
12156
|
+
exports2.askJobConfirmation = askJobConfirmation;
|
|
12157
|
+
var types_1 = require_types_impl();
|
|
12158
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
12159
|
+
var CodeGenService_12 = require_CodeGenService();
|
|
12355
12160
|
var logger_12 = require_logger();
|
|
12356
|
-
var
|
|
12357
|
-
|
|
12358
|
-
|
|
12161
|
+
var DECISION_POLL_INTERVAL_MS = 2e3;
|
|
12162
|
+
var UserDecisionCancelledError = class extends Error {
|
|
12163
|
+
constructor(jobId, decisionId) {
|
|
12164
|
+
super(`User decision ${decisionId} cancelled for job ${jobId}`);
|
|
12165
|
+
this.jobId = jobId;
|
|
12166
|
+
this.decisionId = decisionId;
|
|
12167
|
+
this.name = "UserDecisionCancelledError";
|
|
12168
|
+
}
|
|
12169
|
+
};
|
|
12170
|
+
exports2.UserDecisionCancelledError = UserDecisionCancelledError;
|
|
12171
|
+
async function pauseForUserDecision(jobId, request) {
|
|
12172
|
+
const decisionId = crypto.randomUUID();
|
|
12173
|
+
const userDecision = {
|
|
12174
|
+
id: decisionId,
|
|
12175
|
+
request: {
|
|
12176
|
+
...request,
|
|
12177
|
+
requestedAt: /* @__PURE__ */ new Date()
|
|
12178
|
+
}
|
|
12179
|
+
};
|
|
12180
|
+
await codeGenerationService_12.codeGenerationService.updateJobWithPendingDecision(jobId, userDecision);
|
|
12181
|
+
logger_12.logger.info("[JobDecision] Paused for user input", {
|
|
12182
|
+
question: request.question
|
|
12183
|
+
});
|
|
12184
|
+
const startTime = Date.now();
|
|
12185
|
+
const response = await pollForJobDecisionResponse(jobId, decisionId);
|
|
12186
|
+
const durationMs = Date.now() - startTime;
|
|
12187
|
+
await codeGenerationService_12.codeGenerationService.resumeJobFromDecision(jobId);
|
|
12188
|
+
logger_12.logger.info("[JobDecision] Resumed after user decision", {
|
|
12189
|
+
selectedOptionId: response.selectedOptionId,
|
|
12190
|
+
durationMs
|
|
12191
|
+
});
|
|
12192
|
+
return response;
|
|
12359
12193
|
}
|
|
12360
|
-
async function
|
|
12361
|
-
for
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
});
|
|
12194
|
+
async function pollForJobDecisionResponse(jobId, decisionId) {
|
|
12195
|
+
logger_12.logger.info("[JobDecision] Polling for user decision response", {
|
|
12196
|
+
decisionId
|
|
12197
|
+
});
|
|
12198
|
+
while (true) {
|
|
12199
|
+
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
12200
|
+
if (!job) {
|
|
12201
|
+
throw new Error(`Job ${jobId} not found`);
|
|
12202
|
+
}
|
|
12203
|
+
if (job.status === CodeGenService_12.Status.CANCELLED || job.status === CodeGenService_12.Status.PENDING_CANCEL) {
|
|
12204
|
+
logger_12.logger.warn("[JobDecision] Job cancelled while waiting for user decision", { decisionId });
|
|
12205
|
+
throw new UserDecisionCancelledError(jobId, decisionId);
|
|
12206
|
+
}
|
|
12207
|
+
const decision = job.pendingUserDecisions?.find((d) => d.id === decisionId) ?? job.userDecisionHistory?.find((d) => d.id === decisionId);
|
|
12208
|
+
if (decision?.response?.selectedOptionId) {
|
|
12209
|
+
return {
|
|
12210
|
+
selectedOptionId: decision.response.selectedOptionId,
|
|
12211
|
+
respondedAt: decision.response.respondedAt ?? /* @__PURE__ */ new Date()
|
|
12212
|
+
};
|
|
12371
12213
|
}
|
|
12214
|
+
await new Promise((resolve) => setTimeout(resolve, DECISION_POLL_INTERVAL_MS));
|
|
12372
12215
|
}
|
|
12373
12216
|
}
|
|
12374
|
-
async function
|
|
12375
|
-
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12382
|
-
|
|
12383
|
-
hook: hook.name,
|
|
12384
|
-
error: hookError instanceof Error ? hookError.message : String(hookError)
|
|
12385
|
-
});
|
|
12386
|
-
continue;
|
|
12387
|
-
}
|
|
12388
|
-
throw hookError;
|
|
12389
|
-
}
|
|
12217
|
+
async function askJobChoice(jobId, question, options, context) {
|
|
12218
|
+
const response = await pauseForUserDecision(jobId, {
|
|
12219
|
+
question,
|
|
12220
|
+
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
12221
|
+
options,
|
|
12222
|
+
context
|
|
12223
|
+
});
|
|
12224
|
+
if (!response.selectedOptionId) {
|
|
12225
|
+
throw new Error("No option selected in user decision response");
|
|
12390
12226
|
}
|
|
12227
|
+
return response.selectedOptionId;
|
|
12228
|
+
}
|
|
12229
|
+
async function askJobConfirmation(jobId, question, context) {
|
|
12230
|
+
const response = await pauseForUserDecision(jobId, {
|
|
12231
|
+
question,
|
|
12232
|
+
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
12233
|
+
options: [
|
|
12234
|
+
{ id: "yes", label: "Yes" },
|
|
12235
|
+
{ id: "no", label: "No" }
|
|
12236
|
+
],
|
|
12237
|
+
context
|
|
12238
|
+
});
|
|
12239
|
+
return response.selectedOptionId === "yes";
|
|
12391
12240
|
}
|
|
12392
|
-
}
|
|
12393
|
-
});
|
|
12394
|
-
|
|
12395
|
-
// dist/environments/hooks/index.js
|
|
12396
|
-
var require_hooks2 = __commonJS({
|
|
12397
|
-
"dist/environments/hooks/index.js"(exports2) {
|
|
12398
|
-
"use strict";
|
|
12399
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12400
|
-
exports2.runOnFlowEnd = exports2.runOnToolUse = exports2.getActiveHooks = void 0;
|
|
12401
|
-
var run_hooks_1 = require_run_hooks();
|
|
12402
|
-
Object.defineProperty(exports2, "getActiveHooks", { enumerable: true, get: function() {
|
|
12403
|
-
return run_hooks_1.getActiveHooks;
|
|
12404
|
-
} });
|
|
12405
|
-
Object.defineProperty(exports2, "runOnToolUse", { enumerable: true, get: function() {
|
|
12406
|
-
return run_hooks_1.runOnToolUse;
|
|
12407
|
-
} });
|
|
12408
|
-
Object.defineProperty(exports2, "runOnFlowEnd", { enumerable: true, get: function() {
|
|
12409
|
-
return run_hooks_1.runOnFlowEnd;
|
|
12410
|
-
} });
|
|
12411
12241
|
}
|
|
12412
12242
|
});
|
|
12413
12243
|
|
|
@@ -12416,21 +12246,14 @@ var require_environments = __commonJS({
|
|
|
12416
12246
|
"dist/environments/index.js"(exports2) {
|
|
12417
12247
|
"use strict";
|
|
12418
12248
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12419
|
-
exports2.getActiveHooks = void 0;
|
|
12420
12249
|
exports2.getCodegenEnvironmentConfig = getCodegenEnvironmentConfig;
|
|
12421
12250
|
var types_1 = require_types_impl();
|
|
12422
12251
|
var codegen_app_builder_config_1 = require_dist5();
|
|
12423
|
-
var codegen_studio_2_config_1 =
|
|
12252
|
+
var codegen_studio_2_config_1 = require_dist7();
|
|
12424
12253
|
var codegen_rules_1 = require_codegen_rules();
|
|
12425
12254
|
var ask_rules_1 = require_ask_rules();
|
|
12426
12255
|
var job_decision_manager_1 = require_job_decision_manager();
|
|
12427
12256
|
var logger_12 = require_logger();
|
|
12428
|
-
var checkpoint_1 = require_checkpoint();
|
|
12429
|
-
var checkpoint_rules_1 = require_checkpoint_rules();
|
|
12430
|
-
var hooks_1 = require_hooks2();
|
|
12431
|
-
Object.defineProperty(exports2, "getActiveHooks", { enumerable: true, get: function() {
|
|
12432
|
-
return hooks_1.getActiveHooks;
|
|
12433
|
-
} });
|
|
12434
12257
|
var SHARED_CODEGEN_RULE = {
|
|
12435
12258
|
filename: "codegen-instructions.md",
|
|
12436
12259
|
content: codegen_rules_1.CODEGEN_RULES
|
|
@@ -12447,18 +12270,7 @@ var require_environments = __commonJS({
|
|
|
12447
12270
|
function getCodegenEnvironmentConfig() {
|
|
12448
12271
|
switch (process.env.CODEGEN_ENVIRONMENT) {
|
|
12449
12272
|
case types_1.Environment.STUDIO_2:
|
|
12450
|
-
return withSharedRules(
|
|
12451
|
-
...codegen_studio_2_config_1.studio2CodegenConfig,
|
|
12452
|
-
codegenRules: [
|
|
12453
|
-
{
|
|
12454
|
-
filename: "checkpoint-commit-message.md",
|
|
12455
|
-
content: checkpoint_rules_1.CHECKPOINT_COMMIT_MESSAGE_RULES
|
|
12456
|
-
},
|
|
12457
|
-
...codegen_studio_2_config_1.studio2CodegenConfig.codegenRules
|
|
12458
|
-
],
|
|
12459
|
-
hooks: [checkpoint_1.checkpointHookFactory],
|
|
12460
|
-
tools: ["set-commit-message.ts"]
|
|
12461
|
-
});
|
|
12273
|
+
return withSharedRules(codegen_studio_2_config_1.studio2CodegenConfig);
|
|
12462
12274
|
case types_1.Environment.APP_BUILDER:
|
|
12463
12275
|
default:
|
|
12464
12276
|
return withSharedRules({
|
|
@@ -12992,6 +12804,54 @@ var require_progress_handler = __commonJS({
|
|
|
12992
12804
|
}
|
|
12993
12805
|
});
|
|
12994
12806
|
|
|
12807
|
+
// dist/plugins-runtime.js
|
|
12808
|
+
var require_plugins_runtime = __commonJS({
|
|
12809
|
+
"dist/plugins-runtime.js"(exports2) {
|
|
12810
|
+
"use strict";
|
|
12811
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12812
|
+
exports2.getActivePlugins = getActivePlugins;
|
|
12813
|
+
exports2.runOnToolUse = runOnToolUse;
|
|
12814
|
+
exports2.runOnFlowEnd = runOnFlowEnd;
|
|
12815
|
+
var job_context_storage_12 = require_job_context_storage();
|
|
12816
|
+
function getActivePlugins() {
|
|
12817
|
+
return job_context_storage_12.jobContextStorage.getStore()?.plugins ?? [];
|
|
12818
|
+
}
|
|
12819
|
+
var errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
12820
|
+
async function runOnToolUse(plugins, event, logger) {
|
|
12821
|
+
for (const plugin of plugins) {
|
|
12822
|
+
if (!plugin.onToolUse)
|
|
12823
|
+
continue;
|
|
12824
|
+
try {
|
|
12825
|
+
await plugin.onToolUse(event);
|
|
12826
|
+
} catch (error) {
|
|
12827
|
+
logger.error("[Plugin] onToolUse failed", {
|
|
12828
|
+
plugin: plugin.name,
|
|
12829
|
+
error: errorMessage(error)
|
|
12830
|
+
});
|
|
12831
|
+
}
|
|
12832
|
+
}
|
|
12833
|
+
}
|
|
12834
|
+
async function runOnFlowEnd(plugins, ctx, logger) {
|
|
12835
|
+
logger.info("[Plugin] Running onFlowEnd", {
|
|
12836
|
+
plugins: plugins.map((plugin) => plugin.name),
|
|
12837
|
+
codegenFailed: ctx.codegenFailed
|
|
12838
|
+
});
|
|
12839
|
+
for (const plugin of plugins) {
|
|
12840
|
+
if (!plugin.onFlowEnd)
|
|
12841
|
+
continue;
|
|
12842
|
+
try {
|
|
12843
|
+
await plugin.onFlowEnd(ctx);
|
|
12844
|
+
} catch (pluginError) {
|
|
12845
|
+
logger.error("[Plugin] onFlowEnd failed", {
|
|
12846
|
+
plugin: plugin.name,
|
|
12847
|
+
error: errorMessage(pluginError)
|
|
12848
|
+
});
|
|
12849
|
+
}
|
|
12850
|
+
}
|
|
12851
|
+
}
|
|
12852
|
+
}
|
|
12853
|
+
});
|
|
12854
|
+
|
|
12995
12855
|
// dist/opencode-integration/task-tracker/task-tracker.js
|
|
12996
12856
|
var require_task_tracker = __commonJS({
|
|
12997
12857
|
"dist/opencode-integration/task-tracker/task-tracker.js"(exports2) {
|
|
@@ -13002,7 +12862,7 @@ var require_task_tracker = __commonJS({
|
|
|
13002
12862
|
var types_1 = require_types4();
|
|
13003
12863
|
var logger_12 = require_logger();
|
|
13004
12864
|
var progress_handler_1 = require_progress_handler();
|
|
13005
|
-
var
|
|
12865
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
13006
12866
|
var OpenCodeTaskTracker = class {
|
|
13007
12867
|
constructor(workingDirectory) {
|
|
13008
12868
|
this.skillsUsed = /* @__PURE__ */ new Set();
|
|
@@ -13046,7 +12906,7 @@ var require_task_tracker = __commonJS({
|
|
|
13046
12906
|
if (tool === "progress") {
|
|
13047
12907
|
void this.progressHandler.handle(state, this.handlerContext);
|
|
13048
12908
|
}
|
|
13049
|
-
await (0,
|
|
12909
|
+
await (0, plugins_runtime_1.runOnToolUse)((0, plugins_runtime_1.getActivePlugins)(), { tool, state }, logger_12.logger);
|
|
13050
12910
|
}
|
|
13051
12911
|
handleSkillEvent(state) {
|
|
13052
12912
|
const skillName = state.title?.replace("Loaded skill: ", "") || "unknown";
|
|
@@ -13494,27 +13354,51 @@ var require_collect_extensions_created = __commonJS({
|
|
|
13494
13354
|
var promises_1 = require("fs/promises");
|
|
13495
13355
|
var ditto_codegen_types_12 = require_dist4();
|
|
13496
13356
|
var constants_1 = require_constants5();
|
|
13357
|
+
var DATA_COLLECTION_MARKER = /import\s+(?:type\s+)?\{[^}]*\bDataCollection\b[^}]*\}\s+from\s+['"]@wix\/astro\/builders['"]/;
|
|
13497
13358
|
var getExtensionDirectory = (extensionDefinitionPath) => `${path_1.posix.dirname(extensionDefinitionPath)}/`;
|
|
13498
13359
|
var isFileInExtensionFolder = (filePath, extensionDefinitionPath) => filePath === extensionDefinitionPath || filePath.startsWith(getExtensionDirectory(extensionDefinitionPath));
|
|
13360
|
+
var resolveFilePath = (outputPath, filePath) => (0, path_1.isAbsolute)(filePath) ? filePath : (0, path_1.join)(outputPath, filePath);
|
|
13361
|
+
var buildJobExtension = (definitionPath, extensionType, contentForTitle, titlePath, files) => ({
|
|
13362
|
+
path: definitionPath,
|
|
13363
|
+
extensionType,
|
|
13364
|
+
title: (0, constants_1.extractExtensionDisplayTitle)(contentForTitle, titlePath),
|
|
13365
|
+
files: [...files]
|
|
13366
|
+
});
|
|
13367
|
+
async function collectDataCollectionEntries(outputPath, parentExtensionFile, folderFiles) {
|
|
13368
|
+
const entries = [];
|
|
13369
|
+
for (const file of folderFiles) {
|
|
13370
|
+
if (file.path === parentExtensionFile.path)
|
|
13371
|
+
continue;
|
|
13372
|
+
try {
|
|
13373
|
+
const content = await (0, promises_1.readFile)(resolveFilePath(outputPath, file.path), "utf-8");
|
|
13374
|
+
if (!DATA_COLLECTION_MARKER.test(content))
|
|
13375
|
+
continue;
|
|
13376
|
+
entries.push(buildJobExtension(parentExtensionFile.path, "dataCollection", content, file.path, [parentExtensionFile, file]));
|
|
13377
|
+
} catch {
|
|
13378
|
+
continue;
|
|
13379
|
+
}
|
|
13380
|
+
}
|
|
13381
|
+
return entries;
|
|
13382
|
+
}
|
|
13499
13383
|
async function collectInsertedExtensionsMetadata(outputPath, files) {
|
|
13500
13384
|
const results = [];
|
|
13501
|
-
for (const
|
|
13502
|
-
if (
|
|
13385
|
+
for (const fileChange of files) {
|
|
13386
|
+
if (fileChange.operation !== ditto_codegen_types_12.ExtensionGenerationOperation.INSERT)
|
|
13503
13387
|
continue;
|
|
13504
|
-
if (!(0, constants_1.isExtensionsFile)(
|
|
13388
|
+
if (!(0, constants_1.isExtensionsFile)(fileChange.path))
|
|
13505
13389
|
continue;
|
|
13506
|
-
const fullPath = (0, path_1.isAbsolute)(f.path) ? f.path : (0, path_1.join)(outputPath, f.path);
|
|
13507
13390
|
try {
|
|
13508
|
-
const content = await (0, promises_1.readFile)(
|
|
13391
|
+
const content = await (0, promises_1.readFile)(resolveFilePath(outputPath, fileChange.path), "utf-8");
|
|
13509
13392
|
const detected = (0, constants_1.detectExtension)(content);
|
|
13510
13393
|
if (!detected)
|
|
13511
13394
|
continue;
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
}
|
|
13395
|
+
const folderFiles = files.filter((file) => isFileInExtensionFolder(file.path, fileChange.path));
|
|
13396
|
+
if (detected.extensionType === "dataCollections") {
|
|
13397
|
+
const dataCollectionEntries = await collectDataCollectionEntries(outputPath, fileChange, folderFiles);
|
|
13398
|
+
results.push(...dataCollectionEntries);
|
|
13399
|
+
continue;
|
|
13400
|
+
}
|
|
13401
|
+
results.push(buildJobExtension(fileChange.path, detected.extensionType, content, fileChange.path, folderFiles));
|
|
13518
13402
|
} catch {
|
|
13519
13403
|
continue;
|
|
13520
13404
|
}
|
|
@@ -13616,6 +13500,93 @@ var require_OpenCodeOrchestrator = __commonJS({
|
|
|
13616
13500
|
}
|
|
13617
13501
|
});
|
|
13618
13502
|
|
|
13503
|
+
// dist/utils.js
|
|
13504
|
+
var require_utils9 = __commonJS({
|
|
13505
|
+
"dist/utils.js"(exports2) {
|
|
13506
|
+
"use strict";
|
|
13507
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13508
|
+
exports2.serializeError = serializeError;
|
|
13509
|
+
exports2.updateAllRunningTasks = updateAllRunningTasks;
|
|
13510
|
+
var types_1 = require_types_impl();
|
|
13511
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
13512
|
+
function serializeError(error) {
|
|
13513
|
+
if (error instanceof Error) {
|
|
13514
|
+
const base = {
|
|
13515
|
+
name: error.name,
|
|
13516
|
+
message: error.message,
|
|
13517
|
+
stack: error.stack
|
|
13518
|
+
};
|
|
13519
|
+
const anyErr = error;
|
|
13520
|
+
for (const key in anyErr) {
|
|
13521
|
+
if (!(key in base)) {
|
|
13522
|
+
try {
|
|
13523
|
+
base[key] = anyErr[key];
|
|
13524
|
+
} catch {
|
|
13525
|
+
}
|
|
13526
|
+
}
|
|
13527
|
+
}
|
|
13528
|
+
const withCause = error;
|
|
13529
|
+
if (withCause && "cause" in withCause) {
|
|
13530
|
+
base.cause = withCause.cause;
|
|
13531
|
+
}
|
|
13532
|
+
const maybeHttp = error;
|
|
13533
|
+
if (maybeHttp?.response?.data !== void 0)
|
|
13534
|
+
base.data = maybeHttp.response.data;
|
|
13535
|
+
if (maybeHttp?.code !== void 0)
|
|
13536
|
+
base.code = maybeHttp.code;
|
|
13537
|
+
if (maybeHttp?.details !== void 0)
|
|
13538
|
+
base.details = maybeHttp.details;
|
|
13539
|
+
return base;
|
|
13540
|
+
}
|
|
13541
|
+
if (typeof error === "object" && error !== null) {
|
|
13542
|
+
try {
|
|
13543
|
+
return JSON.parse(JSON.stringify(error));
|
|
13544
|
+
} catch {
|
|
13545
|
+
return { message: String(error) };
|
|
13546
|
+
}
|
|
13547
|
+
}
|
|
13548
|
+
return { message: String(error) };
|
|
13549
|
+
}
|
|
13550
|
+
async function updateAllRunningTasks(jobId, status, error) {
|
|
13551
|
+
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
13552
|
+
const tasks = (job?.tasks ?? []).filter((task) => task.status === types_1.Status.RUNNING || task.status === types_1.Status.PENDING) || [];
|
|
13553
|
+
for (const task of tasks) {
|
|
13554
|
+
if (!task.id)
|
|
13555
|
+
continue;
|
|
13556
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobId, task.id, status, error ? { error: serializeError(error) } : {});
|
|
13557
|
+
}
|
|
13558
|
+
}
|
|
13559
|
+
}
|
|
13560
|
+
});
|
|
13561
|
+
|
|
13562
|
+
// dist/flows/codegen-flow-helpers.js
|
|
13563
|
+
var require_codegen_flow_helpers = __commonJS({
|
|
13564
|
+
"dist/flows/codegen-flow-helpers.js"(exports2) {
|
|
13565
|
+
"use strict";
|
|
13566
|
+
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
13567
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
13568
|
+
};
|
|
13569
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13570
|
+
exports2.updateJobPayload = updateJobPayload;
|
|
13571
|
+
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
13572
|
+
exports2.getOutputPath = getOutputPath;
|
|
13573
|
+
var path_1 = __importDefault2(require("path"));
|
|
13574
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
13575
|
+
var utils_1 = require_utils9();
|
|
13576
|
+
var DEFAULT_OUTPUT_PATH = "generated-app";
|
|
13577
|
+
async function updateJobPayload(jobContext, payload) {
|
|
13578
|
+
await codeGenerationService_12.codeGenerationService.updateJob(jobContext.jobId, payload);
|
|
13579
|
+
}
|
|
13580
|
+
async function updateParentTaskStatus(jobContext, status, error) {
|
|
13581
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, jobContext.taskId, status, error ? { error: (0, utils_1.serializeError)(error) } : {});
|
|
13582
|
+
}
|
|
13583
|
+
function getOutputPath() {
|
|
13584
|
+
const outputDir = process.env.OUTPUT_PATH || DEFAULT_OUTPUT_PATH;
|
|
13585
|
+
return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
13586
|
+
}
|
|
13587
|
+
}
|
|
13588
|
+
});
|
|
13589
|
+
|
|
13619
13590
|
// dist/flows/agent-io.js
|
|
13620
13591
|
var require_agent_io = __commonJS({
|
|
13621
13592
|
"dist/flows/agent-io.js"(exports2) {
|
|
@@ -15919,7 +15890,7 @@ var require_bi_logger_factory = __commonJS({
|
|
|
15919
15890
|
});
|
|
15920
15891
|
|
|
15921
15892
|
// ../../node_modules/@wix/wix-bi-logger-client/dist/index.js
|
|
15922
|
-
var
|
|
15893
|
+
var require_dist8 = __commonJS({
|
|
15923
15894
|
"../../node_modules/@wix/wix-bi-logger-client/dist/index.js"(exports2, module2) {
|
|
15924
15895
|
"use strict";
|
|
15925
15896
|
var BiLoggerClientFactory = require_bi_logger_factory();
|
|
@@ -18519,7 +18490,7 @@ var require_src2 = __commonJS({
|
|
|
18519
18490
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18520
18491
|
exports2.StandaloneNodeLogger = void 0;
|
|
18521
18492
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
18522
|
-
var wix_bi_logger_client_1 = tslib_1.__importDefault(
|
|
18493
|
+
var wix_bi_logger_client_1 = tslib_1.__importDefault(require_dist8());
|
|
18523
18494
|
var http_client_1 = require_index_node2();
|
|
18524
18495
|
var defaultOptions = {
|
|
18525
18496
|
baseUrl: process.env.BI_BASE_URL || "https://frog.wix.com",
|
|
@@ -18765,7 +18736,7 @@ var require_opencode_init = __commonJS({
|
|
|
18765
18736
|
var biEvents_1 = require_biEvents();
|
|
18766
18737
|
var pre_run_decision_1 = require_pre_run_decision();
|
|
18767
18738
|
var environments_12 = require_environments();
|
|
18768
|
-
var
|
|
18739
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
18769
18740
|
var runOpencodeInitFlow = async (blueprint, history, agentData) => {
|
|
18770
18741
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
18771
18742
|
if (!store?.jobId || !store?.taskId) {
|
|
@@ -18879,10 +18850,7 @@ var require_opencode_init = __commonJS({
|
|
|
18879
18850
|
error: error instanceof Error ? error.message : String(error)
|
|
18880
18851
|
});
|
|
18881
18852
|
} finally {
|
|
18882
|
-
await (0,
|
|
18883
|
-
failed: caughtError !== void 0,
|
|
18884
|
-
error: caughtError
|
|
18885
|
-
});
|
|
18853
|
+
await (0, plugins_runtime_1.runOnFlowEnd)((0, plugins_runtime_1.getActivePlugins)(), { codegenFailed: caughtError !== void 0, codegenError: caughtError }, logger_12.logger);
|
|
18886
18854
|
}
|
|
18887
18855
|
};
|
|
18888
18856
|
exports2.runOpencodeInitFlow = runOpencodeInitFlow;
|
|
@@ -18961,7 +18929,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
18961
18929
|
var inject_created_by_1 = require_inject_created_by();
|
|
18962
18930
|
var collect_extensions_created_1 = require_collect_extensions_created();
|
|
18963
18931
|
var biEvents_1 = require_biEvents();
|
|
18964
|
-
var
|
|
18932
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
18965
18933
|
var runOpencodeIterateFlow = async (chatHistory, agentData) => {
|
|
18966
18934
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
18967
18935
|
if (!store?.jobId || !store?.taskId) {
|
|
@@ -19065,10 +19033,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
19065
19033
|
error: error instanceof Error ? error.message : String(error)
|
|
19066
19034
|
});
|
|
19067
19035
|
} finally {
|
|
19068
|
-
await (0,
|
|
19069
|
-
failed: caughtError !== void 0,
|
|
19070
|
-
error: caughtError
|
|
19071
|
-
});
|
|
19036
|
+
await (0, plugins_runtime_1.runOnFlowEnd)((0, plugins_runtime_1.getActivePlugins)(), { codegenFailed: caughtError !== void 0, codegenError: caughtError }, logger_12.logger);
|
|
19072
19037
|
}
|
|
19073
19038
|
};
|
|
19074
19039
|
exports2.runOpencodeIterateFlow = runOpencodeIterateFlow;
|
|
@@ -19485,28 +19450,70 @@ var require_tools_writer = __commonJS({
|
|
|
19485
19450
|
var os_1 = require("os");
|
|
19486
19451
|
var path_1 = require("path");
|
|
19487
19452
|
var logger_12 = require_logger();
|
|
19488
|
-
var environments_12 = require_environments();
|
|
19489
19453
|
var GLOBAL_TOOLS_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "tools");
|
|
19490
19454
|
var OPENCODE_TOOLS_DIR = (0, path_1.join)(__dirname, "opencode-tools");
|
|
19491
|
-
|
|
19492
|
-
async function writeToolFiles() {
|
|
19455
|
+
async function writeToolFiles(pluginTools = []) {
|
|
19493
19456
|
await (0, promises_1.mkdir)(GLOBAL_TOOLS_DIR, { recursive: true });
|
|
19494
19457
|
const entries = await (0, promises_1.readdir)(OPENCODE_TOOLS_DIR);
|
|
19495
19458
|
const alwaysOnTools = entries.filter((f) => f.endsWith(".ts"));
|
|
19496
|
-
const envTools = (0, environments_12.getCodegenEnvironmentConfig)().tools ?? [];
|
|
19497
19459
|
await Promise.all([
|
|
19498
19460
|
...alwaysOnTools.map((file) => (0, promises_1.copyFile)((0, path_1.join)(OPENCODE_TOOLS_DIR, file), (0, path_1.join)(GLOBAL_TOOLS_DIR, file))),
|
|
19499
|
-
...
|
|
19461
|
+
...pluginTools.map((tool) => (0, promises_1.writeFile)((0, path_1.join)(GLOBAL_TOOLS_DIR, tool.filename), tool.source, "utf-8"))
|
|
19500
19462
|
]);
|
|
19501
19463
|
logger_12.logger.info("[OpenCode] Wrote global tool files", {
|
|
19502
19464
|
targetDir: GLOBAL_TOOLS_DIR,
|
|
19503
19465
|
alwaysOnTools,
|
|
19504
|
-
|
|
19466
|
+
pluginTools: pluginTools.map((t) => t.filename)
|
|
19505
19467
|
});
|
|
19506
19468
|
}
|
|
19507
19469
|
}
|
|
19508
19470
|
});
|
|
19509
19471
|
|
|
19472
|
+
// dist/plugin-host.js
|
|
19473
|
+
var require_plugin_host = __commonJS({
|
|
19474
|
+
"dist/plugin-host.js"(exports2) {
|
|
19475
|
+
"use strict";
|
|
19476
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19477
|
+
exports2.buildPluginHost = void 0;
|
|
19478
|
+
var logger_12 = require_logger();
|
|
19479
|
+
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
19480
|
+
var config_12 = require_config();
|
|
19481
|
+
var buildPluginHost = () => ({
|
|
19482
|
+
logger: logger_12.logger,
|
|
19483
|
+
jobs: {
|
|
19484
|
+
updatePayload: codegen_flow_helpers_12.updateJobPayload
|
|
19485
|
+
},
|
|
19486
|
+
auth: {
|
|
19487
|
+
getAccessToken: config_12.getCurrentAccessToken
|
|
19488
|
+
}
|
|
19489
|
+
});
|
|
19490
|
+
exports2.buildPluginHost = buildPluginHost;
|
|
19491
|
+
}
|
|
19492
|
+
});
|
|
19493
|
+
|
|
19494
|
+
// dist/plugin-artifacts.js
|
|
19495
|
+
var require_plugin_artifacts = __commonJS({
|
|
19496
|
+
"dist/plugin-artifacts.js"(exports2) {
|
|
19497
|
+
"use strict";
|
|
19498
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19499
|
+
exports2.collectPluginArtifacts = collectPluginArtifacts;
|
|
19500
|
+
var plugin_host_12 = require_plugin_host();
|
|
19501
|
+
function collectPluginArtifacts(envConfig) {
|
|
19502
|
+
const rules = [];
|
|
19503
|
+
const tools = [];
|
|
19504
|
+
const host = (0, plugin_host_12.buildPluginHost)();
|
|
19505
|
+
for (const factory of envConfig.plugins) {
|
|
19506
|
+
const plugin = factory({ host });
|
|
19507
|
+
if (plugin.rules)
|
|
19508
|
+
rules.push(...plugin.rules);
|
|
19509
|
+
if (plugin.tools)
|
|
19510
|
+
tools.push(...plugin.tools);
|
|
19511
|
+
}
|
|
19512
|
+
return { rules, tools };
|
|
19513
|
+
}
|
|
19514
|
+
}
|
|
19515
|
+
});
|
|
19516
|
+
|
|
19510
19517
|
// dist/index.js
|
|
19511
19518
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19512
19519
|
exports.processJob = processJob;
|
|
@@ -19526,8 +19533,10 @@ var logger_1 = require_logger();
|
|
|
19526
19533
|
var skills_installer_1 = require_skills_installer();
|
|
19527
19534
|
var rules_writer_1 = require_rules_writer();
|
|
19528
19535
|
var tools_writer_1 = require_tools_writer();
|
|
19536
|
+
var plugin_artifacts_1 = require_plugin_artifacts();
|
|
19529
19537
|
var config_1 = require_config();
|
|
19530
19538
|
var environments_1 = require_environments();
|
|
19539
|
+
var plugin_host_1 = require_plugin_host();
|
|
19531
19540
|
var sessionId = process.env.CODEGEN_SESSION_ID || (0, crypto_1.randomUUID)();
|
|
19532
19541
|
process.env.CODEGEN_SESSION_ID = sessionId;
|
|
19533
19542
|
(0, logger_1.initLogger)(sessionId);
|
|
@@ -19577,11 +19586,12 @@ var alwaysOnLoop = async () => {
|
|
|
19577
19586
|
};
|
|
19578
19587
|
async function initOpenCode() {
|
|
19579
19588
|
const envConfig = (0, environments_1.getCodegenEnvironmentConfig)();
|
|
19589
|
+
const pluginArtifacts = (0, plugin_artifacts_1.collectPluginArtifacts)(envConfig);
|
|
19580
19590
|
await Promise.all([
|
|
19581
|
-
(0, rules_writer_1.writeRuleFiles)(envConfig.codegenRules),
|
|
19591
|
+
(0, rules_writer_1.writeRuleFiles)([...envConfig.codegenRules, ...pluginArtifacts.rules]),
|
|
19582
19592
|
(0, rules_writer_1.writeRuleFiles)(envConfig.askRules),
|
|
19583
19593
|
(0, skills_installer_1.installSkills)((0, codegen_flow_helpers_1.getOutputPath)(), logger_1.logger),
|
|
19584
|
-
(0, tools_writer_1.writeToolFiles)()
|
|
19594
|
+
(0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools)
|
|
19585
19595
|
]);
|
|
19586
19596
|
}
|
|
19587
19597
|
async function main(ctx) {
|
|
@@ -19597,17 +19607,21 @@ async function main(ctx) {
|
|
|
19597
19607
|
var getFirstTask = (job) => {
|
|
19598
19608
|
return job.tasks?.[0];
|
|
19599
19609
|
};
|
|
19600
|
-
function
|
|
19610
|
+
function buildPluginsForTask(jobId, taskId, kind, payload) {
|
|
19601
19611
|
if (kind !== CodeGenService_1.TaskKind.INIT_CODEGEN && kind !== CodeGenService_1.TaskKind.ITERATE_CODEGEN) {
|
|
19602
19612
|
return void 0;
|
|
19603
19613
|
}
|
|
19604
19614
|
const userInput = extractUserInput(kind, payload);
|
|
19605
|
-
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19615
|
+
const host = (0, plugin_host_1.buildPluginHost)();
|
|
19616
|
+
return (0, environments_1.getCodegenEnvironmentConfig)().plugins.map((factory) => factory({
|
|
19617
|
+
host,
|
|
19618
|
+
job: {
|
|
19619
|
+
projectId: context_1.ctx.projectId,
|
|
19620
|
+
jobId,
|
|
19621
|
+
taskId,
|
|
19622
|
+
kind,
|
|
19623
|
+
userInput
|
|
19624
|
+
}
|
|
19611
19625
|
}));
|
|
19612
19626
|
}
|
|
19613
19627
|
function extractUserInput(kind, payload) {
|
|
@@ -19635,8 +19649,8 @@ async function processJob(job) {
|
|
|
19635
19649
|
return;
|
|
19636
19650
|
}
|
|
19637
19651
|
const payload = task.payload ?? {};
|
|
19638
|
-
const
|
|
19639
|
-
await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind,
|
|
19652
|
+
const plugins = buildPluginsForTask(jobId, task.id, task.kind, payload);
|
|
19653
|
+
await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind, plugins }, async () => {
|
|
19640
19654
|
logger_1.logger.info("[Job] Start processing", { taskKind: task.kind });
|
|
19641
19655
|
context_1.ctx.setJobStatus(jobId, CodeGenService_1.Status.RUNNING);
|
|
19642
19656
|
logger_1.logger.info("[Job] Marked job RUNNING", { initTaskId: task.id });
|