@wix/ditto-codegen-public 1.0.355 → 1.0.356

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.
@@ -2,6 +2,20 @@ import { tool } from "@opencode-ai/plugin";
2
2
  import { writeFile, mkdir } from "fs/promises";
3
3
  import { join, dirname, isAbsolute } from "path";
4
4
 
5
+ function unescapeString(str: string): string {
6
+ return str.replace(/\\(n|t|r|"|\\)/g, (_, c: string) => {
7
+ if (c === "n") return "\n";
8
+ if (c === "t") return "\t";
9
+ if (c === "r") return "\r";
10
+ if (c === '"') return '"';
11
+ return "\\";
12
+ });
13
+ }
14
+
15
+ function normalizeToolString(text: string): string {
16
+ return unescapeString(text).replace(/\r\n/g, "\n");
17
+ }
18
+
5
19
  export default tool({
6
20
  description:
7
21
  "Write multiple files at once. Creates directories as needed. " +
@@ -28,7 +42,7 @@ export default tool({
28
42
  await mkdir(dirname(fullPath), { recursive: true });
29
43
  const content =
30
44
  typeof f.content === "string"
31
- ? f.content
45
+ ? normalizeToolString(f.content)
32
46
  : JSON.stringify(f.content, null, 2);
33
47
  await writeFile(fullPath, content, "utf-8");
34
48
  results.push(`OK: ${f.path}`);
@@ -2,6 +2,20 @@ import { tool } from "@opencode-ai/plugin";
2
2
  import { readFile, writeFile } from "fs/promises";
3
3
  import { join, isAbsolute } from "path";
4
4
 
5
+ function unescapeString(str: string): string {
6
+ return str.replace(/\\(n|t|r|"|\\)/g, (_, c: string) => {
7
+ if (c === "n") return "\n";
8
+ if (c === "t") return "\t";
9
+ if (c === "r") return "\r";
10
+ if (c === '"') return '"';
11
+ return "\\";
12
+ });
13
+ }
14
+
15
+ function normalizeToolString(text: string): string {
16
+ return unescapeString(text).replace(/\r\n/g, "\n");
17
+ }
18
+
5
19
  export default tool({
6
20
  description:
7
21
  "Apply multiple find-and-replace edits across one or more files in a single call. " +
@@ -36,7 +50,9 @@ export default tool({
36
50
  : join(context.directory, e.path);
37
51
  try {
38
52
  const content = await readFile(fullPath, "utf-8");
39
- const occurrences = content.split(e.oldString).length - 1;
53
+ const oldString = normalizeToolString(e.oldString);
54
+ const newString = normalizeToolString(e.newString);
55
+ const occurrences = content.split(oldString).length - 1;
40
56
  if (occurrences === 0) {
41
57
  results.push(`FAILED: ${e.path} - oldString not found`);
42
58
  continue;
@@ -48,8 +64,8 @@ export default tool({
48
64
  continue;
49
65
  }
50
66
  const updated = e.replaceAll
51
- ? content.split(e.oldString).join(e.newString)
52
- : content.replace(e.oldString, e.newString);
67
+ ? content.split(oldString).join(newString)
68
+ : content.replace(oldString, newString);
53
69
  await writeFile(fullPath, updated, "utf-8");
54
70
  results.push(`OK: ${e.path}`);
55
71
  } catch (err) {
package/dist/out.js CHANGED
@@ -12175,7 +12175,7 @@ TOOL USAGE:
12175
12175
  - \`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.
12176
12176
  - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
12177
12177
  - \`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.
12178
- - In \`write\`/\`batch-write\` (\`content\`) and \`edit\`/\`multi-edit\` (\`newString\`) payloads, use real newlines/tabs/quotes \u2014 NEVER the two-character escape sequences \`\\n\`, \`\\t\`, or \`\\"\`. Those are written literally to disk and break \`tsc\`.
12178
+ - 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.
12179
12179
  - 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.
12180
12180
  - Before calling MCP tools, check if loaded skills already cover the API. Only use MCP for gaps.
12181
12181
  - 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.355",
3
+ "version": "1.0.356",
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": "dd6728e78e15bfd74a1b9833c183856688581fdb5c38a7c055f003e6"
32
+ "falconPackageHash": "46430d23524ff58385dfa134d092b0d3cee668df1418e967dec43c10"
33
33
  }