@wix/ditto-codegen-public 1.0.347 → 1.0.349
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 +515 -515
- package/package.json +4 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { tool } from "@opencode-ai/plugin";
|
|
2
|
+
|
|
3
|
+
export default tool({
|
|
4
|
+
description:
|
|
5
|
+
"Set the commit message for this codegen run. The message becomes the " +
|
|
6
|
+
"subject of a real `git commit -m` for the run, visible to " +
|
|
7
|
+
"non-technical users in their checkpoint history. Call this once, as " +
|
|
8
|
+
"the first thing you do, before writing any code.",
|
|
9
|
+
args: {
|
|
10
|
+
commitMessage: tool.schema
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.describe(
|
|
14
|
+
"One-line summary of the user's request. " +
|
|
15
|
+
'Imperative mood (e.g. "Add", "Fix", "Update"). ' +
|
|
16
|
+
"No trailing period, no quotes, no prefix. " +
|
|
17
|
+
"Ideally under 150 characters.",
|
|
18
|
+
),
|
|
19
|
+
},
|
|
20
|
+
async execute(args) {
|
|
21
|
+
return `Commit message set: ${args.commitMessage}`;
|
|
22
|
+
},
|
|
23
|
+
});
|
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);
|
|
@@ -11492,250 +11492,11 @@ var require_dist5 = __commonJS({
|
|
|
11492
11492
|
codegenRules: [],
|
|
11493
11493
|
askRules: [],
|
|
11494
11494
|
decisionCheckers: [],
|
|
11495
|
-
|
|
11495
|
+
plugins: []
|
|
11496
11496
|
};
|
|
11497
11497
|
}
|
|
11498
11498
|
});
|
|
11499
11499
|
|
|
11500
|
-
// ../codegen-studio-2-config/dist/site-data-layer-rules.js
|
|
11501
|
-
var require_site_data_layer_rules = __commonJS({
|
|
11502
|
-
"../codegen-studio-2-config/dist/site-data-layer-rules.js"(exports2) {
|
|
11503
|
-
"use strict";
|
|
11504
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11505
|
-
exports2.SITE_DATA_LAYER_RULES = void 0;
|
|
11506
|
-
exports2.SITE_DATA_LAYER_RULES = `# Site Data Layer Rules
|
|
11507
|
-
|
|
11508
|
-
The agent operates on a live Wix site (METASITE_ID is in your prompt context).
|
|
11509
|
-
|
|
11510
|
-
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.
|
|
11511
|
-
|
|
11512
|
-
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.
|
|
11513
|
-
|
|
11514
|
-
DO NOT write any code relating to Wix CLI data extensions \u2014 for example, do not generate \`src/extensions/data/extensions.ts\`.`;
|
|
11515
|
-
}
|
|
11516
|
-
});
|
|
11517
|
-
|
|
11518
|
-
// ../codegen-studio-2-config/dist/index.js
|
|
11519
|
-
var require_dist6 = __commonJS({
|
|
11520
|
-
"../codegen-studio-2-config/dist/index.js"(exports2) {
|
|
11521
|
-
"use strict";
|
|
11522
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11523
|
-
exports2.studio2CodegenConfig = void 0;
|
|
11524
|
-
var site_data_layer_rules_1 = require_site_data_layer_rules();
|
|
11525
|
-
exports2.studio2CodegenConfig = {
|
|
11526
|
-
codegenRules: [
|
|
11527
|
-
{ filename: "site-data-layer-rules.md", content: site_data_layer_rules_1.SITE_DATA_LAYER_RULES }
|
|
11528
|
-
],
|
|
11529
|
-
askRules: [],
|
|
11530
|
-
decisionCheckers: [],
|
|
11531
|
-
hooks: []
|
|
11532
|
-
};
|
|
11533
|
-
}
|
|
11534
|
-
});
|
|
11535
|
-
|
|
11536
|
-
// dist/opencode-integration/rules/codegen-rules.js
|
|
11537
|
-
var require_codegen_rules = __commonJS({
|
|
11538
|
-
"dist/opencode-integration/rules/codegen-rules.js"(exports2) {
|
|
11539
|
-
"use strict";
|
|
11540
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11541
|
-
exports2.CODEGEN_RULES = void 0;
|
|
11542
|
-
exports2.CODEGEN_RULES = `CORE PRINCIPLES:
|
|
11543
|
-
- Do NOT invent or assume new types, modules, functions, props, events, or imports.
|
|
11544
|
-
- NEVER use mocks, placeholders, debugging, or TODOs in any code.
|
|
11545
|
-
- ALWAYS implement complete, production-ready functionality.
|
|
11546
|
-
- Do NOT create test files or test code. Tests are out of scope for code generation.
|
|
11547
|
-
|
|
11548
|
-
MINIMIZE TEXT OUTPUT \u2014 CRITICAL:
|
|
11549
|
-
- Do NOT narrate your actions. No "Let me now...", "Perfect!", "Now I'll...", "Excellent!", "Great!".
|
|
11550
|
-
- Do NOT explain what you just did. The tool output speaks for itself.
|
|
11551
|
-
- Do NOT read back files you just wrote. Trust the write succeeded.
|
|
11552
|
-
- Every text token costs money. Use tools, not words.
|
|
11553
|
-
|
|
11554
|
-
TOOL USAGE:
|
|
11555
|
-
- \`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:
|
|
11556
|
-
- "Planning extensions"
|
|
11557
|
-
- "Reading documentation"
|
|
11558
|
-
- "Creating dashboard page"
|
|
11559
|
-
- "Creating service plugin"
|
|
11560
|
-
- "Creating data collection"
|
|
11561
|
-
- "Registering extensions"
|
|
11562
|
-
- "Running type checks"
|
|
11563
|
-
- "Building project"
|
|
11564
|
-
- \`validate\` for all validation (tsc + build).
|
|
11565
|
-
- \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
|
|
11566
|
-
- File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
|
|
11567
|
-
- \`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.
|
|
11568
|
-
- \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
|
|
11569
|
-
- \`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.
|
|
11570
|
-
- 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.
|
|
11571
|
-
- Before calling MCP tools, check if loaded skills already cover the API. Only use MCP for gaps.
|
|
11572
|
-
- 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.
|
|
11573
|
-
- 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.
|
|
11574
|
-
- NEVER run preview, dev, release, or promote commands.
|
|
11575
|
-
|
|
11576
|
-
IMPLEMENTATION WORKFLOW:
|
|
11577
|
-
1. **Plan**: Determine extension types using the \`wix-app\` skill. Generate ALL UUIDs upfront. Include a \`progress\` call (e.g. "Planning extensions").
|
|
11578
|
-
2. **Research**: Load relevant SDK docs and skills for each extension type. Include a \`progress\` call (e.g. "Reading documentation").
|
|
11579
|
-
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").
|
|
11580
|
-
4. **Register**: Register all extensions in \`src/extensions.ts\`. Include a \`progress\` call (e.g. "Registering extensions").
|
|
11581
|
-
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").
|
|
11582
|
-
6. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
|
|
11583
|
-
|
|
11584
|
-
EFFICIENCY:
|
|
11585
|
-
- Always prefer the BATCH variant: \`batch-write\` over multiple \`write\`s, \`batch-read\` over multiple \`read\`s, \`multi-edit\` over multiple \`edit\`s.
|
|
11586
|
-
- When fixing type errors across N files, use ONE \`multi-edit\` call with all N edits.
|
|
11587
|
-
|
|
11588
|
-
FILE CREATION:
|
|
11589
|
-
- NEVER rewrite the same file twice. Once written, move on.
|
|
11590
|
-
- Keep each file under 200 lines. Split into types.ts, utils.ts if needed.
|
|
11591
|
-
- Do NOT output comments in code unless they explain non-obvious logic.
|
|
11592
|
-
|
|
11593
|
-
TYPESCRIPT:
|
|
11594
|
-
- The project enables \`verbatimModuleSyntax\`. Type-only imports MUST use \`import type\`.
|
|
11595
|
-
|
|
11596
|
-
PERMISSIONS:
|
|
11597
|
-
At the end of your response, output the required Wix app permissions as a JSON block.
|
|
11598
|
-
Use SCOPE ID format (not human-readable names). Examples:
|
|
11599
|
-
- \`@wix/data\` read \u2192 "SCOPE.DC-DATA.READ", write \u2192 "SCOPE.DC-DATA.WRITE"
|
|
11600
|
-
- Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
|
|
11601
|
-
|
|
11602
|
-
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.
|
|
11603
|
-
|
|
11604
|
-
\`\`\`json:required-permissions
|
|
11605
|
-
["SCOPE.DC-DATA.READ", "SCOPE.DC-DATA.WRITE"]
|
|
11606
|
-
\`\`\`
|
|
11607
|
-
|
|
11608
|
-
If no permissions are required, output an empty array:
|
|
11609
|
-
\`\`\`json:required-permissions
|
|
11610
|
-
[]
|
|
11611
|
-
\`\`\``;
|
|
11612
|
-
}
|
|
11613
|
-
});
|
|
11614
|
-
|
|
11615
|
-
// dist/opencode-integration/rules/ask-rules.js
|
|
11616
|
-
var require_ask_rules = __commonJS({
|
|
11617
|
-
"dist/opencode-integration/rules/ask-rules.js"(exports2) {
|
|
11618
|
-
"use strict";
|
|
11619
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11620
|
-
exports2.ASK_RULES = void 0;
|
|
11621
|
-
exports2.ASK_RULES = `CORE PRINCIPLES:
|
|
11622
|
-
- You are a READ-ONLY assistant. You MUST NOT modify, create, or delete any files.
|
|
11623
|
-
- Your job is to answer questions about the codebase and Wix platform by reading code and fetching documentation.
|
|
11624
|
-
- Use the read tool to explore the codebase and find relevant code.
|
|
11625
|
-
- Use the wix-mcp tools to fetch Wix SDK/API documentation when needed.
|
|
11626
|
-
- Provide clear, accurate, and well-structured answers.
|
|
11627
|
-
|
|
11628
|
-
TOOL USAGE:
|
|
11629
|
-
- \`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:
|
|
11630
|
-
- "Reading codebase"
|
|
11631
|
-
- "Looking up documentation"
|
|
11632
|
-
- "Analyzing code"
|
|
11633
|
-
|
|
11634
|
-
IMPORTANT INSTRUCTIONS:
|
|
11635
|
-
1. Do NOT edit, write, or create any files.
|
|
11636
|
-
2. Do NOT run any bash commands.
|
|
11637
|
-
3. READ the codebase to understand the code structure and find answers.
|
|
11638
|
-
4. Use MCP tools to look up Wix documentation when the question involves Wix APIs, SDKs, or platform features.
|
|
11639
|
-
5. If you cannot find a definitive answer, say so clearly and explain what you found.`;
|
|
11640
|
-
}
|
|
11641
|
-
});
|
|
11642
|
-
|
|
11643
|
-
// dist/job-decision-manager.js
|
|
11644
|
-
var require_job_decision_manager = __commonJS({
|
|
11645
|
-
"dist/job-decision-manager.js"(exports2) {
|
|
11646
|
-
"use strict";
|
|
11647
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11648
|
-
exports2.UserDecisionCancelledError = void 0;
|
|
11649
|
-
exports2.pauseForUserDecision = pauseForUserDecision;
|
|
11650
|
-
exports2.askJobChoice = askJobChoice;
|
|
11651
|
-
exports2.askJobConfirmation = askJobConfirmation;
|
|
11652
|
-
var types_1 = require_types_impl();
|
|
11653
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
11654
|
-
var CodeGenService_12 = require_CodeGenService();
|
|
11655
|
-
var logger_12 = require_logger();
|
|
11656
|
-
var DECISION_POLL_INTERVAL_MS = 2e3;
|
|
11657
|
-
var UserDecisionCancelledError = class extends Error {
|
|
11658
|
-
constructor(jobId, decisionId) {
|
|
11659
|
-
super(`User decision ${decisionId} cancelled for job ${jobId}`);
|
|
11660
|
-
this.jobId = jobId;
|
|
11661
|
-
this.decisionId = decisionId;
|
|
11662
|
-
this.name = "UserDecisionCancelledError";
|
|
11663
|
-
}
|
|
11664
|
-
};
|
|
11665
|
-
exports2.UserDecisionCancelledError = UserDecisionCancelledError;
|
|
11666
|
-
async function pauseForUserDecision(jobId, request) {
|
|
11667
|
-
const decisionId = crypto.randomUUID();
|
|
11668
|
-
const userDecision = {
|
|
11669
|
-
id: decisionId,
|
|
11670
|
-
request: {
|
|
11671
|
-
...request,
|
|
11672
|
-
requestedAt: /* @__PURE__ */ new Date()
|
|
11673
|
-
}
|
|
11674
|
-
};
|
|
11675
|
-
await codeGenerationService_12.codeGenerationService.updateJobWithPendingDecision(jobId, userDecision);
|
|
11676
|
-
logger_12.logger.info("[JobDecision] Paused for user input", {
|
|
11677
|
-
question: request.question
|
|
11678
|
-
});
|
|
11679
|
-
const startTime = Date.now();
|
|
11680
|
-
const response = await pollForJobDecisionResponse(jobId, decisionId);
|
|
11681
|
-
const durationMs = Date.now() - startTime;
|
|
11682
|
-
await codeGenerationService_12.codeGenerationService.resumeJobFromDecision(jobId);
|
|
11683
|
-
logger_12.logger.info("[JobDecision] Resumed after user decision", {
|
|
11684
|
-
selectedOptionId: response.selectedOptionId,
|
|
11685
|
-
durationMs
|
|
11686
|
-
});
|
|
11687
|
-
return response;
|
|
11688
|
-
}
|
|
11689
|
-
async function pollForJobDecisionResponse(jobId, decisionId) {
|
|
11690
|
-
logger_12.logger.info("[JobDecision] Polling for user decision response", {
|
|
11691
|
-
decisionId
|
|
11692
|
-
});
|
|
11693
|
-
while (true) {
|
|
11694
|
-
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
11695
|
-
if (!job) {
|
|
11696
|
-
throw new Error(`Job ${jobId} not found`);
|
|
11697
|
-
}
|
|
11698
|
-
if (job.status === CodeGenService_12.Status.CANCELLED || job.status === CodeGenService_12.Status.PENDING_CANCEL) {
|
|
11699
|
-
logger_12.logger.warn("[JobDecision] Job cancelled while waiting for user decision", { decisionId });
|
|
11700
|
-
throw new UserDecisionCancelledError(jobId, decisionId);
|
|
11701
|
-
}
|
|
11702
|
-
const decision = job.pendingUserDecisions?.find((d) => d.id === decisionId) ?? job.userDecisionHistory?.find((d) => d.id === decisionId);
|
|
11703
|
-
if (decision?.response?.selectedOptionId) {
|
|
11704
|
-
return {
|
|
11705
|
-
selectedOptionId: decision.response.selectedOptionId,
|
|
11706
|
-
respondedAt: decision.response.respondedAt ?? /* @__PURE__ */ new Date()
|
|
11707
|
-
};
|
|
11708
|
-
}
|
|
11709
|
-
await new Promise((resolve) => setTimeout(resolve, DECISION_POLL_INTERVAL_MS));
|
|
11710
|
-
}
|
|
11711
|
-
}
|
|
11712
|
-
async function askJobChoice(jobId, question, options, context) {
|
|
11713
|
-
const response = await pauseForUserDecision(jobId, {
|
|
11714
|
-
question,
|
|
11715
|
-
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
11716
|
-
options,
|
|
11717
|
-
context
|
|
11718
|
-
});
|
|
11719
|
-
if (!response.selectedOptionId) {
|
|
11720
|
-
throw new Error("No option selected in user decision response");
|
|
11721
|
-
}
|
|
11722
|
-
return response.selectedOptionId;
|
|
11723
|
-
}
|
|
11724
|
-
async function askJobConfirmation(jobId, question, context) {
|
|
11725
|
-
const response = await pauseForUserDecision(jobId, {
|
|
11726
|
-
question,
|
|
11727
|
-
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
11728
|
-
options: [
|
|
11729
|
-
{ id: "yes", label: "Yes" },
|
|
11730
|
-
{ id: "no", label: "No" }
|
|
11731
|
-
],
|
|
11732
|
-
context
|
|
11733
|
-
});
|
|
11734
|
-
return response.selectedOptionId === "yes";
|
|
11735
|
-
}
|
|
11736
|
-
}
|
|
11737
|
-
});
|
|
11738
|
-
|
|
11739
11500
|
// ../../node_modules/@wix/ambassador-code-studio-orchestrator-v1-project/cjs/build/http.impl.js
|
|
11740
11501
|
var require_http_impl2 = __commonJS({
|
|
11741
11502
|
"../../node_modules/@wix/ambassador-code-studio-orchestrator-v1-project/cjs/build/http.impl.js"(exports2) {
|
|
@@ -12092,165 +11853,47 @@ var require_http_impl2 = __commonJS({
|
|
|
12092
11853
|
}
|
|
12093
11854
|
});
|
|
12094
11855
|
|
|
12095
|
-
// dist/
|
|
12096
|
-
var require_utils9 = __commonJS({
|
|
12097
|
-
"dist/utils.js"(exports2) {
|
|
12098
|
-
"use strict";
|
|
12099
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12100
|
-
exports2.serializeError = serializeError;
|
|
12101
|
-
exports2.updateAllRunningTasks = updateAllRunningTasks;
|
|
12102
|
-
var types_1 = require_types_impl();
|
|
12103
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
12104
|
-
function serializeError(error) {
|
|
12105
|
-
if (error instanceof Error) {
|
|
12106
|
-
const base = {
|
|
12107
|
-
name: error.name,
|
|
12108
|
-
message: error.message,
|
|
12109
|
-
stack: error.stack
|
|
12110
|
-
};
|
|
12111
|
-
const anyErr = error;
|
|
12112
|
-
for (const key in anyErr) {
|
|
12113
|
-
if (!(key in base)) {
|
|
12114
|
-
try {
|
|
12115
|
-
base[key] = anyErr[key];
|
|
12116
|
-
} catch {
|
|
12117
|
-
}
|
|
12118
|
-
}
|
|
12119
|
-
}
|
|
12120
|
-
const withCause = error;
|
|
12121
|
-
if (withCause && "cause" in withCause) {
|
|
12122
|
-
base.cause = withCause.cause;
|
|
12123
|
-
}
|
|
12124
|
-
const maybeHttp = error;
|
|
12125
|
-
if (maybeHttp?.response?.data !== void 0)
|
|
12126
|
-
base.data = maybeHttp.response.data;
|
|
12127
|
-
if (maybeHttp?.code !== void 0)
|
|
12128
|
-
base.code = maybeHttp.code;
|
|
12129
|
-
if (maybeHttp?.details !== void 0)
|
|
12130
|
-
base.details = maybeHttp.details;
|
|
12131
|
-
return base;
|
|
12132
|
-
}
|
|
12133
|
-
if (typeof error === "object" && error !== null) {
|
|
12134
|
-
try {
|
|
12135
|
-
return JSON.parse(JSON.stringify(error));
|
|
12136
|
-
} catch {
|
|
12137
|
-
return { message: String(error) };
|
|
12138
|
-
}
|
|
12139
|
-
}
|
|
12140
|
-
return { message: String(error) };
|
|
12141
|
-
}
|
|
12142
|
-
async function updateAllRunningTasks(jobId, status, error) {
|
|
12143
|
-
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
12144
|
-
const tasks = (job?.tasks ?? []).filter((task) => task.status === types_1.Status.RUNNING || task.status === types_1.Status.PENDING) || [];
|
|
12145
|
-
for (const task of tasks) {
|
|
12146
|
-
if (!task.id)
|
|
12147
|
-
continue;
|
|
12148
|
-
await codeGenerationService_12.codeGenerationService.updateTask(jobId, task.id, status, error ? { error: serializeError(error) } : {});
|
|
12149
|
-
}
|
|
12150
|
-
}
|
|
12151
|
-
}
|
|
12152
|
-
});
|
|
12153
|
-
|
|
12154
|
-
// dist/flows/codegen-flow-helpers.js
|
|
12155
|
-
var require_codegen_flow_helpers = __commonJS({
|
|
12156
|
-
"dist/flows/codegen-flow-helpers.js"(exports2) {
|
|
12157
|
-
"use strict";
|
|
12158
|
-
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
12159
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
12160
|
-
};
|
|
12161
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12162
|
-
exports2.updateJobPayload = updateJobPayload;
|
|
12163
|
-
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
12164
|
-
exports2.getOutputPath = getOutputPath;
|
|
12165
|
-
var path_1 = __importDefault2(require("path"));
|
|
12166
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
12167
|
-
var utils_1 = require_utils9();
|
|
12168
|
-
var DEFAULT_OUTPUT_PATH = "generated-app";
|
|
12169
|
-
async function updateJobPayload(jobContext, payload) {
|
|
12170
|
-
await codeGenerationService_12.codeGenerationService.updateJob(jobContext.jobId, payload);
|
|
12171
|
-
}
|
|
12172
|
-
async function updateParentTaskStatus(jobContext, status, error) {
|
|
12173
|
-
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, jobContext.taskId, status, error ? { error: (0, utils_1.serializeError)(error) } : {});
|
|
12174
|
-
}
|
|
12175
|
-
function getOutputPath() {
|
|
12176
|
-
const outputDir = process.env.OUTPUT_PATH || DEFAULT_OUTPUT_PATH;
|
|
12177
|
-
return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
12178
|
-
}
|
|
12179
|
-
}
|
|
12180
|
-
});
|
|
12181
|
-
|
|
12182
|
-
// dist/environments/hooks/checkpoint.js
|
|
11856
|
+
// ../codegen-checkpoint-plugin/dist/checkpoint.js
|
|
12183
11857
|
var require_checkpoint = __commonJS({
|
|
12184
|
-
"dist/
|
|
11858
|
+
"../codegen-checkpoint-plugin/dist/checkpoint.js"(exports2) {
|
|
12185
11859
|
"use strict";
|
|
12186
11860
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12187
|
-
exports2.
|
|
11861
|
+
exports2.checkpointPluginFactory = void 0;
|
|
11862
|
+
var fs_1 = require("fs");
|
|
11863
|
+
var path_1 = require("path");
|
|
12188
11864
|
var http_1 = require_http_impl2();
|
|
12189
11865
|
var http_client_1 = require_index_node();
|
|
12190
|
-
var logger_12 = require_logger();
|
|
12191
|
-
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
12192
|
-
var config_12 = require_config();
|
|
12193
|
-
var wixTokenRefresh_1 = require_wixTokenRefresh();
|
|
12194
11866
|
var FALLBACK_COMMIT_MESSAGE = "Auto-save";
|
|
12195
11867
|
var EML_MARKER = "generate-eml.ts";
|
|
12196
11868
|
var SET_COMMIT_MESSAGE_TOOL = "set-commit-message";
|
|
12197
11869
|
var MAX_COMMIT_MESSAGE_LENGTH = 1e3;
|
|
12198
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
|
+
];
|
|
12199
11885
|
var truncateCommitMessage = (message) => {
|
|
12200
11886
|
if (message.length <= MAX_COMMIT_MESSAGE_LENGTH)
|
|
12201
11887
|
return message;
|
|
12202
11888
|
return message.slice(0, MAX_COMMIT_MESSAGE_LENGTH - TRUNCATION_SUFFIX.length) + TRUNCATION_SUFFIX;
|
|
12203
11889
|
};
|
|
12204
|
-
var
|
|
12205
|
-
|
|
12206
|
-
});
|
|
12207
|
-
var withAuth = (req) => {
|
|
12208
|
-
const authHeader = {
|
|
12209
|
-
authorization: `Bearer ${process.env.WIX_ACCESS_TOKEN}`
|
|
12210
|
-
};
|
|
12211
|
-
if (typeof req === "function") {
|
|
12212
|
-
return (ctx) => {
|
|
12213
|
-
const r = req(ctx);
|
|
12214
|
-
return { ...r, headers: { ...r.headers ?? {}, ...authHeader } };
|
|
12215
|
-
};
|
|
12216
|
-
}
|
|
12217
|
-
return { ...req, headers: { ...req.headers ?? {}, ...authHeader } };
|
|
12218
|
-
};
|
|
12219
|
-
var isUnauthorized = (error) => {
|
|
12220
|
-
if (!http_client_1.HttpClient.isHttpError(error))
|
|
12221
|
-
return false;
|
|
12222
|
-
if (orchestratorHttpClient.isCancel(error))
|
|
12223
|
-
return false;
|
|
12224
|
-
return error.response?.status === 401;
|
|
12225
|
-
};
|
|
12226
|
-
var refreshAndPropagate = async () => {
|
|
12227
|
-
const token = await (0, wixTokenRefresh_1.refreshWixAccessToken)();
|
|
12228
|
-
(0, config_12.setCurrentAccessToken)(token);
|
|
12229
|
-
};
|
|
12230
|
-
var requestWithRefresh = async (req) => {
|
|
12231
|
-
try {
|
|
12232
|
-
return await orchestratorHttpClient.request(withAuth(req));
|
|
12233
|
-
} catch (err) {
|
|
12234
|
-
if (!isUnauthorized(err))
|
|
12235
|
-
throw err;
|
|
12236
|
-
logger_12.logger.warn("[Checkpoint] 401 received, refreshing token and retrying once");
|
|
12237
|
-
await refreshAndPropagate();
|
|
12238
|
-
return await orchestratorHttpClient.request(withAuth(req));
|
|
12239
|
-
}
|
|
12240
|
-
};
|
|
12241
|
-
var callCreateCheckpoint = async (appId, commitMessage) => {
|
|
12242
|
-
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)({
|
|
12243
11892
|
appId,
|
|
12244
11893
|
commitMessage: truncateCommitMessage(commitMessage)
|
|
12245
11894
|
}));
|
|
12246
11895
|
return { checkpointId: resp.data?.checkpointId };
|
|
12247
11896
|
};
|
|
12248
|
-
var readBashCommand = (input) => {
|
|
12249
|
-
if (typeof input !== "object" || input === null)
|
|
12250
|
-
return void 0;
|
|
12251
|
-
const value = input.command;
|
|
12252
|
-
return typeof value === "string" ? value : void 0;
|
|
12253
|
-
};
|
|
12254
11897
|
var readToolCommitMessage = (input) => {
|
|
12255
11898
|
if (typeof input !== "object" || input === null)
|
|
12256
11899
|
return void 0;
|
|
@@ -12260,25 +11903,38 @@ var require_checkpoint = __commonJS({
|
|
|
12260
11903
|
const trimmed = value.trim();
|
|
12261
11904
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
12262
11905
|
};
|
|
12263
|
-
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
|
+
});
|
|
12264
11918
|
let outcome;
|
|
12265
11919
|
let capturedCommitMessage;
|
|
12266
11920
|
const commitCheckpoint = async (commitMessage) => {
|
|
11921
|
+
if (!job)
|
|
11922
|
+
return;
|
|
12267
11923
|
try {
|
|
12268
|
-
const { checkpointId } = await callCreateCheckpoint(
|
|
11924
|
+
const { checkpointId } = await callCreateCheckpoint(orchestratorHttpClient, job.projectId, commitMessage);
|
|
12269
11925
|
outcome = { status: "created", checkpointId };
|
|
12270
11926
|
if (checkpointId) {
|
|
12271
|
-
await
|
|
11927
|
+
await host.jobs.updatePayload({ jobId: job.jobId, taskId: job.taskId }, { checkpointId });
|
|
12272
11928
|
}
|
|
12273
|
-
|
|
12274
|
-
projectId:
|
|
11929
|
+
host.logger.info("[Checkpoint] created", {
|
|
11930
|
+
projectId: job.projectId,
|
|
12275
11931
|
checkpointId,
|
|
12276
11932
|
commitMessage
|
|
12277
11933
|
});
|
|
12278
11934
|
} catch (error) {
|
|
12279
11935
|
outcome = { status: "failed", error };
|
|
12280
|
-
|
|
12281
|
-
projectId:
|
|
11936
|
+
host.logger.error("[Checkpoint] create failed", {
|
|
11937
|
+
projectId: job.projectId,
|
|
12282
11938
|
error: error instanceof Error ? error.message : String(error)
|
|
12283
11939
|
});
|
|
12284
11940
|
throw error;
|
|
@@ -12286,10 +11942,12 @@ var require_checkpoint = __commonJS({
|
|
|
12286
11942
|
};
|
|
12287
11943
|
return {
|
|
12288
11944
|
name: "checkpoint",
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
//
|
|
12292
|
-
// 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.
|
|
12293
11951
|
async onToolUse({ tool, state }) {
|
|
12294
11952
|
if (state.status === "error")
|
|
12295
11953
|
return;
|
|
@@ -12314,97 +11972,279 @@ var require_checkpoint = __commonJS({
|
|
|
12314
11972
|
},
|
|
12315
11973
|
// Flow-end fallback: only fires if onToolUse didn't already create the
|
|
12316
11974
|
// checkpoint. Re-throws an earlier failure so the task is marked failed.
|
|
12317
|
-
async onFlowEnd({
|
|
11975
|
+
async onFlowEnd({ codegenFailed }) {
|
|
12318
11976
|
if (outcome?.status === "failed")
|
|
12319
11977
|
throw outcome.error;
|
|
12320
11978
|
if (outcome?.status === "created")
|
|
12321
11979
|
return;
|
|
12322
|
-
if (
|
|
11980
|
+
if (codegenFailed)
|
|
12323
11981
|
return;
|
|
12324
11982
|
const commitMessage = capturedCommitMessage ?? FALLBACK_COMMIT_MESSAGE;
|
|
12325
11983
|
await commitCheckpoint(commitMessage);
|
|
12326
11984
|
}
|
|
12327
11985
|
};
|
|
12328
11986
|
};
|
|
12329
|
-
exports2.
|
|
11987
|
+
exports2.checkpointPluginFactory = checkpointPluginFactory;
|
|
11988
|
+
}
|
|
11989
|
+
});
|
|
11990
|
+
|
|
11991
|
+
// ../codegen-checkpoint-plugin/dist/index.js
|
|
11992
|
+
var require_dist6 = __commonJS({
|
|
11993
|
+
"../codegen-checkpoint-plugin/dist/index.js"(exports2) {
|
|
11994
|
+
"use strict";
|
|
11995
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
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
|
+
\`\`\``;
|
|
12330
12117
|
}
|
|
12331
12118
|
});
|
|
12332
12119
|
|
|
12333
|
-
// dist/
|
|
12334
|
-
var
|
|
12335
|
-
"dist/
|
|
12336
|
-
"use strict";
|
|
12337
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12338
|
-
exports2.
|
|
12339
|
-
exports2.
|
|
12340
|
-
|
|
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.
|
|
12145
|
+
|
|
12146
|
+
DEBUGGING GUIDANCE:
|
|
12147
|
+
- A preview/dev server is ALREADY running in this environment. NEVER recommend \`wix dev\`, \`wix preview\`, \`npx wix dev\`, or \`npx wix preview\`. Starting another server conflicts with and breaks the one already running, costing the user their work.
|
|
12148
|
+
- When asked how to debug the app, view logs, or inspect errors/network requests, recommend ONLY approaches that are safe alongside the running server:
|
|
12149
|
+
- Browser DevTools: the Console, Network, and Sources tabs.
|
|
12150
|
+
- \`console.log\` statements, then read the output in the already-running server logs.
|
|
12151
|
+
- Inspecting network requests in the browser, without starting a new server.`;
|
|
12341
12152
|
}
|
|
12342
12153
|
});
|
|
12343
12154
|
|
|
12344
|
-
// dist/
|
|
12345
|
-
var
|
|
12346
|
-
"dist/
|
|
12155
|
+
// dist/job-decision-manager.js
|
|
12156
|
+
var require_job_decision_manager = __commonJS({
|
|
12157
|
+
"dist/job-decision-manager.js"(exports2) {
|
|
12347
12158
|
"use strict";
|
|
12348
12159
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12349
|
-
exports2.
|
|
12350
|
-
exports2.
|
|
12351
|
-
exports2.
|
|
12160
|
+
exports2.UserDecisionCancelledError = void 0;
|
|
12161
|
+
exports2.pauseForUserDecision = pauseForUserDecision;
|
|
12162
|
+
exports2.askJobChoice = askJobChoice;
|
|
12163
|
+
exports2.askJobConfirmation = askJobConfirmation;
|
|
12164
|
+
var types_1 = require_types_impl();
|
|
12165
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
12166
|
+
var CodeGenService_12 = require_CodeGenService();
|
|
12352
12167
|
var logger_12 = require_logger();
|
|
12353
|
-
var
|
|
12354
|
-
|
|
12355
|
-
|
|
12168
|
+
var DECISION_POLL_INTERVAL_MS = 2e3;
|
|
12169
|
+
var UserDecisionCancelledError = class extends Error {
|
|
12170
|
+
constructor(jobId, decisionId) {
|
|
12171
|
+
super(`User decision ${decisionId} cancelled for job ${jobId}`);
|
|
12172
|
+
this.jobId = jobId;
|
|
12173
|
+
this.decisionId = decisionId;
|
|
12174
|
+
this.name = "UserDecisionCancelledError";
|
|
12175
|
+
}
|
|
12176
|
+
};
|
|
12177
|
+
exports2.UserDecisionCancelledError = UserDecisionCancelledError;
|
|
12178
|
+
async function pauseForUserDecision(jobId, request) {
|
|
12179
|
+
const decisionId = crypto.randomUUID();
|
|
12180
|
+
const userDecision = {
|
|
12181
|
+
id: decisionId,
|
|
12182
|
+
request: {
|
|
12183
|
+
...request,
|
|
12184
|
+
requestedAt: /* @__PURE__ */ new Date()
|
|
12185
|
+
}
|
|
12186
|
+
};
|
|
12187
|
+
await codeGenerationService_12.codeGenerationService.updateJobWithPendingDecision(jobId, userDecision);
|
|
12188
|
+
logger_12.logger.info("[JobDecision] Paused for user input", {
|
|
12189
|
+
question: request.question
|
|
12190
|
+
});
|
|
12191
|
+
const startTime = Date.now();
|
|
12192
|
+
const response = await pollForJobDecisionResponse(jobId, decisionId);
|
|
12193
|
+
const durationMs = Date.now() - startTime;
|
|
12194
|
+
await codeGenerationService_12.codeGenerationService.resumeJobFromDecision(jobId);
|
|
12195
|
+
logger_12.logger.info("[JobDecision] Resumed after user decision", {
|
|
12196
|
+
selectedOptionId: response.selectedOptionId,
|
|
12197
|
+
durationMs
|
|
12198
|
+
});
|
|
12199
|
+
return response;
|
|
12356
12200
|
}
|
|
12357
|
-
async function
|
|
12358
|
-
for
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
});
|
|
12201
|
+
async function pollForJobDecisionResponse(jobId, decisionId) {
|
|
12202
|
+
logger_12.logger.info("[JobDecision] Polling for user decision response", {
|
|
12203
|
+
decisionId
|
|
12204
|
+
});
|
|
12205
|
+
while (true) {
|
|
12206
|
+
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
12207
|
+
if (!job) {
|
|
12208
|
+
throw new Error(`Job ${jobId} not found`);
|
|
12209
|
+
}
|
|
12210
|
+
if (job.status === CodeGenService_12.Status.CANCELLED || job.status === CodeGenService_12.Status.PENDING_CANCEL) {
|
|
12211
|
+
logger_12.logger.warn("[JobDecision] Job cancelled while waiting for user decision", { decisionId });
|
|
12212
|
+
throw new UserDecisionCancelledError(jobId, decisionId);
|
|
12213
|
+
}
|
|
12214
|
+
const decision = job.pendingUserDecisions?.find((d) => d.id === decisionId) ?? job.userDecisionHistory?.find((d) => d.id === decisionId);
|
|
12215
|
+
if (decision?.response?.selectedOptionId) {
|
|
12216
|
+
return {
|
|
12217
|
+
selectedOptionId: decision.response.selectedOptionId,
|
|
12218
|
+
respondedAt: decision.response.respondedAt ?? /* @__PURE__ */ new Date()
|
|
12219
|
+
};
|
|
12368
12220
|
}
|
|
12221
|
+
await new Promise((resolve) => setTimeout(resolve, DECISION_POLL_INTERVAL_MS));
|
|
12369
12222
|
}
|
|
12370
12223
|
}
|
|
12371
|
-
async function
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12375
|
-
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
hook: hook.name,
|
|
12381
|
-
error: hookError instanceof Error ? hookError.message : String(hookError)
|
|
12382
|
-
});
|
|
12383
|
-
continue;
|
|
12384
|
-
}
|
|
12385
|
-
throw hookError;
|
|
12386
|
-
}
|
|
12224
|
+
async function askJobChoice(jobId, question, options, context) {
|
|
12225
|
+
const response = await pauseForUserDecision(jobId, {
|
|
12226
|
+
question,
|
|
12227
|
+
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
12228
|
+
options,
|
|
12229
|
+
context
|
|
12230
|
+
});
|
|
12231
|
+
if (!response.selectedOptionId) {
|
|
12232
|
+
throw new Error("No option selected in user decision response");
|
|
12387
12233
|
}
|
|
12234
|
+
return response.selectedOptionId;
|
|
12235
|
+
}
|
|
12236
|
+
async function askJobConfirmation(jobId, question, context) {
|
|
12237
|
+
const response = await pauseForUserDecision(jobId, {
|
|
12238
|
+
question,
|
|
12239
|
+
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
12240
|
+
options: [
|
|
12241
|
+
{ id: "yes", label: "Yes" },
|
|
12242
|
+
{ id: "no", label: "No" }
|
|
12243
|
+
],
|
|
12244
|
+
context
|
|
12245
|
+
});
|
|
12246
|
+
return response.selectedOptionId === "yes";
|
|
12388
12247
|
}
|
|
12389
|
-
}
|
|
12390
|
-
});
|
|
12391
|
-
|
|
12392
|
-
// dist/environments/hooks/index.js
|
|
12393
|
-
var require_hooks2 = __commonJS({
|
|
12394
|
-
"dist/environments/hooks/index.js"(exports2) {
|
|
12395
|
-
"use strict";
|
|
12396
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12397
|
-
exports2.runOnFlowEnd = exports2.runOnToolUse = exports2.getActiveHooks = void 0;
|
|
12398
|
-
var run_hooks_1 = require_run_hooks();
|
|
12399
|
-
Object.defineProperty(exports2, "getActiveHooks", { enumerable: true, get: function() {
|
|
12400
|
-
return run_hooks_1.getActiveHooks;
|
|
12401
|
-
} });
|
|
12402
|
-
Object.defineProperty(exports2, "runOnToolUse", { enumerable: true, get: function() {
|
|
12403
|
-
return run_hooks_1.runOnToolUse;
|
|
12404
|
-
} });
|
|
12405
|
-
Object.defineProperty(exports2, "runOnFlowEnd", { enumerable: true, get: function() {
|
|
12406
|
-
return run_hooks_1.runOnFlowEnd;
|
|
12407
|
-
} });
|
|
12408
12248
|
}
|
|
12409
12249
|
});
|
|
12410
12250
|
|
|
@@ -12413,21 +12253,14 @@ var require_environments = __commonJS({
|
|
|
12413
12253
|
"dist/environments/index.js"(exports2) {
|
|
12414
12254
|
"use strict";
|
|
12415
12255
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12416
|
-
exports2.getActiveHooks = void 0;
|
|
12417
12256
|
exports2.getCodegenEnvironmentConfig = getCodegenEnvironmentConfig;
|
|
12418
12257
|
var types_1 = require_types_impl();
|
|
12419
12258
|
var codegen_app_builder_config_1 = require_dist5();
|
|
12420
|
-
var codegen_studio_2_config_1 =
|
|
12259
|
+
var codegen_studio_2_config_1 = require_dist7();
|
|
12421
12260
|
var codegen_rules_1 = require_codegen_rules();
|
|
12422
12261
|
var ask_rules_1 = require_ask_rules();
|
|
12423
12262
|
var job_decision_manager_1 = require_job_decision_manager();
|
|
12424
12263
|
var logger_12 = require_logger();
|
|
12425
|
-
var checkpoint_1 = require_checkpoint();
|
|
12426
|
-
var checkpoint_rules_1 = require_checkpoint_rules();
|
|
12427
|
-
var hooks_1 = require_hooks2();
|
|
12428
|
-
Object.defineProperty(exports2, "getActiveHooks", { enumerable: true, get: function() {
|
|
12429
|
-
return hooks_1.getActiveHooks;
|
|
12430
|
-
} });
|
|
12431
12264
|
var SHARED_CODEGEN_RULE = {
|
|
12432
12265
|
filename: "codegen-instructions.md",
|
|
12433
12266
|
content: codegen_rules_1.CODEGEN_RULES
|
|
@@ -12444,18 +12277,7 @@ var require_environments = __commonJS({
|
|
|
12444
12277
|
function getCodegenEnvironmentConfig() {
|
|
12445
12278
|
switch (process.env.CODEGEN_ENVIRONMENT) {
|
|
12446
12279
|
case types_1.Environment.STUDIO_2:
|
|
12447
|
-
return withSharedRules(
|
|
12448
|
-
...codegen_studio_2_config_1.studio2CodegenConfig,
|
|
12449
|
-
codegenRules: [
|
|
12450
|
-
{
|
|
12451
|
-
filename: "checkpoint-commit-message.md",
|
|
12452
|
-
content: checkpoint_rules_1.CHECKPOINT_COMMIT_MESSAGE_RULES
|
|
12453
|
-
},
|
|
12454
|
-
...codegen_studio_2_config_1.studio2CodegenConfig.codegenRules
|
|
12455
|
-
],
|
|
12456
|
-
hooks: [checkpoint_1.checkpointHookFactory],
|
|
12457
|
-
tools: ["set-commit-message.ts"]
|
|
12458
|
-
});
|
|
12280
|
+
return withSharedRules(codegen_studio_2_config_1.studio2CodegenConfig);
|
|
12459
12281
|
case types_1.Environment.APP_BUILDER:
|
|
12460
12282
|
default:
|
|
12461
12283
|
return withSharedRules({
|
|
@@ -12989,6 +12811,54 @@ var require_progress_handler = __commonJS({
|
|
|
12989
12811
|
}
|
|
12990
12812
|
});
|
|
12991
12813
|
|
|
12814
|
+
// dist/plugins-runtime.js
|
|
12815
|
+
var require_plugins_runtime = __commonJS({
|
|
12816
|
+
"dist/plugins-runtime.js"(exports2) {
|
|
12817
|
+
"use strict";
|
|
12818
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12819
|
+
exports2.getActivePlugins = getActivePlugins;
|
|
12820
|
+
exports2.runOnToolUse = runOnToolUse;
|
|
12821
|
+
exports2.runOnFlowEnd = runOnFlowEnd;
|
|
12822
|
+
var job_context_storage_12 = require_job_context_storage();
|
|
12823
|
+
function getActivePlugins() {
|
|
12824
|
+
return job_context_storage_12.jobContextStorage.getStore()?.plugins ?? [];
|
|
12825
|
+
}
|
|
12826
|
+
var errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
12827
|
+
async function runOnToolUse(plugins, event, logger) {
|
|
12828
|
+
for (const plugin of plugins) {
|
|
12829
|
+
if (!plugin.onToolUse)
|
|
12830
|
+
continue;
|
|
12831
|
+
try {
|
|
12832
|
+
await plugin.onToolUse(event);
|
|
12833
|
+
} catch (error) {
|
|
12834
|
+
logger.error("[Plugin] onToolUse failed", {
|
|
12835
|
+
plugin: plugin.name,
|
|
12836
|
+
error: errorMessage(error)
|
|
12837
|
+
});
|
|
12838
|
+
}
|
|
12839
|
+
}
|
|
12840
|
+
}
|
|
12841
|
+
async function runOnFlowEnd(plugins, ctx, logger) {
|
|
12842
|
+
logger.info("[Plugin] Running onFlowEnd", {
|
|
12843
|
+
plugins: plugins.map((plugin) => plugin.name),
|
|
12844
|
+
codegenFailed: ctx.codegenFailed
|
|
12845
|
+
});
|
|
12846
|
+
for (const plugin of plugins) {
|
|
12847
|
+
if (!plugin.onFlowEnd)
|
|
12848
|
+
continue;
|
|
12849
|
+
try {
|
|
12850
|
+
await plugin.onFlowEnd(ctx);
|
|
12851
|
+
} catch (pluginError) {
|
|
12852
|
+
logger.error("[Plugin] onFlowEnd failed", {
|
|
12853
|
+
plugin: plugin.name,
|
|
12854
|
+
error: errorMessage(pluginError)
|
|
12855
|
+
});
|
|
12856
|
+
}
|
|
12857
|
+
}
|
|
12858
|
+
}
|
|
12859
|
+
}
|
|
12860
|
+
});
|
|
12861
|
+
|
|
12992
12862
|
// dist/opencode-integration/task-tracker/task-tracker.js
|
|
12993
12863
|
var require_task_tracker = __commonJS({
|
|
12994
12864
|
"dist/opencode-integration/task-tracker/task-tracker.js"(exports2) {
|
|
@@ -12999,7 +12869,7 @@ var require_task_tracker = __commonJS({
|
|
|
12999
12869
|
var types_1 = require_types4();
|
|
13000
12870
|
var logger_12 = require_logger();
|
|
13001
12871
|
var progress_handler_1 = require_progress_handler();
|
|
13002
|
-
var
|
|
12872
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
13003
12873
|
var OpenCodeTaskTracker = class {
|
|
13004
12874
|
constructor(workingDirectory) {
|
|
13005
12875
|
this.skillsUsed = /* @__PURE__ */ new Set();
|
|
@@ -13043,7 +12913,7 @@ var require_task_tracker = __commonJS({
|
|
|
13043
12913
|
if (tool === "progress") {
|
|
13044
12914
|
void this.progressHandler.handle(state, this.handlerContext);
|
|
13045
12915
|
}
|
|
13046
|
-
await (0,
|
|
12916
|
+
await (0, plugins_runtime_1.runOnToolUse)((0, plugins_runtime_1.getActivePlugins)(), { tool, state }, logger_12.logger);
|
|
13047
12917
|
}
|
|
13048
12918
|
handleSkillEvent(state) {
|
|
13049
12919
|
const skillName = state.title?.replace("Loaded skill: ", "") || "unknown";
|
|
@@ -13637,6 +13507,93 @@ var require_OpenCodeOrchestrator = __commonJS({
|
|
|
13637
13507
|
}
|
|
13638
13508
|
});
|
|
13639
13509
|
|
|
13510
|
+
// dist/utils.js
|
|
13511
|
+
var require_utils9 = __commonJS({
|
|
13512
|
+
"dist/utils.js"(exports2) {
|
|
13513
|
+
"use strict";
|
|
13514
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13515
|
+
exports2.serializeError = serializeError;
|
|
13516
|
+
exports2.updateAllRunningTasks = updateAllRunningTasks;
|
|
13517
|
+
var types_1 = require_types_impl();
|
|
13518
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
13519
|
+
function serializeError(error) {
|
|
13520
|
+
if (error instanceof Error) {
|
|
13521
|
+
const base = {
|
|
13522
|
+
name: error.name,
|
|
13523
|
+
message: error.message,
|
|
13524
|
+
stack: error.stack
|
|
13525
|
+
};
|
|
13526
|
+
const anyErr = error;
|
|
13527
|
+
for (const key in anyErr) {
|
|
13528
|
+
if (!(key in base)) {
|
|
13529
|
+
try {
|
|
13530
|
+
base[key] = anyErr[key];
|
|
13531
|
+
} catch {
|
|
13532
|
+
}
|
|
13533
|
+
}
|
|
13534
|
+
}
|
|
13535
|
+
const withCause = error;
|
|
13536
|
+
if (withCause && "cause" in withCause) {
|
|
13537
|
+
base.cause = withCause.cause;
|
|
13538
|
+
}
|
|
13539
|
+
const maybeHttp = error;
|
|
13540
|
+
if (maybeHttp?.response?.data !== void 0)
|
|
13541
|
+
base.data = maybeHttp.response.data;
|
|
13542
|
+
if (maybeHttp?.code !== void 0)
|
|
13543
|
+
base.code = maybeHttp.code;
|
|
13544
|
+
if (maybeHttp?.details !== void 0)
|
|
13545
|
+
base.details = maybeHttp.details;
|
|
13546
|
+
return base;
|
|
13547
|
+
}
|
|
13548
|
+
if (typeof error === "object" && error !== null) {
|
|
13549
|
+
try {
|
|
13550
|
+
return JSON.parse(JSON.stringify(error));
|
|
13551
|
+
} catch {
|
|
13552
|
+
return { message: String(error) };
|
|
13553
|
+
}
|
|
13554
|
+
}
|
|
13555
|
+
return { message: String(error) };
|
|
13556
|
+
}
|
|
13557
|
+
async function updateAllRunningTasks(jobId, status, error) {
|
|
13558
|
+
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
13559
|
+
const tasks = (job?.tasks ?? []).filter((task) => task.status === types_1.Status.RUNNING || task.status === types_1.Status.PENDING) || [];
|
|
13560
|
+
for (const task of tasks) {
|
|
13561
|
+
if (!task.id)
|
|
13562
|
+
continue;
|
|
13563
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobId, task.id, status, error ? { error: serializeError(error) } : {});
|
|
13564
|
+
}
|
|
13565
|
+
}
|
|
13566
|
+
}
|
|
13567
|
+
});
|
|
13568
|
+
|
|
13569
|
+
// dist/flows/codegen-flow-helpers.js
|
|
13570
|
+
var require_codegen_flow_helpers = __commonJS({
|
|
13571
|
+
"dist/flows/codegen-flow-helpers.js"(exports2) {
|
|
13572
|
+
"use strict";
|
|
13573
|
+
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
13574
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
13575
|
+
};
|
|
13576
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13577
|
+
exports2.updateJobPayload = updateJobPayload;
|
|
13578
|
+
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
13579
|
+
exports2.getOutputPath = getOutputPath;
|
|
13580
|
+
var path_1 = __importDefault2(require("path"));
|
|
13581
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
13582
|
+
var utils_1 = require_utils9();
|
|
13583
|
+
var DEFAULT_OUTPUT_PATH = "generated-app";
|
|
13584
|
+
async function updateJobPayload(jobContext, payload) {
|
|
13585
|
+
await codeGenerationService_12.codeGenerationService.updateJob(jobContext.jobId, payload);
|
|
13586
|
+
}
|
|
13587
|
+
async function updateParentTaskStatus(jobContext, status, error) {
|
|
13588
|
+
await codeGenerationService_12.codeGenerationService.updateTask(jobContext.jobId, jobContext.taskId, status, error ? { error: (0, utils_1.serializeError)(error) } : {});
|
|
13589
|
+
}
|
|
13590
|
+
function getOutputPath() {
|
|
13591
|
+
const outputDir = process.env.OUTPUT_PATH || DEFAULT_OUTPUT_PATH;
|
|
13592
|
+
return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
|
|
13593
|
+
}
|
|
13594
|
+
}
|
|
13595
|
+
});
|
|
13596
|
+
|
|
13640
13597
|
// dist/flows/agent-io.js
|
|
13641
13598
|
var require_agent_io = __commonJS({
|
|
13642
13599
|
"dist/flows/agent-io.js"(exports2) {
|
|
@@ -15940,7 +15897,7 @@ var require_bi_logger_factory = __commonJS({
|
|
|
15940
15897
|
});
|
|
15941
15898
|
|
|
15942
15899
|
// ../../node_modules/@wix/wix-bi-logger-client/dist/index.js
|
|
15943
|
-
var
|
|
15900
|
+
var require_dist8 = __commonJS({
|
|
15944
15901
|
"../../node_modules/@wix/wix-bi-logger-client/dist/index.js"(exports2, module2) {
|
|
15945
15902
|
"use strict";
|
|
15946
15903
|
var BiLoggerClientFactory = require_bi_logger_factory();
|
|
@@ -18540,7 +18497,7 @@ var require_src2 = __commonJS({
|
|
|
18540
18497
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18541
18498
|
exports2.StandaloneNodeLogger = void 0;
|
|
18542
18499
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
18543
|
-
var wix_bi_logger_client_1 = tslib_1.__importDefault(
|
|
18500
|
+
var wix_bi_logger_client_1 = tslib_1.__importDefault(require_dist8());
|
|
18544
18501
|
var http_client_1 = require_index_node2();
|
|
18545
18502
|
var defaultOptions = {
|
|
18546
18503
|
baseUrl: process.env.BI_BASE_URL || "https://frog.wix.com",
|
|
@@ -18786,7 +18743,7 @@ var require_opencode_init = __commonJS({
|
|
|
18786
18743
|
var biEvents_1 = require_biEvents();
|
|
18787
18744
|
var pre_run_decision_1 = require_pre_run_decision();
|
|
18788
18745
|
var environments_12 = require_environments();
|
|
18789
|
-
var
|
|
18746
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
18790
18747
|
var runOpencodeInitFlow = async (blueprint, history, agentData) => {
|
|
18791
18748
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
18792
18749
|
if (!store?.jobId || !store?.taskId) {
|
|
@@ -18900,10 +18857,7 @@ var require_opencode_init = __commonJS({
|
|
|
18900
18857
|
error: error instanceof Error ? error.message : String(error)
|
|
18901
18858
|
});
|
|
18902
18859
|
} finally {
|
|
18903
|
-
await (0,
|
|
18904
|
-
failed: caughtError !== void 0,
|
|
18905
|
-
error: caughtError
|
|
18906
|
-
});
|
|
18860
|
+
await (0, plugins_runtime_1.runOnFlowEnd)((0, plugins_runtime_1.getActivePlugins)(), { codegenFailed: caughtError !== void 0, codegenError: caughtError }, logger_12.logger);
|
|
18907
18861
|
}
|
|
18908
18862
|
};
|
|
18909
18863
|
exports2.runOpencodeInitFlow = runOpencodeInitFlow;
|
|
@@ -18982,7 +18936,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
18982
18936
|
var inject_created_by_1 = require_inject_created_by();
|
|
18983
18937
|
var collect_extensions_created_1 = require_collect_extensions_created();
|
|
18984
18938
|
var biEvents_1 = require_biEvents();
|
|
18985
|
-
var
|
|
18939
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
18986
18940
|
var runOpencodeIterateFlow = async (chatHistory, agentData) => {
|
|
18987
18941
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
18988
18942
|
if (!store?.jobId || !store?.taskId) {
|
|
@@ -19086,10 +19040,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
19086
19040
|
error: error instanceof Error ? error.message : String(error)
|
|
19087
19041
|
});
|
|
19088
19042
|
} finally {
|
|
19089
|
-
await (0,
|
|
19090
|
-
failed: caughtError !== void 0,
|
|
19091
|
-
error: caughtError
|
|
19092
|
-
});
|
|
19043
|
+
await (0, plugins_runtime_1.runOnFlowEnd)((0, plugins_runtime_1.getActivePlugins)(), { codegenFailed: caughtError !== void 0, codegenError: caughtError }, logger_12.logger);
|
|
19093
19044
|
}
|
|
19094
19045
|
};
|
|
19095
19046
|
exports2.runOpencodeIterateFlow = runOpencodeIterateFlow;
|
|
@@ -19506,28 +19457,70 @@ var require_tools_writer = __commonJS({
|
|
|
19506
19457
|
var os_1 = require("os");
|
|
19507
19458
|
var path_1 = require("path");
|
|
19508
19459
|
var logger_12 = require_logger();
|
|
19509
|
-
var environments_12 = require_environments();
|
|
19510
19460
|
var GLOBAL_TOOLS_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "tools");
|
|
19511
19461
|
var OPENCODE_TOOLS_DIR = (0, path_1.join)(__dirname, "opencode-tools");
|
|
19512
|
-
|
|
19513
|
-
async function writeToolFiles() {
|
|
19462
|
+
async function writeToolFiles(pluginTools = []) {
|
|
19514
19463
|
await (0, promises_1.mkdir)(GLOBAL_TOOLS_DIR, { recursive: true });
|
|
19515
19464
|
const entries = await (0, promises_1.readdir)(OPENCODE_TOOLS_DIR);
|
|
19516
19465
|
const alwaysOnTools = entries.filter((f) => f.endsWith(".ts"));
|
|
19517
|
-
const envTools = (0, environments_12.getCodegenEnvironmentConfig)().tools ?? [];
|
|
19518
19466
|
await Promise.all([
|
|
19519
19467
|
...alwaysOnTools.map((file) => (0, promises_1.copyFile)((0, path_1.join)(OPENCODE_TOOLS_DIR, file), (0, path_1.join)(GLOBAL_TOOLS_DIR, file))),
|
|
19520
|
-
...
|
|
19468
|
+
...pluginTools.map((tool) => (0, promises_1.writeFile)((0, path_1.join)(GLOBAL_TOOLS_DIR, tool.filename), tool.source, "utf-8"))
|
|
19521
19469
|
]);
|
|
19522
19470
|
logger_12.logger.info("[OpenCode] Wrote global tool files", {
|
|
19523
19471
|
targetDir: GLOBAL_TOOLS_DIR,
|
|
19524
19472
|
alwaysOnTools,
|
|
19525
|
-
|
|
19473
|
+
pluginTools: pluginTools.map((t) => t.filename)
|
|
19526
19474
|
});
|
|
19527
19475
|
}
|
|
19528
19476
|
}
|
|
19529
19477
|
});
|
|
19530
19478
|
|
|
19479
|
+
// dist/plugin-host.js
|
|
19480
|
+
var require_plugin_host = __commonJS({
|
|
19481
|
+
"dist/plugin-host.js"(exports2) {
|
|
19482
|
+
"use strict";
|
|
19483
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19484
|
+
exports2.buildPluginHost = void 0;
|
|
19485
|
+
var logger_12 = require_logger();
|
|
19486
|
+
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
19487
|
+
var config_12 = require_config();
|
|
19488
|
+
var buildPluginHost = () => ({
|
|
19489
|
+
logger: logger_12.logger,
|
|
19490
|
+
jobs: {
|
|
19491
|
+
updatePayload: codegen_flow_helpers_12.updateJobPayload
|
|
19492
|
+
},
|
|
19493
|
+
auth: {
|
|
19494
|
+
getAccessToken: config_12.getCurrentAccessToken
|
|
19495
|
+
}
|
|
19496
|
+
});
|
|
19497
|
+
exports2.buildPluginHost = buildPluginHost;
|
|
19498
|
+
}
|
|
19499
|
+
});
|
|
19500
|
+
|
|
19501
|
+
// dist/plugin-artifacts.js
|
|
19502
|
+
var require_plugin_artifacts = __commonJS({
|
|
19503
|
+
"dist/plugin-artifacts.js"(exports2) {
|
|
19504
|
+
"use strict";
|
|
19505
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19506
|
+
exports2.collectPluginArtifacts = collectPluginArtifacts;
|
|
19507
|
+
var plugin_host_12 = require_plugin_host();
|
|
19508
|
+
function collectPluginArtifacts(envConfig) {
|
|
19509
|
+
const rules = [];
|
|
19510
|
+
const tools = [];
|
|
19511
|
+
const host = (0, plugin_host_12.buildPluginHost)();
|
|
19512
|
+
for (const factory of envConfig.plugins) {
|
|
19513
|
+
const plugin = factory({ host });
|
|
19514
|
+
if (plugin.rules)
|
|
19515
|
+
rules.push(...plugin.rules);
|
|
19516
|
+
if (plugin.tools)
|
|
19517
|
+
tools.push(...plugin.tools);
|
|
19518
|
+
}
|
|
19519
|
+
return { rules, tools };
|
|
19520
|
+
}
|
|
19521
|
+
}
|
|
19522
|
+
});
|
|
19523
|
+
|
|
19531
19524
|
// dist/index.js
|
|
19532
19525
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19533
19526
|
exports.processJob = processJob;
|
|
@@ -19547,8 +19540,10 @@ var logger_1 = require_logger();
|
|
|
19547
19540
|
var skills_installer_1 = require_skills_installer();
|
|
19548
19541
|
var rules_writer_1 = require_rules_writer();
|
|
19549
19542
|
var tools_writer_1 = require_tools_writer();
|
|
19543
|
+
var plugin_artifacts_1 = require_plugin_artifacts();
|
|
19550
19544
|
var config_1 = require_config();
|
|
19551
19545
|
var environments_1 = require_environments();
|
|
19546
|
+
var plugin_host_1 = require_plugin_host();
|
|
19552
19547
|
var sessionId = process.env.CODEGEN_SESSION_ID || (0, crypto_1.randomUUID)();
|
|
19553
19548
|
process.env.CODEGEN_SESSION_ID = sessionId;
|
|
19554
19549
|
(0, logger_1.initLogger)(sessionId);
|
|
@@ -19598,11 +19593,12 @@ var alwaysOnLoop = async () => {
|
|
|
19598
19593
|
};
|
|
19599
19594
|
async function initOpenCode() {
|
|
19600
19595
|
const envConfig = (0, environments_1.getCodegenEnvironmentConfig)();
|
|
19596
|
+
const pluginArtifacts = (0, plugin_artifacts_1.collectPluginArtifacts)(envConfig);
|
|
19601
19597
|
await Promise.all([
|
|
19602
|
-
(0, rules_writer_1.writeRuleFiles)(envConfig.codegenRules),
|
|
19598
|
+
(0, rules_writer_1.writeRuleFiles)([...envConfig.codegenRules, ...pluginArtifacts.rules]),
|
|
19603
19599
|
(0, rules_writer_1.writeRuleFiles)(envConfig.askRules),
|
|
19604
19600
|
(0, skills_installer_1.installSkills)((0, codegen_flow_helpers_1.getOutputPath)(), logger_1.logger),
|
|
19605
|
-
(0, tools_writer_1.writeToolFiles)()
|
|
19601
|
+
(0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools)
|
|
19606
19602
|
]);
|
|
19607
19603
|
}
|
|
19608
19604
|
async function main(ctx) {
|
|
@@ -19618,17 +19614,21 @@ async function main(ctx) {
|
|
|
19618
19614
|
var getFirstTask = (job) => {
|
|
19619
19615
|
return job.tasks?.[0];
|
|
19620
19616
|
};
|
|
19621
|
-
function
|
|
19617
|
+
function buildPluginsForTask(jobId, taskId, kind, payload) {
|
|
19622
19618
|
if (kind !== CodeGenService_1.TaskKind.INIT_CODEGEN && kind !== CodeGenService_1.TaskKind.ITERATE_CODEGEN) {
|
|
19623
19619
|
return void 0;
|
|
19624
19620
|
}
|
|
19625
19621
|
const userInput = extractUserInput(kind, payload);
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19629
|
-
|
|
19630
|
-
|
|
19631
|
-
|
|
19622
|
+
const host = (0, plugin_host_1.buildPluginHost)();
|
|
19623
|
+
return (0, environments_1.getCodegenEnvironmentConfig)().plugins.map((factory) => factory({
|
|
19624
|
+
host,
|
|
19625
|
+
job: {
|
|
19626
|
+
projectId: context_1.ctx.projectId,
|
|
19627
|
+
jobId,
|
|
19628
|
+
taskId,
|
|
19629
|
+
kind,
|
|
19630
|
+
userInput
|
|
19631
|
+
}
|
|
19632
19632
|
}));
|
|
19633
19633
|
}
|
|
19634
19634
|
function extractUserInput(kind, payload) {
|
|
@@ -19656,8 +19656,8 @@ async function processJob(job) {
|
|
|
19656
19656
|
return;
|
|
19657
19657
|
}
|
|
19658
19658
|
const payload = task.payload ?? {};
|
|
19659
|
-
const
|
|
19660
|
-
await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind,
|
|
19659
|
+
const plugins = buildPluginsForTask(jobId, task.id, task.kind, payload);
|
|
19660
|
+
await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind, plugins }, async () => {
|
|
19661
19661
|
logger_1.logger.info("[Job] Start processing", { taskKind: task.kind });
|
|
19662
19662
|
context_1.ctx.setJobStatus(jobId, CodeGenService_1.Status.RUNNING);
|
|
19663
19663
|
logger_1.logger.info("[Job] Marked job RUNNING", { initTaskId: task.id });
|
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.349",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"bin": "dist/out.js",
|
|
10
10
|
"files": [
|
|
11
|
-
"dist"
|
|
11
|
+
"dist",
|
|
12
|
+
"assets"
|
|
12
13
|
],
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"esbuild": "^0.27.2"
|
|
@@ -28,5 +29,5 @@
|
|
|
28
29
|
"esbuild": "^0.27.2",
|
|
29
30
|
"vitest": "^4.0.16"
|
|
30
31
|
},
|
|
31
|
-
"falconPackageHash": "
|
|
32
|
+
"falconPackageHash": "7bf8f9326f7820f00099545cc4aebcdd29a5edecaf96fb1f3cbd53c3"
|
|
32
33
|
}
|