@wix/ditto-codegen-public 1.0.413 → 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
 
@@ -22967,6 +22967,155 @@ var require_tools_writer = __commonJS({
22967
22967
  }
22968
22968
  });
22969
22969
 
22970
+ // dist/opencode-integration/generated-files-guard.js
22971
+ var require_generated_files_guard = __commonJS({
22972
+ "dist/opencode-integration/generated-files-guard.js"(exports2) {
22973
+ "use strict";
22974
+ Object.defineProperty(exports2, "__esModule", { value: true });
22975
+ exports2.GENERATED_FILES_GUARD_PLUGIN_PATH = exports2.GUARD_MESSAGE = void 0;
22976
+ exports2.isEditorComponentManifest = isEditorComponentManifest;
22977
+ exports2.extractWritePaths = extractWritePaths;
22978
+ exports2.buildGeneratedFilesGuardSource = buildGeneratedFilesGuardSource;
22979
+ exports2.writeGeneratedFilesGuardPlugin = writeGeneratedFilesGuardPlugin;
22980
+ var promises_1 = require("fs/promises");
22981
+ var os_1 = require("os");
22982
+ var path_1 = require("path");
22983
+ var logger_12 = require_logger();
22984
+ var ERC_MANIFEST_RE = /(^|\/)src\/extensions\/site\/components\/.+\.generated\.tsx?$/;
22985
+ exports2.GUARD_MESSAGE = "BLOCKED: *.generated.ts is an auto-generated manifest. Do not create or edit it by hand. It is derived from the component's React markup (*.tsx) and CSS module (*.module.css) and regenerated by running `npx wix build && npx wix generate manifest`. To change it, edit the *.tsx / *.module.css / *.props.ts source and regenerate; to override manifest values, edit the component's *.extension.ts. Do not retry this write.";
22986
+ function isEditorComponentManifest(path) {
22987
+ return ERC_MANIFEST_RE.test(path);
22988
+ }
22989
+ function extractWritePaths(tool, args) {
22990
+ if (tool === "write" || tool === "edit") {
22991
+ return typeof args.filePath === "string" ? [args.filePath] : [];
22992
+ }
22993
+ const list = tool === "batch-write" ? args.files : tool === "multi-edit" ? args.edits : void 0;
22994
+ if (!list)
22995
+ return [];
22996
+ return list.map((item) => item.path).filter((p) => typeof p === "string");
22997
+ }
22998
+ var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
22999
+ var GUARD_PLUGIN_FILENAME = "generated-files-guard.ts";
23000
+ exports2.GENERATED_FILES_GUARD_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, GUARD_PLUGIN_FILENAME);
23001
+ function buildGeneratedFilesGuardSource() {
23002
+ return `// Generated by @wix/ditto-codegen (generated-files-guard). Do not edit.
23003
+ const ERC_MANIFEST_RE = /${ERC_MANIFEST_RE.source}/;
23004
+ const GUARD_MESSAGE = ${JSON.stringify(exports2.GUARD_MESSAGE)};
23005
+
23006
+ function extractWritePaths(tool, args) {
23007
+ if (tool === "${"write"}" || tool === "${"edit"}") {
23008
+ return typeof args.filePath === "string" ? [args.filePath] : [];
23009
+ }
23010
+ const list =
23011
+ tool === "${"batch-write"}" ? args.files : tool === "${"multi-edit"}" ? args.edits : undefined;
23012
+ if (!list) return [];
23013
+ return list
23014
+ .map((item) => item.path)
23015
+ .filter((p) => typeof p === "string");
23016
+ }
23017
+
23018
+ export const GeneratedFilesGuard = async () => ({
23019
+ "tool.execute.before": async (input, output) => {
23020
+ const blocked = extractWritePaths(input.tool, output.args).filter((p) =>
23021
+ ERC_MANIFEST_RE.test(p),
23022
+ );
23023
+ if (blocked.length > 0) {
23024
+ throw new Error(GUARD_MESSAGE + " (blocked: " + blocked.join(", ") + ")");
23025
+ }
23026
+ },
23027
+ });
23028
+ `;
23029
+ }
23030
+ async function writeGeneratedFilesGuardPlugin() {
23031
+ await (0, promises_1.mkdir)(GLOBAL_PLUGIN_DIR, { recursive: true });
23032
+ await (0, promises_1.writeFile)(exports2.GENERATED_FILES_GUARD_PLUGIN_PATH, buildGeneratedFilesGuardSource(), "utf-8");
23033
+ logger_12.logger.info("[OpenCode] Wrote generated-files guard plugin", {
23034
+ path: exports2.GENERATED_FILES_GUARD_PLUGIN_PATH
23035
+ });
23036
+ }
23037
+ }
23038
+ });
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
+
22970
23119
  // dist/plugin-host.js
22971
23120
  var require_plugin_host = __commonJS({
22972
23121
  "dist/plugin-host.js"(exports2) {
@@ -23033,7 +23182,9 @@ var skills_installer_1 = require_skills_installer();
23033
23182
  var rules_writer_1 = require_rules_writer();
23034
23183
  var tools_writer_1 = require_tools_writer();
23035
23184
  var node_modules_guard_1 = require_node_modules_guard();
23185
+ var generated_files_guard_1 = require_generated_files_guard();
23036
23186
  var subagent_tool_logger_1 = require_subagent_tool_logger();
23187
+ var edit_normalizer_1 = require_edit_normalizer();
23037
23188
  var plugin_artifacts_1 = require_plugin_artifacts();
23038
23189
  var config_1 = require_config();
23039
23190
  var environments_1 = require_environments();
@@ -23108,7 +23259,9 @@ async function initOpenCode() {
23108
23259
  (0, skills_installer_1.applySkillsOverride)((0, codegen_flow_helpers_1.getOutputPath)(), logger_1.logger),
23109
23260
  (0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
23110
23261
  (0, node_modules_guard_1.writeGuardPlugin)(),
23111
- (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)()
23262
+ (0, generated_files_guard_1.writeGeneratedFilesGuardPlugin)(),
23263
+ (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)(),
23264
+ (0, edit_normalizer_1.writeNormalizePlugin)()
23112
23265
  ]);
23113
23266
  }
23114
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.413",
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": "9dbcb468e044e06b03b189b5fed7bf99f05b205e2f06c786a503690e"
32
+ "falconPackageHash": "7a14ad1a82b18e6c58decd5e574c0849d34961c3d4a5fdddc5bd0491"
33
33
  }