@wix/ditto-codegen-public 1.0.347 → 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 +508 -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,272 @@ 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;
|
|
12330
11988
|
}
|
|
12331
11989
|
});
|
|
12332
11990
|
|
|
12333
|
-
// dist/
|
|
12334
|
-
var
|
|
12335
|
-
"dist/
|
|
12336
|
-
"use strict";
|
|
12337
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12338
|
-
exports2.
|
|
12339
|
-
|
|
12340
|
-
|
|
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
|
+
\`\`\``;
|
|
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.`;
|
|
12341
12145
|
}
|
|
12342
12146
|
});
|
|
12343
12147
|
|
|
12344
|
-
// dist/
|
|
12345
|
-
var
|
|
12346
|
-
"dist/
|
|
12148
|
+
// dist/job-decision-manager.js
|
|
12149
|
+
var require_job_decision_manager = __commonJS({
|
|
12150
|
+
"dist/job-decision-manager.js"(exports2) {
|
|
12347
12151
|
"use strict";
|
|
12348
12152
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12349
|
-
exports2.
|
|
12350
|
-
exports2.
|
|
12351
|
-
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();
|
|
12352
12160
|
var logger_12 = require_logger();
|
|
12353
|
-
var
|
|
12354
|
-
|
|
12355
|
-
|
|
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;
|
|
12356
12193
|
}
|
|
12357
|
-
async function
|
|
12358
|
-
for
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
});
|
|
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
|
+
};
|
|
12368
12213
|
}
|
|
12214
|
+
await new Promise((resolve) => setTimeout(resolve, DECISION_POLL_INTERVAL_MS));
|
|
12369
12215
|
}
|
|
12370
12216
|
}
|
|
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
|
-
}
|
|
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");
|
|
12387
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";
|
|
12388
12240
|
}
|
|
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
12241
|
}
|
|
12409
12242
|
});
|
|
12410
12243
|
|
|
@@ -12413,21 +12246,14 @@ var require_environments = __commonJS({
|
|
|
12413
12246
|
"dist/environments/index.js"(exports2) {
|
|
12414
12247
|
"use strict";
|
|
12415
12248
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12416
|
-
exports2.getActiveHooks = void 0;
|
|
12417
12249
|
exports2.getCodegenEnvironmentConfig = getCodegenEnvironmentConfig;
|
|
12418
12250
|
var types_1 = require_types_impl();
|
|
12419
12251
|
var codegen_app_builder_config_1 = require_dist5();
|
|
12420
|
-
var codegen_studio_2_config_1 =
|
|
12252
|
+
var codegen_studio_2_config_1 = require_dist7();
|
|
12421
12253
|
var codegen_rules_1 = require_codegen_rules();
|
|
12422
12254
|
var ask_rules_1 = require_ask_rules();
|
|
12423
12255
|
var job_decision_manager_1 = require_job_decision_manager();
|
|
12424
12256
|
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
12257
|
var SHARED_CODEGEN_RULE = {
|
|
12432
12258
|
filename: "codegen-instructions.md",
|
|
12433
12259
|
content: codegen_rules_1.CODEGEN_RULES
|
|
@@ -12444,18 +12270,7 @@ var require_environments = __commonJS({
|
|
|
12444
12270
|
function getCodegenEnvironmentConfig() {
|
|
12445
12271
|
switch (process.env.CODEGEN_ENVIRONMENT) {
|
|
12446
12272
|
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
|
-
});
|
|
12273
|
+
return withSharedRules(codegen_studio_2_config_1.studio2CodegenConfig);
|
|
12459
12274
|
case types_1.Environment.APP_BUILDER:
|
|
12460
12275
|
default:
|
|
12461
12276
|
return withSharedRules({
|
|
@@ -12989,6 +12804,54 @@ var require_progress_handler = __commonJS({
|
|
|
12989
12804
|
}
|
|
12990
12805
|
});
|
|
12991
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
|
+
|
|
12992
12855
|
// dist/opencode-integration/task-tracker/task-tracker.js
|
|
12993
12856
|
var require_task_tracker = __commonJS({
|
|
12994
12857
|
"dist/opencode-integration/task-tracker/task-tracker.js"(exports2) {
|
|
@@ -12999,7 +12862,7 @@ var require_task_tracker = __commonJS({
|
|
|
12999
12862
|
var types_1 = require_types4();
|
|
13000
12863
|
var logger_12 = require_logger();
|
|
13001
12864
|
var progress_handler_1 = require_progress_handler();
|
|
13002
|
-
var
|
|
12865
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
13003
12866
|
var OpenCodeTaskTracker = class {
|
|
13004
12867
|
constructor(workingDirectory) {
|
|
13005
12868
|
this.skillsUsed = /* @__PURE__ */ new Set();
|
|
@@ -13043,7 +12906,7 @@ var require_task_tracker = __commonJS({
|
|
|
13043
12906
|
if (tool === "progress") {
|
|
13044
12907
|
void this.progressHandler.handle(state, this.handlerContext);
|
|
13045
12908
|
}
|
|
13046
|
-
await (0,
|
|
12909
|
+
await (0, plugins_runtime_1.runOnToolUse)((0, plugins_runtime_1.getActivePlugins)(), { tool, state }, logger_12.logger);
|
|
13047
12910
|
}
|
|
13048
12911
|
handleSkillEvent(state) {
|
|
13049
12912
|
const skillName = state.title?.replace("Loaded skill: ", "") || "unknown";
|
|
@@ -13637,6 +13500,93 @@ var require_OpenCodeOrchestrator = __commonJS({
|
|
|
13637
13500
|
}
|
|
13638
13501
|
});
|
|
13639
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
|
+
|
|
13640
13590
|
// dist/flows/agent-io.js
|
|
13641
13591
|
var require_agent_io = __commonJS({
|
|
13642
13592
|
"dist/flows/agent-io.js"(exports2) {
|
|
@@ -15940,7 +15890,7 @@ var require_bi_logger_factory = __commonJS({
|
|
|
15940
15890
|
});
|
|
15941
15891
|
|
|
15942
15892
|
// ../../node_modules/@wix/wix-bi-logger-client/dist/index.js
|
|
15943
|
-
var
|
|
15893
|
+
var require_dist8 = __commonJS({
|
|
15944
15894
|
"../../node_modules/@wix/wix-bi-logger-client/dist/index.js"(exports2, module2) {
|
|
15945
15895
|
"use strict";
|
|
15946
15896
|
var BiLoggerClientFactory = require_bi_logger_factory();
|
|
@@ -18540,7 +18490,7 @@ var require_src2 = __commonJS({
|
|
|
18540
18490
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18541
18491
|
exports2.StandaloneNodeLogger = void 0;
|
|
18542
18492
|
var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
18543
|
-
var wix_bi_logger_client_1 = tslib_1.__importDefault(
|
|
18493
|
+
var wix_bi_logger_client_1 = tslib_1.__importDefault(require_dist8());
|
|
18544
18494
|
var http_client_1 = require_index_node2();
|
|
18545
18495
|
var defaultOptions = {
|
|
18546
18496
|
baseUrl: process.env.BI_BASE_URL || "https://frog.wix.com",
|
|
@@ -18786,7 +18736,7 @@ var require_opencode_init = __commonJS({
|
|
|
18786
18736
|
var biEvents_1 = require_biEvents();
|
|
18787
18737
|
var pre_run_decision_1 = require_pre_run_decision();
|
|
18788
18738
|
var environments_12 = require_environments();
|
|
18789
|
-
var
|
|
18739
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
18790
18740
|
var runOpencodeInitFlow = async (blueprint, history, agentData) => {
|
|
18791
18741
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
18792
18742
|
if (!store?.jobId || !store?.taskId) {
|
|
@@ -18900,10 +18850,7 @@ var require_opencode_init = __commonJS({
|
|
|
18900
18850
|
error: error instanceof Error ? error.message : String(error)
|
|
18901
18851
|
});
|
|
18902
18852
|
} finally {
|
|
18903
|
-
await (0,
|
|
18904
|
-
failed: caughtError !== void 0,
|
|
18905
|
-
error: caughtError
|
|
18906
|
-
});
|
|
18853
|
+
await (0, plugins_runtime_1.runOnFlowEnd)((0, plugins_runtime_1.getActivePlugins)(), { codegenFailed: caughtError !== void 0, codegenError: caughtError }, logger_12.logger);
|
|
18907
18854
|
}
|
|
18908
18855
|
};
|
|
18909
18856
|
exports2.runOpencodeInitFlow = runOpencodeInitFlow;
|
|
@@ -18982,7 +18929,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
18982
18929
|
var inject_created_by_1 = require_inject_created_by();
|
|
18983
18930
|
var collect_extensions_created_1 = require_collect_extensions_created();
|
|
18984
18931
|
var biEvents_1 = require_biEvents();
|
|
18985
|
-
var
|
|
18932
|
+
var plugins_runtime_1 = require_plugins_runtime();
|
|
18986
18933
|
var runOpencodeIterateFlow = async (chatHistory, agentData) => {
|
|
18987
18934
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
18988
18935
|
if (!store?.jobId || !store?.taskId) {
|
|
@@ -19086,10 +19033,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
19086
19033
|
error: error instanceof Error ? error.message : String(error)
|
|
19087
19034
|
});
|
|
19088
19035
|
} finally {
|
|
19089
|
-
await (0,
|
|
19090
|
-
failed: caughtError !== void 0,
|
|
19091
|
-
error: caughtError
|
|
19092
|
-
});
|
|
19036
|
+
await (0, plugins_runtime_1.runOnFlowEnd)((0, plugins_runtime_1.getActivePlugins)(), { codegenFailed: caughtError !== void 0, codegenError: caughtError }, logger_12.logger);
|
|
19093
19037
|
}
|
|
19094
19038
|
};
|
|
19095
19039
|
exports2.runOpencodeIterateFlow = runOpencodeIterateFlow;
|
|
@@ -19506,28 +19450,70 @@ var require_tools_writer = __commonJS({
|
|
|
19506
19450
|
var os_1 = require("os");
|
|
19507
19451
|
var path_1 = require("path");
|
|
19508
19452
|
var logger_12 = require_logger();
|
|
19509
|
-
var environments_12 = require_environments();
|
|
19510
19453
|
var GLOBAL_TOOLS_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "tools");
|
|
19511
19454
|
var OPENCODE_TOOLS_DIR = (0, path_1.join)(__dirname, "opencode-tools");
|
|
19512
|
-
|
|
19513
|
-
async function writeToolFiles() {
|
|
19455
|
+
async function writeToolFiles(pluginTools = []) {
|
|
19514
19456
|
await (0, promises_1.mkdir)(GLOBAL_TOOLS_DIR, { recursive: true });
|
|
19515
19457
|
const entries = await (0, promises_1.readdir)(OPENCODE_TOOLS_DIR);
|
|
19516
19458
|
const alwaysOnTools = entries.filter((f) => f.endsWith(".ts"));
|
|
19517
|
-
const envTools = (0, environments_12.getCodegenEnvironmentConfig)().tools ?? [];
|
|
19518
19459
|
await Promise.all([
|
|
19519
19460
|
...alwaysOnTools.map((file) => (0, promises_1.copyFile)((0, path_1.join)(OPENCODE_TOOLS_DIR, file), (0, path_1.join)(GLOBAL_TOOLS_DIR, file))),
|
|
19520
|
-
...
|
|
19461
|
+
...pluginTools.map((tool) => (0, promises_1.writeFile)((0, path_1.join)(GLOBAL_TOOLS_DIR, tool.filename), tool.source, "utf-8"))
|
|
19521
19462
|
]);
|
|
19522
19463
|
logger_12.logger.info("[OpenCode] Wrote global tool files", {
|
|
19523
19464
|
targetDir: GLOBAL_TOOLS_DIR,
|
|
19524
19465
|
alwaysOnTools,
|
|
19525
|
-
|
|
19466
|
+
pluginTools: pluginTools.map((t) => t.filename)
|
|
19526
19467
|
});
|
|
19527
19468
|
}
|
|
19528
19469
|
}
|
|
19529
19470
|
});
|
|
19530
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
|
+
|
|
19531
19517
|
// dist/index.js
|
|
19532
19518
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19533
19519
|
exports.processJob = processJob;
|
|
@@ -19547,8 +19533,10 @@ var logger_1 = require_logger();
|
|
|
19547
19533
|
var skills_installer_1 = require_skills_installer();
|
|
19548
19534
|
var rules_writer_1 = require_rules_writer();
|
|
19549
19535
|
var tools_writer_1 = require_tools_writer();
|
|
19536
|
+
var plugin_artifacts_1 = require_plugin_artifacts();
|
|
19550
19537
|
var config_1 = require_config();
|
|
19551
19538
|
var environments_1 = require_environments();
|
|
19539
|
+
var plugin_host_1 = require_plugin_host();
|
|
19552
19540
|
var sessionId = process.env.CODEGEN_SESSION_ID || (0, crypto_1.randomUUID)();
|
|
19553
19541
|
process.env.CODEGEN_SESSION_ID = sessionId;
|
|
19554
19542
|
(0, logger_1.initLogger)(sessionId);
|
|
@@ -19598,11 +19586,12 @@ var alwaysOnLoop = async () => {
|
|
|
19598
19586
|
};
|
|
19599
19587
|
async function initOpenCode() {
|
|
19600
19588
|
const envConfig = (0, environments_1.getCodegenEnvironmentConfig)();
|
|
19589
|
+
const pluginArtifacts = (0, plugin_artifacts_1.collectPluginArtifacts)(envConfig);
|
|
19601
19590
|
await Promise.all([
|
|
19602
|
-
(0, rules_writer_1.writeRuleFiles)(envConfig.codegenRules),
|
|
19591
|
+
(0, rules_writer_1.writeRuleFiles)([...envConfig.codegenRules, ...pluginArtifacts.rules]),
|
|
19603
19592
|
(0, rules_writer_1.writeRuleFiles)(envConfig.askRules),
|
|
19604
19593
|
(0, skills_installer_1.installSkills)((0, codegen_flow_helpers_1.getOutputPath)(), logger_1.logger),
|
|
19605
|
-
(0, tools_writer_1.writeToolFiles)()
|
|
19594
|
+
(0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools)
|
|
19606
19595
|
]);
|
|
19607
19596
|
}
|
|
19608
19597
|
async function main(ctx) {
|
|
@@ -19618,17 +19607,21 @@ async function main(ctx) {
|
|
|
19618
19607
|
var getFirstTask = (job) => {
|
|
19619
19608
|
return job.tasks?.[0];
|
|
19620
19609
|
};
|
|
19621
|
-
function
|
|
19610
|
+
function buildPluginsForTask(jobId, taskId, kind, payload) {
|
|
19622
19611
|
if (kind !== CodeGenService_1.TaskKind.INIT_CODEGEN && kind !== CodeGenService_1.TaskKind.ITERATE_CODEGEN) {
|
|
19623
19612
|
return void 0;
|
|
19624
19613
|
}
|
|
19625
19614
|
const userInput = extractUserInput(kind, payload);
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19629
|
-
|
|
19630
|
-
|
|
19631
|
-
|
|
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
|
+
}
|
|
19632
19625
|
}));
|
|
19633
19626
|
}
|
|
19634
19627
|
function extractUserInput(kind, payload) {
|
|
@@ -19656,8 +19649,8 @@ async function processJob(job) {
|
|
|
19656
19649
|
return;
|
|
19657
19650
|
}
|
|
19658
19651
|
const payload = task.payload ?? {};
|
|
19659
|
-
const
|
|
19660
|
-
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 () => {
|
|
19661
19654
|
logger_1.logger.info("[Job] Start processing", { taskKind: task.kind });
|
|
19662
19655
|
context_1.ctx.setJobStatus(jobId, CodeGenService_1.Status.RUNNING);
|
|
19663
19656
|
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.348",
|
|
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": "9385832b914e969b7852981c6e1ab35edf0e525c0405d332ee8da2ae"
|
|
32
33
|
}
|