@wix/ditto-codegen-public 1.0.425 → 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
@@ -14912,6 +14912,7 @@ var require_shared_rules = __commonJS({
14912
14912
  Object.defineProperty(exports2, "__esModule", { value: true });
14913
14913
  exports2.OUTPUT_MESSAGE_RULES = exports2.BOUNDARY_RULES = void 0;
14914
14914
  exports2.buildEnvironmentRules = buildEnvironmentRules;
14915
+ exports2.buildFileOperationsRules = buildFileOperationsRules;
14915
14916
  function buildEnvironmentRules(environmentIdentity) {
14916
14917
  return `ENVIRONMENT:
14917
14918
  ${environmentIdentity}`;
@@ -14924,6 +14925,15 @@ ${environmentIdentity}`;
14924
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).
14925
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).
14926
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
+ }
14927
14937
  }
14928
14938
  });
14929
14939
 
@@ -14953,13 +14963,7 @@ TOOL USAGE:
14953
14963
  - \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
14954
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.
14955
14965
  - \`required-permissions\` \u2014 declare the Wix app permissions the generated code needs (when/whether to call: workflow step 6 + PERMISSIONS).
14956
- - 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.
14957
- - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
14958
- - \`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.
14959
- - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
14960
- - \`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.
14961
- - 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.
14962
- - 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")}
14963
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.
14964
14968
  - NEVER run preview, dev, release, or promote commands.
14965
14969
 
@@ -15048,6 +15052,7 @@ var require_git_conflicts_rules = __commonJS({
15048
15052
  "use strict";
15049
15053
  Object.defineProperty(exports2, "__esModule", { value: true });
15050
15054
  exports2.GIT_CONFLICTS_RULES = void 0;
15055
+ var shared_rules_1 = require_shared_rules();
15051
15056
  exports2.GIT_CONFLICTS_RULES = `CORE PRINCIPLES:
15052
15057
  - You are a Git merge conflict resolver. Your ONLY job is to fix merge conflict markers in files.
15053
15058
  - Do NOT generate new features, refactor code, or make changes beyond resolving conflicts.
@@ -15079,13 +15084,7 @@ MINIMIZE TEXT OUTPUT \u2014 CRITICAL:
15079
15084
 
15080
15085
  TOOL USAGE:
15081
15086
  - \`validate\` for all validation (tsc + build). Run it after resolving the conflicts to make sure nothing breaks.
15082
- - 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.
15083
- - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
15084
- - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
15085
- - \`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.
15086
- - \`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.
15087
- - 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.
15088
- - 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")}
15089
15088
  - NEVER run preview, dev, release, or promote commands.
15090
15089
 
15091
15090
  WORKFLOW:
@@ -23239,85 +23238,6 @@ export const GeneratedFilesGuard = async () => ({
23239
23238
  }
23240
23239
  });
23241
23240
 
23242
- // dist/opencode-integration/normalize-tool-string.js
23243
- var require_normalize_tool_string = __commonJS({
23244
- "dist/opencode-integration/normalize-tool-string.js"(exports2) {
23245
- "use strict";
23246
- Object.defineProperty(exports2, "__esModule", { value: true });
23247
- exports2.unescapeString = unescapeString;
23248
- exports2.normalizeToolString = normalizeToolString;
23249
- function unescapeString(str) {
23250
- return str.replace(/\\(n|t|r)/g, (_, c) => {
23251
- if (c === "n")
23252
- return "\n";
23253
- if (c === "t")
23254
- return " ";
23255
- return "\r";
23256
- });
23257
- }
23258
- function normalizeToolString(text) {
23259
- return unescapeString(text).replace(/\r\n/g, "\n");
23260
- }
23261
- }
23262
- });
23263
-
23264
- // dist/opencode-integration/edit-normalizer.js
23265
- var require_edit_normalizer = __commonJS({
23266
- "dist/opencode-integration/edit-normalizer.js"(exports2) {
23267
- "use strict";
23268
- Object.defineProperty(exports2, "__esModule", { value: true });
23269
- exports2.NORMALIZE_PLUGIN_PATH = void 0;
23270
- exports2.buildNormalizePluginSource = buildNormalizePluginSource;
23271
- exports2.writeNormalizePlugin = writeNormalizePlugin;
23272
- var promises_1 = require("fs/promises");
23273
- var os_1 = require("os");
23274
- var path_1 = require("path");
23275
- var logger_12 = require_logger();
23276
- var normalize_tool_string_1 = require_normalize_tool_string();
23277
- var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
23278
- var NORMALIZE_PLUGIN_FILENAME = "edit-write-normalizer.ts";
23279
- exports2.NORMALIZE_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, NORMALIZE_PLUGIN_FILENAME);
23280
- function buildNormalizePluginSource() {
23281
- return `// Generated by @wix/ditto-codegen (edit-normalizer) \u2014 do not edit.
23282
- ${normalize_tool_string_1.unescapeString.toString()}
23283
-
23284
- ${normalize_tool_string_1.normalizeToolString.toString()}
23285
-
23286
- export const EditWriteNormalizer = async () => ({
23287
- "tool.execute.before": async (
23288
- input: { tool: string },
23289
- output: {
23290
- args?: { oldString?: string; newString?: string; content?: string };
23291
- },
23292
- ) => {
23293
- const args = output?.args;
23294
- if (!args) return;
23295
- if (input.tool === "edit") {
23296
- if (typeof args.oldString === "string") {
23297
- args.oldString = normalizeToolString(args.oldString);
23298
- }
23299
- if (typeof args.newString === "string") {
23300
- args.newString = normalizeToolString(args.newString);
23301
- }
23302
- } else if (input.tool === "write") {
23303
- if (typeof args.content === "string") {
23304
- args.content = normalizeToolString(args.content);
23305
- }
23306
- }
23307
- },
23308
- });
23309
- `;
23310
- }
23311
- async function writeNormalizePlugin() {
23312
- await (0, promises_1.mkdir)(GLOBAL_PLUGIN_DIR, { recursive: true });
23313
- await (0, promises_1.writeFile)(exports2.NORMALIZE_PLUGIN_PATH, buildNormalizePluginSource(), "utf-8");
23314
- logger_12.logger.info("[OpenCode] Wrote edit/write normalizer plugin", {
23315
- path: exports2.NORMALIZE_PLUGIN_PATH
23316
- });
23317
- }
23318
- }
23319
- });
23320
-
23321
23241
  // dist/plugin-host.js
23322
23242
  var require_plugin_host = __commonJS({
23323
23243
  "dist/plugin-host.js"(exports2) {
@@ -23386,7 +23306,6 @@ var tools_writer_1 = require_tools_writer();
23386
23306
  var node_modules_guard_1 = require_node_modules_guard();
23387
23307
  var generated_files_guard_1 = require_generated_files_guard();
23388
23308
  var subagent_tool_logger_1 = require_subagent_tool_logger();
23389
- var edit_normalizer_1 = require_edit_normalizer();
23390
23309
  var plugin_artifacts_1 = require_plugin_artifacts();
23391
23310
  var config_1 = require_config();
23392
23311
  var environments_1 = require_environments();
@@ -23462,8 +23381,7 @@ async function initOpenCode() {
23462
23381
  (0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
23463
23382
  (0, node_modules_guard_1.writeGuardPlugin)(),
23464
23383
  (0, generated_files_guard_1.writeGeneratedFilesGuardPlugin)(),
23465
- (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)(),
23466
- (0, edit_normalizer_1.writeNormalizePlugin)()
23384
+ (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)()
23467
23385
  ]);
23468
23386
  }
23469
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.425",
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": "1f6d562a70f6dbe69b890854b369976d285c889a8b16687fb4980d2d"
32
+ "falconPackageHash": "1b3d84241cfe457e433522d63186279c3add83d56ad0810a90bc7a66"
33
33
  }