@wix/ditto-codegen-public 1.0.424 → 1.0.426

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.
@@ -16,14 +16,13 @@ async function existingFileSize(path: string): Promise<number | null> {
16
16
  }
17
17
  }
18
18
 
19
- // Keep in sync with normalize-tool-string.ts. Only whitespace/control escapes
20
- // are unescaped; `\"` and `\\` are NOT, or legitimate escaped quotes/backslashes
21
- // in the content (e.g. "C:\\Users", /\\d+/) would be silently corrupted.
22
19
  function unescapeString(str: string): string {
23
- return str.replace(/\\(n|t|r)/g, (_, c: string) => {
20
+ return str.replace(/\\(n|t|r|"|\\)/g, (_, c: string) => {
24
21
  if (c === "n") return "\n";
25
22
  if (c === "t") return "\t";
26
- return "\r";
23
+ if (c === "r") return "\r";
24
+ if (c === '"') return '"';
25
+ return "\\";
27
26
  });
28
27
  }
29
28
 
@@ -2,14 +2,13 @@ import { tool } from "@opencode-ai/plugin";
2
2
  import { readFile, writeFile } from "fs/promises";
3
3
  import { join, isAbsolute } from "path";
4
4
 
5
- // Keep in sync with normalize-tool-string.ts. Only whitespace/control escapes
6
- // are unescaped; `\"` and `\\` are NOT, or legitimate escaped quotes/backslashes
7
- // in the content (e.g. "C:\\Users", /\\d+/) would be silently corrupted.
8
5
  function unescapeString(str: string): string {
9
- return str.replace(/\\(n|t|r)/g, (_, c: string) => {
6
+ return str.replace(/\\(n|t|r|"|\\)/g, (_, c: string) => {
10
7
  if (c === "n") return "\n";
11
8
  if (c === "t") return "\t";
12
- return "\r";
9
+ if (c === "r") return "\r";
10
+ if (c === '"') return '"';
11
+ return "\\";
13
12
  });
14
13
  }
15
14
 
package/dist/out.js CHANGED
@@ -14465,7 +14465,22 @@ var require_studio_2_site_ui_rules = __commonJS({
14465
14465
  In the **Studio 2** environment, all site UI MUST be built as **Editor React Components** (\`extensionType: EDITOR_REACT_COMPONENT\`).
14466
14466
 
14467
14467
  - **Never create a Custom Element / site widget** (\`extensionType: CUSTOM_ELEMENT\`, \`CUSTOM_ELEMENT_WIDGET\`). This rule overrides the prompt \u2014 even if the prompt explicitly says "custom element", build it as an Editor React Component instead.
14468
- - The words "widget" and "custom element" in the prompt do **not** mean Custom Element \u2014 always implement them as Editor React Components.`;
14468
+ - The words "widget" and "custom element" in the prompt do **not** mean Custom Element \u2014 always implement them as Editor React Components.
14469
+
14470
+ ## Studio 2 Site Plugin Restrictions
14471
+
14472
+ The following pages **no longer support site plugins** in Studio 2. **This overrides the site plugin skills reference** \u2014 even if SLOTS.md lists these pages as supported, do NOT use a site plugin for them:
14473
+
14474
+ - **Product Page (New Version)** (Wix Stores)
14475
+ - **Product Page (Old Version)** (Wix Stores)
14476
+ - **Service Page** (Wix Bookings)
14477
+ - **Event Details Page** (Wix Events)
14478
+
14479
+ Build the appropriate Studio 2 extension instead:
14480
+ - **Need to render UI on the page** \u2192 Editor React Component (\`extensionType: EDITOR_REACT_COMPONENT\`)
14481
+ - **Need to expose shared data or state to components on the page (no UI)** \u2192 Context Provider (use the \`wix-cli-context-provider\` skill)
14482
+
14483
+ Both can be combined when the use case requires rendering UI and sharing state.`;
14469
14484
  }
14470
14485
  });
14471
14486
 
@@ -14897,6 +14912,7 @@ var require_shared_rules = __commonJS({
14897
14912
  Object.defineProperty(exports2, "__esModule", { value: true });
14898
14913
  exports2.OUTPUT_MESSAGE_RULES = exports2.BOUNDARY_RULES = void 0;
14899
14914
  exports2.buildEnvironmentRules = buildEnvironmentRules;
14915
+ exports2.buildFileOperationsRules = buildFileOperationsRules;
14900
14916
  function buildEnvironmentRules(environmentIdentity) {
14901
14917
  return `ENVIRONMENT:
14902
14918
  ${environmentIdentity}`;
@@ -14909,6 +14925,15 @@ ${environmentIdentity}`;
14909
14925
  - Match their technical level: include code/technical detail only if their request was technical; otherwise describe the outcome in plain language (no code, file/type names, or internals).
14910
14926
  - List any manual setup the user must still do for the feature to work, as short "next steps" (e.g. installing a dependent app or enabling a dashboard setting).
14911
14927
  - Be honest: if you didn't fully build what was asked (e.g. stored data but didn't send it), say so. Keep it short.`;
14928
+ function buildFileOperationsRules(multiEditContextClause) {
14929
+ return `- Package dependencies \u2014 \`npm install <pkg>\` any package not already in \`package.json\` BEFORE the first \`validate\` (do NOT wait for \`TS2307\`); install all needed packages in ONE command. Do NOT hand-edit \`package.json\` for deps unless npm cannot be used.
14930
+ - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
14931
+ - \`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.
14932
+ - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
14933
+ - \`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. When ${multiEditContextClause} across N files, use ONE \`multi-edit\` with all N edits.
14934
+ - Tool arguments are strict JSON, and \`write\`/\`edit\`/\`batch-write\`/\`multi-edit\` write \`content\`/\`oldString\`/\`newString\` to disk EXACTLY as decoded from that JSON \u2014 there is no second unescaping pass, so encode for the ONE decode that happens. Use \`\\n\`/\`\\t\`/\`\\"\` in the JSON when you want the file to contain a REAL newline/tab/quote character (a raw unescaped newline inside a JSON string value breaks parsing). If the file itself must contain the two LITERAL characters backslash-then-n (e.g. inside a string literal like \`.join('\\n')\`, a regex, or an already-escaped JSON value), escape the backslash itself in your JSON so it survives the one decode intact \u2014 do NOT emit a bare \`\\n\` expecting a tool to turn it back into two literal characters for you; none of them do.
14935
+ - 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.`;
14936
+ }
14912
14937
  }
14913
14938
  });
14914
14939
 
@@ -14938,13 +14963,7 @@ TOOL USAGE:
14938
14963
  - \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
14939
14964
  - \`wix-generate\` to scaffold extensions non-interactively \u2014 prefer over hand-writing boilerplate; pass an array to scaffold several at once. It RETURNS every created file's contents, so trust that and do NOT \`read\`/\`batch-read\` them afterward. On a \`FAILED\` block, fix the params per the error and retry.
14940
14965
  - \`required-permissions\` \u2014 declare the Wix app permissions the generated code needs (when/whether to call: workflow step 6 + PERMISSIONS).
14941
- - Package dependencies \u2014 \`npm install <pkg>\` any package not already in \`package.json\` BEFORE the first \`validate\` (do NOT wait for \`TS2307\`); install all needed packages in ONE command. Do NOT hand-edit \`package.json\` for deps unless npm cannot be used.
14942
- - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
14943
- - \`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.
14944
- - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
14945
- - \`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. When fixing type errors across N files, use ONE \`multi-edit\` with all N edits.
14946
- - Tool arguments are strict JSON. For multiline strings in \`write\`, \`edit\`, \`batch-write\`, and \`multi-edit\`, use JSON escape sequences (\`\\n\`, \`\\t\`, \`\\"\`) \u2014 do NOT put raw (unescaped) newlines inside JSON string values (that breaks parsing). All four write tools (\`write\`, \`edit\`, \`batch-write\`, \`multi-edit\`) normalize literal two-character escape sequences before writing; prefer proper JSON escapes.
14947
- - 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.
14966
+ ${(0, shared_rules_1.buildFileOperationsRules)("fixing type errors")}
14948
14967
  - API discovery (shapes, method signatures, types) \u2014 in this order: (1) loaded skills + KNOWN WIX APIS, if they already cover the API \u2014 if so, do NOT delegate; (2) only when you genuinely don't know which method/API to use, delegate to \`codegen-wix-docs\` (Wix SDK) or \`codegen-wds-docs\` (WDS) to SEARCH for it \u2014 pass the question, not a known article link; the subagent searches AND reads the right schema (\`ReadFullDocsMethodSchema\` is the source of truth for parameter shapes) and returns a summary. Do NOT delegate just to fetch a doc you already identified; (3) grepping \`node_modules\` ONLY as a last resort if the above return nothing \u2014 SDK internals are not a documentation source, and doing it first wastes turns, inflates context, and is unreliable. ENFORCED: after 2 such lookups, further bash inspection of \`node_modules\` Wix/vite/astro internals is rejected.
14949
14968
  - NEVER run preview, dev, release, or promote commands.
14950
14969
 
@@ -15033,6 +15052,7 @@ var require_git_conflicts_rules = __commonJS({
15033
15052
  "use strict";
15034
15053
  Object.defineProperty(exports2, "__esModule", { value: true });
15035
15054
  exports2.GIT_CONFLICTS_RULES = void 0;
15055
+ var shared_rules_1 = require_shared_rules();
15036
15056
  exports2.GIT_CONFLICTS_RULES = `CORE PRINCIPLES:
15037
15057
  - You are a Git merge conflict resolver. Your ONLY job is to fix merge conflict markers in files.
15038
15058
  - Do NOT generate new features, refactor code, or make changes beyond resolving conflicts.
@@ -15064,13 +15084,7 @@ MINIMIZE TEXT OUTPUT \u2014 CRITICAL:
15064
15084
 
15065
15085
  TOOL USAGE:
15066
15086
  - \`validate\` for all validation (tsc + build). Run it after resolving the conflicts to make sure nothing breaks.
15067
- - Package dependencies \u2014 \`npm install <pkg>\` any package not already in \`package.json\` BEFORE the first \`validate\` (do NOT wait for \`TS2307\`); install all needed packages in ONE command. Do NOT hand-edit \`package.json\` for deps unless npm cannot be used.
15068
- - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
15069
- - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
15070
- - \`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. When resolving conflicts across N files, use ONE \`multi-edit\` with all N edits.
15071
- - \`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.
15072
- - Tool arguments are strict JSON. For multiline strings in \`write\`, \`edit\`, \`batch-write\`, and \`multi-edit\`, use JSON escape sequences (\`\\n\`, \`\\t\`, \`\\"\`) \u2014 do NOT put raw (unescaped) newlines inside JSON string values (that breaks parsing). All four write tools (\`write\`, \`edit\`, \`batch-write\`, \`multi-edit\`) normalize literal two-character escape sequences before writing; prefer proper JSON escapes.
15073
- - 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.
15087
+ ${(0, shared_rules_1.buildFileOperationsRules)("resolving conflicts")}
15074
15088
  - NEVER run preview, dev, release, or promote commands.
15075
15089
 
15076
15090
  WORKFLOW:
@@ -23224,85 +23238,6 @@ export const GeneratedFilesGuard = async () => ({
23224
23238
  }
23225
23239
  });
23226
23240
 
23227
- // dist/opencode-integration/normalize-tool-string.js
23228
- var require_normalize_tool_string = __commonJS({
23229
- "dist/opencode-integration/normalize-tool-string.js"(exports2) {
23230
- "use strict";
23231
- Object.defineProperty(exports2, "__esModule", { value: true });
23232
- exports2.unescapeString = unescapeString;
23233
- exports2.normalizeToolString = normalizeToolString;
23234
- function unescapeString(str) {
23235
- return str.replace(/\\(n|t|r)/g, (_, c) => {
23236
- if (c === "n")
23237
- return "\n";
23238
- if (c === "t")
23239
- return " ";
23240
- return "\r";
23241
- });
23242
- }
23243
- function normalizeToolString(text) {
23244
- return unescapeString(text).replace(/\r\n/g, "\n");
23245
- }
23246
- }
23247
- });
23248
-
23249
- // dist/opencode-integration/edit-normalizer.js
23250
- var require_edit_normalizer = __commonJS({
23251
- "dist/opencode-integration/edit-normalizer.js"(exports2) {
23252
- "use strict";
23253
- Object.defineProperty(exports2, "__esModule", { value: true });
23254
- exports2.NORMALIZE_PLUGIN_PATH = void 0;
23255
- exports2.buildNormalizePluginSource = buildNormalizePluginSource;
23256
- exports2.writeNormalizePlugin = writeNormalizePlugin;
23257
- var promises_1 = require("fs/promises");
23258
- var os_1 = require("os");
23259
- var path_1 = require("path");
23260
- var logger_12 = require_logger();
23261
- var normalize_tool_string_1 = require_normalize_tool_string();
23262
- var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
23263
- var NORMALIZE_PLUGIN_FILENAME = "edit-write-normalizer.ts";
23264
- exports2.NORMALIZE_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, NORMALIZE_PLUGIN_FILENAME);
23265
- function buildNormalizePluginSource() {
23266
- return `// Generated by @wix/ditto-codegen (edit-normalizer) \u2014 do not edit.
23267
- ${normalize_tool_string_1.unescapeString.toString()}
23268
-
23269
- ${normalize_tool_string_1.normalizeToolString.toString()}
23270
-
23271
- export const EditWriteNormalizer = async () => ({
23272
- "tool.execute.before": async (
23273
- input: { tool: string },
23274
- output: {
23275
- args?: { oldString?: string; newString?: string; content?: string };
23276
- },
23277
- ) => {
23278
- const args = output?.args;
23279
- if (!args) return;
23280
- if (input.tool === "edit") {
23281
- if (typeof args.oldString === "string") {
23282
- args.oldString = normalizeToolString(args.oldString);
23283
- }
23284
- if (typeof args.newString === "string") {
23285
- args.newString = normalizeToolString(args.newString);
23286
- }
23287
- } else if (input.tool === "write") {
23288
- if (typeof args.content === "string") {
23289
- args.content = normalizeToolString(args.content);
23290
- }
23291
- }
23292
- },
23293
- });
23294
- `;
23295
- }
23296
- async function writeNormalizePlugin() {
23297
- await (0, promises_1.mkdir)(GLOBAL_PLUGIN_DIR, { recursive: true });
23298
- await (0, promises_1.writeFile)(exports2.NORMALIZE_PLUGIN_PATH, buildNormalizePluginSource(), "utf-8");
23299
- logger_12.logger.info("[OpenCode] Wrote edit/write normalizer plugin", {
23300
- path: exports2.NORMALIZE_PLUGIN_PATH
23301
- });
23302
- }
23303
- }
23304
- });
23305
-
23306
23241
  // dist/plugin-host.js
23307
23242
  var require_plugin_host = __commonJS({
23308
23243
  "dist/plugin-host.js"(exports2) {
@@ -23371,7 +23306,6 @@ var tools_writer_1 = require_tools_writer();
23371
23306
  var node_modules_guard_1 = require_node_modules_guard();
23372
23307
  var generated_files_guard_1 = require_generated_files_guard();
23373
23308
  var subagent_tool_logger_1 = require_subagent_tool_logger();
23374
- var edit_normalizer_1 = require_edit_normalizer();
23375
23309
  var plugin_artifacts_1 = require_plugin_artifacts();
23376
23310
  var config_1 = require_config();
23377
23311
  var environments_1 = require_environments();
@@ -23447,8 +23381,7 @@ async function initOpenCode() {
23447
23381
  (0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
23448
23382
  (0, node_modules_guard_1.writeGuardPlugin)(),
23449
23383
  (0, generated_files_guard_1.writeGeneratedFilesGuardPlugin)(),
23450
- (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)(),
23451
- (0, edit_normalizer_1.writeNormalizePlugin)()
23384
+ (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)()
23452
23385
  ]);
23453
23386
  }
23454
23387
  async function main(ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.424",
3
+ "version": "1.0.426",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -29,5 +29,5 @@
29
29
  "esbuild": "^0.27.2",
30
30
  "vitest": "^4.0.16"
31
31
  },
32
- "falconPackageHash": "19c959ce8c377c9693839db1f61b64933d0eda5f91ab0b5e7b6182bf"
32
+ "falconPackageHash": "1b3d84241cfe457e433522d63186279c3add83d56ad0810a90bc7a66"
33
33
  }