@wix/ditto-codegen-public 1.0.32 → 1.0.34

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.
Files changed (2) hide show
  1. package/dist/out.js +212 -209
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -123145,6 +123145,68 @@ var require_dist11 = __commonJS({
123145
123145
  }
123146
123146
  });
123147
123147
 
123148
+ // dist/utils.js
123149
+ var require_utils18 = __commonJS({
123150
+ "dist/utils.js"(exports2) {
123151
+ "use strict";
123152
+ Object.defineProperty(exports2, "__esModule", { value: true });
123153
+ exports2.serializeError = serializeError;
123154
+ exports2.mapGroupBy = mapGroupBy;
123155
+ function serializeError(error) {
123156
+ if (error instanceof Error) {
123157
+ const base = {
123158
+ name: error.name,
123159
+ message: error.message,
123160
+ stack: error.stack
123161
+ };
123162
+ const anyErr = error;
123163
+ for (const key in anyErr) {
123164
+ if (!(key in base)) {
123165
+ try {
123166
+ base[key] = anyErr[key];
123167
+ } catch {
123168
+ }
123169
+ }
123170
+ }
123171
+ const withCause = error;
123172
+ if (withCause && "cause" in withCause) {
123173
+ base.cause = withCause.cause;
123174
+ }
123175
+ const maybeHttp = error;
123176
+ if (maybeHttp?.response?.data !== void 0)
123177
+ base.data = maybeHttp.response.data;
123178
+ if (maybeHttp?.code !== void 0)
123179
+ base.code = maybeHttp.code;
123180
+ if (maybeHttp?.details !== void 0)
123181
+ base.details = maybeHttp.details;
123182
+ return base;
123183
+ }
123184
+ if (typeof error === "object" && error !== null) {
123185
+ try {
123186
+ return JSON.parse(JSON.stringify(error));
123187
+ } catch {
123188
+ return { message: String(error) };
123189
+ }
123190
+ }
123191
+ return { message: String(error) };
123192
+ }
123193
+ function mapGroupBy(items, keyExtractor) {
123194
+ const groups = /* @__PURE__ */ new Map();
123195
+ for (const item of items) {
123196
+ const key = keyExtractor(item);
123197
+ if (key === void 0 || key === null) {
123198
+ continue;
123199
+ }
123200
+ if (!groups.has(key)) {
123201
+ groups.set(key, []);
123202
+ }
123203
+ groups.get(key).push(item);
123204
+ }
123205
+ return groups;
123206
+ }
123207
+ }
123208
+ });
123209
+
123148
123210
  // dist/validators/TypescriptValidator.js
123149
123211
  var require_TypescriptValidator = __commonJS({
123150
123212
  "dist/validators/TypescriptValidator.js"(exports2) {
@@ -123232,87 +123294,67 @@ var require_ValidatorFactory = __commonJS({
123232
123294
  }
123233
123295
  });
123234
123296
 
123235
- // dist/system-prompts/fixers/naiveFixerSystemPrompt.js
123236
- var require_naiveFixerSystemPrompt = __commonJS({
123237
- "dist/system-prompts/fixers/naiveFixerSystemPrompt.js"(exports2) {
123238
- "use strict";
123239
- Object.defineProperty(exports2, "__esModule", { value: true });
123240
- exports2.naiveFixerSystemPrompt = void 0;
123241
- exports2.naiveFixerSystemPrompt = `You are a senior TypeScript engineer and build tooling expert.
123242
- You receive a single broken line that caused a build/compile error.
123243
- You also receive the entire file content.
123244
- Your task is to return the minimal set of line edits required to fix the error.
123245
- You should use 3 operators:
123246
- - replace
123247
- - insert
123248
- - delete
123249
- Add the operator to the response object.
123250
-
123251
- Rules:
123252
- - Return ONLY a JSON array of objects with shape: { lineNumber, content, operator }
123253
- - Preserve the original intent of the lines; fix only syntax/type/identifier issues
123254
- - Keep imports/names consistent and valid for TypeScript
123255
- - If generics/JSX/parens are needed, add them correctly
123256
- - Do NOT add comments or surrounding lines
123257
- `;
123258
- exports2.default = exports2.naiveFixerSystemPrompt;
123259
- }
123260
- });
123261
-
123262
123297
  // dist/agents/NaiveFixerAgent.js
123263
123298
  var require_NaiveFixerAgent = __commonJS({
123264
123299
  "dist/agents/NaiveFixerAgent.js"(exports2) {
123265
123300
  "use strict";
123266
- var __importDefault2 = exports2 && exports2.__importDefault || function(mod2) {
123267
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
123268
- };
123269
123301
  Object.defineProperty(exports2, "__esModule", { value: true });
123270
- exports2.NaiveFixerAgent = void 0;
123271
123302
  var zod_1 = require_zod();
123272
123303
  var ai_1 = require_dist7();
123273
123304
  var anthropic_1 = require_dist5();
123274
- var naiveFixerSystemPrompt_1 = __importDefault2(require_naiveFixerSystemPrompt());
123275
- var LinesFixSchema = zod_1.z.object({
123276
- fixes: zod_1.z.array(zod_1.z.object({
123277
- lineNumber: zod_1.z.number().describe("1-based line number that should be replaced"),
123278
- content: zod_1.z.string().describe("Full content of the replacement line (single line)"),
123279
- operator: zod_1.z.enum(["replace", "insert", "delete"]).describe("The operator to use to fix the line")
123280
- }))
123305
+ var BatchFixSchema = zod_1.z.object({
123306
+ fixedContent: zod_1.z.string().describe("The complete fixed file content with all errors resolved"),
123307
+ summary: zod_1.z.string().describe("Brief summary of what was fixed in the file")
123281
123308
  });
123282
123309
  var NaiveFixerAgent = class {
123283
123310
  constructor(apiKey) {
123284
123311
  this.apiKey = apiKey;
123285
123312
  }
123286
- async fixLines(error) {
123287
- const system = naiveFixerSystemPrompt_1.default;
123288
- const prompt = `File: ${error.filePath ?? "(unknown)"}
123289
- Line: ${error.line ?? "(unknown)"}${error.column ? ", Column: " + error.column : ""}
123290
- Error message: ${error.message ?? "(no message)"}
123291
-
123292
- Broken line:
123293
- ${error.brokenLine}
123294
-
123295
- Relevant files:
123296
- ${error.relevantFiles?.map((f) => `Path: ${f.path}
123297
- Content: ${f.content}`).join("\n") ?? "(no relevant files)"}
123298
- `;
123313
+ async fixFileWithMultipleErrors(input) {
123314
+ const system = `You are an expert TypeScript/JavaScript developer. Your task is to fix ALL compilation errors in a file by providing the complete corrected file content.
123315
+
123316
+ Key principles:
123317
+ 1. Fix ALL errors listed in the input
123318
+ 2. Make minimal changes - only fix what's broken
123319
+ 3. Preserve code style and formatting as much as possible
123320
+ 4. Return the COMPLETE file content, not just diffs
123321
+ 5. Use block replacements instead of line-by-line changes
123322
+ 6. Think like Cursor - analyze the context and make intelligent fixes
123323
+
123324
+ Focus on common TypeScript errors:
123325
+ - Missing imports
123326
+ - Type mismatches
123327
+ - Undefined variables
123328
+ - Syntax errors
123329
+ - Missing semicolons or brackets
123330
+ - Incorrect component props`;
123331
+ const errorsList = input.errors.map((error, index) => `${index + 1}. Line ${error.line}, Column ${error.column}: ${error.message}`).join("\n");
123332
+ const prompt = `File: ${input.filePath}
123333
+ Language: ${input.language}
123334
+
123335
+ ERRORS TO FIX:
123336
+ ${errorsList}
123337
+
123338
+ CURRENT FILE CONTENT:
123339
+ ${input.content}
123340
+
123341
+ Please provide the complete fixed file content that resolves ALL the errors listed above.`;
123299
123342
  const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-sonnet-4-20250514");
123300
123343
  const result = await (0, ai_1.generateObject)({
123301
123344
  model,
123302
- schema: LinesFixSchema,
123345
+ schema: BatchFixSchema,
123303
123346
  system,
123304
123347
  prompt,
123305
- maxRetries: 3,
123306
- temperature: 0,
123348
+ maxRetries: 2,
123349
+ temperature: 0.1,
123307
123350
  experimental_telemetry: {
123308
123351
  isEnabled: true,
123309
- functionId: "NaiveFixAgent"
123352
+ functionId: "BatchFixAgent"
123310
123353
  }
123311
123354
  });
123312
123355
  return result.object;
123313
123356
  }
123314
123357
  };
123315
- exports2.NaiveFixerAgent = NaiveFixerAgent;
123316
123358
  exports2.default = NaiveFixerAgent;
123317
123359
  }
123318
123360
  });
@@ -123332,65 +123374,41 @@ var require_NaiveErrorFixer = __commonJS({
123332
123374
  constructor(apiKey) {
123333
123375
  this.apiKey = apiKey;
123334
123376
  }
123335
- async fixError(projectDir, error) {
123336
- await this.naiveFixError(projectDir, error);
123337
- }
123338
- async naiveFixError(outputPath, error) {
123339
- if (!error.filePath || !error.line) {
123377
+ async fixMultipleErrors(projectDir, filePath, errors) {
123378
+ if (errors.length === 0) {
123340
123379
  return;
123341
123380
  }
123342
- const absolutePath = path_1.default.isAbsolute(error.filePath) ? error.filePath : path_1.default.join(outputPath, error.filePath);
123343
- const content = fs_1.default.readFileSync(absolutePath, "utf8");
123344
- const newlineSymbol = this.getNewLineSymbol(content);
123345
- const lines = content.split(/\r?\n/);
123346
- const idx = error.line - 1;
123347
- const originalLine = lines[idx] ?? "";
123348
- const fixerAgent = new NaiveFixerAgent_1.default(this.apiKey);
123349
- const linesToFix = await fixerAgent.fixLines({
123350
- filePath: error.filePath,
123351
- line: error.line,
123352
- column: error.column,
123353
- message: error.message,
123354
- brokenLine: originalLine,
123355
- language: "typescript",
123356
- relevantFiles: [{ path: absolutePath, content }]
123357
- });
123358
- console.log("linesToFix", linesToFix);
123359
- const { fixes } = linesToFix;
123360
- if (fixes.length === 0) {
123381
+ const absolutePath = path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(projectDir, filePath);
123382
+ if (!fs_1.default.existsSync(absolutePath)) {
123383
+ console.warn(`\u26A0\uFE0F File not found: ${absolutePath}`);
123361
123384
  return;
123362
123385
  }
123363
- for (const lineFix of fixes) {
123364
- const op = lineFix.operator;
123365
- const targetIdx = lineFix.lineNumber - 1;
123366
- if (op === "delete") {
123367
- if (targetIdx >= 0 && targetIdx < lines.length) {
123368
- const removed = lines[targetIdx];
123369
- lines.splice(targetIdx, 1);
123370
- console.log(`\u{1F5D1}\uFE0F Deleted line ${lineFix.lineNumber} in ${error.filePath}. Original line: ${removed}`);
123386
+ const originalContent = fs_1.default.readFileSync(absolutePath, "utf8");
123387
+ const fixerAgent = new NaiveFixerAgent_1.default(this.apiKey);
123388
+ try {
123389
+ const batchResult = await fixerAgent.fixFileWithMultipleErrors({
123390
+ filePath,
123391
+ content: originalContent,
123392
+ errors: errors.map((error) => ({
123393
+ line: error.line || 1,
123394
+ column: error.column || 1,
123395
+ message: error.message || "Unknown error"
123396
+ })),
123397
+ language: "typescript"
123398
+ });
123399
+ if (batchResult.fixedContent) {
123400
+ fs_1.default.writeFileSync(absolutePath, batchResult.fixedContent, "utf8");
123401
+ console.log(`\u2705 Applied block replacements to ${filePath}`);
123402
+ if (batchResult.summary) {
123403
+ console.log(`\u{1F4CB} Fix summary: ${batchResult.summary}`);
123371
123404
  }
123372
- continue;
123373
- }
123374
- const contextLine = lines[targetIdx];
123375
- const originalIndent = (contextLine.match(/^\s*/) || [""])[0];
123376
- const providedIndent = (lineFix.content.match(/^\s*/) || [""])[0];
123377
- const replacementLine = providedIndent.length === 0 ? `${originalIndent}${lineFix.content}` : lineFix.content;
123378
- if (op === "insert") {
123379
- const insertIdx = Math.min(Math.max(0, targetIdx), lines.length);
123380
- lines.splice(insertIdx, 0, replacementLine);
123381
- console.log(`\u2795 Inserted line at ${lineFix.lineNumber} in ${error.filePath}. Content: ${replacementLine}`);
123382
- continue;
123405
+ } else {
123406
+ console.warn(`\u26A0\uFE0F No fixes generated for ${filePath}`);
123383
123407
  }
123384
- const original = lines[targetIdx];
123385
- lines[targetIdx] = replacementLine;
123386
- console.log(`\u{1F6E0}\uFE0F Replaced line ${lineFix.lineNumber} in ${error.filePath}. Original: ${original}, Replacement: ${replacementLine}`);
123408
+ } catch (error) {
123409
+ console.error(`\u274C Batch fix failed for ${filePath}:`, error);
123410
+ throw error;
123387
123411
  }
123388
- fs_1.default.writeFileSync(absolutePath, lines.join(newlineSymbol), "utf8");
123389
- }
123390
- getNewLineSymbol(content) {
123391
- const usesCRLF = content.includes("\r\n");
123392
- const newline = usesCRLF ? "\r\n" : "\n";
123393
- return newline;
123394
123412
  }
123395
123413
  };
123396
123414
  exports2.default = NaiveErrorFixer;
@@ -124343,7 +124361,7 @@ var require_fs = __commonJS({
124343
124361
  });
124344
124362
 
124345
124363
  // ../../node_modules/fs-extra/lib/mkdirs/utils.js
124346
- var require_utils18 = __commonJS({
124364
+ var require_utils19 = __commonJS({
124347
124365
  "../../node_modules/fs-extra/lib/mkdirs/utils.js"(exports2, module2) {
124348
124366
  "use strict";
124349
124367
  var path2 = require("path");
@@ -124365,7 +124383,7 @@ var require_make_dir = __commonJS({
124365
124383
  "../../node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports2, module2) {
124366
124384
  "use strict";
124367
124385
  var fs4 = require_fs();
124368
- var { checkPath } = require_utils18();
124386
+ var { checkPath } = require_utils19();
124369
124387
  var getMode = (options) => {
124370
124388
  const defaults = { mode: 511 };
124371
124389
  if (typeof options === "number") return options;
@@ -125258,7 +125276,7 @@ var require_ensure = __commonJS({
125258
125276
  });
125259
125277
 
125260
125278
  // ../../node_modules/jsonfile/utils.js
125261
- var require_utils19 = __commonJS({
125279
+ var require_utils20 = __commonJS({
125262
125280
  "../../node_modules/jsonfile/utils.js"(exports2, module2) {
125263
125281
  function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
125264
125282
  const EOF = finalEOL ? EOL : "";
@@ -125283,7 +125301,7 @@ var require_jsonfile = __commonJS({
125283
125301
  _fs = require("fs");
125284
125302
  }
125285
125303
  var universalify = require_universalify();
125286
- var { stringify, stripBom } = require_utils19();
125304
+ var { stringify, stripBom } = require_utils20();
125287
125305
  async function _readFile(file, options = {}) {
125288
125306
  if (typeof options === "string") {
125289
125307
  options = { encoding: options };
@@ -125394,7 +125412,7 @@ var require_output_file = __commonJS({
125394
125412
  var require_output_json = __commonJS({
125395
125413
  "../../node_modules/fs-extra/lib/json/output-json.js"(exports2, module2) {
125396
125414
  "use strict";
125397
- var { stringify } = require_utils19();
125415
+ var { stringify } = require_utils20();
125398
125416
  var { outputFile } = require_output_file();
125399
125417
  async function outputJson(file, data, options = {}) {
125400
125418
  const str = stringify(data, options);
@@ -125408,7 +125426,7 @@ var require_output_json = __commonJS({
125408
125426
  var require_output_json_sync = __commonJS({
125409
125427
  "../../node_modules/fs-extra/lib/json/output-json-sync.js"(exports2, module2) {
125410
125428
  "use strict";
125411
- var { stringify } = require_utils19();
125429
+ var { stringify } = require_utils20();
125412
125430
  var { outputFileSync } = require_output_file();
125413
125431
  function outputJsonSync(file, data, options) {
125414
125432
  const str = stringify(data, options);
@@ -126221,7 +126239,7 @@ var require_glob_parent = __commonJS({
126221
126239
  });
126222
126240
 
126223
126241
  // ../../node_modules/braces/lib/utils.js
126224
- var require_utils20 = __commonJS({
126242
+ var require_utils21 = __commonJS({
126225
126243
  "../../node_modules/braces/lib/utils.js"(exports2) {
126226
126244
  "use strict";
126227
126245
  exports2.isInteger = (num) => {
@@ -126306,7 +126324,7 @@ var require_utils20 = __commonJS({
126306
126324
  var require_stringify = __commonJS({
126307
126325
  "../../node_modules/braces/lib/stringify.js"(exports2, module2) {
126308
126326
  "use strict";
126309
- var utils = require_utils20();
126327
+ var utils = require_utils21();
126310
126328
  module2.exports = (ast, options = {}) => {
126311
126329
  const stringify = (node, parent = {}) => {
126312
126330
  const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
@@ -126759,7 +126777,7 @@ var require_compile = __commonJS({
126759
126777
  "../../node_modules/braces/lib/compile.js"(exports2, module2) {
126760
126778
  "use strict";
126761
126779
  var fill = require_fill_range();
126762
- var utils = require_utils20();
126780
+ var utils = require_utils21();
126763
126781
  var compile = (ast, options = {}) => {
126764
126782
  const walk = (node, parent = {}) => {
126765
126783
  const invalidBlock = utils.isInvalidBrace(parent);
@@ -126812,7 +126830,7 @@ var require_expand = __commonJS({
126812
126830
  "use strict";
126813
126831
  var fill = require_fill_range();
126814
126832
  var stringify = require_stringify();
126815
- var utils = require_utils20();
126833
+ var utils = require_utils21();
126816
126834
  var append = (queue = "", stash = "", enclose = false) => {
126817
126835
  const result = [];
126818
126836
  queue = [].concat(queue);
@@ -127500,7 +127518,7 @@ var require_constants7 = __commonJS({
127500
127518
  });
127501
127519
 
127502
127520
  // ../../node_modules/picomatch/lib/utils.js
127503
- var require_utils21 = __commonJS({
127521
+ var require_utils22 = __commonJS({
127504
127522
  "../../node_modules/picomatch/lib/utils.js"(exports2) {
127505
127523
  "use strict";
127506
127524
  var path2 = require("path");
@@ -127564,7 +127582,7 @@ var require_utils21 = __commonJS({
127564
127582
  var require_scan = __commonJS({
127565
127583
  "../../node_modules/picomatch/lib/scan.js"(exports2, module2) {
127566
127584
  "use strict";
127567
- var utils = require_utils21();
127585
+ var utils = require_utils22();
127568
127586
  var {
127569
127587
  CHAR_ASTERISK,
127570
127588
  /* * */
@@ -127895,7 +127913,7 @@ var require_parse5 = __commonJS({
127895
127913
  "../../node_modules/picomatch/lib/parse.js"(exports2, module2) {
127896
127914
  "use strict";
127897
127915
  var constants = require_constants7();
127898
- var utils = require_utils21();
127916
+ var utils = require_utils22();
127899
127917
  var {
127900
127918
  MAX_LENGTH,
127901
127919
  POSIX_REGEX_SOURCE,
@@ -128670,7 +128688,7 @@ var require_picomatch = __commonJS({
128670
128688
  var path2 = require("path");
128671
128689
  var scan = require_scan();
128672
128690
  var parse = require_parse5();
128673
- var utils = require_utils21();
128691
+ var utils = require_utils22();
128674
128692
  var constants = require_constants7();
128675
128693
  var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
128676
128694
  var picomatch = (glob, options, returnState = false) => {
@@ -128819,7 +128837,7 @@ var require_micromatch = __commonJS({
128819
128837
  var util = require("util");
128820
128838
  var braces = require_braces();
128821
128839
  var picomatch = require_picomatch2();
128822
- var utils = require_utils21();
128840
+ var utils = require_utils22();
128823
128841
  var isEmptyString = (v) => v === "" || v === "./";
128824
128842
  var hasBraces = (v) => {
128825
128843
  const index = v.indexOf("{");
@@ -129298,7 +129316,7 @@ var require_string = __commonJS({
129298
129316
  });
129299
129317
 
129300
129318
  // ../../node_modules/fast-glob/out/utils/index.js
129301
- var require_utils22 = __commonJS({
129319
+ var require_utils23 = __commonJS({
129302
129320
  "../../node_modules/fast-glob/out/utils/index.js"(exports2) {
129303
129321
  "use strict";
129304
129322
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -129326,7 +129344,7 @@ var require_tasks = __commonJS({
129326
129344
  "use strict";
129327
129345
  Object.defineProperty(exports2, "__esModule", { value: true });
129328
129346
  exports2.convertPatternGroupToTask = exports2.convertPatternGroupsToTasks = exports2.groupPatternsByBaseDirectory = exports2.getNegativePatternsAsPositive = exports2.getPositivePatterns = exports2.convertPatternsToTasks = exports2.generate = void 0;
129329
- var utils = require_utils22();
129347
+ var utils = require_utils23();
129330
129348
  function generate(input, settings) {
129331
129349
  const patterns = processPatterns(input, settings);
129332
129350
  const ignore = processPatterns(settings.ignore, settings);
@@ -129669,7 +129687,7 @@ var require_fs4 = __commonJS({
129669
129687
  });
129670
129688
 
129671
129689
  // ../../node_modules/@nodelib/fs.scandir/out/utils/index.js
129672
- var require_utils23 = __commonJS({
129690
+ var require_utils24 = __commonJS({
129673
129691
  "../../node_modules/@nodelib/fs.scandir/out/utils/index.js"(exports2) {
129674
129692
  "use strict";
129675
129693
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -129704,7 +129722,7 @@ var require_async4 = __commonJS({
129704
129722
  var fsStat = require_out();
129705
129723
  var rpl = require_run_parallel();
129706
129724
  var constants_1 = require_constants8();
129707
- var utils = require_utils23();
129725
+ var utils = require_utils24();
129708
129726
  var common = require_common4();
129709
129727
  function read(directory, settings, callback) {
129710
129728
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
@@ -129813,7 +129831,7 @@ var require_sync3 = __commonJS({
129813
129831
  exports2.readdir = exports2.readdirWithFileTypes = exports2.read = void 0;
129814
129832
  var fsStat = require_out();
129815
129833
  var constants_1 = require_constants8();
129816
- var utils = require_utils23();
129834
+ var utils = require_utils24();
129817
129835
  var common = require_common4();
129818
129836
  function read(directory, settings) {
129819
129837
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
@@ -130637,7 +130655,7 @@ var require_reader3 = __commonJS({
130637
130655
  Object.defineProperty(exports2, "__esModule", { value: true });
130638
130656
  var path2 = require("path");
130639
130657
  var fsStat = require_out();
130640
- var utils = require_utils22();
130658
+ var utils = require_utils23();
130641
130659
  var Reader = class {
130642
130660
  constructor(_settings) {
130643
130661
  this._settings = _settings;
@@ -130770,7 +130788,7 @@ var require_matcher = __commonJS({
130770
130788
  "../../node_modules/fast-glob/out/providers/matchers/matcher.js"(exports2) {
130771
130789
  "use strict";
130772
130790
  Object.defineProperty(exports2, "__esModule", { value: true });
130773
- var utils = require_utils22();
130791
+ var utils = require_utils23();
130774
130792
  var Matcher = class {
130775
130793
  constructor(_patterns, _settings, _micromatchOptions) {
130776
130794
  this._patterns = _patterns;
@@ -130858,7 +130876,7 @@ var require_deep = __commonJS({
130858
130876
  "../../node_modules/fast-glob/out/providers/filters/deep.js"(exports2) {
130859
130877
  "use strict";
130860
130878
  Object.defineProperty(exports2, "__esModule", { value: true });
130861
- var utils = require_utils22();
130879
+ var utils = require_utils23();
130862
130880
  var partial_1 = require_partial();
130863
130881
  var DeepFilter = class {
130864
130882
  constructor(_settings, _micromatchOptions) {
@@ -130923,7 +130941,7 @@ var require_entry = __commonJS({
130923
130941
  "../../node_modules/fast-glob/out/providers/filters/entry.js"(exports2) {
130924
130942
  "use strict";
130925
130943
  Object.defineProperty(exports2, "__esModule", { value: true });
130926
- var utils = require_utils22();
130944
+ var utils = require_utils23();
130927
130945
  var EntryFilter = class {
130928
130946
  constructor(_settings, _micromatchOptions) {
130929
130947
  this._settings = _settings;
@@ -131011,7 +131029,7 @@ var require_error3 = __commonJS({
131011
131029
  "../../node_modules/fast-glob/out/providers/filters/error.js"(exports2) {
131012
131030
  "use strict";
131013
131031
  Object.defineProperty(exports2, "__esModule", { value: true });
131014
- var utils = require_utils22();
131032
+ var utils = require_utils23();
131015
131033
  var ErrorFilter = class {
131016
131034
  constructor(_settings) {
131017
131035
  this._settings = _settings;
@@ -131032,7 +131050,7 @@ var require_entry2 = __commonJS({
131032
131050
  "../../node_modules/fast-glob/out/providers/transformers/entry.js"(exports2) {
131033
131051
  "use strict";
131034
131052
  Object.defineProperty(exports2, "__esModule", { value: true });
131035
- var utils = require_utils22();
131053
+ var utils = require_utils23();
131036
131054
  var EntryTransformer = class {
131037
131055
  constructor(_settings) {
131038
131056
  this._settings = _settings;
@@ -131322,7 +131340,7 @@ var require_out4 = __commonJS({
131322
131340
  var stream_1 = require_stream5();
131323
131341
  var sync_1 = require_sync7();
131324
131342
  var settings_1 = require_settings4();
131325
- var utils = require_utils22();
131343
+ var utils = require_utils23();
131326
131344
  async function FastGlob(source, options) {
131327
131345
  assertPatternsInput2(source);
131328
131346
  const works = getWorks(source, async_1.default, options);
@@ -132339,11 +132357,12 @@ var require_orchestrator = __commonJS({
132339
132357
  var types_1 = require_types_impl();
132340
132358
  var ditto_scaffolding_1 = require_dist11();
132341
132359
  var fs_1 = __importDefault2(require("fs"));
132360
+ var utils_1 = require_utils18();
132342
132361
  var ValidatorFactory_1 = __importDefault2(require_ValidatorFactory());
132343
132362
  var FixerFactory_1 = __importDefault2(require_FixerFactory());
132344
132363
  var extensionGenerators_1 = require_extensionGenerators();
132345
132364
  var extensionIndexer_1 = require_extensionIndexer();
132346
- var MAX_FIX_ATTEMPTS = 3;
132365
+ var MAX_ERRORS_PER_BATCH = 20;
132347
132366
  var DittoOrchestrator = class extends events_1.EventEmitter {
132348
132367
  constructor(agentsFactory, apiKey) {
132349
132368
  super();
@@ -132446,6 +132465,9 @@ var require_orchestrator = __commonJS({
132446
132465
  async processExtension({ extension, blueprint, outputPath, createdCollections }) {
132447
132466
  this.emitEvent("scaffold:start", { extension });
132448
132467
  const scaffolds = await (0, ditto_scaffolding_1.copyScaffoldingTemplate)(extension, outputPath);
132468
+ if (!scaffolds) {
132469
+ console.error(`\u274C Failed to scaffold ${extension.type}`);
132470
+ }
132449
132471
  this.emitEvent("scaffold:done", {
132450
132472
  extension,
132451
132473
  scaffoldPath: scaffolds.map((s) => s.path).join(", ")
@@ -132678,38 +132700,66 @@ var require_orchestrator = __commonJS({
132678
132700
  }
132679
132701
  async startFixFlow(request) {
132680
132702
  const { projectDir, apiKey } = request;
132703
+ if (!apiKey) {
132704
+ throw new Error("\u26A0\uFE0F No API key provided for fix flow - fixes may be limited");
132705
+ }
132681
132706
  this.emitEvent("validation:start", { outputPath: projectDir });
132682
132707
  const fixerFactory = new FixerFactory_1.default(apiKey);
132683
132708
  const validatorFactory = new ValidatorFactory_1.default();
132684
132709
  const validator = validatorFactory.getValidator();
132685
- for (let iteration = 0; iteration < MAX_FIX_ATTEMPTS; iteration++) {
132686
- console.log(`\u{1F50D} Running typecheck ${iteration + 1} of ${MAX_FIX_ATTEMPTS}...`);
132687
- const initialValidation = await validator.validate(projectDir);
132688
- if (initialValidation.status === 0) {
132689
- console.log(`\u2705 ${validator.type} validation finished`);
132690
- this.emitEvent("validation:done", { outputPath: projectDir });
132691
- return;
132710
+ console.log("\u{1F50D} Running validation and batch fix...");
132711
+ const initialValidation = await validator.validate(projectDir);
132712
+ if (initialValidation.status === 0) {
132713
+ console.log(`\u2705 ${validator.type} validation passed - no fixes needed`);
132714
+ this.emitEvent("validation:done", { outputPath: projectDir });
132715
+ return;
132716
+ }
132717
+ if (!initialValidation.parsedValidationErrors || initialValidation.parsedValidationErrors.length === 0) {
132718
+ const errorMessage2 = `Validation failed but no parsed errors available. Raw errors: ${initialValidation.validationErrors}`;
132719
+ console.warn(`\u26A0\uFE0F ${errorMessage2}`);
132720
+ this.emitEvent("validation:error", {
132721
+ error: new Error(errorMessage2)
132722
+ });
132723
+ throw new Error(errorMessage2);
132724
+ }
132725
+ const totalErrors = initialValidation.parsedValidationErrors.length;
132726
+ console.log(`\u{1F4DD} Found ${totalErrors} errors to fix`);
132727
+ const errorsByFile = (0, utils_1.mapGroupBy)(initialValidation.parsedValidationErrors, (error) => error.filePath);
132728
+ console.log(`\u{1F4C1} Errors span ${errorsByFile.size} files`);
132729
+ let totalFixesApplied = 0;
132730
+ const fixer = fixerFactory.getFixer();
132731
+ for (const [filePath, fileErrors] of errorsByFile) {
132732
+ const errorsToFix = fileErrors.slice(0, MAX_ERRORS_PER_BATCH);
132733
+ if (errorsToFix.length < fileErrors.length) {
132734
+ console.log(`\u{1F4CB} Processing ${errorsToFix.length}/${fileErrors.length} errors for ${filePath} (batching to prevent AI overload)`);
132735
+ } else {
132736
+ console.log(`\u{1F4CB} Processing ${errorsToFix.length} errors for ${filePath}`);
132692
132737
  }
132693
- const numberOfPlannedFixes = initialValidation?.parsedValidationErrors?.length ?? 0;
132694
- for (let i = 0; i < numberOfPlannedFixes; i++) {
132695
- const { status, parsedValidationErrors } = await validator.validate(projectDir);
132696
- if (status === 0) {
132697
- console.log(`\u2705 ${validator.type} validation finished`);
132698
- this.emitEvent("validation:done", { outputPath: projectDir });
132699
- return;
132700
- }
132701
- const [firstError] = parsedValidationErrors;
132702
- const fixer = fixerFactory.getFixer();
132703
- await fixer.fixError(projectDir, firstError);
132738
+ try {
132739
+ await fixer.fixMultipleErrors(projectDir, filePath, errorsToFix);
132740
+ totalFixesApplied += errorsToFix.length;
132741
+ console.log(`\u2705 Applied batch fixes for ${filePath}`);
132742
+ } catch (fixError) {
132743
+ console.error(`\u274C Failed to fix errors in ${filePath}: ${fixError instanceof Error ? fixError.message : String(fixError)}`);
132744
+ continue;
132704
132745
  }
132705
132746
  }
132706
- const { validationErrors: unfixedValidationErrors } = await validator.validate(projectDir);
132747
+ console.log(`\u{1F4CA} Batch fix completed: ${totalFixesApplied} fixes applied across ${errorsByFile.size} files`);
132748
+ const finalValidation = await validator.validate(projectDir);
132749
+ if (finalValidation.status === 0) {
132750
+ console.log(`\u2705 ${validator.type} validation passed after batch fixes`);
132751
+ this.emitEvent("validation:done", { outputPath: projectDir });
132752
+ return;
132753
+ }
132754
+ const remainingErrors = finalValidation.parsedValidationErrors?.length || 0;
132755
+ const unfixedValidationErrors = finalValidation.validationErrors || "Unknown validation errors";
132756
+ console.log(`\u{1F4CB} ${remainingErrors} errors remaining after fixes`);
132757
+ const errorMessage = `Validation failed after batch fix attempt. Fixed ${totalFixesApplied} errors, but ${remainingErrors} remain:
132758
+ ${unfixedValidationErrors}`;
132707
132759
  this.emitEvent("validation:error", {
132708
- error: new Error(`Validation failed after ${MAX_FIX_ATTEMPTS} attempts. Errors:
132709
- ${unfixedValidationErrors}`)
132760
+ error: new Error(errorMessage)
132710
132761
  });
132711
- throw new Error(`Validation failed after ${MAX_FIX_ATTEMPTS} attempts. Errors:
132712
- ${unfixedValidationErrors}`);
132762
+ throw new Error(errorMessage);
132713
132763
  }
132714
132764
  listGeneratedAppFiles(outputPath) {
132715
132765
  const root = outputPath;
@@ -132737,53 +132787,6 @@ ${unfixedValidationErrors}`);
132737
132787
  }
132738
132788
  });
132739
132789
 
132740
- // dist/utils.js
132741
- var require_utils24 = __commonJS({
132742
- "dist/utils.js"(exports2) {
132743
- "use strict";
132744
- Object.defineProperty(exports2, "__esModule", { value: true });
132745
- exports2.serializeError = serializeError;
132746
- function serializeError(error) {
132747
- if (error instanceof Error) {
132748
- const base = {
132749
- name: error.name,
132750
- message: error.message,
132751
- stack: error.stack
132752
- };
132753
- const anyErr = error;
132754
- for (const key in anyErr) {
132755
- if (!(key in base)) {
132756
- try {
132757
- base[key] = anyErr[key];
132758
- } catch {
132759
- }
132760
- }
132761
- }
132762
- const withCause = error;
132763
- if (withCause && "cause" in withCause) {
132764
- base.cause = withCause.cause;
132765
- }
132766
- const maybeHttp = error;
132767
- if (maybeHttp?.response?.data !== void 0)
132768
- base.data = maybeHttp.response.data;
132769
- if (maybeHttp?.code !== void 0)
132770
- base.code = maybeHttp.code;
132771
- if (maybeHttp?.details !== void 0)
132772
- base.details = maybeHttp.details;
132773
- return base;
132774
- }
132775
- if (typeof error === "object" && error !== null) {
132776
- try {
132777
- return JSON.parse(JSON.stringify(error));
132778
- } catch {
132779
- return { message: String(error) };
132780
- }
132781
- }
132782
- return { message: String(error) };
132783
- }
132784
- }
132785
- });
132786
-
132787
132790
  // dist/flows/init-codegen.js
132788
132791
  var require_init_codegen = __commonJS({
132789
132792
  "dist/flows/init-codegen.js"(exports2) {
@@ -132801,7 +132804,7 @@ var require_init_codegen = __commonJS({
132801
132804
  var job_context_storage_1 = require_job_context_storage();
132802
132805
  var orchestrator_1 = require_orchestrator();
132803
132806
  var CodeGenService_1 = require_CodeGenService();
132804
- var utils_1 = require_utils24();
132807
+ var utils_1 = require_utils18();
132805
132808
  var slugify = (str = "") => {
132806
132809
  return str.toLowerCase().replace(/ /g, "-");
132807
132810
  };
@@ -132814,7 +132817,7 @@ var require_init_codegen = __commonJS({
132814
132817
  const outputDir = process.env.OUTPUT_PATH || orchestrator_1.DittoOrchestrator.DEFAULT_OUTPUT_PATH;
132815
132818
  const outputPath = outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
132816
132819
  const agentsFactory = new AgentsFactory_1.AgentsFactory(context_1.ctx?.apiKey);
132817
- const orchestrator = new orchestrator_1.DittoOrchestrator(agentsFactory);
132820
+ const orchestrator = new orchestrator_1.DittoOrchestrator(agentsFactory, context_1.ctx?.apiKey);
132818
132821
  orchestrator.onEvent("agent:start", ({ extension }) => {
132819
132822
  console.log(`[Agent] start: ${extension.name}`);
132820
132823
  __1.codeGenerationService.addTask(localJobContext.jobId, {
@@ -132867,7 +132870,7 @@ var require_iterate_codegen = __commonJS({
132867
132870
  var job_context_storage_1 = require_job_context_storage();
132868
132871
  var orchestrator_1 = require_orchestrator();
132869
132872
  var CodeGenService_1 = require_CodeGenService();
132870
- var utils_1 = require_utils24();
132873
+ var utils_1 = require_utils18();
132871
132874
  var slugify = (str = "") => {
132872
132875
  return str.toLowerCase().replace(/ /g, "-");
132873
132876
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -24,5 +24,5 @@
24
24
  "@wix/ditto-codegen": "1.0.0",
25
25
  "esbuild": "^0.25.9"
26
26
  },
27
- "falconPackageHash": "aedba2bc0fa2e47c3994a3d0c21987c43b53a615db9cdb88d83b0840"
27
+ "falconPackageHash": "80306d2c03e6975d17c7cec5431af767930cb43809ce4584e21be88e"
28
28
  }