@wix/ditto-codegen-public 1.0.220 → 1.0.221
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.
- package/dist/out.js +192 -2
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -105384,6 +105384,122 @@ Please provide the complete fixed file content that resolves ALL the errors list
|
|
|
105384
105384
|
}
|
|
105385
105385
|
});
|
|
105386
105386
|
|
|
105387
|
+
// dist/agents/BuildFixerAgent.js
|
|
105388
|
+
var require_BuildFixerAgent = __commonJS({
|
|
105389
|
+
"dist/agents/BuildFixerAgent.js"(exports2) {
|
|
105390
|
+
"use strict";
|
|
105391
|
+
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
105392
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
105393
|
+
};
|
|
105394
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
105395
|
+
exports2.BuildFixerAgent = void 0;
|
|
105396
|
+
var zod_1 = require_zod();
|
|
105397
|
+
var ditto_codegen_types_12 = require_dist();
|
|
105398
|
+
var codegen_common_logic_1 = require_dist12();
|
|
105399
|
+
var dedent_1 = __importDefault2(require_dedent());
|
|
105400
|
+
var constants_1 = require_constants2();
|
|
105401
|
+
var customAnthropicProvider_1 = require_customAnthropicProvider();
|
|
105402
|
+
var tools_1 = require_tools2();
|
|
105403
|
+
var BuildFixSchema = zod_1.z.object({
|
|
105404
|
+
filePath: zod_1.z.string().describe("Relative path to the file to fix"),
|
|
105405
|
+
fixedContent: zod_1.z.string().describe("The complete fixed file content"),
|
|
105406
|
+
summary: zod_1.z.string().describe("Brief summary of what was fixed")
|
|
105407
|
+
});
|
|
105408
|
+
var SUBMIT_FIX_TOOL_NAME = "submit_fix";
|
|
105409
|
+
function createSubmitFixTool() {
|
|
105410
|
+
return {
|
|
105411
|
+
description: "Submit the fix for a build error. Use this after reading the file and understanding what needs to be fixed.",
|
|
105412
|
+
inputSchema: BuildFixSchema,
|
|
105413
|
+
execute: async (input) => input
|
|
105414
|
+
};
|
|
105415
|
+
}
|
|
105416
|
+
var BuildFixerAgent = class {
|
|
105417
|
+
constructor() {
|
|
105418
|
+
this.name = "BuildFixerAgent";
|
|
105419
|
+
}
|
|
105420
|
+
buildSystemPrompt() {
|
|
105421
|
+
return (0, dedent_1.default)`You are an expert TypeScript/JavaScript developer. Your task is to fix build errors.
|
|
105422
|
+
|
|
105423
|
+
WORKFLOW:
|
|
105424
|
+
1. Analyze the build output to identify the error type and files involved
|
|
105425
|
+
2. Read the relevant file(s) to understand the context
|
|
105426
|
+
3. Only AFTER reading, decide what to fix and submit
|
|
105427
|
+
|
|
105428
|
+
EXTENSION-VALIDATOR ERRORS (most common):
|
|
105429
|
+
Format: "[field] message (... → ./path/source.ts)"
|
|
105430
|
+
- Look for the arrow (→) - it points to a source file path
|
|
105431
|
+
- The extension.ts config is in the SAME FOLDER as that source file
|
|
105432
|
+
- Example: "→ ./backend/spi/foo/plugin.ts" means read:
|
|
105433
|
+
- ./backend/spi/foo/plugin.ts (source)
|
|
105434
|
+
- ./backend/spi/foo/extension.ts (config)
|
|
105435
|
+
- READ BOTH files before deciding which one needs the fix
|
|
105436
|
+
|
|
105437
|
+
OTHER BUILD ERRORS:
|
|
105438
|
+
- Read the file mentioned in the error
|
|
105439
|
+
- Use the error message and file content to determine the fix
|
|
105440
|
+
|
|
105441
|
+
IMPORTANT:
|
|
105442
|
+
- ALWAYS read files FIRST before submitting a fix
|
|
105443
|
+
- Read only the files you NEED - typically just 1-2 files
|
|
105444
|
+
- Make minimal changes - only fix what's broken
|
|
105445
|
+
- Preserve code style and formatting
|
|
105446
|
+
- Be efficient - submit the fix quickly after reading`;
|
|
105447
|
+
}
|
|
105448
|
+
formatPreviousBuildOutput(previousBuildOutput) {
|
|
105449
|
+
if (!previousBuildOutput) {
|
|
105450
|
+
return "";
|
|
105451
|
+
}
|
|
105452
|
+
return (0, dedent_1.default)`
|
|
105453
|
+
The following build output was from the previous fix attempt.
|
|
105454
|
+
Please try a DIFFERENT approach to solve the remaining errors:
|
|
105455
|
+
|
|
105456
|
+
${previousBuildOutput}
|
|
105457
|
+
`;
|
|
105458
|
+
}
|
|
105459
|
+
async fixBuildErrors(input) {
|
|
105460
|
+
const previousErrorsSection = this.formatPreviousBuildOutput(input.previousBuildOutput);
|
|
105461
|
+
const userMessage = (0, dedent_1.default)`
|
|
105462
|
+
BUILD OUTPUT:
|
|
105463
|
+
${input.buildOutput}
|
|
105464
|
+
|
|
105465
|
+
${previousErrorsSection}
|
|
105466
|
+
|
|
105467
|
+
Instructions:
|
|
105468
|
+
1. Identify the error type and files involved
|
|
105469
|
+
2. Read the relevant file(s) first to understand the context
|
|
105470
|
+
3. After reading, submit the fix for the file that needs changing
|
|
105471
|
+
`;
|
|
105472
|
+
try {
|
|
105473
|
+
console.log(`\u{1F527} BuildFixerAgent starting with tools...`);
|
|
105474
|
+
const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.CLAUDE_HAIKU_4_5, {
|
|
105475
|
+
agentName: this.name
|
|
105476
|
+
});
|
|
105477
|
+
const result = await (0, codegen_common_logic_1.generateAgentText)({
|
|
105478
|
+
agentName: this.name,
|
|
105479
|
+
model,
|
|
105480
|
+
tools: {
|
|
105481
|
+
[tools_1.TOOL_NAMES.READ_FILE]: (0, tools_1.createReadFileTool)(input.projectDir),
|
|
105482
|
+
[SUBMIT_FIX_TOOL_NAME]: createSubmitFixTool()
|
|
105483
|
+
},
|
|
105484
|
+
systemPrompt: this.buildSystemPrompt(),
|
|
105485
|
+
userMessage,
|
|
105486
|
+
stopWhen: (0, codegen_common_logic_1.stopOnToolCall)(SUBMIT_FIX_TOOL_NAME)
|
|
105487
|
+
});
|
|
105488
|
+
const fixResult = (0, codegen_common_logic_1.extractToolResult)(result.toolCalls, SUBMIT_FIX_TOOL_NAME);
|
|
105489
|
+
if (!fixResult) {
|
|
105490
|
+
throw new Error("BuildFixerAgent did not submit a fix");
|
|
105491
|
+
}
|
|
105492
|
+
console.log(`\u{1F527} BuildFixerAgent fix submitted for: ${fixResult.filePath}`);
|
|
105493
|
+
return fixResult;
|
|
105494
|
+
} catch (error) {
|
|
105495
|
+
throw (0, ditto_codegen_types_12.toCodegenError)(error);
|
|
105496
|
+
}
|
|
105497
|
+
}
|
|
105498
|
+
};
|
|
105499
|
+
exports2.BuildFixerAgent = BuildFixerAgent;
|
|
105500
|
+
}
|
|
105501
|
+
});
|
|
105502
|
+
|
|
105387
105503
|
// dist/fixers/NaiveErrorFixer.js
|
|
105388
105504
|
var require_NaiveErrorFixer = __commonJS({
|
|
105389
105505
|
"dist/fixers/NaiveErrorFixer.js"(exports2) {
|
|
@@ -105395,6 +105511,7 @@ var require_NaiveErrorFixer = __commonJS({
|
|
|
105395
105511
|
var fs_1 = __importDefault2(require("fs"));
|
|
105396
105512
|
var path_1 = __importDefault2(require("path"));
|
|
105397
105513
|
var NaiveFixerAgent_1 = require_NaiveFixerAgent();
|
|
105514
|
+
var BuildFixerAgent_1 = require_BuildFixerAgent();
|
|
105398
105515
|
var ditto_codegen_types_12 = require_dist();
|
|
105399
105516
|
var NaiveErrorFixer = class {
|
|
105400
105517
|
constructor() {
|
|
@@ -105437,6 +105554,30 @@ var require_NaiveErrorFixer = __commonJS({
|
|
|
105437
105554
|
throw (0, ditto_codegen_types_12.toCodegenError)(error);
|
|
105438
105555
|
}
|
|
105439
105556
|
}
|
|
105557
|
+
async fixBuildErrors(projectDir, buildOutput, previousBuildOutput) {
|
|
105558
|
+
const buildFixerAgent = new BuildFixerAgent_1.BuildFixerAgent();
|
|
105559
|
+
try {
|
|
105560
|
+
const result = await buildFixerAgent.fixBuildErrors({
|
|
105561
|
+
projectDir,
|
|
105562
|
+
buildOutput,
|
|
105563
|
+
previousBuildOutput
|
|
105564
|
+
});
|
|
105565
|
+
const absolutePath = path_1.default.join(projectDir, result.filePath);
|
|
105566
|
+
if (!fs_1.default.existsSync(absolutePath)) {
|
|
105567
|
+
console.warn(`\u26A0\uFE0F File not found: ${absolutePath}`);
|
|
105568
|
+
return { fixed: false, summary: result.summary };
|
|
105569
|
+
}
|
|
105570
|
+
fs_1.default.writeFileSync(absolutePath, result.fixedContent, "utf8");
|
|
105571
|
+
console.log(`\u2705 Applied build fix to ${result.filePath}`);
|
|
105572
|
+
if (result.summary) {
|
|
105573
|
+
console.log(`\u{1F4CB} Build fix summary: ${result.summary}`);
|
|
105574
|
+
}
|
|
105575
|
+
return { fixed: true, summary: result.summary };
|
|
105576
|
+
} catch (error) {
|
|
105577
|
+
console.error(`\u274C Build fix failed:`, error);
|
|
105578
|
+
throw (0, ditto_codegen_types_12.toCodegenError)(error);
|
|
105579
|
+
}
|
|
105580
|
+
}
|
|
105440
105581
|
};
|
|
105441
105582
|
exports2.default = NaiveErrorFixer;
|
|
105442
105583
|
var formatErrorToString = (err) => {
|
|
@@ -105480,6 +105621,7 @@ var require_fixFlow = __commonJS({
|
|
|
105480
105621
|
};
|
|
105481
105622
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
105482
105623
|
exports2.startFixFlow = startFixFlow;
|
|
105624
|
+
var child_process_1 = require("child_process");
|
|
105483
105625
|
var utils_1 = require_utils15();
|
|
105484
105626
|
var ValidatorFactory_1 = __importDefault2(require_ValidatorFactory());
|
|
105485
105627
|
var FixerFactory_1 = __importDefault2(require_FixerFactory());
|
|
@@ -105488,6 +105630,41 @@ var require_fixFlow = __commonJS({
|
|
|
105488
105630
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
105489
105631
|
var MAX_ERRORS_PER_BATCH = 20;
|
|
105490
105632
|
var MAX_FIX_ATTEMPTS = 3;
|
|
105633
|
+
var MAX_BUILD_FIX_ATTEMPTS = 3;
|
|
105634
|
+
var runBuild = (projectDir) => {
|
|
105635
|
+
const result = (0, child_process_1.spawnSync)("npm", ["run", "build"], {
|
|
105636
|
+
cwd: projectDir,
|
|
105637
|
+
stdio: "pipe",
|
|
105638
|
+
shell: true,
|
|
105639
|
+
env: process.env
|
|
105640
|
+
});
|
|
105641
|
+
return {
|
|
105642
|
+
status: result.status ?? 1,
|
|
105643
|
+
output: (result.stdout?.toString() || "") + (result.stderr?.toString() || "")
|
|
105644
|
+
};
|
|
105645
|
+
};
|
|
105646
|
+
var runBuildFixLoop = async (projectDir, fixer, attempt = 1, previousBuildOutput) => {
|
|
105647
|
+
if (attempt > MAX_BUILD_FIX_ATTEMPTS) {
|
|
105648
|
+
return false;
|
|
105649
|
+
}
|
|
105650
|
+
const buildResult = runBuild(projectDir);
|
|
105651
|
+
if (buildResult.status === 0) {
|
|
105652
|
+
console.log(`\u2705 Build passed`);
|
|
105653
|
+
return true;
|
|
105654
|
+
}
|
|
105655
|
+
console.log(`\u274C Build failed (attempt ${attempt}/${MAX_BUILD_FIX_ATTEMPTS}), trying to fix...`);
|
|
105656
|
+
try {
|
|
105657
|
+
const buildFixResult = await fixer.fixBuildErrors(projectDir, buildResult.output, previousBuildOutput);
|
|
105658
|
+
if (!buildFixResult.fixed) {
|
|
105659
|
+
console.log(`\u26A0\uFE0F No fixes generated for build errors`);
|
|
105660
|
+
return false;
|
|
105661
|
+
}
|
|
105662
|
+
return runBuildFixLoop(projectDir, fixer, attempt + 1, buildResult.output);
|
|
105663
|
+
} catch (fixError) {
|
|
105664
|
+
console.error(`\u274C Failed to fix build errors: ${fixError instanceof Error ? fixError.message : String(fixError)}`);
|
|
105665
|
+
return false;
|
|
105666
|
+
}
|
|
105667
|
+
};
|
|
105491
105668
|
var toErrorSummary = (error) => ({
|
|
105492
105669
|
filePath: error.filePath,
|
|
105493
105670
|
line: error.line,
|
|
@@ -105573,9 +105750,22 @@ var require_fixFlow = __commonJS({
|
|
|
105573
105750
|
const isLastAttempt = attempt === MAX_FIX_ATTEMPTS;
|
|
105574
105751
|
if (validationPassed) {
|
|
105575
105752
|
const fixedErrors = getFixedErrors([]);
|
|
105576
|
-
console.log(`\u2705 ${validator.type} validation passed -
|
|
105753
|
+
console.log(`\u2705 ${validator.type} validation passed - checking build...`);
|
|
105754
|
+
const buildPassed = await runBuildFixLoop(projectDir, fixer);
|
|
105755
|
+
if (!buildPassed) {
|
|
105756
|
+
const finalBuildResult = runBuild(projectDir);
|
|
105757
|
+
await updateFixTask(ditto_codegen_types_12.Status.COMPLETED, {
|
|
105758
|
+
description: `Fixed ${fixedErrors.length} TypeScript errors, but build still failing`,
|
|
105759
|
+
warning: `Build error: ${finalBuildResult.output.slice(0, 500)}`,
|
|
105760
|
+
fixedErrors: fixedErrors.map(toErrorSummary)
|
|
105761
|
+
});
|
|
105762
|
+
throw new ditto_codegen_types_12.CodeValidationError("Build failed after TypeScript passed", {
|
|
105763
|
+
validationType: ditto_codegen_types_12.ValidationType.BUILD,
|
|
105764
|
+
errors: []
|
|
105765
|
+
});
|
|
105766
|
+
}
|
|
105577
105767
|
await updateFixTask(ditto_codegen_types_12.Status.COMPLETED, {
|
|
105578
|
-
description: `Fixed ${fixedErrors.length} errors.`,
|
|
105768
|
+
description: `Fixed ${fixedErrors.length} TypeScript errors. Build passed.`,
|
|
105579
105769
|
fixedErrors: fixedErrors.map(toErrorSummary)
|
|
105580
105770
|
});
|
|
105581
105771
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/ditto-codegen-public",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.221",
|
|
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.27.2"
|
|
26
26
|
},
|
|
27
|
-
"falconPackageHash": "
|
|
27
|
+
"falconPackageHash": "f685e53eb204f432a8444894d84209d942ed0d846820b3ea10a2a150"
|
|
28
28
|
}
|