@wix/ditto-codegen-public 1.0.414 → 1.0.415

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,13 +16,14 @@ 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.
19
22
  function unescapeString(str: string): string {
20
- return str.replace(/\\(n|t|r|"|\\)/g, (_, c: string) => {
23
+ return str.replace(/\\(n|t|r)/g, (_, c: string) => {
21
24
  if (c === "n") return "\n";
22
25
  if (c === "t") return "\t";
23
- if (c === "r") return "\r";
24
- if (c === '"') return '"';
25
- return "\\";
26
+ return "\r";
26
27
  });
27
28
  }
28
29
 
@@ -2,13 +2,14 @@ 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.
5
8
  function unescapeString(str: string): string {
6
- return str.replace(/\\(n|t|r|"|\\)/g, (_, c: string) => {
9
+ return str.replace(/\\(n|t|r)/g, (_, c: string) => {
7
10
  if (c === "n") return "\n";
8
11
  if (c === "t") return "\t";
9
- if (c === "r") return "\r";
10
- if (c === '"') return '"';
11
- return "\\";
12
+ return "\r";
12
13
  });
13
14
  }
14
15
 
package/dist/out.js CHANGED
@@ -14803,7 +14803,7 @@ TOOL USAGE:
14803
14803
  - \`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.
14804
14804
  - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
14805
14805
  - \`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.
14806
- - 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). \`batch-write\` and \`multi-edit\` also normalize literal two-character escape sequences before writing; prefer proper JSON escapes.
14806
+ - 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.
14807
14807
  - 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.
14808
14808
  - 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.
14809
14809
  - NEVER run preview, dev, release, or promote commands.
@@ -14929,7 +14929,7 @@ TOOL USAGE:
14929
14929
  - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
14930
14930
  - \`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.
14931
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
- - 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). \`batch-write\` and \`multi-edit\` also normalize literal two-character escape sequences before writing; prefer proper JSON escapes.
14932
+ - 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.
14933
14933
  - 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.
14934
14934
  - NEVER run preview, dev, release, or promote commands.
14935
14935
 
@@ -23037,6 +23037,85 @@ export const GeneratedFilesGuard = async () => ({
23037
23037
  }
23038
23038
  });
23039
23039
 
23040
+ // dist/opencode-integration/normalize-tool-string.js
23041
+ var require_normalize_tool_string = __commonJS({
23042
+ "dist/opencode-integration/normalize-tool-string.js"(exports2) {
23043
+ "use strict";
23044
+ Object.defineProperty(exports2, "__esModule", { value: true });
23045
+ exports2.unescapeString = unescapeString;
23046
+ exports2.normalizeToolString = normalizeToolString;
23047
+ function unescapeString(str) {
23048
+ return str.replace(/\\(n|t|r)/g, (_, c) => {
23049
+ if (c === "n")
23050
+ return "\n";
23051
+ if (c === "t")
23052
+ return " ";
23053
+ return "\r";
23054
+ });
23055
+ }
23056
+ function normalizeToolString(text) {
23057
+ return unescapeString(text).replace(/\r\n/g, "\n");
23058
+ }
23059
+ }
23060
+ });
23061
+
23062
+ // dist/opencode-integration/edit-normalizer.js
23063
+ var require_edit_normalizer = __commonJS({
23064
+ "dist/opencode-integration/edit-normalizer.js"(exports2) {
23065
+ "use strict";
23066
+ Object.defineProperty(exports2, "__esModule", { value: true });
23067
+ exports2.NORMALIZE_PLUGIN_PATH = void 0;
23068
+ exports2.buildNormalizePluginSource = buildNormalizePluginSource;
23069
+ exports2.writeNormalizePlugin = writeNormalizePlugin;
23070
+ var promises_1 = require("fs/promises");
23071
+ var os_1 = require("os");
23072
+ var path_1 = require("path");
23073
+ var logger_12 = require_logger();
23074
+ var normalize_tool_string_1 = require_normalize_tool_string();
23075
+ var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
23076
+ var NORMALIZE_PLUGIN_FILENAME = "edit-write-normalizer.ts";
23077
+ exports2.NORMALIZE_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, NORMALIZE_PLUGIN_FILENAME);
23078
+ function buildNormalizePluginSource() {
23079
+ return `// Generated by @wix/ditto-codegen (edit-normalizer) \u2014 do not edit.
23080
+ ${normalize_tool_string_1.unescapeString.toString()}
23081
+
23082
+ ${normalize_tool_string_1.normalizeToolString.toString()}
23083
+
23084
+ export const EditWriteNormalizer = async () => ({
23085
+ "tool.execute.before": async (
23086
+ input: { tool: string },
23087
+ output: {
23088
+ args?: { oldString?: string; newString?: string; content?: string };
23089
+ },
23090
+ ) => {
23091
+ const args = output?.args;
23092
+ if (!args) return;
23093
+ if (input.tool === "edit") {
23094
+ if (typeof args.oldString === "string") {
23095
+ args.oldString = normalizeToolString(args.oldString);
23096
+ }
23097
+ if (typeof args.newString === "string") {
23098
+ args.newString = normalizeToolString(args.newString);
23099
+ }
23100
+ } else if (input.tool === "write") {
23101
+ if (typeof args.content === "string") {
23102
+ args.content = normalizeToolString(args.content);
23103
+ }
23104
+ }
23105
+ },
23106
+ });
23107
+ `;
23108
+ }
23109
+ async function writeNormalizePlugin() {
23110
+ await (0, promises_1.mkdir)(GLOBAL_PLUGIN_DIR, { recursive: true });
23111
+ await (0, promises_1.writeFile)(exports2.NORMALIZE_PLUGIN_PATH, buildNormalizePluginSource(), "utf-8");
23112
+ logger_12.logger.info("[OpenCode] Wrote edit/write normalizer plugin", {
23113
+ path: exports2.NORMALIZE_PLUGIN_PATH
23114
+ });
23115
+ }
23116
+ }
23117
+ });
23118
+
23040
23119
  // dist/plugin-host.js
23041
23120
  var require_plugin_host = __commonJS({
23042
23121
  "dist/plugin-host.js"(exports2) {
@@ -23105,6 +23184,7 @@ var tools_writer_1 = require_tools_writer();
23105
23184
  var node_modules_guard_1 = require_node_modules_guard();
23106
23185
  var generated_files_guard_1 = require_generated_files_guard();
23107
23186
  var subagent_tool_logger_1 = require_subagent_tool_logger();
23187
+ var edit_normalizer_1 = require_edit_normalizer();
23108
23188
  var plugin_artifacts_1 = require_plugin_artifacts();
23109
23189
  var config_1 = require_config();
23110
23190
  var environments_1 = require_environments();
@@ -23180,7 +23260,8 @@ async function initOpenCode() {
23180
23260
  (0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
23181
23261
  (0, node_modules_guard_1.writeGuardPlugin)(),
23182
23262
  (0, generated_files_guard_1.writeGeneratedFilesGuardPlugin)(),
23183
- (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)()
23263
+ (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)(),
23264
+ (0, edit_normalizer_1.writeNormalizePlugin)()
23184
23265
  ]);
23185
23266
  }
23186
23267
  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.414",
3
+ "version": "1.0.415",
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": "3f4e50c396df8c8be63a1dbca9cd2473b5971b403ca96677f6b82bfc"
32
+ "falconPackageHash": "7a14ad1a82b18e6c58decd5e574c0849d34961c3d4a5fdddc5bd0491"
33
33
  }