@wix/ditto-codegen-public 1.0.106 → 1.0.108
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 +1 -0
- package/dist/runCodegenFlow.js +247 -174
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -76977,6 +76977,7 @@ var require_enums2 = __commonJS({
|
|
|
76977
76977
|
ExtensionGenerationOperation2["INSERT"] = "insert";
|
|
76978
76978
|
ExtensionGenerationOperation2["UPDATE"] = "update";
|
|
76979
76979
|
ExtensionGenerationOperation2["DELETE"] = "delete";
|
|
76980
|
+
ExtensionGenerationOperation2["EDIT"] = "edit";
|
|
76980
76981
|
})(ExtensionGenerationOperation || (exports2.ExtensionGenerationOperation = ExtensionGenerationOperation = {}));
|
|
76981
76982
|
var ErrorOrigin;
|
|
76982
76983
|
(function(ErrorOrigin2) {
|
package/dist/runCodegenFlow.js
CHANGED
|
@@ -91,6 +91,7 @@ var require_enums = __commonJS({
|
|
|
91
91
|
ExtensionGenerationOperation7["INSERT"] = "insert";
|
|
92
92
|
ExtensionGenerationOperation7["UPDATE"] = "update";
|
|
93
93
|
ExtensionGenerationOperation7["DELETE"] = "delete";
|
|
94
|
+
ExtensionGenerationOperation7["EDIT"] = "edit";
|
|
94
95
|
})(ExtensionGenerationOperation6 || (exports2.ExtensionGenerationOperation = ExtensionGenerationOperation6 = {}));
|
|
95
96
|
var ErrorOrigin4;
|
|
96
97
|
(function(ErrorOrigin5) {
|
|
@@ -292,7 +293,7 @@ var require_FileSystemError = __commonJS({
|
|
|
292
293
|
exports2.FileSystemError = void 0;
|
|
293
294
|
var BaseCodegenError_1 = require_BaseCodegenError();
|
|
294
295
|
var ErrorTypes_1 = require_ErrorTypes();
|
|
295
|
-
var
|
|
296
|
+
var FileSystemError3 = class extends BaseCodegenError_1.BaseCodegenError {
|
|
296
297
|
constructor(message, options) {
|
|
297
298
|
super(message);
|
|
298
299
|
this.name = "FileSystemError";
|
|
@@ -314,7 +315,7 @@ var require_FileSystemError = __commonJS({
|
|
|
314
315
|
return props;
|
|
315
316
|
}
|
|
316
317
|
};
|
|
317
|
-
exports2.FileSystemError =
|
|
318
|
+
exports2.FileSystemError = FileSystemError3;
|
|
318
319
|
}
|
|
319
320
|
});
|
|
320
321
|
|
|
@@ -59148,15 +59149,37 @@ ${hasEmbeddedScriptExtensions ? embeddedScriptDynamicParametersPrompt() : 'No em
|
|
|
59148
59149
|
var import_fs = __toESM(require("fs"));
|
|
59149
59150
|
var import_path2 = __toESM(require("path"));
|
|
59150
59151
|
var import_ditto_codegen_types3 = __toESM(require_dist());
|
|
59151
|
-
var FileItemSchema = external_exports.
|
|
59152
|
-
|
|
59153
|
-
|
|
59154
|
-
|
|
59155
|
-
|
|
59156
|
-
|
|
59157
|
-
|
|
59158
|
-
|
|
59159
|
-
|
|
59152
|
+
var FileItemSchema = external_exports.discriminatedUnion("operation", [
|
|
59153
|
+
external_exports.object({
|
|
59154
|
+
operation: external_exports.union([
|
|
59155
|
+
external_exports.literal(import_ditto_codegen_types3.ExtensionGenerationOperation.INSERT),
|
|
59156
|
+
external_exports.literal(import_ditto_codegen_types3.ExtensionGenerationOperation.UPDATE),
|
|
59157
|
+
external_exports.literal(import_ditto_codegen_types3.ExtensionGenerationOperation.DELETE)
|
|
59158
|
+
]).describe(
|
|
59159
|
+
"File operation: insert (new file), update (modify existing), delete (remove file)"
|
|
59160
|
+
).default(import_ditto_codegen_types3.ExtensionGenerationOperation.INSERT),
|
|
59161
|
+
path: external_exports.string().describe("Relative file path from project root").optional(),
|
|
59162
|
+
content: external_exports.string().describe(
|
|
59163
|
+
"Complete file content as a string (for JSON files, stringify the object). Required for insert and update operations."
|
|
59164
|
+
).optional()
|
|
59165
|
+
}),
|
|
59166
|
+
external_exports.object({
|
|
59167
|
+
operation: external_exports.literal(import_ditto_codegen_types3.ExtensionGenerationOperation.EDIT),
|
|
59168
|
+
path: external_exports.string().describe("Relative file path from project root"),
|
|
59169
|
+
replacements: external_exports.array(
|
|
59170
|
+
external_exports.object({
|
|
59171
|
+
oldString: external_exports.string().describe(
|
|
59172
|
+
"The text to replace (must match the file contents exactly, including all whitespace and indentation)"
|
|
59173
|
+
),
|
|
59174
|
+
newString: external_exports.string().describe("The edited text to replace the oldString"),
|
|
59175
|
+
replaceAll: external_exports.boolean().optional().describe("Replace all occurrences of oldString (default false)")
|
|
59176
|
+
})
|
|
59177
|
+
).min(1).describe("List of string replacements to apply")
|
|
59178
|
+
})
|
|
59179
|
+
]).describe(`Representation of an operation that modifies a file on the local file system.
|
|
59180
|
+
Use the 'insert' operation to create a new file.
|
|
59181
|
+
Use the 'delete' operation to remove a file.
|
|
59182
|
+
To modify a file, you can either use the 'edit' operation to replace a specific strings with new strings (THIS IS THE PREFERRED WAY TO MODIFY A FILE), or use the 'update' operation to replace the entire file with new content.`);
|
|
59160
59183
|
var FilesSchema = external_exports.object({
|
|
59161
59184
|
files: external_exports.array(FileItemSchema).default([]).describe("An array of files")
|
|
59162
59185
|
});
|
|
@@ -63372,12 +63395,12 @@ function attachOrchestratorListeners(eventEmitter) {
|
|
|
63372
63395
|
timer.delete("PlannerAgent");
|
|
63373
63396
|
console.log(`\u{1F916}\u2714\uFE0F Generated plan in ${duration3 / 1e3}s`);
|
|
63374
63397
|
});
|
|
63375
|
-
eventEmitter.onEvent("
|
|
63398
|
+
eventEmitter.onEvent("iterationPlanAgent:start", () => {
|
|
63376
63399
|
timer.set("IterationAgent", Date.now());
|
|
63377
63400
|
console.log("\u{1F916} Generating iteration plan...");
|
|
63378
63401
|
});
|
|
63379
63402
|
eventEmitter.onEvent(
|
|
63380
|
-
"
|
|
63403
|
+
"iterationPlanAgent:done",
|
|
63381
63404
|
({ newExtensions, currentExtensions }) => {
|
|
63382
63405
|
const duration3 = Date.now() - timer.get("IterationAgent");
|
|
63383
63406
|
timer.delete("IterationAgent");
|
|
@@ -63854,10 +63877,6 @@ var DittoEventEmitter = class extends import_events.EventEmitter {
|
|
|
63854
63877
|
// src/extensions/extensionProcessors.ts
|
|
63855
63878
|
var import_types11 = __toESM(require_types_impl());
|
|
63856
63879
|
|
|
63857
|
-
// src/extensions/extensionHelpers.ts
|
|
63858
|
-
var import_path9 = __toESM(require("path"));
|
|
63859
|
-
var import_fs6 = __toESM(require("fs"));
|
|
63860
|
-
|
|
63861
63880
|
// src/extensions/extensionGenerators.ts
|
|
63862
63881
|
var import_path7 = __toESM(require("path"));
|
|
63863
63882
|
var import_fs_extra = __toESM(require_lib());
|
|
@@ -64266,9 +64285,137 @@ function collectAllCreatedFiles(options) {
|
|
|
64266
64285
|
return uniqueFiles;
|
|
64267
64286
|
}
|
|
64268
64287
|
|
|
64269
|
-
// src/extensions/
|
|
64270
|
-
var import_ditto_scaffolding4 = __toESM(require_dist5());
|
|
64288
|
+
// src/extensions/write-file.ts
|
|
64271
64289
|
var import_ditto_codegen_types16 = __toESM(require_dist());
|
|
64290
|
+
var import_fs6 = __toESM(require("fs"));
|
|
64291
|
+
var import_path9 = __toESM(require("path"));
|
|
64292
|
+
|
|
64293
|
+
// src/truncate.ts
|
|
64294
|
+
function truncate(str, maxLength = 50) {
|
|
64295
|
+
if (str.length <= maxLength) {
|
|
64296
|
+
return str;
|
|
64297
|
+
}
|
|
64298
|
+
return str.substring(0, maxLength) + "...";
|
|
64299
|
+
}
|
|
64300
|
+
|
|
64301
|
+
// src/extensions/write-file.ts
|
|
64302
|
+
var handleInsert = (file2, fullPath) => {
|
|
64303
|
+
if (!("content" in file2) || !file2.content) {
|
|
64304
|
+
console.warn(
|
|
64305
|
+
`\u26A0\uFE0F Skipping insert operation for ${file2.path}: no content provided`
|
|
64306
|
+
);
|
|
64307
|
+
return;
|
|
64308
|
+
}
|
|
64309
|
+
const dir = import_path9.default.dirname(fullPath);
|
|
64310
|
+
if (!import_fs6.default.existsSync(dir)) {
|
|
64311
|
+
import_fs6.default.mkdirSync(dir, { recursive: true });
|
|
64312
|
+
}
|
|
64313
|
+
writeFileInFileSystem(fullPath, file2.content.trim());
|
|
64314
|
+
console.log(`\u{1F4DD} Inserted: ${file2.path}`);
|
|
64315
|
+
};
|
|
64316
|
+
var handleUpdate = (file2, fullPath) => {
|
|
64317
|
+
if (!("content" in file2) || !file2.content) {
|
|
64318
|
+
console.warn(
|
|
64319
|
+
`\u26A0\uFE0F Skipping update operation for ${file2.path}: no content provided`
|
|
64320
|
+
);
|
|
64321
|
+
return;
|
|
64322
|
+
}
|
|
64323
|
+
if (!import_fs6.default.existsSync(fullPath)) {
|
|
64324
|
+
console.warn(
|
|
64325
|
+
`\u26A0\uFE0F Skipping update operation for ${file2.path}: file does not exist`
|
|
64326
|
+
);
|
|
64327
|
+
return;
|
|
64328
|
+
}
|
|
64329
|
+
writeFileInFileSystem(fullPath, file2.content.trim());
|
|
64330
|
+
console.log(`\u{1F4DD} Updated: ${file2.path}`);
|
|
64331
|
+
};
|
|
64332
|
+
var handleDelete = (file2, fullPath) => {
|
|
64333
|
+
if (import_fs6.default.existsSync(fullPath)) {
|
|
64334
|
+
try {
|
|
64335
|
+
import_fs6.default.unlinkSync(fullPath);
|
|
64336
|
+
console.log(`\u{1F5D1}\uFE0F Deleted: ${file2.path}`);
|
|
64337
|
+
} catch (error46) {
|
|
64338
|
+
throw new import_ditto_codegen_types16.FileSystemError(`Failed to delete file: ${file2.path}`, {
|
|
64339
|
+
filePath: fullPath,
|
|
64340
|
+
operation: import_ditto_codegen_types16.FileSystemOperation.DELETE,
|
|
64341
|
+
cause: error46
|
|
64342
|
+
});
|
|
64343
|
+
}
|
|
64344
|
+
} else {
|
|
64345
|
+
console.warn(
|
|
64346
|
+
`\u26A0\uFE0F Skipping delete operation for ${file2.path}: file does not exist`
|
|
64347
|
+
);
|
|
64348
|
+
}
|
|
64349
|
+
};
|
|
64350
|
+
var handleEdit = (file2, fullPath) => {
|
|
64351
|
+
if (!("replacements" in file2) || !file2.replacements || file2.replacements.length === 0) {
|
|
64352
|
+
console.warn(
|
|
64353
|
+
`\u26A0\uFE0F Skipping edit operation for ${file2.path}: no replacements provided`
|
|
64354
|
+
);
|
|
64355
|
+
return;
|
|
64356
|
+
}
|
|
64357
|
+
if (!import_fs6.default.existsSync(fullPath)) {
|
|
64358
|
+
console.warn(
|
|
64359
|
+
`\u26A0\uFE0F Skipping edit operation for ${file2.path}: file does not exist`
|
|
64360
|
+
);
|
|
64361
|
+
return;
|
|
64362
|
+
}
|
|
64363
|
+
let content = import_fs6.default.readFileSync(fullPath, "utf8");
|
|
64364
|
+
for (const replacement of file2.replacements) {
|
|
64365
|
+
if (!content.includes(replacement.oldString)) {
|
|
64366
|
+
console.warn(
|
|
64367
|
+
`\u26A0\uFE0F Replacement pattern not found in ${file2.path}: "${truncate(replacement.oldString)}"`
|
|
64368
|
+
);
|
|
64369
|
+
continue;
|
|
64370
|
+
}
|
|
64371
|
+
content = replacement.replaceAll ? content.replaceAll(replacement.oldString, replacement.newString) : content.replace(replacement.oldString, replacement.newString);
|
|
64372
|
+
}
|
|
64373
|
+
writeFileInFileSystem(fullPath, content);
|
|
64374
|
+
console.log(`\u270F\uFE0F Edited: ${file2.path}`);
|
|
64375
|
+
};
|
|
64376
|
+
var operationHandlers = {
|
|
64377
|
+
[import_ditto_codegen_types16.ExtensionGenerationOperation.INSERT]: handleInsert,
|
|
64378
|
+
[import_ditto_codegen_types16.ExtensionGenerationOperation.UPDATE]: handleUpdate,
|
|
64379
|
+
[import_ditto_codegen_types16.ExtensionGenerationOperation.DELETE]: handleDelete,
|
|
64380
|
+
[import_ditto_codegen_types16.ExtensionGenerationOperation.EDIT]: handleEdit
|
|
64381
|
+
};
|
|
64382
|
+
function writeFile(files, outputPath) {
|
|
64383
|
+
if (!files) {
|
|
64384
|
+
console.warn("\u26A0\uFE0F Skipping file operation: no files provided");
|
|
64385
|
+
return;
|
|
64386
|
+
}
|
|
64387
|
+
for (const file2 of files) {
|
|
64388
|
+
if (!file2.path) {
|
|
64389
|
+
console.warn("\u26A0\uFE0F Skipping file operation: no path specified");
|
|
64390
|
+
continue;
|
|
64391
|
+
}
|
|
64392
|
+
const fullPath = import_path9.default.join(outputPath, file2.path);
|
|
64393
|
+
const handler = operationHandlers[file2.operation];
|
|
64394
|
+
if (!handler) {
|
|
64395
|
+
throw new import_ditto_codegen_types16.ExtensionGenerationError(
|
|
64396
|
+
`Unknown operation "${file2.operation}" for file ${file2.path || "unknown"}`,
|
|
64397
|
+
{
|
|
64398
|
+
operation: file2.operation,
|
|
64399
|
+
filePath: file2.path || "unknown"
|
|
64400
|
+
}
|
|
64401
|
+
);
|
|
64402
|
+
}
|
|
64403
|
+
handler(file2, fullPath);
|
|
64404
|
+
}
|
|
64405
|
+
}
|
|
64406
|
+
function writeFileInFileSystem(filePath, content) {
|
|
64407
|
+
try {
|
|
64408
|
+
import_fs6.default.writeFileSync(filePath, content);
|
|
64409
|
+
} catch (error46) {
|
|
64410
|
+
throw new import_ditto_codegen_types16.FileSystemError(`Failed to write file: ${filePath}`, {
|
|
64411
|
+
filePath,
|
|
64412
|
+
operation: import_ditto_codegen_types16.FileSystemOperation.WRITE,
|
|
64413
|
+
cause: error46
|
|
64414
|
+
});
|
|
64415
|
+
}
|
|
64416
|
+
}
|
|
64417
|
+
|
|
64418
|
+
// src/extensions/finalize-extension-generation.ts
|
|
64272
64419
|
function finalizeExtensionGeneration(options, eventEmitter) {
|
|
64273
64420
|
const {
|
|
64274
64421
|
extension,
|
|
@@ -64306,101 +64453,16 @@ function finalizeExtensionGeneration(options, eventEmitter) {
|
|
|
64306
64453
|
throw createExtensionErrorHandler(eventEmitter, extension)(error46);
|
|
64307
64454
|
}
|
|
64308
64455
|
}
|
|
64309
|
-
|
|
64310
|
-
|
|
64311
|
-
|
|
64312
|
-
|
|
64313
|
-
}
|
|
64314
|
-
for (const file2 of files) {
|
|
64315
|
-
if (!file2.path) {
|
|
64316
|
-
console.warn("\u26A0\uFE0F Skipping file operation: no path specified");
|
|
64317
|
-
continue;
|
|
64318
|
-
}
|
|
64319
|
-
const fullPath = import_path9.default.join(outputPath, file2.path);
|
|
64320
|
-
switch (file2.operation) {
|
|
64321
|
-
case import_ditto_codegen_types16.ExtensionGenerationOperation.INSERT: {
|
|
64322
|
-
if (!file2.content) {
|
|
64323
|
-
console.warn(
|
|
64324
|
-
`\u26A0\uFE0F Skipping insert operation for ${file2.path}: no content provided`
|
|
64325
|
-
);
|
|
64326
|
-
continue;
|
|
64327
|
-
}
|
|
64328
|
-
try {
|
|
64329
|
-
const dir = import_path9.default.dirname(fullPath);
|
|
64330
|
-
if (!import_fs6.default.existsSync(dir)) {
|
|
64331
|
-
import_fs6.default.mkdirSync(dir, { recursive: true });
|
|
64332
|
-
}
|
|
64333
|
-
import_fs6.default.writeFileSync(fullPath, file2.content.trim());
|
|
64334
|
-
console.log(`\u{1F4DD} Inserted: ${file2.path}`);
|
|
64335
|
-
} catch (error46) {
|
|
64336
|
-
throw new import_ditto_codegen_types16.FileSystemError(`Failed to write file: ${file2.path}`, {
|
|
64337
|
-
filePath: fullPath,
|
|
64338
|
-
operation: import_ditto_codegen_types16.FileSystemOperation.WRITE,
|
|
64339
|
-
cause: error46
|
|
64340
|
-
});
|
|
64341
|
-
}
|
|
64342
|
-
break;
|
|
64343
|
-
}
|
|
64344
|
-
case import_ditto_codegen_types16.ExtensionGenerationOperation.UPDATE:
|
|
64345
|
-
if (!file2.content) {
|
|
64346
|
-
console.warn(
|
|
64347
|
-
`\u26A0\uFE0F Skipping update operation for ${file2.path}: no content provided`
|
|
64348
|
-
);
|
|
64349
|
-
continue;
|
|
64350
|
-
}
|
|
64351
|
-
if (!import_fs6.default.existsSync(fullPath)) {
|
|
64352
|
-
console.warn(
|
|
64353
|
-
`\u26A0\uFE0F Skipping update operation for ${file2.path}: file does not exist`
|
|
64354
|
-
);
|
|
64355
|
-
continue;
|
|
64356
|
-
}
|
|
64357
|
-
try {
|
|
64358
|
-
import_fs6.default.writeFileSync(fullPath, file2.content.trim());
|
|
64359
|
-
console.log(`\u{1F4DD} Updated: ${file2.path}`);
|
|
64360
|
-
} catch (error46) {
|
|
64361
|
-
throw new import_ditto_codegen_types16.FileSystemError(`Failed to update file: ${file2.path}`, {
|
|
64362
|
-
filePath: fullPath,
|
|
64363
|
-
operation: import_ditto_codegen_types16.FileSystemOperation.WRITE,
|
|
64364
|
-
cause: error46
|
|
64365
|
-
});
|
|
64366
|
-
}
|
|
64367
|
-
break;
|
|
64368
|
-
case import_ditto_codegen_types16.ExtensionGenerationOperation.DELETE:
|
|
64369
|
-
if (import_fs6.default.existsSync(fullPath)) {
|
|
64370
|
-
try {
|
|
64371
|
-
import_fs6.default.unlinkSync(fullPath);
|
|
64372
|
-
console.log(`\u{1F5D1}\uFE0F Deleted: ${file2.path}`);
|
|
64373
|
-
} catch (error46) {
|
|
64374
|
-
throw new import_ditto_codegen_types16.FileSystemError(`Failed to delete file: ${file2.path}`, {
|
|
64375
|
-
filePath: fullPath,
|
|
64376
|
-
operation: import_ditto_codegen_types16.FileSystemOperation.DELETE,
|
|
64377
|
-
cause: error46
|
|
64378
|
-
});
|
|
64379
|
-
}
|
|
64380
|
-
} else {
|
|
64381
|
-
console.warn(
|
|
64382
|
-
`\u26A0\uFE0F Skipping delete operation for ${file2.path}: file does not exist`
|
|
64383
|
-
);
|
|
64384
|
-
}
|
|
64385
|
-
break;
|
|
64386
|
-
default: {
|
|
64387
|
-
throw new import_ditto_codegen_types16.ExtensionGenerationError(
|
|
64388
|
-
`Unknown operation "${file2.operation}" for file ${file2.path}`,
|
|
64389
|
-
{
|
|
64390
|
-
operation: file2.operation,
|
|
64391
|
-
filePath: file2.path
|
|
64392
|
-
}
|
|
64393
|
-
);
|
|
64394
|
-
}
|
|
64395
|
-
}
|
|
64396
|
-
}
|
|
64397
|
-
}
|
|
64456
|
+
|
|
64457
|
+
// src/extensions/create-scaffolding.ts
|
|
64458
|
+
var import_ditto_codegen_types17 = __toESM(require_dist());
|
|
64459
|
+
var import_ditto_scaffolding4 = __toESM(require_dist5());
|
|
64398
64460
|
async function createScaffolding(extension, outputPath, eventEmitter) {
|
|
64399
64461
|
eventEmitter.emitEvent("scaffold:start", { extension });
|
|
64400
64462
|
try {
|
|
64401
64463
|
const scaffolds = await (0, import_ditto_scaffolding4.copyScaffoldingTemplate)(extension, outputPath);
|
|
64402
64464
|
if (!scaffolds || scaffolds.length === 0) {
|
|
64403
|
-
throw new
|
|
64465
|
+
throw new import_ditto_codegen_types17.ScaffoldingError(`Failed to scaffold ${extension.type}`, {
|
|
64404
64466
|
extensionType: extension.type
|
|
64405
64467
|
});
|
|
64406
64468
|
}
|
|
@@ -64410,10 +64472,10 @@ async function createScaffolding(extension, outputPath, eventEmitter) {
|
|
|
64410
64472
|
});
|
|
64411
64473
|
return scaffolds;
|
|
64412
64474
|
} catch (error46) {
|
|
64413
|
-
if (error46 instanceof
|
|
64475
|
+
if (error46 instanceof import_ditto_codegen_types17.FileSystemError || error46 instanceof import_ditto_codegen_types17.ScaffoldingError) {
|
|
64414
64476
|
throw error46;
|
|
64415
64477
|
}
|
|
64416
|
-
throw (0,
|
|
64478
|
+
throw (0, import_ditto_codegen_types17.toCodegenError)(error46);
|
|
64417
64479
|
}
|
|
64418
64480
|
}
|
|
64419
64481
|
|
|
@@ -64506,7 +64568,7 @@ async function processExistingExtension(params) {
|
|
|
64506
64568
|
}
|
|
64507
64569
|
|
|
64508
64570
|
// src/extensions/dashboardPage.ts
|
|
64509
|
-
var
|
|
64571
|
+
var import_ditto_codegen_types18 = __toESM(require_dist());
|
|
64510
64572
|
async function processDashboardPage(params) {
|
|
64511
64573
|
const {
|
|
64512
64574
|
extension,
|
|
@@ -64544,10 +64606,10 @@ async function processDashboardPage(params) {
|
|
|
64544
64606
|
console.log("\u{1F3AF} Using auto-patterns for dashboard generation");
|
|
64545
64607
|
const relevantCollection = plan?.collections?.map((op) => op.data).find((c) => c.idSuffix === decision.relevantCollectionId);
|
|
64546
64608
|
if (!relevantCollection) {
|
|
64547
|
-
throw new
|
|
64609
|
+
throw new import_ditto_codegen_types18.ResourceNotFoundError(
|
|
64548
64610
|
`Collection with ID ${decision.relevantCollectionId} not found in created collections`,
|
|
64549
64611
|
{
|
|
64550
|
-
resourceType:
|
|
64612
|
+
resourceType: import_ditto_codegen_types18.ResourceType.COLLECTION,
|
|
64551
64613
|
resourceId: decision.relevantCollectionId
|
|
64552
64614
|
}
|
|
64553
64615
|
);
|
|
@@ -64579,7 +64641,7 @@ async function processDashboardPage(params) {
|
|
|
64579
64641
|
|
|
64580
64642
|
// src/extensions/servicePlugin.ts
|
|
64581
64643
|
var import_types12 = __toESM(require_types_impl());
|
|
64582
|
-
var
|
|
64644
|
+
var import_ditto_codegen_types19 = __toESM(require_dist());
|
|
64583
64645
|
async function processMultipleServicePluginScaffolds(params) {
|
|
64584
64646
|
const {
|
|
64585
64647
|
extension,
|
|
@@ -64592,18 +64654,18 @@ async function processMultipleServicePluginScaffolds(params) {
|
|
|
64592
64654
|
userRequestSummary
|
|
64593
64655
|
} = params;
|
|
64594
64656
|
if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
|
|
64595
|
-
throw new
|
|
64657
|
+
throw new import_ditto_codegen_types19.UnsupportedExtensionTypeError(
|
|
64596
64658
|
"Service plugin extension must have related SPIs",
|
|
64597
64659
|
{
|
|
64598
64660
|
extensionType: extension.type || import_types12.ExtensionType.SERVICE_PLUGIN,
|
|
64599
|
-
origin:
|
|
64661
|
+
origin: import_ditto_codegen_types19.ErrorOrigin.INITIAL
|
|
64600
64662
|
}
|
|
64601
64663
|
);
|
|
64602
64664
|
}
|
|
64603
64665
|
const parallelTasks = extension.relatedSpis.map(async (spi, i) => {
|
|
64604
64666
|
const scaffold = scaffolds[i];
|
|
64605
64667
|
if (!scaffold) {
|
|
64606
|
-
throw new
|
|
64668
|
+
throw new import_ditto_codegen_types19.ScaffoldingError("No scaffold generated for extension", {
|
|
64607
64669
|
extensionType: extension.type
|
|
64608
64670
|
});
|
|
64609
64671
|
}
|
|
@@ -64733,7 +64795,7 @@ async function processEmbeddedScriptExtension(params) {
|
|
|
64733
64795
|
// src/cms/index.ts
|
|
64734
64796
|
var import_path10 = __toESM(require("path"));
|
|
64735
64797
|
var import_crypto2 = require("crypto");
|
|
64736
|
-
var
|
|
64798
|
+
var import_ditto_codegen_types20 = __toESM(require_dist());
|
|
64737
64799
|
var getDataExtensionAndCollectionsFiles = ({
|
|
64738
64800
|
plan
|
|
64739
64801
|
}) => {
|
|
@@ -64767,7 +64829,7 @@ export const dataExtension = extensions.genericExtension(${JSON.stringify(
|
|
|
64767
64829
|
)});
|
|
64768
64830
|
`;
|
|
64769
64831
|
files.push({
|
|
64770
|
-
operation:
|
|
64832
|
+
operation: import_ditto_codegen_types20.ExtensionGenerationOperation.INSERT,
|
|
64771
64833
|
path: import_path10.default.join("src", "data", "extensions.ts"),
|
|
64772
64834
|
content: generatedCode
|
|
64773
64835
|
});
|
|
@@ -64905,11 +64967,11 @@ var DittoOrchestrator = class extends DittoEventEmitter {
|
|
|
64905
64967
|
};
|
|
64906
64968
|
|
|
64907
64969
|
// src/flows/init-codegen.ts
|
|
64908
|
-
var
|
|
64970
|
+
var import_ditto_codegen_types22 = __toESM(require_dist());
|
|
64909
64971
|
|
|
64910
64972
|
// src/flows/codegen-flow-helpers.ts
|
|
64911
64973
|
var import_path11 = __toESM(require("path"));
|
|
64912
|
-
var
|
|
64974
|
+
var import_ditto_codegen_types21 = __toESM(require_dist());
|
|
64913
64975
|
var import_http = __toESM(require_http_impl());
|
|
64914
64976
|
var import_http_client = __toESM(require_index_node());
|
|
64915
64977
|
var slugify = (str = "") => {
|
|
@@ -64925,7 +64987,7 @@ function setupAgentTaskTracking(eventEmitter, jobContext) {
|
|
|
64925
64987
|
codeGenerationService.addTask(jobContext.jobId, {
|
|
64926
64988
|
id: taskId,
|
|
64927
64989
|
kind: "run_agent",
|
|
64928
|
-
status:
|
|
64990
|
+
status: import_ditto_codegen_types21.Status.RUNNING,
|
|
64929
64991
|
name: "run_agent",
|
|
64930
64992
|
description: `Run agent for ${extension.name}`,
|
|
64931
64993
|
payload: { extension }
|
|
@@ -64937,7 +64999,7 @@ function setupAgentTaskTracking(eventEmitter, jobContext) {
|
|
|
64937
64999
|
codeGenerationService.updateTask(
|
|
64938
65000
|
jobContext.jobId,
|
|
64939
65001
|
taskId,
|
|
64940
|
-
|
|
65002
|
+
import_ditto_codegen_types21.Status.COMPLETED,
|
|
64941
65003
|
{ taskOutput: { files } }
|
|
64942
65004
|
);
|
|
64943
65005
|
});
|
|
@@ -64947,7 +65009,7 @@ function setupAgentTaskTracking(eventEmitter, jobContext) {
|
|
|
64947
65009
|
await codeGenerationService.updateTask(
|
|
64948
65010
|
jobContext.jobId,
|
|
64949
65011
|
taskId,
|
|
64950
|
-
|
|
65012
|
+
import_ditto_codegen_types21.Status.FAILED,
|
|
64951
65013
|
{
|
|
64952
65014
|
error: serializeError(error46)
|
|
64953
65015
|
}
|
|
@@ -64999,7 +65061,7 @@ function getRelatedApis(extensions) {
|
|
|
64999
65061
|
}
|
|
65000
65062
|
|
|
65001
65063
|
// src/flows/init-codegen.ts
|
|
65002
|
-
var
|
|
65064
|
+
var import_ditto_codegen_types23 = __toESM(require_dist());
|
|
65003
65065
|
var runInitCodegenFlow = async (blueprint) => {
|
|
65004
65066
|
const localJobContext = jobContextStorage.getStore();
|
|
65005
65067
|
console.log(
|
|
@@ -65008,7 +65070,7 @@ var runInitCodegenFlow = async (blueprint) => {
|
|
|
65008
65070
|
await codeGenerationService.updateTask(
|
|
65009
65071
|
localJobContext.jobId,
|
|
65010
65072
|
localJobContext.taskId,
|
|
65011
|
-
|
|
65073
|
+
import_ditto_codegen_types22.Status.RUNNING,
|
|
65012
65074
|
{}
|
|
65013
65075
|
);
|
|
65014
65076
|
console.log(
|
|
@@ -65028,7 +65090,7 @@ var runInitCodegenFlow = async (blueprint) => {
|
|
|
65028
65090
|
requiredPermissions: requiredPermissionsResponse?.data?.requiredPermissions ?? []
|
|
65029
65091
|
});
|
|
65030
65092
|
} catch (error46) {
|
|
65031
|
-
const codegenError = (0,
|
|
65093
|
+
const codegenError = (0, import_ditto_codegen_types23.toCodegenError)(error46);
|
|
65032
65094
|
console.error(
|
|
65033
65095
|
`\u274C [Init] Failed to get required permissions: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`,
|
|
65034
65096
|
error46
|
|
@@ -65045,13 +65107,13 @@ var runInitCodegenFlow = async (blueprint) => {
|
|
|
65045
65107
|
accessToken: ctx.accessToken,
|
|
65046
65108
|
appNamespace: ctx.appNamespace
|
|
65047
65109
|
});
|
|
65048
|
-
await updateParentTaskStatus(localJobContext,
|
|
65110
|
+
await updateParentTaskStatus(localJobContext, import_ditto_codegen_types22.Status.COMPLETED);
|
|
65049
65111
|
console.log(
|
|
65050
65112
|
`[Init] Completed init codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`
|
|
65051
65113
|
);
|
|
65052
65114
|
} catch (error46) {
|
|
65053
|
-
const codegenError = (0,
|
|
65054
|
-
await updateParentTaskStatus(localJobContext,
|
|
65115
|
+
const codegenError = (0, import_ditto_codegen_types23.toCodegenError)(error46);
|
|
65116
|
+
await updateParentTaskStatus(localJobContext, import_ditto_codegen_types22.Status.FAILED, codegenError);
|
|
65055
65117
|
console.error(
|
|
65056
65118
|
`\u274C [Init] Failed init codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`,
|
|
65057
65119
|
error46
|
|
@@ -65060,7 +65122,7 @@ var runInitCodegenFlow = async (blueprint) => {
|
|
|
65060
65122
|
};
|
|
65061
65123
|
|
|
65062
65124
|
// src/flows/iterate-codegen.ts
|
|
65063
|
-
var
|
|
65125
|
+
var import_ditto_codegen_types24 = __toESM(require_dist());
|
|
65064
65126
|
|
|
65065
65127
|
// src/IterationOrchestrator.ts
|
|
65066
65128
|
var import_path12 = __toESM(require("path"));
|
|
@@ -65072,22 +65134,27 @@ var IterationOrchestrator = class extends DittoEventEmitter {
|
|
|
65072
65134
|
this.agentsFactory = agentsFactory;
|
|
65073
65135
|
this.apiKey = apiKey;
|
|
65074
65136
|
}
|
|
65075
|
-
|
|
65076
|
-
* Main entry point for iteration code generation
|
|
65077
|
-
*/
|
|
65078
|
-
async generateIterationCode(request) {
|
|
65137
|
+
async getIterationPlan(request) {
|
|
65079
65138
|
this.emitEvent("start:iteration", {});
|
|
65080
|
-
const { outputPath, chatHistory
|
|
65081
|
-
|
|
65082
|
-
this.emitEvent("iterationAgent:start", {});
|
|
65139
|
+
const { outputPath, chatHistory } = request;
|
|
65140
|
+
this.emitEvent("iterationPlanAgent:start", {});
|
|
65083
65141
|
const iterationPlan = await this.runIterationPlanning(
|
|
65084
65142
|
outputPath,
|
|
65085
65143
|
chatHistory
|
|
65086
65144
|
);
|
|
65087
|
-
this.emitEvent("
|
|
65145
|
+
this.emitEvent("iterationPlanAgent:done", {
|
|
65088
65146
|
newExtensions: iterationPlan?.additionalExtensions?.length || 0,
|
|
65089
65147
|
currentExtensions: iterationPlan?.currentExtensions?.length || 0
|
|
65090
65148
|
});
|
|
65149
|
+
return iterationPlan;
|
|
65150
|
+
}
|
|
65151
|
+
/**
|
|
65152
|
+
* Main entry point for iteration code generation
|
|
65153
|
+
*/
|
|
65154
|
+
async generateIterationCode(request) {
|
|
65155
|
+
const startTime = Date.now();
|
|
65156
|
+
const { outputPath, appNamespace, iterationPlan } = request;
|
|
65157
|
+
this.emitEvent("start:code-generation", {});
|
|
65091
65158
|
const newExtensions = iterationPlan?.additionalExtensions?.map((ext) => ext.extension) || [];
|
|
65092
65159
|
const currentExtensions = iterationPlan?.currentExtensions?.map((ext) => ext.extension) || [];
|
|
65093
65160
|
const plan = await this.generatePlan(
|
|
@@ -65143,7 +65210,7 @@ var IterationOrchestrator = class extends DittoEventEmitter {
|
|
|
65143
65210
|
const results = await Promise.allSettled(parallelTasks.filter(Boolean));
|
|
65144
65211
|
throwIfFailures(results);
|
|
65145
65212
|
await generateMainExtensionsFile(outputPath);
|
|
65146
|
-
const durationMsCodeGeneration = Date.now() -
|
|
65213
|
+
const durationMsCodeGeneration = Date.now() - startTime;
|
|
65147
65214
|
this.emitEvent("finish:code-generation", {
|
|
65148
65215
|
outputPath,
|
|
65149
65216
|
durationMs: durationMsCodeGeneration
|
|
@@ -65155,9 +65222,8 @@ var IterationOrchestrator = class extends DittoEventEmitter {
|
|
|
65155
65222
|
},
|
|
65156
65223
|
this
|
|
65157
65224
|
);
|
|
65158
|
-
const durationMs = Date.now() -
|
|
65225
|
+
const durationMs = Date.now() - startTime;
|
|
65159
65226
|
this.emitEvent("finish:iteration", { outputPath, durationMs });
|
|
65160
|
-
return iterationPlan;
|
|
65161
65227
|
}
|
|
65162
65228
|
/**
|
|
65163
65229
|
* Run iteration planning to determine which extensions to create/update
|
|
@@ -65290,7 +65356,7 @@ var IterationOrchestrator = class extends DittoEventEmitter {
|
|
|
65290
65356
|
};
|
|
65291
65357
|
|
|
65292
65358
|
// src/flows/iterate-codegen.ts
|
|
65293
|
-
var
|
|
65359
|
+
var import_ditto_codegen_types25 = __toESM(require_dist());
|
|
65294
65360
|
var runIterateCodegenFlow = async (chatHistory) => {
|
|
65295
65361
|
const localJobContext = jobContextStorage.getStore();
|
|
65296
65362
|
console.log(
|
|
@@ -65299,7 +65365,7 @@ var runIterateCodegenFlow = async (chatHistory) => {
|
|
|
65299
65365
|
await codeGenerationService.updateTask(
|
|
65300
65366
|
localJobContext.jobId,
|
|
65301
65367
|
localJobContext.taskId,
|
|
65302
|
-
|
|
65368
|
+
import_ditto_codegen_types24.Status.RUNNING,
|
|
65303
65369
|
{}
|
|
65304
65370
|
);
|
|
65305
65371
|
console.log(
|
|
@@ -65314,49 +65380,56 @@ var runIterateCodegenFlow = async (chatHistory) => {
|
|
|
65314
65380
|
);
|
|
65315
65381
|
setupAgentTaskTracking(iterationOrchestrator, localJobContext);
|
|
65316
65382
|
attachOrchestratorListeners(iterationOrchestrator);
|
|
65317
|
-
const iterationPlan = await iterationOrchestrator.
|
|
65318
|
-
|
|
65383
|
+
const iterationPlan = await iterationOrchestrator.getIterationPlan({
|
|
65384
|
+
outputPath,
|
|
65385
|
+
chatHistory
|
|
65386
|
+
});
|
|
65387
|
+
await updateRequiredPermissions(iterationPlan, localJobContext);
|
|
65388
|
+
await iterationOrchestrator.generateIterationCode({
|
|
65319
65389
|
outputPath,
|
|
65320
65390
|
siteId: ctx.siteId,
|
|
65321
65391
|
accessToken: ctx.accessToken,
|
|
65322
|
-
appNamespace: ctx.appNamespace
|
|
65392
|
+
appNamespace: ctx.appNamespace,
|
|
65393
|
+
iterationPlan
|
|
65323
65394
|
});
|
|
65324
|
-
|
|
65325
|
-
const requiredPermissionsResponse = await getRequiredPermissions([
|
|
65326
|
-
...iterationPlan.additionalExtensions.map(
|
|
65327
|
-
(extension) => extension.extension
|
|
65328
|
-
),
|
|
65329
|
-
...iterationPlan.currentExtensions.map(
|
|
65330
|
-
(extension) => extension.extension
|
|
65331
|
-
)
|
|
65332
|
-
]);
|
|
65333
|
-
await updateJobPayload(localJobContext, {
|
|
65334
|
-
requiredPermissions: requiredPermissionsResponse?.data?.requiredPermissions ?? []
|
|
65335
|
-
});
|
|
65336
|
-
} catch (error46) {
|
|
65337
|
-
const codegenError = (0, import_ditto_codegen_types24.toCodegenError)(error46);
|
|
65338
|
-
console.error(
|
|
65339
|
-
`\u274C [Iterate] Failed to get required permissions: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`,
|
|
65340
|
-
error46
|
|
65341
|
-
);
|
|
65342
|
-
await updateJobPayload(localJobContext, {
|
|
65343
|
-
requiredPermissions: [],
|
|
65344
|
-
requiredPermissionsErrors: codegenError
|
|
65345
|
-
});
|
|
65346
|
-
}
|
|
65347
|
-
await updateParentTaskStatus(localJobContext, import_ditto_codegen_types23.Status.COMPLETED);
|
|
65395
|
+
await updateParentTaskStatus(localJobContext, import_ditto_codegen_types24.Status.COMPLETED);
|
|
65348
65396
|
console.log(
|
|
65349
65397
|
`[Init] Completed iterate codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`
|
|
65350
65398
|
);
|
|
65351
65399
|
} catch (error46) {
|
|
65352
|
-
const codegenError = (0,
|
|
65353
|
-
await updateParentTaskStatus(localJobContext,
|
|
65400
|
+
const codegenError = (0, import_ditto_codegen_types25.toCodegenError)(error46);
|
|
65401
|
+
await updateParentTaskStatus(localJobContext, import_ditto_codegen_types24.Status.FAILED, codegenError);
|
|
65354
65402
|
console.error(
|
|
65355
65403
|
`\u274C [Iterate] Failed iterate codegen task: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`,
|
|
65356
65404
|
error46
|
|
65357
65405
|
);
|
|
65358
65406
|
}
|
|
65359
65407
|
};
|
|
65408
|
+
async function updateRequiredPermissions(iterationPlan, localJobContext) {
|
|
65409
|
+
try {
|
|
65410
|
+
const requiredPermissionsResponse = await getRequiredPermissions([
|
|
65411
|
+
...iterationPlan.additionalExtensions.map(
|
|
65412
|
+
(extension) => extension.extension
|
|
65413
|
+
),
|
|
65414
|
+
...iterationPlan.currentExtensions.map(
|
|
65415
|
+
(extension) => extension.extension
|
|
65416
|
+
)
|
|
65417
|
+
]);
|
|
65418
|
+
await updateJobPayload(localJobContext, {
|
|
65419
|
+
requiredPermissions: requiredPermissionsResponse?.data?.requiredPermissions ?? []
|
|
65420
|
+
});
|
|
65421
|
+
} catch (error46) {
|
|
65422
|
+
const codegenError = (0, import_ditto_codegen_types25.toCodegenError)(error46);
|
|
65423
|
+
console.error(
|
|
65424
|
+
`\u274C [Iterate] Failed to get required permissions: jobId=${localJobContext.jobId}, taskId=${localJobContext.taskId}`,
|
|
65425
|
+
error46
|
|
65426
|
+
);
|
|
65427
|
+
await updateJobPayload(localJobContext, {
|
|
65428
|
+
requiredPermissions: [],
|
|
65429
|
+
requiredPermissionsErrors: codegenError
|
|
65430
|
+
});
|
|
65431
|
+
}
|
|
65432
|
+
}
|
|
65360
65433
|
|
|
65361
65434
|
// src/runCodegenFlow.ts
|
|
65362
65435
|
async function runCodegenFlow() {
|
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.108",
|
|
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": "d308a26ac94d9e52b29937f76e7837685cfd0ba752c295ffc1e14a9d"
|
|
28
28
|
}
|