@wix/ditto-codegen-public 1.0.192 → 1.0.193
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 +62 -36
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -83827,8 +83827,8 @@ var require_ValidatorFactory = __commonJS({
|
|
|
83827
83827
|
if (type === ditto_codegen_types_12.ValidationType.TYPESCRIPT) {
|
|
83828
83828
|
return new TypescriptValidator_1.default();
|
|
83829
83829
|
}
|
|
83830
|
-
throw new ditto_codegen_types_12.
|
|
83831
|
-
|
|
83830
|
+
throw new ditto_codegen_types_12.ValidationConfigurationError(`Invalid validator type: ${type}`, {
|
|
83831
|
+
validatorType: type
|
|
83832
83832
|
});
|
|
83833
83833
|
}
|
|
83834
83834
|
};
|
|
@@ -84034,14 +84034,23 @@ var require_fixFlow = __commonJS({
|
|
|
84034
84034
|
var job_context_storage_12 = require_job_context_storage();
|
|
84035
84035
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
84036
84036
|
var MAX_ERRORS_PER_BATCH = 20;
|
|
84037
|
+
var MAX_FIX_ATTEMPTS = 3;
|
|
84038
|
+
var toErrorSummary = (error) => ({
|
|
84039
|
+
filePath: error.filePath,
|
|
84040
|
+
line: error.line,
|
|
84041
|
+
message: error.errorMessage
|
|
84042
|
+
});
|
|
84043
|
+
var createErrorComparisonKey = (e) => `${e.filePath}:${e.line ?? "unknown"}:${e.errorMessage}`;
|
|
84037
84044
|
async function startFixFlow(request) {
|
|
84038
84045
|
const { projectDir } = request;
|
|
84039
84046
|
const fixerFactory = new FixerFactory_1.default();
|
|
84040
84047
|
const validatorFactory = new ValidatorFactory_1.default();
|
|
84041
84048
|
const validator = validatorFactory.getValidator();
|
|
84042
84049
|
const fixer = fixerFactory.getFixer();
|
|
84043
|
-
const MAX_FIX_ATTEMPTS = 3;
|
|
84044
84050
|
const parentContext = job_context_storage_12.jobContextStorage.getStore();
|
|
84051
|
+
if (!parentContext?.jobId) {
|
|
84052
|
+
throw new Error("Fix flow must be called within a job context");
|
|
84053
|
+
}
|
|
84045
84054
|
const fixTaskId = `fix-flow`;
|
|
84046
84055
|
const updateFixTask = async (status, payload = {}) => {
|
|
84047
84056
|
await codeGenerationService_12.codeGenerationService.updateTask(parentContext.jobId, fixTaskId, status, payload);
|
|
@@ -84052,9 +84061,13 @@ var require_fixFlow = __commonJS({
|
|
|
84052
84061
|
name: "Auto-Fixer",
|
|
84053
84062
|
status: ditto_codegen_types_12.Status.RUNNING,
|
|
84054
84063
|
description: "Running automatic code fixes",
|
|
84055
|
-
agentName: "
|
|
84064
|
+
agentName: "FixerAgent"
|
|
84056
84065
|
});
|
|
84057
84066
|
console.log("\u{1F50D} Running validation and batch fix...");
|
|
84067
|
+
const fixState = {
|
|
84068
|
+
initialErrors: [],
|
|
84069
|
+
lastRunErrors: /* @__PURE__ */ new Map()
|
|
84070
|
+
};
|
|
84058
84071
|
const processFiles = async (fileEntries, lastRunErrors) => {
|
|
84059
84072
|
for (const [filePath, fileErrors] of fileEntries) {
|
|
84060
84073
|
const errorsToFix = fileErrors.slice(0, MAX_ERRORS_PER_BATCH);
|
|
@@ -84072,48 +84085,62 @@ var require_fixFlow = __commonJS({
|
|
|
84072
84085
|
}
|
|
84073
84086
|
}
|
|
84074
84087
|
};
|
|
84075
|
-
const
|
|
84076
|
-
|
|
84077
|
-
|
|
84088
|
+
const getFixedErrors = (remainingErrors) => {
|
|
84089
|
+
const remainingKeys = new Set(remainingErrors.map(createErrorComparisonKey));
|
|
84090
|
+
return fixState.initialErrors.filter((e) => !remainingKeys.has(createErrorComparisonKey(e)));
|
|
84078
84091
|
};
|
|
84079
|
-
const
|
|
84080
|
-
const remainingErrors = validation.parsedValidationErrors
|
|
84081
|
-
const
|
|
84082
|
-
console.log(`\u{1F4CB} ${remainingErrors} errors remaining after
|
|
84083
|
-
const
|
|
84084
|
-
${
|
|
84085
|
-
const validationErrors = validation.parsedValidationErrors || [];
|
|
84092
|
+
const buildExhaustedResult = (validation, attemptsMade) => {
|
|
84093
|
+
const remainingErrors = validation.parsedValidationErrors ?? [];
|
|
84094
|
+
const fixedErrors = getFixedErrors(remainingErrors);
|
|
84095
|
+
console.log(`\u{1F4CB} ${remainingErrors.length} errors remaining after ${attemptsMade} fix attempts (fixed ${fixedErrors.length})`);
|
|
84096
|
+
const hasNoParseableErrors = remainingErrors.length === 0;
|
|
84097
|
+
const errorMessage = hasNoParseableErrors ? `Auto-fix exhausted: validation still failing after ${attemptsMade} attempts (no parseable errors)` : `Auto-fix exhausted: ${remainingErrors.length} TypeScript errors remain after ${attemptsMade} attempts`;
|
|
84086
84098
|
const error = new ditto_codegen_types_12.CodeValidationError(errorMessage, {
|
|
84087
84099
|
validationType: ditto_codegen_types_12.ValidationType.TYPESCRIPT,
|
|
84088
|
-
errors:
|
|
84100
|
+
errors: remainingErrors
|
|
84089
84101
|
});
|
|
84090
|
-
|
|
84091
|
-
throw error;
|
|
84102
|
+
return { error, fixedErrors };
|
|
84092
84103
|
};
|
|
84093
|
-
const ensureParsedErrorsExist =
|
|
84094
|
-
const
|
|
84095
|
-
if (
|
|
84096
|
-
const errorMessage = `Validation failed but no parsed errors available. Raw errors: ${validation.validationErrors}`;
|
|
84104
|
+
const ensureParsedErrorsExist = (validation) => {
|
|
84105
|
+
const parsedErrors = validation.parsedValidationErrors ?? [];
|
|
84106
|
+
if (parsedErrors.length === 0) {
|
|
84107
|
+
const errorMessage = `Validation failed but no parsed errors available. Raw errors: ${validation.validationErrors ?? "No errors"}`;
|
|
84097
84108
|
console.warn(`\u26A0\uFE0F ${errorMessage}`);
|
|
84098
|
-
|
|
84099
|
-
|
|
84109
|
+
throw new ditto_codegen_types_12.ValidationConfigurationError(errorMessage, {
|
|
84110
|
+
validatorType: validator.type
|
|
84111
|
+
});
|
|
84100
84112
|
}
|
|
84101
84113
|
};
|
|
84102
84114
|
try {
|
|
84103
|
-
for (let attempt =
|
|
84115
|
+
for (let attempt = 1; attempt <= MAX_FIX_ATTEMPTS; attempt++) {
|
|
84104
84116
|
console.log(`\u{1F504} Fix Attempt ${attempt}/${MAX_FIX_ATTEMPTS}`);
|
|
84105
84117
|
const currentValidation = await validator.validate(projectDir);
|
|
84106
|
-
|
|
84118
|
+
const validationPassed = currentValidation.status === 0;
|
|
84119
|
+
const isFirstAttempt = attempt === 1;
|
|
84120
|
+
const isLastAttempt = attempt === MAX_FIX_ATTEMPTS;
|
|
84121
|
+
if (validationPassed) {
|
|
84122
|
+
const fixedErrors = getFixedErrors([]);
|
|
84107
84123
|
console.log(`\u2705 ${validator.type} validation passed - no fixes needed`);
|
|
84108
84124
|
await updateFixTask(ditto_codegen_types_12.Status.COMPLETED, {
|
|
84109
|
-
description: `Fixed ${
|
|
84125
|
+
description: `Fixed ${fixedErrors.length} errors.`,
|
|
84126
|
+
fixedErrors: fixedErrors.map(toErrorSummary)
|
|
84110
84127
|
});
|
|
84111
84128
|
return;
|
|
84112
84129
|
}
|
|
84113
|
-
if (
|
|
84114
|
-
|
|
84130
|
+
if (isFirstAttempt) {
|
|
84131
|
+
fixState.initialErrors = currentValidation.parsedValidationErrors ?? [];
|
|
84115
84132
|
}
|
|
84116
|
-
|
|
84133
|
+
if (isLastAttempt) {
|
|
84134
|
+
const { error, fixedErrors } = buildExhaustedResult(currentValidation, attempt);
|
|
84135
|
+
await updateFixTask(ditto_codegen_types_12.Status.COMPLETED, {
|
|
84136
|
+
description: `Completed with ${error.errors.length} unresolved errors after ${attempt} attempts`,
|
|
84137
|
+
warning: error.message,
|
|
84138
|
+
fixedErrors: fixedErrors.map(toErrorSummary),
|
|
84139
|
+
remainingErrors: error.errors.map(toErrorSummary)
|
|
84140
|
+
});
|
|
84141
|
+
throw error;
|
|
84142
|
+
}
|
|
84143
|
+
ensureParsedErrorsExist(currentValidation);
|
|
84117
84144
|
const totalErrors = currentValidation.parsedValidationErrors.length;
|
|
84118
84145
|
console.log(`\u{1F4DD} Found ${totalErrors} errors to fix`);
|
|
84119
84146
|
const errorsByFile = (0, utils_1.mapGroupBy)(currentValidation.parsedValidationErrors, (error) => error.filePath);
|
|
@@ -84122,15 +84149,14 @@ ${unfixedValidationErrors}`;
|
|
|
84122
84149
|
fixState.lastRunErrors = errorsByFile;
|
|
84123
84150
|
}
|
|
84124
84151
|
} catch (error) {
|
|
84125
|
-
|
|
84126
|
-
|
|
84127
|
-
|
|
84128
|
-
|
|
84129
|
-
});
|
|
84152
|
+
if (error instanceof ditto_codegen_types_12.CodeValidationError) {
|
|
84153
|
+
throw error;
|
|
84154
|
+
}
|
|
84155
|
+
const codegenError = (0, ditto_codegen_types_12.toCodegenError)(error);
|
|
84130
84156
|
await updateFixTask(ditto_codegen_types_12.Status.FAILED, {
|
|
84131
|
-
error:
|
|
84157
|
+
error: codegenError.message
|
|
84132
84158
|
});
|
|
84133
|
-
throw
|
|
84159
|
+
throw codegenError;
|
|
84134
84160
|
}
|
|
84135
84161
|
}
|
|
84136
84162
|
}
|
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.193",
|
|
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": "
|
|
27
|
+
"falconPackageHash": "416717af517d1fd26dd71583134531f28a30e81a627516f294036aaa"
|
|
28
28
|
}
|