@wix/ditto-codegen-public 1.0.233 → 1.0.234
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 +184 -37
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -101719,12 +101719,101 @@ var require_submitPlanIteration = __commonJS({
|
|
|
101719
101719
|
}
|
|
101720
101720
|
});
|
|
101721
101721
|
|
|
101722
|
+
// dist/tools/bash.js
|
|
101723
|
+
var require_bash = __commonJS({
|
|
101724
|
+
"dist/tools/bash.js"(exports2) {
|
|
101725
|
+
"use strict";
|
|
101726
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
101727
|
+
exports2.createBashTool = createBashTool;
|
|
101728
|
+
var child_process_1 = require("child_process");
|
|
101729
|
+
var zod_1 = require_zod();
|
|
101730
|
+
var ALLOWED_BASH_PATTERNS = [
|
|
101731
|
+
/^npm install(\s+[\w@./-]+)*$/
|
|
101732
|
+
// npm install, npm install @wix/stores @wix/ecom
|
|
101733
|
+
];
|
|
101734
|
+
var bashSchema = zod_1.z.object({
|
|
101735
|
+
command: zod_1.z.string().describe("The shell command to execute")
|
|
101736
|
+
});
|
|
101737
|
+
function isCommandAllowed(command) {
|
|
101738
|
+
return ALLOWED_BASH_PATTERNS.some((pattern) => pattern.test(command.trim()));
|
|
101739
|
+
}
|
|
101740
|
+
function createBashTool(basePath, options) {
|
|
101741
|
+
const { onActivity } = options ?? {};
|
|
101742
|
+
return {
|
|
101743
|
+
description: `Execute allowed shell commands in the project directory.
|
|
101744
|
+
Currently allowed commands:
|
|
101745
|
+
- npm install [packages] - Install npm packages
|
|
101746
|
+
|
|
101747
|
+
Example: bash({ command: "npm install @wix/stores @wix/ecom" })`,
|
|
101748
|
+
inputSchema: bashSchema,
|
|
101749
|
+
execute: async ({ command }) => {
|
|
101750
|
+
const trimmedCommand = command.trim();
|
|
101751
|
+
if (!isCommandAllowed(trimmedCommand)) {
|
|
101752
|
+
return {
|
|
101753
|
+
success: false,
|
|
101754
|
+
error: `Command not allowed: "${trimmedCommand}". Allowed patterns: npm install [packages]`
|
|
101755
|
+
};
|
|
101756
|
+
}
|
|
101757
|
+
await onActivity?.({ type: "bash:start", command: trimmedCommand });
|
|
101758
|
+
const result = (0, child_process_1.spawnSync)("sh", ["-c", trimmedCommand], {
|
|
101759
|
+
cwd: basePath,
|
|
101760
|
+
stdio: "pipe",
|
|
101761
|
+
env: process.env
|
|
101762
|
+
});
|
|
101763
|
+
const stdout = result.stdout?.toString().trim() || "";
|
|
101764
|
+
const stderr = result.stderr?.toString().trim() || "";
|
|
101765
|
+
const success2 = result.status === 0;
|
|
101766
|
+
await onActivity?.({
|
|
101767
|
+
type: "bash:done",
|
|
101768
|
+
command: trimmedCommand,
|
|
101769
|
+
success: success2
|
|
101770
|
+
});
|
|
101771
|
+
if (success2) {
|
|
101772
|
+
console.log(`\u{1F527} Executed: ${trimmedCommand}`);
|
|
101773
|
+
return { success: true, stdout, stderr };
|
|
101774
|
+
}
|
|
101775
|
+
return {
|
|
101776
|
+
success: false,
|
|
101777
|
+
stdout,
|
|
101778
|
+
stderr,
|
|
101779
|
+
error: `Command failed with exit code ${result.status}`
|
|
101780
|
+
};
|
|
101781
|
+
}
|
|
101782
|
+
};
|
|
101783
|
+
}
|
|
101784
|
+
}
|
|
101785
|
+
});
|
|
101786
|
+
|
|
101787
|
+
// dist/tools/submitFix.js
|
|
101788
|
+
var require_submitFix = __commonJS({
|
|
101789
|
+
"dist/tools/submitFix.js"(exports2) {
|
|
101790
|
+
"use strict";
|
|
101791
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
101792
|
+
exports2.SUBMIT_FIX_TOOL_NAME = exports2.FixSchema = void 0;
|
|
101793
|
+
exports2.createSubmitFixTool = createSubmitFixTool;
|
|
101794
|
+
var zod_1 = require_zod();
|
|
101795
|
+
exports2.FixSchema = zod_1.z.object({
|
|
101796
|
+
filePath: zod_1.z.string().describe("Relative path to the file that was fixed"),
|
|
101797
|
+
fixedContent: zod_1.z.string().describe("The complete fixed file content with all errors resolved"),
|
|
101798
|
+
summary: zod_1.z.string().describe("Brief summary of what was fixed")
|
|
101799
|
+
});
|
|
101800
|
+
exports2.SUBMIT_FIX_TOOL_NAME = "submit_fix";
|
|
101801
|
+
function createSubmitFixTool() {
|
|
101802
|
+
return {
|
|
101803
|
+
description: "Submit the fix after resolving all errors. Call this ONLY after you have successfully fixed all errors in the file.",
|
|
101804
|
+
inputSchema: exports2.FixSchema,
|
|
101805
|
+
execute: async (input) => input
|
|
101806
|
+
};
|
|
101807
|
+
}
|
|
101808
|
+
}
|
|
101809
|
+
});
|
|
101810
|
+
|
|
101722
101811
|
// dist/tools/index.js
|
|
101723
101812
|
var require_tools2 = __commonJS({
|
|
101724
101813
|
"dist/tools/index.js"(exports2) {
|
|
101725
101814
|
"use strict";
|
|
101726
101815
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
101727
|
-
exports2.TOOL_NAMES = exports2.createSubmitPlanTool = exports2.createListDirTool = exports2.createDeleteFileTool = exports2.createEditFileTool = exports2.createCreateFileTool = exports2.createGlobTool = exports2.createGrepTool = exports2.createReadFileTool = void 0;
|
|
101816
|
+
exports2.TOOL_NAMES = exports2.SUBMIT_FIX_TOOL_NAME = exports2.FixSchema = exports2.createSubmitFixTool = exports2.createBashTool = exports2.createSubmitPlanTool = exports2.createListDirTool = exports2.createDeleteFileTool = exports2.createEditFileTool = exports2.createCreateFileTool = exports2.createGlobTool = exports2.createGrepTool = exports2.createReadFileTool = void 0;
|
|
101728
101817
|
var readFile_1 = require_readFile();
|
|
101729
101818
|
Object.defineProperty(exports2, "createReadFileTool", { enumerable: true, get: function() {
|
|
101730
101819
|
return readFile_1.createReadFileTool;
|
|
@@ -101757,6 +101846,20 @@ var require_tools2 = __commonJS({
|
|
|
101757
101846
|
Object.defineProperty(exports2, "createSubmitPlanTool", { enumerable: true, get: function() {
|
|
101758
101847
|
return submitPlanIteration_1.createSubmitIterationPlanTool;
|
|
101759
101848
|
} });
|
|
101849
|
+
var bash_1 = require_bash();
|
|
101850
|
+
Object.defineProperty(exports2, "createBashTool", { enumerable: true, get: function() {
|
|
101851
|
+
return bash_1.createBashTool;
|
|
101852
|
+
} });
|
|
101853
|
+
var submitFix_1 = require_submitFix();
|
|
101854
|
+
Object.defineProperty(exports2, "createSubmitFixTool", { enumerable: true, get: function() {
|
|
101855
|
+
return submitFix_1.createSubmitFixTool;
|
|
101856
|
+
} });
|
|
101857
|
+
Object.defineProperty(exports2, "FixSchema", { enumerable: true, get: function() {
|
|
101858
|
+
return submitFix_1.FixSchema;
|
|
101859
|
+
} });
|
|
101860
|
+
Object.defineProperty(exports2, "SUBMIT_FIX_TOOL_NAME", { enumerable: true, get: function() {
|
|
101861
|
+
return submitFix_1.SUBMIT_FIX_TOOL_NAME;
|
|
101862
|
+
} });
|
|
101760
101863
|
var TOOL_NAMES;
|
|
101761
101864
|
(function(TOOL_NAMES2) {
|
|
101762
101865
|
TOOL_NAMES2["READ_FILE"] = "read_file";
|
|
@@ -101766,6 +101869,7 @@ var require_tools2 = __commonJS({
|
|
|
101766
101869
|
TOOL_NAMES2["LIST_DIR"] = "list_dir";
|
|
101767
101870
|
TOOL_NAMES2["GREP"] = "grep";
|
|
101768
101871
|
TOOL_NAMES2["GLOB"] = "glob";
|
|
101872
|
+
TOOL_NAMES2["BASH"] = "bash";
|
|
101769
101873
|
})(TOOL_NAMES || (exports2.TOOL_NAMES = TOOL_NAMES = {}));
|
|
101770
101874
|
}
|
|
101771
101875
|
});
|
|
@@ -120940,18 +121044,15 @@ var require_NaiveFixerAgent = __commonJS({
|
|
|
120940
121044
|
};
|
|
120941
121045
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
120942
121046
|
exports2.NaiveFixerAgent = void 0;
|
|
120943
|
-
var zod_1 = require_zod();
|
|
120944
121047
|
var ditto_codegen_types_12 = require_dist4();
|
|
121048
|
+
var codegen_common_logic_1 = require_dist12();
|
|
120945
121049
|
var dedent_1 = __importDefault2(require_dedent());
|
|
120946
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
120947
121050
|
var constants_1 = require_constants2();
|
|
120948
|
-
var
|
|
120949
|
-
|
|
120950
|
-
summary: zod_1.z.string().describe("Brief summary of what was fixed in the file")
|
|
120951
|
-
});
|
|
121051
|
+
var customAnthropicProvider_1 = require_customAnthropicProvider();
|
|
121052
|
+
var tools_1 = require_tools2();
|
|
120952
121053
|
var NaiveFixerAgent = class {
|
|
120953
121054
|
constructor() {
|
|
120954
|
-
this.name = "
|
|
121055
|
+
this.name = "NaiveFixerAgent";
|
|
120955
121056
|
}
|
|
120956
121057
|
formatErrors(errors) {
|
|
120957
121058
|
return errors.map((error48, index) => `${index + 1}. Line ${error48.line}, Column ${error48.column}${error48.errorCode ? ` (${error48.errorCode})` : ""}: ${error48.message}`).join("\n");
|
|
@@ -120960,52 +121061,97 @@ var require_NaiveFixerAgent = __commonJS({
|
|
|
120960
121061
|
if (!previousErrors || previousErrors.length === 0) {
|
|
120961
121062
|
return "";
|
|
120962
121063
|
}
|
|
120963
|
-
return
|
|
120964
|
-
|
|
120965
|
-
|
|
121064
|
+
return (0, dedent_1.default)`
|
|
121065
|
+
The following errors persisted after your last fix attempt.
|
|
121066
|
+
Please try a DIFFERENT approach to solve them:
|
|
121067
|
+
${previousErrors.map((err) => `- ${err}`).join("\n")}
|
|
121068
|
+
`;
|
|
120966
121069
|
}
|
|
120967
|
-
|
|
120968
|
-
|
|
121070
|
+
buildSystemPrompt() {
|
|
121071
|
+
return (0, dedent_1.default)`You are an expert TypeScript/JavaScript developer. Your task is to fix ALL compilation errors in a file.
|
|
120969
121072
|
|
|
120970
121073
|
Key principles:
|
|
120971
121074
|
1. Fix ALL errors listed in the input
|
|
120972
121075
|
2. Make minimal changes - only fix what's broken
|
|
120973
121076
|
3. Preserve code style and formatting as much as possible
|
|
120974
121077
|
4. Return the COMPLETE file content, not just diffs
|
|
120975
|
-
5.
|
|
120976
|
-
|
|
121078
|
+
5. Think like Cursor - analyze the context and make intelligent fixes
|
|
121079
|
+
|
|
121080
|
+
HANDLING TS2307 "Cannot find module" ERRORS:
|
|
121081
|
+
- When you see error code TS2307 with message "Cannot find module 'X'":
|
|
121082
|
+
1. FIRST, use the bash tool to run: npm install <package-name>
|
|
121083
|
+
2. Example: For "Cannot find module '@wix/stores'", run: npm install @wix/stores
|
|
121084
|
+
3. After installing, the error should be resolved
|
|
121085
|
+
4. If the package name is unclear, extract it from the import statement
|
|
121086
|
+
- DO NOT try to fix TS2307 by changing import paths - install the package instead!
|
|
121087
|
+
|
|
121088
|
+
WORKFLOW:
|
|
121089
|
+
1. Analyze the errors to understand what needs fixing
|
|
121090
|
+
2. For TS2307 errors: Use bash tool to npm install the missing package(s)
|
|
121091
|
+
3. For other errors: Read the file if needed, then determine the fix
|
|
121092
|
+
4. Submit your fix using the submit_fix tool
|
|
121093
|
+
|
|
121094
|
+
Common TypeScript errors and fixes:
|
|
121095
|
+
- TS2307 (Cannot find module): Use npm install
|
|
121096
|
+
- Type mismatches: Fix the type annotation or value
|
|
121097
|
+
- Missing imports: Add the import statement
|
|
121098
|
+
- Undefined variables: Declare or import the variable
|
|
121099
|
+
- Syntax errors: Fix the syntax
|
|
120977
121100
|
|
|
120978
|
-
|
|
120979
|
-
-
|
|
120980
|
-
-
|
|
120981
|
-
-
|
|
120982
|
-
|
|
120983
|
-
|
|
120984
|
-
- Incorrect component props`;
|
|
121101
|
+
IMPORTANT:
|
|
121102
|
+
- ALWAYS call submit_fix when done, even if you only ran npm install
|
|
121103
|
+
- If npm install was the only action needed, return the original file content unchanged
|
|
121104
|
+
- Be efficient - don't read files unnecessarily if you have the content`;
|
|
121105
|
+
}
|
|
121106
|
+
async fixFileWithMultipleErrors(input) {
|
|
120985
121107
|
const errorsList = this.formatErrors(input.errors);
|
|
120986
121108
|
const previousErrorsSection = this.formatPreviousErrors(input.previousErrors);
|
|
120987
|
-
const userMessage =
|
|
120988
|
-
|
|
121109
|
+
const userMessage = (0, dedent_1.default)`
|
|
121110
|
+
File: ${input.filePath}
|
|
121111
|
+
Language: ${input.language}
|
|
120989
121112
|
|
|
120990
|
-
ERRORS TO FIX:
|
|
120991
|
-
${errorsList}
|
|
121113
|
+
ERRORS TO FIX:
|
|
121114
|
+
${errorsList}
|
|
120992
121115
|
|
|
120993
|
-
CURRENT FILE CONTENT:
|
|
120994
|
-
${input.content}
|
|
121116
|
+
CURRENT FILE CONTENT:
|
|
121117
|
+
${input.content}
|
|
120995
121118
|
|
|
120996
|
-
${previousErrorsSection}
|
|
121119
|
+
${previousErrorsSection}
|
|
120997
121120
|
|
|
120998
|
-
|
|
121121
|
+
Instructions:
|
|
121122
|
+
1. Analyze the errors above
|
|
121123
|
+
2. For TS2307 errors, use npm install via the bash tool
|
|
121124
|
+
3. For other errors, fix the code
|
|
121125
|
+
4. Call submit_fix with the complete fixed file content
|
|
121126
|
+
`;
|
|
120999
121127
|
try {
|
|
121000
|
-
|
|
121001
|
-
|
|
121002
|
-
systemPrompt,
|
|
121003
|
-
provider: constants_1.LLM_PROVIDERS.ANTHROPIC,
|
|
121004
|
-
model: constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929,
|
|
121005
|
-
schema: BatchFixSchema,
|
|
121128
|
+
console.log(`\u{1F527} NaiveFixerAgent starting fix for ${input.filePath}...`);
|
|
121129
|
+
const model = (0, customAnthropicProvider_1.createCustomTextModel)()(constants_1.LLM_MODELS.CLAUDE_SONNET_4_5_20250929, {
|
|
121006
121130
|
agentName: this.name
|
|
121007
121131
|
});
|
|
121008
|
-
|
|
121132
|
+
const result = await (0, codegen_common_logic_1.generateAgentText)({
|
|
121133
|
+
agentName: this.name,
|
|
121134
|
+
model,
|
|
121135
|
+
tools: {
|
|
121136
|
+
[tools_1.TOOL_NAMES.READ_FILE]: (0, tools_1.createReadFileTool)(input.projectDir),
|
|
121137
|
+
[tools_1.TOOL_NAMES.EDIT_FILE]: (0, tools_1.createEditFileTool)(input.projectDir),
|
|
121138
|
+
[tools_1.TOOL_NAMES.BASH]: (0, tools_1.createBashTool)(input.projectDir),
|
|
121139
|
+
[tools_1.SUBMIT_FIX_TOOL_NAME]: (0, tools_1.createSubmitFixTool)()
|
|
121140
|
+
},
|
|
121141
|
+
systemPrompt: this.buildSystemPrompt(),
|
|
121142
|
+
userMessage,
|
|
121143
|
+
stopWhen: (0, codegen_common_logic_1.stopOnToolCall)(tools_1.SUBMIT_FIX_TOOL_NAME)
|
|
121144
|
+
});
|
|
121145
|
+
const fixResult = (0, codegen_common_logic_1.extractToolResult)(result.toolCalls, tools_1.SUBMIT_FIX_TOOL_NAME);
|
|
121146
|
+
if (!fixResult) {
|
|
121147
|
+
const toolCallsMade = result.toolCalls.map((tc) => tc.toolName).join(", ");
|
|
121148
|
+
throw new Error(`NaiveFixerAgent did not submit a fix. Tool calls made: ${toolCallsMade || "none"}. Agent response: ${result.text?.slice(0, 200) || "no response"}`);
|
|
121149
|
+
}
|
|
121150
|
+
console.log(`\u{1F527} NaiveFixerAgent fix submitted for: ${fixResult.filePath}`);
|
|
121151
|
+
return {
|
|
121152
|
+
fixedContent: fixResult.fixedContent,
|
|
121153
|
+
summary: fixResult.summary
|
|
121154
|
+
};
|
|
121009
121155
|
} catch (error48) {
|
|
121010
121156
|
const isTokenLimitError = error48.response?.body?.stop_reason === "max_tokens" || error48.finishReason === "length" || error48.cause?.response?.body?.stop_reason === "max_tokens";
|
|
121011
121157
|
if (isTokenLimitError) {
|
|
@@ -121193,6 +121339,7 @@ var require_NaiveErrorFixer = __commonJS({
|
|
|
121193
121339
|
const fixerAgent = new NaiveFixerAgent_1.NaiveFixerAgent();
|
|
121194
121340
|
try {
|
|
121195
121341
|
const batchResult = await fixerAgent.fixFileWithMultipleErrors({
|
|
121342
|
+
projectDir,
|
|
121196
121343
|
filePath,
|
|
121197
121344
|
content: originalContent,
|
|
121198
121345
|
errors: errors.map((error48) => ({
|
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.234",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"@wix/ditto-codegen": "1.0.0",
|
|
29
29
|
"esbuild": "^0.27.2"
|
|
30
30
|
},
|
|
31
|
-
"falconPackageHash": "
|
|
31
|
+
"falconPackageHash": "f2b144b85739248671d0347b8952d7ee8702bd0076e2df5cde88a4e9"
|
|
32
32
|
}
|