@wix/ditto-codegen-public 1.0.272 → 1.0.274

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.
@@ -0,0 +1,28 @@
1
+ import { tool } from "@opencode-ai/plugin";
2
+ import { readFile } from "fs/promises";
3
+ import { join, isAbsolute } from "path";
4
+
5
+ export default tool({
6
+ description:
7
+ "Read multiple files at once and return their contents. " +
8
+ "Use this instead of calling read multiple times sequentially.",
9
+ args: {
10
+ paths: tool.schema
11
+ .array(tool.schema.string())
12
+ .describe("Array of file paths (relative to project root) to read"),
13
+ },
14
+ async execute(args, context) {
15
+ const results: string[] = [];
16
+ for (const filePath of args.paths) {
17
+ const fullPath = isAbsolute(filePath) ? filePath : join(context.directory, filePath);
18
+ try {
19
+ const content = await readFile(fullPath, "utf-8");
20
+ results.push(`--- ${filePath} ---\n${content}`);
21
+ } catch (e) {
22
+ const msg = e instanceof Error ? e.message : String(e);
23
+ results.push(`--- ${filePath} ---\nERROR: ${msg}`);
24
+ }
25
+ }
26
+ return results.join("\n\n");
27
+ },
28
+ });
@@ -0,0 +1,38 @@
1
+ import { tool } from "@opencode-ai/plugin";
2
+ import { writeFile, mkdir } from "fs/promises";
3
+ import { join, dirname, isAbsolute } from "path";
4
+
5
+ export default tool({
6
+ description:
7
+ "Write multiple files at once. Creates directories as needed. " +
8
+ "Use this instead of calling write/edit multiple times for new files.",
9
+ args: {
10
+ files: tool.schema
11
+ .array(
12
+ tool.schema.object({
13
+ path: tool.schema
14
+ .string()
15
+ .describe("File path relative to project root"),
16
+ content: tool.schema.string().describe("Full file content"),
17
+ }),
18
+ )
19
+ .describe("Array of { path, content } objects to write"),
20
+ },
21
+ async execute(args, context) {
22
+ const results: string[] = [];
23
+ for (const f of args.files) {
24
+ const fullPath = isAbsolute(f.path)
25
+ ? f.path
26
+ : join(context.directory, f.path);
27
+ try {
28
+ await mkdir(dirname(fullPath), { recursive: true });
29
+ await writeFile(fullPath, f.content, "utf-8");
30
+ results.push(`OK: ${f.path}`);
31
+ } catch (e) {
32
+ const msg = e instanceof Error ? e.message : String(e);
33
+ results.push(`FAILED: ${f.path} - ${msg}`);
34
+ }
35
+ }
36
+ return results.join("\n");
37
+ },
38
+ });
@@ -0,0 +1,19 @@
1
+ import { tool } from "@opencode-ai/plugin";
2
+ import { randomUUID } from "crypto";
3
+
4
+ export default tool({
5
+ description:
6
+ "Generate one or more UUID v4s. Use this instead of bash commands. " +
7
+ "Set count to generate multiple UUIDs in a single call.",
8
+ args: {
9
+ count: tool.schema
10
+ .number()
11
+ .min(1)
12
+ .max(10)
13
+ .default(1)
14
+ .describe("Number of UUIDs to generate."),
15
+ },
16
+ async execute(args) {
17
+ return Array.from({ length: args.count }, () => randomUUID()).join("\n");
18
+ },
19
+ });
@@ -0,0 +1,51 @@
1
+ import { tool } from "@opencode-ai/plugin";
2
+
3
+ export default tool({
4
+ description:
5
+ "Run full project validation: install deps (if needed), TypeScript check, and build. " +
6
+ "Use this instead of running npm install, tsc, and wix build separately.",
7
+ args: {
8
+ installDeps: tool.schema
9
+ .boolean()
10
+ .optional()
11
+ .describe(
12
+ "Run npm install first (default: false, set true if you added new deps)",
13
+ ),
14
+ },
15
+ async execute(args, context) {
16
+ const steps: string[] = [];
17
+ const cwd = context.directory;
18
+
19
+ if (args.installDeps) {
20
+ const install = await Bun.$`npm install`.cwd(cwd).nothrow().quiet();
21
+ if (install.exitCode !== 0) {
22
+ return `FAILED at npm install (exit ${install.exitCode}):\n${install.stderr.toString()}`;
23
+ }
24
+ steps.push("npm install: OK");
25
+ }
26
+
27
+ const tsc = await Bun.$`npx tsc --noEmit`.cwd(cwd).nothrow().quiet();
28
+ if (tsc.exitCode !== 0) {
29
+ return [
30
+ ...steps,
31
+ `FAILED at tsc --noEmit (exit ${tsc.exitCode}):`,
32
+ tsc.stdout.toString(),
33
+ tsc.stderr.toString(),
34
+ ].join("\n");
35
+ }
36
+ steps.push("tsc --noEmit: OK");
37
+
38
+ const build = await Bun.$`npx wix build`.cwd(cwd).nothrow().quiet();
39
+ if (build.exitCode !== 0) {
40
+ return [
41
+ ...steps,
42
+ `FAILED at wix build (exit ${build.exitCode}):`,
43
+ build.stdout.toString(),
44
+ build.stderr.toString(),
45
+ ].join("\n");
46
+ }
47
+ steps.push("wix build: OK");
48
+
49
+ return steps.join("\n");
50
+ },
51
+ });
@@ -0,0 +1,134 @@
1
+ import { tool } from "@opencode-ai/plugin";
2
+ import { readFile, readdir } from "fs/promises";
3
+ import { join } from "path";
4
+ const MAX_EXAMPLE_LINES = 80;
5
+
6
+ const stripBlankLines = (s: string): string =>
7
+ s.split("\n").filter((l) => l.trim().length > 0).join("\n");
8
+
9
+ function parseComponentNames(files: string[]): string[] {
10
+ const names = new Set<string>();
11
+ for (const f of files) {
12
+ const m = f.match(/^(.+?)(Props|Examples)\.md$/);
13
+ if (m) names.add(m[1]);
14
+ }
15
+ return [...names].sort();
16
+ }
17
+
18
+ function trimExamples(raw: string): string {
19
+ const lines = raw.split("\n");
20
+ const headers: number[] = [];
21
+ lines.forEach((l, i) => {
22
+ if (l.startsWith("### ")) headers.push(i);
23
+ });
24
+ const end =
25
+ headers.length > 2
26
+ ? headers[2]
27
+ : Math.min(lines.length, MAX_EXAMPLE_LINES);
28
+ return lines.slice(0, end).join("\n");
29
+ }
30
+
31
+ export default tool({
32
+ description:
33
+ "Look up Wix Design System (WDS) component props, examples, and icons. " +
34
+ "Use this INSTEAD of the wds-docs skill. " +
35
+ "Pass component names to get their props (lightweight). " +
36
+ "Pass example names ONLY for complex components where you need usage patterns. " +
37
+ "Set listAll/listIcons to discover available components/icons. " +
38
+ "Combine all in one call. NEVER look up the same component twice.",
39
+ args: {
40
+ listAll: tool.schema
41
+ .boolean()
42
+ .optional()
43
+ .describe("List all available WDS component names."),
44
+ components: tool.schema
45
+ .array(tool.schema.string())
46
+ .optional()
47
+ .describe(
48
+ "Component names to get PROPS for, e.g. ['Table', 'Input'].",
49
+ ),
50
+ examples: tool.schema
51
+ .array(tool.schema.string())
52
+ .optional()
53
+ .describe(
54
+ "Component names to get EXAMPLES for. Only use for complex/unfamiliar components.",
55
+ ),
56
+ listIcons: tool.schema
57
+ .boolean()
58
+ .optional()
59
+ .describe("List all available WDS icon names."),
60
+ },
61
+ async execute(args, context) {
62
+ const docsPath = join(
63
+ context.directory,
64
+ "node_modules",
65
+ "@wix",
66
+ "design-system",
67
+ "dist",
68
+ "docs",
69
+ );
70
+ const compsDir = join(docsPath, "components");
71
+ const sections: string[] = [];
72
+
73
+ if (args.listAll) {
74
+ try {
75
+ const files = await readdir(compsDir);
76
+ const names = parseComponentNames(files);
77
+ sections.push(
78
+ `## Available WDS Components (${names.length})\n${names.join(", ")}`,
79
+ );
80
+ } catch (e) {
81
+ const msg = e instanceof Error ? e.message : String(e);
82
+ sections.push(`ERROR listing components: ${msg}`);
83
+ }
84
+ }
85
+
86
+ if (args.components?.length) {
87
+ for (const comp of args.components) {
88
+ try {
89
+ const raw = await readFile(
90
+ join(compsDir, `${comp}Props.md`),
91
+ "utf-8",
92
+ );
93
+ sections.push(`## ${comp} Props\n${raw}`);
94
+ } catch {
95
+ sections.push(`## ${comp} Props\nNot found: ${comp}Props.md`);
96
+ }
97
+ }
98
+ }
99
+
100
+ if (args.examples?.length) {
101
+ for (const comp of args.examples) {
102
+ try {
103
+ const raw = await readFile(
104
+ join(compsDir, `${comp}Examples.md`),
105
+ "utf-8",
106
+ );
107
+ sections.push(`## ${comp} Examples\n${trimExamples(raw)}`);
108
+ } catch {
109
+ sections.push(`## ${comp} Examples\nNot found: ${comp}Examples.md`);
110
+ }
111
+ }
112
+ }
113
+
114
+ if (args.listIcons) {
115
+ try {
116
+ const iconsMd = await readFile(join(docsPath, "icons.md"), "utf-8");
117
+ sections.push(iconsMd);
118
+ } catch (e) {
119
+ const msg = e instanceof Error ? e.message : String(e);
120
+ sections.push(`ERROR reading icons.md: ${msg}`);
121
+ }
122
+ }
123
+
124
+ if (!sections.length) {
125
+ return "No query provided. Pass listAll, components, examples, or listIcons.";
126
+ }
127
+
128
+ return stripBlankLines(
129
+ "IMPORTS: Components from '@wix/design-system', icons from '@wix/wix-ui-icons-common'.\n" +
130
+ "CSS: import '@wix/design-system/styles.global.css';\n\n" +
131
+ sections.join("\n\n"),
132
+ );
133
+ },
134
+ });
package/dist/out.js CHANGED
@@ -11422,62 +11422,11 @@ var require_codegen_prompt = __commonJS({
11422
11422
  exports2.buildIterationPrompt = buildIterationPrompt;
11423
11423
  exports2.buildRecoveryPrompt = buildRecoveryPrompt;
11424
11424
  var prompt_utils_1 = require_prompt_utils();
11425
- var BASE_PROMPT_INSTRUCTIONS = `CORE PRINCIPLES:
11426
- - Do NOT invent or assume new types, modules, functions, props, events, or imports
11427
- - NEVER use mocks, placeholders, debugging, or TODOs in any code
11428
- - ALWAYS implement complete, production-ready functionality
11429
- - Follow Wix patterns and best practices precisely
11430
- - Handle all edge cases and error scenarios appropriately
11431
-
11432
- IMPORTANT INSTRUCTIONS:
11433
- - NEVER run preview, dev, release, or promote commands. Preview/deployment is handled separately.
11434
- - You MUST run \`npm install\` when you are adding new dependencies to package.json.
11435
- - You SHOULD run \`npx tsc --noEmit\` to check for TypeScript errors after generating code.
11436
- - You SHOULD run \`npm run build\` or \`wix build\` to verify the build succeeds.
11437
- - CRITICAL: After creating any new extension (dashboard page, widget, embedded script, etc.), you MUST update \`src/extensions.ts\` to register it. Every extension needs to be exported from this file or it won't work.
11438
- - UUID GENERATION: To generate UUIDs, use Node.js: \`node -e "console.log(require('crypto').randomUUID())"\`. Do NOT use \`uuidgen\` as it may not be installed.
11439
-
11440
- TYPESCRIPT ENVIRONMENT:
11441
- - The project extends \`astro/tsconfigs/base\` which enables \`verbatimModuleSyntax\`. Type-only imports MUST use the \`type\` keyword (e.g. \`import type { MyType } from './types';\`).
11442
-
11443
- EFFICIENCY - AVOID UNNECESSARY FIX CYCLES:
11444
- - Once validation (tsc + build) passes, do NOT refactor or "clean up" code. Move on immediately.
11445
- - When fixing multiple occurrences of the same pattern, use a single edit that covers all instances instead of separate edits for each occurrence.
11446
-
11447
- FILE CREATION - CRITICAL RULES:
11448
- - NEVER rewrite the same file twice. Once a file is written successfully, move on to the next file immediately.
11449
-
11450
- OUTPUT SIZE LIMITS - CRITICAL:
11451
- - Keep each file under 200 lines. If a component would be larger, split it into multiple files (e.g., separate types.ts, utils.ts, styles).
11452
- - Do NOT output excessive comments or documentation in code.
11453
- - When writing a file, write it IMMEDIATELY after deciding to create it. Do not repeat "Now let me create..." multiple times - just create it.
11454
- - If you find yourself repeating the same text without making progress, STOP and write the file with whatever content you have ready.
11455
-
11456
- PERMISSIONS REQUIREMENT:
11457
- At the end of your response, output the required Wix app permissions as a JSON block.
11458
- Use the SCOPE ID format (not human-readable names). Examples:
11459
- - \`@wix/data\` read operations (query, get) require "SCOPE.DC-DATA.READ"
11460
- - \`@wix/data\` write operations (insert, update, remove) require "SCOPE.DC-DATA.WRITE"
11461
- - Embedded scripts require "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
11462
- - Check the Wix SDK documentation "Method Permissions Scopes IDs" section for the exact scope ID.
11463
-
11464
- IMPORTANT: Use scope IDs like "SCOPE.DC-DATA.READ", NOT human-readable names like "Read Data Items".
11465
-
11466
- Use this exact format (no newlines inside the array):
11467
-
11468
- \`\`\`json:required-permissions
11469
- ["SCOPE.DC-DATA.READ", "SCOPE.DC-DATA.WRITE"]
11470
- \`\`\`
11471
-
11472
- If no permissions are required, output an empty array:
11473
- \`\`\`json:required-permissions
11474
- []
11475
- \`\`\``;
11476
11425
  function buildPrompt(...sections) {
11477
- return [...sections, (0, prompt_utils_1.buildAppContext)(), BASE_PROMPT_INSTRUCTIONS].filter(Boolean).join("\n\n");
11426
+ return [...sections, (0, prompt_utils_1.buildAppContext)()].filter(Boolean).join("\n\n");
11478
11427
  }
11479
11428
  function buildInitPrompt(blueprint, history) {
11480
- const blueprintJson = JSON.stringify({ blueprint }, null, 2);
11429
+ const blueprintJson = JSON.stringify({ blueprint });
11481
11430
  return buildPrompt(`Generate the extensions from this blueprint.
11482
11431
 
11483
11432
  ${blueprintJson}`, (0, prompt_utils_1.formatChatHistory)(history, "CONVERSATION HISTORY"));
@@ -11531,29 +11480,15 @@ var require_ask_prompt = __commonJS({
11531
11480
  Object.defineProperty(exports2, "__esModule", { value: true });
11532
11481
  exports2.buildAskPrompt = buildAskPrompt;
11533
11482
  var prompt_utils_1 = require_prompt_utils();
11534
- var ASK_PROMPT_INSTRUCTIONS = `CORE PRINCIPLES:
11535
- - You are a READ-ONLY assistant. You MUST NOT modify, create, or delete any files.
11536
- - Your job is to answer questions about the codebase and Wix platform by reading code and fetching documentation.
11537
- - Use the read tool to explore the codebase and find relevant code.
11538
- - Use the wix-mcp tools to fetch Wix SDK/API documentation when needed.
11539
- - Provide clear, accurate, and well-structured answers.
11540
-
11541
- IMPORTANT INSTRUCTIONS:
11542
- 1. Do NOT edit, write, or create any files.
11543
- 2. Do NOT run any bash commands.
11544
- 3. READ the codebase to understand the code structure and find answers.
11545
- 4. Use MCP tools to look up Wix documentation when the question involves Wix APIs, SDKs, or platform features.
11546
- 5. If you cannot find a definitive answer, say so clearly and explain what you found.`;
11547
11483
  function buildAskPrompt(chatHistory) {
11548
11484
  const { currentUserRequest } = (0, prompt_utils_1.extractUserRequestAndFilteredHistory)(chatHistory);
11549
11485
  if (!currentUserRequest) {
11550
- return [ASK_PROMPT_INSTRUCTIONS, (0, prompt_utils_1.buildAppContext)()].filter(Boolean).join("\n\n");
11486
+ return (0, prompt_utils_1.buildAppContext)() || "Answer questions about the codebase and Wix platform.";
11551
11487
  }
11552
11488
  const recentHistory = chatHistory.slice(-5);
11553
11489
  const sections = [
11554
11490
  `QUESTION: "${currentUserRequest}"`,
11555
11491
  (0, prompt_utils_1.formatChatHistory)(recentHistory, "CONVERSATION CONTEXT"),
11556
- ASK_PROMPT_INSTRUCTIONS,
11557
11492
  (0, prompt_utils_1.buildAppContext)()
11558
11493
  ];
11559
11494
  return sections.filter(Boolean).join("\n\n");
@@ -11612,8 +11547,18 @@ var require_constants5 = __commonJS({
11612
11547
  }
11613
11548
  return null;
11614
11549
  }
11615
- exports2.CODE_SEARCH_TOOLS = /* @__PURE__ */ new Set(["read", "grep", "glob", "list"]);
11616
- exports2.WRITE_TOOLS = /* @__PURE__ */ new Set(["write", "edit"]);
11550
+ exports2.CODE_SEARCH_TOOLS = /* @__PURE__ */ new Set([
11551
+ "read",
11552
+ "grep",
11553
+ "glob",
11554
+ "list",
11555
+ "batch-read"
11556
+ ]);
11557
+ exports2.WRITE_TOOLS = /* @__PURE__ */ new Set([
11558
+ "write",
11559
+ "edit",
11560
+ "batch-write"
11561
+ ]);
11617
11562
  exports2.BUILDER_TO_EXTENSION_LABEL = {
11618
11563
  dashboardPage: "dashboard page",
11619
11564
  dashboardModal: "dashboard modal",
@@ -11673,6 +11618,286 @@ var require_constants5 = __commonJS({
11673
11618
  }
11674
11619
  });
11675
11620
 
11621
+ // dist/opencode-integration/rules/orchestrator-rules.js
11622
+ var require_orchestrator_rules = __commonJS({
11623
+ "dist/opencode-integration/rules/orchestrator-rules.js"(exports2) {
11624
+ "use strict";
11625
+ Object.defineProperty(exports2, "__esModule", { value: true });
11626
+ exports2.ORCHESTRATOR_RULES = void 0;
11627
+ exports2.ORCHESTRATOR_RULES = `# Wix CLI Extension Orchestrator
11628
+
11629
+ ## Quick Decision Helper
11630
+
11631
+ Answer these questions to find the right extension:
11632
+
11633
+ 1. **What are you trying to build?**
11634
+ - Admin interface \u2192 Dashboard Extensions
11635
+ - Backend logic \u2192 Backend Extensions
11636
+ - Data storage / CMS collections \u2192 Data Collection
11637
+ - Site component \u2192 Site Extensions (app projects only)
11638
+
11639
+ 2. **Who will see it?**
11640
+ - Admin users only \u2192 Dashboard Extensions
11641
+ - Site visitors \u2192 Site Extensions
11642
+ - Server-side only \u2192 Backend Extensions
11643
+
11644
+ 3. **Where will it appear?**
11645
+ - Dashboard sidebar/page \u2192 Dashboard Page or Modal
11646
+ - Existing Wix app dashboard (widget) \u2192 Dashboard Plugin
11647
+ - Existing Wix app dashboard (menu item) \u2192 Dashboard Menu Plugin
11648
+ - Anywhere on site \u2192 Site Widget
11649
+ - Anywhere on site (with editor manifest) \u2192 Site Component
11650
+ - Wix business solution page \u2192 Site Plugin
11651
+ - During business flow \u2192 Service Plugin
11652
+ - After event occurs \u2192 Event Extension
11653
+
11654
+ ## Decision Flow
11655
+
11656
+ - **Admin:** Need full-page UI? \u2192 Dashboard Page. Need popup/form? \u2192 Dashboard Modal. Extending Wix app dashboard with a visual widget? \u2192 Dashboard Plugin. Adding a menu item to a Wix app dashboard's more-actions or bulk-actions menu? \u2192 Dashboard Menu Plugin. **Modal constraint:** Dashboard Pages cannot use \`<Modal />\`; use a separate Dashboard Modal extension and \`dashboard.openModal()\`.
11657
+ - **Backend:** During business flow (checkout/shipping/tax)? \u2192 Service Plugin. After event (webhooks/sync)? \u2192 Event Extension. Custom HTTP endpoints? \u2192 Backend Endpoints. Need CMS collections for app data? \u2192 Data Collection.
11658
+ - **Site:** User places anywhere (standalone)? \u2192 Site Widget. React component with editor manifest (styling, content, elements)? \u2192 Site Component. Fixed slot on Wix app page? \u2192 Site Plugin. Scripts/analytics only? \u2192 Embedded Script.
11659
+
11660
+ ## Extension Type \u2192 Skill Reference
11661
+
11662
+ | Extension Type | Category | Visibility | Use When | Skill |
11663
+ | --------------------- | --------- | ----------- | ----------------------------- | ------------------------- |
11664
+ | Dashboard Page | Dashboard | Admin only | Full admin pages | \`wix-cli-dashboard-page\` |
11665
+ | Dashboard Modal | Dashboard | Admin only | Popup dialogs | \`wix-cli-dashboard-modal\` |
11666
+ | Dashboard Plugin | Dashboard | Admin only | Extend Wix app dashboards | \`wix-cli-dashboard-plugin\` |
11667
+ | Dashboard Menu Plugin | Dashboard | Admin only | Add menu items to Wix app dashboards | \`wix-cli-dashboard-menu-plugin\` |
11668
+ | Service Plugin | Backend | Server-side | Customize business flows | \`wix-cli-service-plugin\` |
11669
+ | Event Extension | Backend | Server-side | React to events | \`wix-cli-backend-event\` |
11670
+ | Backend Endpoints | Backend | API | Custom HTTP handlers | \`wix-cli-backend-api\` |
11671
+ | Data Collection | Backend | Data | CMS collections for app data | \`wix-cli-data-collection\` |
11672
+ | Site Component | Site | Public | React components with editor manifests | \`wix-cli-site-component\` |
11673
+ | Site Widget | Site | Public | Standalone widgets | \`wix-cli-site-widget\` |
11674
+ | Site Plugin | Site | Public | Extend Wix business solutions | \`wix-cli-site-plugin\` |
11675
+ | Embedded Script | Site | Public | Inject scripts/analytics | \`wix-cli-embedded-script\` |
11676
+
11677
+ | Site Widget vs Site Component vs Site Plugin | Dashboard Page vs Modal | Service Plugin vs Event |
11678
+ | -------------------------------------------- | ----------------------- | ----------------------- |
11679
+ | Widget: standalone interactive component. Component: React with editor manifest (CSS/data/elements). Plugin: fixed slot in Wix app page. | Page: full page. Modal: overlay; use for popups. | Service: during flow. Event: after event. |
11680
+
11681
+ ## Data Collection Inference
11682
+
11683
+ **CRITICAL:** Data collections are often needed implicitly \u2014 don't wait for the user to explicitly say "create a CMS collection." Infer the need automatically.
11684
+
11685
+ **Skip this section if the user provides a collection ID directly** (e.g., an existing site-level collection). In that case, use the provided ID as-is \u2014 no Data Collection extension or namespace scoping needed.
11686
+
11687
+ **Always include a Data Collection extension when ANY of these are true:**
11688
+
11689
+ | Indicator | Example |
11690
+ | --- | --- |
11691
+ | User mentions saving/storing/persisting app-specific data | "save the fee amount", "store product recommendations" |
11692
+ | A dashboard page will **manage** (CRUD) domain entities | "dashboard to manage fees", "admin page to edit rules" |
11693
+ | A service plugin reads app-configured data at runtime | "fetch fee rules at checkout", "look up shipping rates" |
11694
+ | User mentions "dedicated database/collection" | "save in a dedicated database collection" |
11695
+ | Multiple extensions reference the same custom data | Dashboard manages fees + service plugin reads fees |
11696
+
11697
+ **Why this matters:** Without the Data Collection extension, the collection won't be created when the app is installed, the Wix Data APIs may not work (code editor not enabled), and collection IDs won't be properly scoped to the app namespace.
11698
+
11699
+ When creating a Data Collection, the user MUST provide their app namespace from Wix Dev Center. Collection IDs must be scoped: \`<app-namespace>/<idSuffix>\` \u2014 pass the full ID to all extensions that reference the collection.
11700
+
11701
+ ## Wix Stores Versioning Requirement
11702
+
11703
+ **Applies when ANY Wix Stores API is used** (products, inventory, orders, etc.):
11704
+
11705
+ 1. Load the \`wix-stores-versioning\` skill
11706
+ 2. All Stores operations must check catalog version first using \`getCatalogVersion()\`
11707
+ 3. Use the correct module based on version: \`productsV3\` (V3) vs \`products\` (V1)
11708
+
11709
+ This is non-negotiable \u2014 V1 and V3 are NOT backwards compatible.
11710
+
11711
+ ## API Reference Discovery
11712
+
11713
+ **Workflow: Check skill references first, use MCP only for gaps.**
11714
+
11715
+ 1. Identify required APIs from user requirements
11716
+ 2. Check relevant reference files in the loaded skill
11717
+ 3. ONLY use MCP if the API is NOT found in reference files
11718
+
11719
+ **Platform APIs (always in skill references \u2014 skip MCP):**
11720
+ - Wix Data, Dashboard SDK, Event SDK (common events), Service Plugin SPIs
11721
+
11722
+ **Vertical APIs (use MCP if needed):**
11723
+ - Wix Stores (\u26A0\uFE0F MUST use \`wix-stores-versioning\` skill), Wix Bookings, Wix Members, Wix Pricing Plans
11724
+
11725
+ | User Requirement | MCP Needed? | Reason |
11726
+ | --- | --- | --- |
11727
+ | "Display store products" | \u2705 YES | Wix Stores API \u2014 also load \`wix-stores-versioning\` skill |
11728
+ | "Show booking calendar" | \u2705 YES | Wix Bookings API not in reference files |
11729
+ | "Send emails to users" | \u2705 YES | Wix Triggered Emails not in reference files |
11730
+ | "Get member info" | \u2705 YES | Wix Members API not in reference files |
11731
+ | "Listen for cart events" | Check \`COMMON-EVENTS.md\` | MCP only if event missing in reference |
11732
+ | "Store data in collection" | \u274C NO | Covered by \`WIX_DATA.md\` in skill refs |
11733
+ | "Show dashboard toast" | \u274C NO | Covered by \`DASHBOARD_API.md\` in skill refs |
11734
+ | "UI only (forms, inputs)" | \u274C NO | No external API needed |
11735
+
11736
+ **MCP Tools to use for discovery:**
11737
+ - \`SearchWixSDKDocumentation\` - SDK methods and APIs (**Always use maxResults: 5**)
11738
+ - \`ReadFullDocsArticle\` - Full documentation when needed (only if search results need more detail)
11739
+ - \`ReadFullDocsMethodSchema\` - **Always call this** for any SDK method you plan to use. The schema is the source of truth for parameter shapes. Code examples may have incorrect call signatures.`;
11740
+ }
11741
+ });
11742
+
11743
+ // dist/opencode-integration/rules/codegen-rules.js
11744
+ var require_codegen_rules = __commonJS({
11745
+ "dist/opencode-integration/rules/codegen-rules.js"(exports2) {
11746
+ "use strict";
11747
+ Object.defineProperty(exports2, "__esModule", { value: true });
11748
+ exports2.CODEGEN_RULES = void 0;
11749
+ exports2.CODEGEN_RULES = `CORE PRINCIPLES:
11750
+ - Do NOT invent or assume new types, modules, functions, props, events, or imports.
11751
+ - NEVER use mocks, placeholders, debugging, or TODOs in any code.
11752
+ - ALWAYS implement complete, production-ready functionality.
11753
+
11754
+ MINIMIZE TEXT OUTPUT \u2014 CRITICAL:
11755
+ - Do NOT narrate your actions. No "Let me now...", "Perfect!", "Now I'll...", "Excellent!", "Great!".
11756
+ - Do NOT explain what you just did. The tool output speaks for itself.
11757
+ - Do NOT read back files you just wrote. Trust the write succeeded.
11758
+ - Every text token costs money. Use tools, not words.
11759
+
11760
+ TOOL USAGE:
11761
+ - \`validate\` for all validation (tsc + build). Do NOT load the \`wix-cli-app-validation\` skill.
11762
+ - \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
11763
+ - \`wds-lookup\` for WDS component props, examples, and icons. Do NOT load the \`wds-docs\` skill.
11764
+ - \`batch-write\` to create new files. NEVER use \`write\` for new files (corrupts newlines).
11765
+ - \`batch-read\` to read multiple files at once.
11766
+ - \`multiedit\` to apply multiple edits across files. Use \`edit\` only for a single edit to one file.
11767
+ - Before calling MCP tools, check if loaded skills already cover the API. Only use MCP for gaps.
11768
+ - 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.
11769
+ - NEVER run preview, dev, release, or promote commands.
11770
+
11771
+ IMPLEMENTATION WORKFLOW:
11772
+ 1. **Plan**: Determine extension types using the orchestrator rule. Generate ALL UUIDs upfront.
11773
+ 2. **Load skills**: Load ALL needed extension skills + call \`wds-lookup\` \u2014 all in a SINGLE step.
11774
+ 3. **Build**: Create each extension using \`batch-write\`. Build all extensions before registering.
11775
+ 4. **Register**: Register all extensions in \`src/extensions.ts\`.
11776
+ 5. **Validate**: Run \`validate\` with installDeps: true ONCE. Fix any errors and re-validate.
11777
+ 6. **Stop**: Once validation passes, STOP. Do NOT refactor, clean up, or verify.
11778
+
11779
+ EFFICIENCY:
11780
+ - Batch ALL tool calls that can run in parallel into the same step.
11781
+ - Use \`multiedit\` to fix multiple errors at once.
11782
+
11783
+ FILE CREATION:
11784
+ - NEVER rewrite the same file twice. Once written, move on.
11785
+ - Keep each file under 200 lines. Split into types.ts, utils.ts if needed.
11786
+ - Do NOT output comments in code unless they explain non-obvious logic.
11787
+
11788
+ TYPESCRIPT:
11789
+ - The project enables \`verbatimModuleSyntax\`. Type-only imports MUST use \`import type\`.
11790
+
11791
+ PERMISSIONS:
11792
+ At the end of your response, output the required Wix app permissions as a JSON block.
11793
+ Use SCOPE ID format (not human-readable names). Examples:
11794
+ - \`@wix/data\` read \u2192 "SCOPE.DC-DATA.READ", write \u2192 "SCOPE.DC-DATA.WRITE"
11795
+ - Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
11796
+
11797
+ \`\`\`json:required-permissions
11798
+ ["SCOPE.DC-DATA.READ", "SCOPE.DC-DATA.WRITE"]
11799
+ \`\`\`
11800
+
11801
+ If no permissions are required, output an empty array:
11802
+ \`\`\`json:required-permissions
11803
+ []
11804
+ \`\`\``;
11805
+ }
11806
+ });
11807
+
11808
+ // dist/opencode-integration/rules/ask-rules.js
11809
+ var require_ask_rules = __commonJS({
11810
+ "dist/opencode-integration/rules/ask-rules.js"(exports2) {
11811
+ "use strict";
11812
+ Object.defineProperty(exports2, "__esModule", { value: true });
11813
+ exports2.ASK_RULES = void 0;
11814
+ exports2.ASK_RULES = `CORE PRINCIPLES:
11815
+ - You are a READ-ONLY assistant. You MUST NOT modify, create, or delete any files.
11816
+ - Your job is to answer questions about the codebase and Wix platform by reading code and fetching documentation.
11817
+ - Use the read tool to explore the codebase and find relevant code.
11818
+ - Use the wix-mcp tools to fetch Wix SDK/API documentation when needed.
11819
+ - Provide clear, accurate, and well-structured answers.
11820
+
11821
+ IMPORTANT INSTRUCTIONS:
11822
+ 1. Do NOT edit, write, or create any files.
11823
+ 2. Do NOT run any bash commands.
11824
+ 3. READ the codebase to understand the code structure and find answers.
11825
+ 4. Use MCP tools to look up Wix documentation when the question involves Wix APIs, SDKs, or platform features.
11826
+ 5. If you cannot find a definitive answer, say so clearly and explain what you found.`;
11827
+ }
11828
+ });
11829
+
11830
+ // dist/opencode-integration/rules-writer.js
11831
+ var require_rules_writer = __commonJS({
11832
+ "dist/opencode-integration/rules-writer.js"(exports2) {
11833
+ "use strict";
11834
+ Object.defineProperty(exports2, "__esModule", { value: true });
11835
+ exports2.ASK_RULES_PATH = exports2.ORCHESTRATOR_RULES_PATH = exports2.CODEGEN_RULES_PATH = void 0;
11836
+ exports2.writeRuleFiles = writeRuleFiles;
11837
+ var promises_1 = require("fs/promises");
11838
+ var os_1 = require("os");
11839
+ var path_1 = require("path");
11840
+ var orchestrator_rules_1 = require_orchestrator_rules();
11841
+ var codegen_rules_1 = require_codegen_rules();
11842
+ var ask_rules_1 = require_ask_rules();
11843
+ var logger_12 = require_logger();
11844
+ var GLOBAL_RULES_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "rules");
11845
+ exports2.CODEGEN_RULES_PATH = (0, path_1.join)(GLOBAL_RULES_DIR, "codegen-instructions.md");
11846
+ exports2.ORCHESTRATOR_RULES_PATH = (0, path_1.join)(GLOBAL_RULES_DIR, "orchestrator.md");
11847
+ exports2.ASK_RULES_PATH = (0, path_1.join)(GLOBAL_RULES_DIR, "ask-instructions.md");
11848
+ async function writeRuleFiles() {
11849
+ await (0, promises_1.mkdir)(GLOBAL_RULES_DIR, { recursive: true });
11850
+ await Promise.all([
11851
+ (0, promises_1.writeFile)(exports2.CODEGEN_RULES_PATH, codegen_rules_1.CODEGEN_RULES, "utf-8"),
11852
+ (0, promises_1.writeFile)(exports2.ORCHESTRATOR_RULES_PATH, orchestrator_rules_1.ORCHESTRATOR_RULES, "utf-8"),
11853
+ (0, promises_1.writeFile)(exports2.ASK_RULES_PATH, ask_rules_1.ASK_RULES, "utf-8")
11854
+ ]);
11855
+ logger_12.logger.info("[OpenCode] Wrote global rule files", { dir: GLOBAL_RULES_DIR });
11856
+ }
11857
+ }
11858
+ });
11859
+
11860
+ // dist/experiments.js
11861
+ var require_experiments = __commonJS({
11862
+ "dist/experiments.js"(exports2) {
11863
+ "use strict";
11864
+ Object.defineProperty(exports2, "__esModule", { value: true });
11865
+ exports2.isExperimentEnabled = isExperimentEnabled;
11866
+ exports2.isUserDecisionsEnabled = isUserDecisionsEnabled;
11867
+ exports2.isUseWixAiGatewayEnabled = isUseWixAiGatewayEnabled;
11868
+ var logger_12 = require_logger();
11869
+ var parsedExperiments = null;
11870
+ function getExperiments() {
11871
+ if (parsedExperiments !== null) {
11872
+ return parsedExperiments;
11873
+ }
11874
+ const raw = process.env.CODEGEN_EXPERIMENTS;
11875
+ if (!raw) {
11876
+ parsedExperiments = {};
11877
+ return parsedExperiments;
11878
+ }
11879
+ try {
11880
+ parsedExperiments = JSON.parse(raw);
11881
+ } catch (error) {
11882
+ logger_12.logger.error("[Experiments] Failed to parse CODEGEN_EXPERIMENTS", {
11883
+ error: error instanceof Error ? error.message : String(error)
11884
+ });
11885
+ parsedExperiments = {};
11886
+ }
11887
+ return parsedExperiments;
11888
+ }
11889
+ function isExperimentEnabled(specName) {
11890
+ return getExperiments()[specName] === "true";
11891
+ }
11892
+ function isUserDecisionsEnabled() {
11893
+ return isExperimentEnabled("specs.ditto.CodegenUserDecisions");
11894
+ }
11895
+ function isUseWixAiGatewayEnabled() {
11896
+ return isExperimentEnabled("specs.ditto.CodegenUseWixAiGateway");
11897
+ }
11898
+ }
11899
+ });
11900
+
11676
11901
  // dist/opencode-integration/config.js
11677
11902
  var require_config = __commonJS({
11678
11903
  "dist/opencode-integration/config.js"(exports2) {
@@ -11684,10 +11909,15 @@ var require_config = __commonJS({
11684
11909
  exports2.getOpenCodeAskEnv = getOpenCodeAskEnv;
11685
11910
  var os_1 = require("os");
11686
11911
  var constants_1 = require_constants5();
11912
+ var rules_writer_12 = require_rules_writer();
11913
+ var experiments_1 = require_experiments();
11687
11914
  exports2.DEFAULT_TIMEOUT_MS = 20 * 60 * 1e3;
11688
11915
  exports2.DEFAULT_MODEL = "anthropic/claude-sonnet-4-6";
11689
11916
  var AI_PROXY_BASE_URL = process.env.CODEGEN_AI_PROXY_BASE_URL || "http://localhost:3001";
11690
11917
  function getAnthropicBaseUrl(projectId) {
11918
+ if ((0, experiments_1.isUseWixAiGatewayEnabled)()) {
11919
+ return `${AI_PROXY_BASE_URL}/projects/${projectId}/wix-ai-gateway/anthropic`;
11920
+ }
11691
11921
  return `${AI_PROXY_BASE_URL}/projects/${projectId}/anthropic`;
11692
11922
  }
11693
11923
  function getProviderConfig() {
@@ -11721,33 +11951,34 @@ var require_config = __commonJS({
11721
11951
  model: exports2.DEFAULT_MODEL,
11722
11952
  provider: getProviderConfig(),
11723
11953
  permission: {
11724
- edit: "allow",
11725
- // NOTE: Per-command deny patterns are unreliable — opencode may
11726
- // ignore them or fail to match compound commands (e.g. `cd /path && npx wix preview`).
11727
- // See: https://github.com/anomalyco/opencode/issues/16331
11728
- // Primary blocking is enforced via the system prompt and validation skill.
11729
- bash: {
11730
- "*wix preview*": "deny",
11731
- "*wix dev*": "deny",
11732
- "*wix release*": "deny",
11733
- "*wix promote*": "deny",
11734
- "*npm run preview*": "deny",
11735
- "*npm run dev*": "deny",
11736
- "*npm run release*": "deny",
11737
- "*npm run promote*": "deny",
11738
- "*": "allow"
11954
+ [
11955
+ "skill"
11956
+ /* OpenCodeTool.Skill */
11957
+ ]: {
11958
+ "*": "allow",
11959
+ "wix-cli-orchestrator": "deny",
11960
+ "wix-cli-app-validation": "deny",
11961
+ "wds-docs": "deny"
11739
11962
  },
11740
- webfetch: "allow",
11741
- skill: "allow",
11742
11963
  task: "deny",
11743
- todowrite: "deny",
11744
- todoread: "deny",
11964
+ doom_loop: "allow",
11965
+ [
11966
+ "todowrite"
11967
+ /* OpenCodeTool.TodoWrite */
11968
+ ]: "deny",
11969
+ [
11970
+ "todoread"
11971
+ /* OpenCodeTool.TodoRead */
11972
+ ]: "deny",
11745
11973
  external_directory: {
11746
11974
  "/root/.agents/**": "allow",
11747
11975
  "/root/.claude/**": "allow",
11748
11976
  "/root/.opencode/**": "allow"
11749
11977
  }
11750
11978
  },
11979
+ instructions: [rules_writer_12.CODEGEN_RULES_PATH, rules_writer_12.ORCHESTRATOR_RULES_PATH],
11980
+ autoupdate: false,
11981
+ share: "disabled",
11751
11982
  lsp: false,
11752
11983
  mcp: WIX_MCP_CONFIG
11753
11984
  };
@@ -11757,10 +11988,29 @@ var require_config = __commonJS({
11757
11988
  model: exports2.DEFAULT_MODEL,
11758
11989
  provider: getProviderConfig(),
11759
11990
  permission: {
11760
- edit: "deny",
11761
- bash: "deny",
11762
- task: "deny"
11991
+ [
11992
+ "edit"
11993
+ /* OpenCodeTool.Edit */
11994
+ ]: "deny",
11995
+ [
11996
+ "bash"
11997
+ /* OpenCodeTool.Bash */
11998
+ ]: "deny",
11999
+ task: "deny",
12000
+ [
12001
+ "batch-write"
12002
+ /* OpenCodeTool.BatchWrite */
12003
+ ]: "deny",
12004
+ [
12005
+ "validate"
12006
+ /* OpenCodeTool.Validate */
12007
+ ]: "deny",
12008
+ [
12009
+ "uuid"
12010
+ /* OpenCodeTool.Uuid */
12011
+ ]: "deny"
11763
12012
  },
12013
+ instructions: [rules_writer_12.ASK_RULES_PATH],
11764
12014
  lsp: false,
11765
12015
  mcp: WIX_MCP_CONFIG
11766
12016
  };
@@ -11966,6 +12216,35 @@ var require_parser = __commonJS({
11966
12216
  }
11967
12217
  });
11968
12218
 
12219
+ // dist/opencode-integration/cost-tracker.js
12220
+ var require_cost_tracker = __commonJS({
12221
+ "dist/opencode-integration/cost-tracker.js"(exports2) {
12222
+ "use strict";
12223
+ Object.defineProperty(exports2, "__esModule", { value: true });
12224
+ exports2.fetchOpenCodeStats = fetchOpenCodeStats;
12225
+ var child_process_1 = require("child_process");
12226
+ var util_1 = require("util");
12227
+ var logger_12 = require_logger();
12228
+ var execAsync = (0, util_1.promisify)(child_process_1.exec);
12229
+ var CLI_TIMEOUT_MS = 15e3;
12230
+ async function fetchOpenCodeStats(cwd, env) {
12231
+ try {
12232
+ const { stdout } = await execAsync("opencode stats --models", {
12233
+ cwd,
12234
+ env,
12235
+ timeout: CLI_TIMEOUT_MS
12236
+ });
12237
+ return stdout.trim() || null;
12238
+ } catch (error) {
12239
+ logger_12.logger.warn("[OpenCode] Could not fetch opencode stats", {
12240
+ error: error instanceof Error ? error.message : String(error)
12241
+ });
12242
+ return null;
12243
+ }
12244
+ }
12245
+ }
12246
+ });
12247
+
11969
12248
  // dist/opencode-integration/task-tracker/extension-handler.js
11970
12249
  var require_extension_handler = __commonJS({
11971
12250
  "dist/opencode-integration/task-tracker/extension-handler.js"(exports2) {
@@ -12176,10 +12455,7 @@ var require_task_tracker = __commonJS({
12176
12455
  if (!tool || !callID || !state)
12177
12456
  return;
12178
12457
  if (constants_1.WRITE_TOOLS.has(tool)) {
12179
- this.collectFileChange(tool, state);
12180
- const ctx = this.handlerContext;
12181
- await this.extensionHandler.handle(tool, state, ctx);
12182
- this.taskCounter = ctx.taskCounter;
12458
+ await this.handleWriteEvent(tool, state);
12183
12459
  }
12184
12460
  if (tool === "skill" && state.status === "completed") {
12185
12461
  this.handleSkillEvent(state);
@@ -12190,10 +12466,26 @@ var require_task_tracker = __commonJS({
12190
12466
  this.taskCounter = ctx.taskCounter;
12191
12467
  }
12192
12468
  }
12193
- /** Records a unique file change (INSERT/EDIT) from a completed write/edit tool call. */
12194
- collectFileChange(tool, state) {
12469
+ async handleWriteEvent(tool, state) {
12195
12470
  if (state.status !== "completed")
12196
12471
  return;
12472
+ const fileStates = tool === "batch-write" ? this.expandBatchWrite(state) : [state];
12473
+ const effectiveTool = tool === "batch-write" ? "write" : tool;
12474
+ for (const fileState of fileStates) {
12475
+ this.trackFileChange(effectiveTool, fileState);
12476
+ const ctx = this.handlerContext;
12477
+ await this.extensionHandler.handle(effectiveTool, fileState, ctx);
12478
+ this.taskCounter = ctx.taskCounter;
12479
+ }
12480
+ }
12481
+ expandBatchWrite(state) {
12482
+ return (state.input?.files ?? []).map((f) => ({
12483
+ status: "completed",
12484
+ input: { filePath: f.path, content: f.content },
12485
+ metadata: { exists: false }
12486
+ }));
12487
+ }
12488
+ trackFileChange(tool, state) {
12197
12489
  const filePath = state.input?.filePath || state.title;
12198
12490
  const operation = (0, constants_1.resolveFileOperation)(tool, state.metadata);
12199
12491
  if (!filePath || !operation)
@@ -12497,6 +12789,7 @@ var require_executor = __commonJS({
12497
12789
  var job_context_storage_12 = require_job_context_storage();
12498
12790
  var parser_1 = require_parser();
12499
12791
  var prompts_1 = require_prompts();
12792
+ var cost_tracker_1 = require_cost_tracker();
12500
12793
  var task_tracker_1 = require_task_tracker2();
12501
12794
  var process_manager_1 = require_process_manager();
12502
12795
  var process_handlers_1 = require_process_handlers();
@@ -12531,6 +12824,7 @@ var require_executor = __commonJS({
12531
12824
  extensionsCreated: accumulatedExtensions
12532
12825
  };
12533
12826
  logger_12.logger.info((0, parser_1.formatUsageStats)(finalResult2.usage));
12827
+ await logOpenCodeStats(options);
12534
12828
  return finalResult2;
12535
12829
  }
12536
12830
  lastResult = result;
@@ -12550,8 +12844,18 @@ var require_executor = __commonJS({
12550
12844
  extensionsCreated: accumulatedExtensions
12551
12845
  };
12552
12846
  logger_12.logger.info((0, parser_1.formatUsageStats)(finalResult.usage));
12847
+ await logOpenCodeStats(options);
12553
12848
  return finalResult;
12554
12849
  }
12850
+ async function logOpenCodeStats(options) {
12851
+ const isAsk = job_context_storage_12.jobContextStorage.getStore()?.kind === ditto_codegen_types_12.TaskKind.ASK_CODEGEN;
12852
+ const env = isAsk ? (0, config_1.getOpenCodeAskEnv)(options.projectId) : (0, config_1.getOpenCodeEnv)(options.projectId);
12853
+ const stats = await (0, cost_tracker_1.fetchOpenCodeStats)(options.outputPath, env);
12854
+ if (stats) {
12855
+ logger_12.logger.info(`[OpenCode] Stats:
12856
+ ${stats}`);
12857
+ }
12858
+ }
12555
12859
  function buildArgs(prompt) {
12556
12860
  return ["run", "--format", "json", prompt];
12557
12861
  }
@@ -14690,43 +14994,6 @@ var require_pre_run_decision = __commonJS({
14690
14994
  }
14691
14995
  });
14692
14996
 
14693
- // dist/experiments.js
14694
- var require_experiments = __commonJS({
14695
- "dist/experiments.js"(exports2) {
14696
- "use strict";
14697
- Object.defineProperty(exports2, "__esModule", { value: true });
14698
- exports2.isExperimentEnabled = isExperimentEnabled;
14699
- exports2.isUserDecisionsEnabled = isUserDecisionsEnabled;
14700
- var logger_12 = require_logger();
14701
- var parsedExperiments = null;
14702
- function getExperiments() {
14703
- if (parsedExperiments !== null) {
14704
- return parsedExperiments;
14705
- }
14706
- const raw = process.env.CODEGEN_EXPERIMENTS;
14707
- if (!raw) {
14708
- parsedExperiments = {};
14709
- return parsedExperiments;
14710
- }
14711
- try {
14712
- parsedExperiments = JSON.parse(raw);
14713
- } catch (error) {
14714
- logger_12.logger.error("[Experiments] Failed to parse CODEGEN_EXPERIMENTS", {
14715
- error: error instanceof Error ? error.message : String(error)
14716
- });
14717
- parsedExperiments = {};
14718
- }
14719
- return parsedExperiments;
14720
- }
14721
- function isExperimentEnabled(specName) {
14722
- return getExperiments()[specName] === "true";
14723
- }
14724
- function isUserDecisionsEnabled() {
14725
- return isExperimentEnabled("specs.ditto.CodegenUserDecisions");
14726
- }
14727
- }
14728
- });
14729
-
14730
14997
  // dist/flows/opencode-init.js
14731
14998
  var require_opencode_init = __commonJS({
14732
14999
  "dist/flows/opencode-init.js"(exports2) {
@@ -15264,6 +15531,31 @@ var require_skills_installer = __commonJS({
15264
15531
  }
15265
15532
  });
15266
15533
 
15534
+ // dist/opencode-integration/tools-writer.js
15535
+ var require_tools_writer = __commonJS({
15536
+ "dist/opencode-integration/tools-writer.js"(exports2) {
15537
+ "use strict";
15538
+ Object.defineProperty(exports2, "__esModule", { value: true });
15539
+ exports2.writeToolFiles = writeToolFiles;
15540
+ var promises_1 = require("fs/promises");
15541
+ var os_1 = require("os");
15542
+ var path_1 = require("path");
15543
+ var logger_12 = require_logger();
15544
+ var GLOBAL_TOOLS_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "tools");
15545
+ async function writeToolFiles() {
15546
+ await (0, promises_1.mkdir)(GLOBAL_TOOLS_DIR, { recursive: true });
15547
+ const sourceToolsDir = (0, path_1.join)(__dirname, "opencode-tools");
15548
+ const files = await (0, promises_1.readdir)(sourceToolsDir);
15549
+ const toolFiles = files.filter((f) => f.endsWith(".ts"));
15550
+ await Promise.all(toolFiles.map((file) => (0, promises_1.copyFile)((0, path_1.join)(sourceToolsDir, file), (0, path_1.join)(GLOBAL_TOOLS_DIR, file))));
15551
+ logger_12.logger.info("[OpenCode] Wrote global tool files", {
15552
+ targetDir: GLOBAL_TOOLS_DIR,
15553
+ tools: toolFiles
15554
+ });
15555
+ }
15556
+ }
15557
+ });
15558
+
15267
15559
  // dist/index.js
15268
15560
  Object.defineProperty(exports, "__esModule", { value: true });
15269
15561
  exports.processJob = processJob;
@@ -15281,6 +15573,8 @@ var crypto_1 = require("crypto");
15281
15573
  var ditto_codegen_types_1 = require_dist4();
15282
15574
  var logger_1 = require_logger();
15283
15575
  var skills_installer_1 = require_skills_installer();
15576
+ var rules_writer_1 = require_rules_writer();
15577
+ var tools_writer_1 = require_tools_writer();
15284
15578
  var sessionId = process.env.CODEGEN_SESSION_ID || (0, crypto_1.randomUUID)();
15285
15579
  process.env.CODEGEN_SESSION_ID = sessionId;
15286
15580
  (0, logger_1.initLogger)(sessionId);
@@ -15326,10 +15620,18 @@ var alwaysOnLoop = async () => {
15326
15620
  context_1.ctx.resetJobs();
15327
15621
  }
15328
15622
  };
15623
+ async function initOpenCode() {
15624
+ await Promise.all([
15625
+ (0, skills_installer_1.installSkills)((0, codegen_flow_helpers_1.getOutputPath)(), logger_1.logger),
15626
+ (0, rules_writer_1.writeRuleFiles)(),
15627
+ (0, tools_writer_1.writeToolFiles)()
15628
+ ]);
15629
+ }
15329
15630
  async function main(ctx) {
15330
15631
  logger_1.logger.info("[Startup] CodeGen CLI starting", {
15331
15632
  projectId: ctx.projectId
15332
15633
  });
15634
+ await initOpenCode();
15333
15635
  await alwaysOnLoop();
15334
15636
  }
15335
15637
  var getFirstTask = (job) => {
@@ -15353,10 +15655,6 @@ async function processJob(job) {
15353
15655
  jobTimeoutMonitor.start(jobId);
15354
15656
  try {
15355
15657
  jobLog.debug("Task Payload", { payload: task.payload });
15356
- jobLog.debug("INSTALL_INTERNAL_SKILLS", {
15357
- value: process.env.INSTALL_INTERNAL_SKILLS
15358
- });
15359
- await (0, skills_installer_1.installSkills)((0, codegen_flow_helpers_1.getOutputPath)(), jobLog);
15360
15658
  await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind }, async () => {
15361
15659
  const payload = task.payload ?? {};
15362
15660
  const history = payload.history ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.272",
3
+ "version": "1.0.274",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -27,5 +27,5 @@
27
27
  "@wix/ditto-codegen": "1.0.0",
28
28
  "esbuild": "^0.27.2"
29
29
  },
30
- "falconPackageHash": "f331461af69f80088614bd1bc150cb8f3bc267d38018a7221434bfd9"
30
+ "falconPackageHash": "77ff9c8c2d7c0c3fd5d4c767a1048f35f75ea0aad65d48272cc7fccc"
31
31
  }