@wix/ditto-codegen-public 1.0.283 → 1.0.285
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 +198 -149
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -497,6 +497,7 @@ var require_context = __commonJS({
|
|
|
497
497
|
history: new HistoryManager(),
|
|
498
498
|
projectId: process.env.PROJECT_ID || "test",
|
|
499
499
|
appNamespace: process.env.APP_NAMESPACE,
|
|
500
|
+
codeIdentifier: process.env.CODE_IDENTIFIER,
|
|
500
501
|
hasActiveJobs: () => {
|
|
501
502
|
return Object.keys(exports2.ctx.activeJobs).some((jobId) => exports2.ctx.activeJobs[jobId] === types_1.Status.RUNNING);
|
|
502
503
|
},
|
|
@@ -10211,6 +10212,17 @@ var require_cjs3 = __commonJS({
|
|
|
10211
10212
|
}
|
|
10212
10213
|
});
|
|
10213
10214
|
|
|
10215
|
+
// dist/job-context-storage.js
|
|
10216
|
+
var require_job_context_storage = __commonJS({
|
|
10217
|
+
"dist/job-context-storage.js"(exports2) {
|
|
10218
|
+
"use strict";
|
|
10219
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10220
|
+
exports2.jobContextStorage = void 0;
|
|
10221
|
+
var async_hooks_1 = require("async_hooks");
|
|
10222
|
+
exports2.jobContextStorage = new async_hooks_1.AsyncLocalStorage();
|
|
10223
|
+
}
|
|
10224
|
+
});
|
|
10225
|
+
|
|
10214
10226
|
// dist/logger.js
|
|
10215
10227
|
var require_logger = __commonJS({
|
|
10216
10228
|
"dist/logger.js"(exports2) {
|
|
@@ -10218,55 +10230,52 @@ var require_logger = __commonJS({
|
|
|
10218
10230
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10219
10231
|
exports2.logger = void 0;
|
|
10220
10232
|
exports2.initLogger = initLogger;
|
|
10221
|
-
exports2.getJobLogger = getJobLogger;
|
|
10222
10233
|
var panorama_client_node_1 = require_cjs3();
|
|
10223
|
-
var
|
|
10224
|
-
var
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
data
|
|
10234
|
-
}).withGlobalConfig(globalConfig);
|
|
10235
|
-
}
|
|
10236
|
-
function initLogger(sessionId2) {
|
|
10237
|
-
globalConfig.setSessionId(sessionId2);
|
|
10238
|
-
factory = createFactory({
|
|
10239
|
-
appNamespace: process.env.APP_NAMESPACE
|
|
10240
|
-
});
|
|
10241
|
-
factory.withGlobalConfig(globalConfig);
|
|
10242
|
-
exports2.logger = createLogger(factory.client());
|
|
10243
|
-
}
|
|
10234
|
+
var job_context_storage_12 = require_job_context_storage();
|
|
10235
|
+
var panoramaConfig = (0, panorama_client_node_1.createGlobalConfig)();
|
|
10236
|
+
var panoramaFactory = (0, panorama_client_node_1.panoramaClientFactory)({
|
|
10237
|
+
baseParams: {
|
|
10238
|
+
fullArtifactId: "com.wixpress.ditto-codegen",
|
|
10239
|
+
componentId: "codegen",
|
|
10240
|
+
platform: panorama_client_node_1.PanoramaPlatform.Standalone,
|
|
10241
|
+
appDefId: process.env.PROJECT_ID
|
|
10242
|
+
}
|
|
10243
|
+
}).withGlobalConfig(panoramaConfig);
|
|
10244
10244
|
function createLogger(client) {
|
|
10245
10245
|
const panoramaLogger = client.logger();
|
|
10246
10246
|
return {
|
|
10247
10247
|
info: (message, data) => {
|
|
10248
|
-
console.log(message, data ?? "");
|
|
10248
|
+
console.log(message, JSON.stringify(data, null, 2) ?? "");
|
|
10249
10249
|
panoramaLogger.info(message, data);
|
|
10250
10250
|
},
|
|
10251
10251
|
warn: (message, data) => {
|
|
10252
|
-
console.warn(message, data ?? "");
|
|
10252
|
+
console.warn(message, JSON.stringify(data, null, 2) ?? "");
|
|
10253
10253
|
panoramaLogger.warn(message, data);
|
|
10254
10254
|
},
|
|
10255
10255
|
error: (message, data) => {
|
|
10256
|
-
console.error(message, data ?? "");
|
|
10256
|
+
console.error(message, JSON.stringify(data, null, 2) ?? "");
|
|
10257
10257
|
panoramaLogger.error(message, data);
|
|
10258
10258
|
},
|
|
10259
10259
|
debug: (message, data) => {
|
|
10260
|
-
console.debug(message, data ?? "");
|
|
10261
10260
|
panoramaLogger.debug(message, data);
|
|
10262
10261
|
}
|
|
10263
10262
|
};
|
|
10264
10263
|
}
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
const client = factory.client({ data: { jobId, taskId } });
|
|
10268
|
-
return createLogger(client);
|
|
10264
|
+
function initLogger(sessionId2) {
|
|
10265
|
+
panoramaConfig.setSessionId(sessionId2);
|
|
10269
10266
|
}
|
|
10267
|
+
exports2.logger = /* @__PURE__ */ (() => {
|
|
10268
|
+
const getContextLogger = () => {
|
|
10269
|
+
const { jobId } = job_context_storage_12.jobContextStorage.getStore() ?? {};
|
|
10270
|
+
return createLogger(panoramaFactory.client(jobId ? { data: { jobId } } : void 0));
|
|
10271
|
+
};
|
|
10272
|
+
return {
|
|
10273
|
+
info: (message, data) => getContextLogger().info(message, data),
|
|
10274
|
+
warn: (message, data) => getContextLogger().warn(message, data),
|
|
10275
|
+
error: (message, data) => getContextLogger().error(message, data),
|
|
10276
|
+
debug: (message, data) => getContextLogger().debug(message, data)
|
|
10277
|
+
};
|
|
10278
|
+
})();
|
|
10270
10279
|
}
|
|
10271
10280
|
});
|
|
10272
10281
|
|
|
@@ -10368,7 +10377,7 @@ var require_CodeGenService = __commonJS({
|
|
|
10368
10377
|
}));
|
|
10369
10378
|
};
|
|
10370
10379
|
this.resumeJobFromDecision = async (jobId) => {
|
|
10371
|
-
logger_12.logger.info("Resuming job from user decision"
|
|
10380
|
+
logger_12.logger.info("Resuming job from user decision");
|
|
10372
10381
|
await this.httpClient.request((0, http_1.updateJob)({
|
|
10373
10382
|
projectId: this.projectId,
|
|
10374
10383
|
job: {
|
|
@@ -10425,17 +10434,6 @@ var require_CodeGenService = __commonJS({
|
|
|
10425
10434
|
}
|
|
10426
10435
|
});
|
|
10427
10436
|
|
|
10428
|
-
// dist/job-context-storage.js
|
|
10429
|
-
var require_job_context_storage = __commonJS({
|
|
10430
|
-
"dist/job-context-storage.js"(exports2) {
|
|
10431
|
-
"use strict";
|
|
10432
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10433
|
-
exports2.jobContextStorage = void 0;
|
|
10434
|
-
var async_hooks_1 = require("async_hooks");
|
|
10435
|
-
exports2.jobContextStorage = new async_hooks_1.AsyncLocalStorage();
|
|
10436
|
-
}
|
|
10437
|
-
});
|
|
10438
|
-
|
|
10439
10437
|
// dist/services/codeGenerationService.js
|
|
10440
10438
|
var require_codeGenerationService = __commonJS({
|
|
10441
10439
|
"dist/services/codeGenerationService.js"(exports2) {
|
|
@@ -10454,53 +10452,68 @@ var require_cli_listeners = __commonJS({
|
|
|
10454
10452
|
"use strict";
|
|
10455
10453
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10456
10454
|
exports2.attachOrchestratorListeners = attachOrchestratorListeners;
|
|
10455
|
+
var logger_12 = require_logger();
|
|
10457
10456
|
function attachOrchestratorListeners(eventEmitter) {
|
|
10458
|
-
eventEmitter.onEvent("start", (info) => {
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10457
|
+
eventEmitter.onEvent("start:init", (info) => {
|
|
10458
|
+
logger_12.logger.info("\u{1F680} Starting initial code generation for app", {
|
|
10459
|
+
appName: info.appName,
|
|
10460
|
+
summary: info.summary,
|
|
10461
|
+
outputPath: info.outputPath,
|
|
10462
|
+
extensionsCount: info.extensionsCount
|
|
10463
|
+
});
|
|
10465
10464
|
});
|
|
10466
|
-
eventEmitter.onEvent("start:iteration", () => {
|
|
10467
|
-
|
|
10465
|
+
eventEmitter.onEvent("start:iteration", ({ outputPath }) => {
|
|
10466
|
+
logger_12.logger.info("\u{1F680} Starting code iteration", { outputPath });
|
|
10468
10467
|
});
|
|
10469
|
-
eventEmitter.onEvent("
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10468
|
+
eventEmitter.onEvent("start:ask", ({ outputPath }) => {
|
|
10469
|
+
logger_12.logger.info("\u{1F680} Starting ask", { outputPath });
|
|
10470
|
+
});
|
|
10471
|
+
eventEmitter.onEvent("finish:init", ({ outputPath, durationMs }) => {
|
|
10472
|
+
logger_12.logger.info("\u2705 Init completed", {
|
|
10473
|
+
outputPath,
|
|
10474
|
+
durationMs,
|
|
10475
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
10476
|
+
});
|
|
10473
10477
|
});
|
|
10474
10478
|
eventEmitter.onEvent("finish:iteration", ({ outputPath, durationMs }) => {
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10479
|
+
logger_12.logger.info("\u2705 Iteration completed", {
|
|
10480
|
+
outputPath,
|
|
10481
|
+
durationMs,
|
|
10482
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
10483
|
+
});
|
|
10478
10484
|
});
|
|
10479
|
-
eventEmitter.onEvent("finish:
|
|
10480
|
-
|
|
10481
|
-
|
|
10485
|
+
eventEmitter.onEvent("finish:ask", ({ durationMs }) => {
|
|
10486
|
+
logger_12.logger.info("\u2705 Ask completed", {
|
|
10487
|
+
durationMs,
|
|
10488
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
10489
|
+
});
|
|
10482
10490
|
});
|
|
10483
10491
|
eventEmitter.onEvent("opencode:start", ({ outputPath }) => {
|
|
10484
|
-
|
|
10492
|
+
logger_12.logger.info("\u{1F527} OpenCode starting", { outputPath });
|
|
10485
10493
|
});
|
|
10486
10494
|
eventEmitter.onEvent("opencode:output", ({ data }) => {
|
|
10487
10495
|
process.stdout.write(data);
|
|
10488
10496
|
});
|
|
10489
10497
|
eventEmitter.onEvent("opencode:done", ({ durationMs }) => {
|
|
10490
|
-
|
|
10491
|
-
|
|
10498
|
+
logger_12.logger.info("\u{1F527} OpenCode completed", {
|
|
10499
|
+
durationMs,
|
|
10500
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
10501
|
+
});
|
|
10492
10502
|
});
|
|
10493
10503
|
eventEmitter.onEvent("opencode:error", ({ error, exitCode, durationMs }) => {
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
console.error(`Error: ${error}`);
|
|
10501
|
-
}
|
|
10504
|
+
logger_12.logger.error("\u274C OpenCode failed", {
|
|
10505
|
+
error,
|
|
10506
|
+
exitCode,
|
|
10507
|
+
durationMs,
|
|
10508
|
+
durationFormatted: getFormattedDuration(durationMs)
|
|
10509
|
+
});
|
|
10502
10510
|
});
|
|
10503
10511
|
}
|
|
10512
|
+
var getFormattedDuration = (ms) => {
|
|
10513
|
+
const seconds = ms / 1e3;
|
|
10514
|
+
const minutes = seconds / 60;
|
|
10515
|
+
return `${ms} ms (${minutes.toFixed(2)} min or ${seconds.toFixed(2)} sec)`;
|
|
10516
|
+
};
|
|
10504
10517
|
}
|
|
10505
10518
|
});
|
|
10506
10519
|
|
|
@@ -12073,7 +12086,7 @@ var require_parser = __commonJS({
|
|
|
12073
12086
|
exports2.parseUsageStats = parseUsageStats;
|
|
12074
12087
|
exports2.mergeUsageStats = mergeUsageStats;
|
|
12075
12088
|
exports2.hasSessionError = hasSessionError;
|
|
12076
|
-
exports2.
|
|
12089
|
+
exports2.summarizeOpenCodeLine = summarizeOpenCodeLine;
|
|
12077
12090
|
var ditto_codegen_types_12 = require_dist4();
|
|
12078
12091
|
var types_1 = require_types4();
|
|
12079
12092
|
var constants_1 = require_constants5();
|
|
@@ -12226,21 +12239,38 @@ var require_parser = __commonJS({
|
|
|
12226
12239
|
return false;
|
|
12227
12240
|
return foundError;
|
|
12228
12241
|
}
|
|
12229
|
-
function
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
` - Input: ${stats.tokens.input.toLocaleString()}`,
|
|
12236
|
-
` - Output: ${stats.tokens.output.toLocaleString()}`,
|
|
12237
|
-
` - Cache Read: ${stats.tokens.cacheRead.toLocaleString()}`,
|
|
12238
|
-
` - Cache Write: ${stats.tokens.cacheWrite.toLocaleString()}`
|
|
12239
|
-
];
|
|
12240
|
-
if (stats.tokens.reasoning > 0) {
|
|
12241
|
-
lines.push(` - Reasoning: ${stats.tokens.reasoning.toLocaleString()}`);
|
|
12242
|
+
function truncate(s, max = 200) {
|
|
12243
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (${s.length} chars)` : s;
|
|
12244
|
+
}
|
|
12245
|
+
function summarizeInput(input) {
|
|
12246
|
+
if (input.files) {
|
|
12247
|
+
return { files: input.files.map(({ path }) => ({ path })) };
|
|
12242
12248
|
}
|
|
12243
|
-
|
|
12249
|
+
if (input.filePath)
|
|
12250
|
+
return { filePath: input.filePath };
|
|
12251
|
+
return {
|
|
12252
|
+
...input,
|
|
12253
|
+
...input.prompt && { prompt: truncate(input.prompt) },
|
|
12254
|
+
...input.description && { description: truncate(input.description) }
|
|
12255
|
+
};
|
|
12256
|
+
}
|
|
12257
|
+
function summarizeOpenCodeLine(line) {
|
|
12258
|
+
if (line.type !== "tool_use") {
|
|
12259
|
+
return line;
|
|
12260
|
+
}
|
|
12261
|
+
const { part } = line;
|
|
12262
|
+
const { state } = part;
|
|
12263
|
+
return {
|
|
12264
|
+
...line,
|
|
12265
|
+
part: {
|
|
12266
|
+
...part,
|
|
12267
|
+
state: {
|
|
12268
|
+
...state,
|
|
12269
|
+
...state?.input && { input: summarizeInput(state.input) },
|
|
12270
|
+
...state?.output && { output: truncate(state.output) }
|
|
12271
|
+
}
|
|
12272
|
+
}
|
|
12273
|
+
};
|
|
12244
12274
|
}
|
|
12245
12275
|
}
|
|
12246
12276
|
});
|
|
@@ -12735,6 +12765,7 @@ var require_process_handlers = __commonJS({
|
|
|
12735
12765
|
exports2.setupStderrHandler = setupStderrHandler;
|
|
12736
12766
|
exports2.setupCloseHandler = setupCloseHandler;
|
|
12737
12767
|
exports2.setupErrorHandler = setupErrorHandler;
|
|
12768
|
+
var parser_1 = require_parser();
|
|
12738
12769
|
var config_1 = require_config();
|
|
12739
12770
|
var process_manager_1 = require_process_manager();
|
|
12740
12771
|
var result_builder_1 = require_result_builder();
|
|
@@ -12770,6 +12801,13 @@ var require_process_handlers = __commonJS({
|
|
|
12770
12801
|
ctx.state.lineBuffer = lines.pop() || "";
|
|
12771
12802
|
for (const line of lines) {
|
|
12772
12803
|
ctx.taskTracker.processLine(line);
|
|
12804
|
+
if (line.trim()) {
|
|
12805
|
+
try {
|
|
12806
|
+
logger_12.logger.debug("[OpenCode] stdout", (0, parser_1.summarizeOpenCodeLine)(JSON.parse(line)));
|
|
12807
|
+
} catch {
|
|
12808
|
+
logger_12.logger.debug("[OpenCode] stdout", { line: line.slice(0, 200) });
|
|
12809
|
+
}
|
|
12810
|
+
}
|
|
12773
12811
|
}
|
|
12774
12812
|
if (onStdout) {
|
|
12775
12813
|
onStdout(text);
|
|
@@ -12854,7 +12892,7 @@ var require_executor = __commonJS({
|
|
|
12854
12892
|
skillsUsed: accumulatedSkills,
|
|
12855
12893
|
extensionsCreated: accumulatedExtensions
|
|
12856
12894
|
};
|
|
12857
|
-
logger_12.logger.info(
|
|
12895
|
+
logger_12.logger.info("[OpenCode] Usage summary", { usage: finalResult2.usage });
|
|
12858
12896
|
await logOpenCodeStats(options);
|
|
12859
12897
|
return finalResult2;
|
|
12860
12898
|
}
|
|
@@ -12875,7 +12913,7 @@ var require_executor = __commonJS({
|
|
|
12875
12913
|
skillsUsed: Array.from(accumulatedSkills),
|
|
12876
12914
|
extensionsCreated: accumulatedExtensions
|
|
12877
12915
|
};
|
|
12878
|
-
logger_12.logger.info(
|
|
12916
|
+
logger_12.logger.info("[OpenCode] Usage summary", { usage: finalResult.usage });
|
|
12879
12917
|
await logOpenCodeStats(options);
|
|
12880
12918
|
return finalResult;
|
|
12881
12919
|
}
|
|
@@ -12884,8 +12922,8 @@ var require_executor = __commonJS({
|
|
|
12884
12922
|
const env = isAsk ? (0, config_1.getOpenCodeAskEnv)(options.projectId) : (0, config_1.getOpenCodeEnv)(options.projectId);
|
|
12885
12923
|
const stats = await (0, cost_tracker_1.fetchOpenCodeStats)(options.outputPath, env);
|
|
12886
12924
|
if (stats) {
|
|
12887
|
-
|
|
12888
|
-
|
|
12925
|
+
console.log("[OpenCode] Stats\n", stats);
|
|
12926
|
+
logger_12.logger.debug("[OpenCode] Stats", { stats });
|
|
12889
12927
|
}
|
|
12890
12928
|
}
|
|
12891
12929
|
function buildArgs(prompt) {
|
|
@@ -13025,7 +13063,7 @@ var require_opencode_integration = __commonJS({
|
|
|
13025
13063
|
"dist/opencode-integration/index.js"(exports2) {
|
|
13026
13064
|
"use strict";
|
|
13027
13065
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13028
|
-
exports2.
|
|
13066
|
+
exports2.OpenCodeTaskTracker = exports2.runOpenCodeAsk = exports2.runOpenCodeIteration = exports2.runOpenCodeInit = void 0;
|
|
13029
13067
|
var opencode_runner_1 = require_opencode_runner();
|
|
13030
13068
|
Object.defineProperty(exports2, "runOpenCodeInit", { enumerable: true, get: function() {
|
|
13031
13069
|
return opencode_runner_1.runOpenCodeInit;
|
|
@@ -13040,10 +13078,6 @@ var require_opencode_integration = __commonJS({
|
|
|
13040
13078
|
Object.defineProperty(exports2, "OpenCodeTaskTracker", { enumerable: true, get: function() {
|
|
13041
13079
|
return task_tracker_1.OpenCodeTaskTracker;
|
|
13042
13080
|
} });
|
|
13043
|
-
var parser_1 = require_parser();
|
|
13044
|
-
Object.defineProperty(exports2, "formatUsageStats", { enumerable: true, get: function() {
|
|
13045
|
-
return parser_1.formatUsageStats;
|
|
13046
|
-
} });
|
|
13047
13081
|
}
|
|
13048
13082
|
});
|
|
13049
13083
|
|
|
@@ -13063,7 +13097,7 @@ var require_OpenCodeOrchestrator = __commonJS({
|
|
|
13063
13097
|
}
|
|
13064
13098
|
async generateCode(request) {
|
|
13065
13099
|
const { blueprint, outputPath, projectId, chatHistory } = request;
|
|
13066
|
-
this.emitEvent("start", {
|
|
13100
|
+
this.emitEvent("start:init", {
|
|
13067
13101
|
appName: blueprint.appName ?? "",
|
|
13068
13102
|
summary: blueprint.summary ?? "",
|
|
13069
13103
|
outputPath,
|
|
@@ -13096,8 +13130,7 @@ var require_OpenCodeOrchestrator = __commonJS({
|
|
|
13096
13130
|
});
|
|
13097
13131
|
}
|
|
13098
13132
|
this.emitEvent("opencode:done", { durationMs });
|
|
13099
|
-
this.emitEvent("finish:
|
|
13100
|
-
this.emitEvent("finish", { outputPath, durationMs });
|
|
13133
|
+
this.emitEvent("finish:init", { outputPath, durationMs });
|
|
13101
13134
|
return result;
|
|
13102
13135
|
}
|
|
13103
13136
|
};
|
|
@@ -17531,24 +17564,30 @@ var require_job_decision_manager = __commonJS({
|
|
|
17531
17564
|
}
|
|
17532
17565
|
};
|
|
17533
17566
|
await codeGenerationService_12.codeGenerationService.updateJobWithPendingDecision(jobId, userDecision);
|
|
17534
|
-
logger_12.logger.info(
|
|
17567
|
+
logger_12.logger.info("[JobDecision] Paused for user input", {
|
|
17535
17568
|
question: request.question
|
|
17536
17569
|
});
|
|
17570
|
+
const startTime = Date.now();
|
|
17537
17571
|
const response = await pollForJobDecisionResponse(jobId, decisionId);
|
|
17572
|
+
const durationMs = Date.now() - startTime;
|
|
17538
17573
|
await codeGenerationService_12.codeGenerationService.resumeJobFromDecision(jobId);
|
|
17539
|
-
logger_12.logger.info(
|
|
17540
|
-
selectedOptionId: response.selectedOptionId
|
|
17574
|
+
logger_12.logger.info("[JobDecision] Resumed after user decision", {
|
|
17575
|
+
selectedOptionId: response.selectedOptionId,
|
|
17576
|
+
durationMs
|
|
17541
17577
|
});
|
|
17542
17578
|
return response;
|
|
17543
17579
|
}
|
|
17544
17580
|
async function pollForJobDecisionResponse(jobId, decisionId) {
|
|
17581
|
+
logger_12.logger.info("[JobDecision] Polling for user decision response", {
|
|
17582
|
+
decisionId
|
|
17583
|
+
});
|
|
17545
17584
|
while (true) {
|
|
17546
17585
|
const job = await codeGenerationService_12.codeGenerationService.getJob(jobId);
|
|
17547
17586
|
if (!job) {
|
|
17548
17587
|
throw new Error(`Job ${jobId} not found`);
|
|
17549
17588
|
}
|
|
17550
|
-
logger_12.logger.info(`[JobDecision] Polling for job ${jobId} decision ${decisionId}`, { job: JSON.stringify(job, null, 2) });
|
|
17551
17589
|
if (job.status === CodeGenService_12.Status.CANCELLED || job.status === CodeGenService_12.Status.PENDING_CANCEL) {
|
|
17590
|
+
logger_12.logger.warn("[JobDecision] Job cancelled while waiting for user decision", { decisionId });
|
|
17552
17591
|
throw new UserDecisionCancelledError(jobId, decisionId);
|
|
17553
17592
|
}
|
|
17554
17593
|
const decision = job.pendingUserDecisions?.find((d) => d.id === decisionId) ?? job.userDecisionHistory?.find((d) => d.id === decisionId);
|
|
@@ -17692,7 +17731,6 @@ var require_opencode_init = __commonJS({
|
|
|
17692
17731
|
}
|
|
17693
17732
|
const { jobId, taskId, kind } = store;
|
|
17694
17733
|
const localJobContext = { jobId, taskId };
|
|
17695
|
-
const jobLog = (0, logger_12.getJobLogger)(jobId, taskId);
|
|
17696
17734
|
const biBaseParams = {
|
|
17697
17735
|
Job_id: jobId,
|
|
17698
17736
|
Task_id: taskId,
|
|
@@ -17701,9 +17739,9 @@ var require_opencode_init = __commonJS({
|
|
|
17701
17739
|
run_kind: kind,
|
|
17702
17740
|
job_input: JSON.stringify(history)
|
|
17703
17741
|
};
|
|
17704
|
-
|
|
17742
|
+
logger_12.logger.info("[OpenCode Init] Starting task", { taskId });
|
|
17705
17743
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
17706
|
-
|
|
17744
|
+
logger_12.logger.info("[OpenCode Init] Marked task RUNNING", { taskId });
|
|
17707
17745
|
(0, biEvents_1.reportSessionStart)({
|
|
17708
17746
|
...biBaseParams,
|
|
17709
17747
|
Task_model: config_1.DEFAULT_MODEL,
|
|
@@ -17716,7 +17754,10 @@ var require_opencode_init = __commonJS({
|
|
|
17716
17754
|
const preDecisionResult = await (0, pre_run_decision_1.runPreDecisionCheck)(localJobContext.jobId, { blueprint }, [pre_run_decision_1.checkSiteUIDecision]);
|
|
17717
17755
|
finalBlueprint = preDecisionResult.modifiedBlueprint ?? blueprint;
|
|
17718
17756
|
if (preDecisionResult.decisionsApplied.length > 0) {
|
|
17719
|
-
|
|
17757
|
+
logger_12.logger.info("[OpenCode Init] Applied pre-decision", {
|
|
17758
|
+
decisions: preDecisionResult.decisionsApplied,
|
|
17759
|
+
finalBlueprint
|
|
17760
|
+
});
|
|
17720
17761
|
}
|
|
17721
17762
|
}
|
|
17722
17763
|
const orchestrator = new OpenCodeOrchestrator_1.OpenCodeOrchestrator();
|
|
@@ -17749,7 +17790,7 @@ var require_opencode_init = __commonJS({
|
|
|
17749
17790
|
Job_skills_used: result.skillsUsed.join(","),
|
|
17750
17791
|
Job_extensions_created: result.extensionsCreated.join(",")
|
|
17751
17792
|
});
|
|
17752
|
-
|
|
17793
|
+
logger_12.logger.info("[OpenCode Init] Completed task", { taskId });
|
|
17753
17794
|
} catch (error) {
|
|
17754
17795
|
const codegenError = (0, ditto_codegen_types_2.toCodegenError)(error);
|
|
17755
17796
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
@@ -17776,7 +17817,10 @@ var require_opencode_init = __commonJS({
|
|
|
17776
17817
|
is_expected: codegenError.expected,
|
|
17777
17818
|
validation_type: codegenError.validationType
|
|
17778
17819
|
});
|
|
17779
|
-
|
|
17820
|
+
logger_12.logger.error("[OpenCode Init] Failed task", {
|
|
17821
|
+
taskId,
|
|
17822
|
+
error: error instanceof Error ? error.message : String(error)
|
|
17823
|
+
});
|
|
17780
17824
|
}
|
|
17781
17825
|
};
|
|
17782
17826
|
exports2.runOpencodeInitFlow = runOpencodeInitFlow;
|
|
@@ -17799,7 +17843,7 @@ var require_OpenCodeIterationOrchestrator = __commonJS({
|
|
|
17799
17843
|
}
|
|
17800
17844
|
async generateIterationCode(request) {
|
|
17801
17845
|
const { outputPath, projectId, chatHistory } = request;
|
|
17802
|
-
this.emitEvent("start:iteration", {});
|
|
17846
|
+
this.emitEvent("start:iteration", { outputPath });
|
|
17803
17847
|
const start = Date.now();
|
|
17804
17848
|
this.emitEvent("opencode:start", { outputPath });
|
|
17805
17849
|
const result = await (0, opencode_integration_1.runOpenCodeIteration)({
|
|
@@ -17858,7 +17902,6 @@ var require_opencode_iterate = __commonJS({
|
|
|
17858
17902
|
}
|
|
17859
17903
|
const { jobId, taskId, kind } = store;
|
|
17860
17904
|
const localJobContext = { jobId, taskId };
|
|
17861
|
-
const jobLog = (0, logger_12.getJobLogger)(jobId, taskId);
|
|
17862
17905
|
const biBaseParams = {
|
|
17863
17906
|
Job_id: jobId,
|
|
17864
17907
|
Task_id: taskId,
|
|
@@ -17867,9 +17910,9 @@ var require_opencode_iterate = __commonJS({
|
|
|
17867
17910
|
run_kind: kind,
|
|
17868
17911
|
job_input: JSON.stringify(chatHistory)
|
|
17869
17912
|
};
|
|
17870
|
-
|
|
17913
|
+
logger_12.logger.info("[OpenCode Iterate] Starting task", { taskId });
|
|
17871
17914
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
17872
|
-
|
|
17915
|
+
logger_12.logger.info("[OpenCode Iterate] Marked task RUNNING", { taskId });
|
|
17873
17916
|
(0, biEvents_1.reportSessionStart)({
|
|
17874
17917
|
...biBaseParams,
|
|
17875
17918
|
Task_model: config_1.DEFAULT_MODEL,
|
|
@@ -17906,7 +17949,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
17906
17949
|
Job_skills_used: result.skillsUsed.join(","),
|
|
17907
17950
|
Job_extensions_created: result.extensionsCreated.join(",")
|
|
17908
17951
|
});
|
|
17909
|
-
|
|
17952
|
+
logger_12.logger.info("[OpenCode Iterate] Completed task", { taskId });
|
|
17910
17953
|
} catch (error) {
|
|
17911
17954
|
const codegenError = (0, ditto_codegen_types_2.toCodegenError)(error);
|
|
17912
17955
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
@@ -17932,7 +17975,8 @@ var require_opencode_iterate = __commonJS({
|
|
|
17932
17975
|
is_expected: codegenError.expected,
|
|
17933
17976
|
validation_type: codegenError.validationType
|
|
17934
17977
|
});
|
|
17935
|
-
|
|
17978
|
+
logger_12.logger.error("[OpenCode Iterate] Failed task", {
|
|
17979
|
+
taskId,
|
|
17936
17980
|
error: error instanceof Error ? error.message : String(error)
|
|
17937
17981
|
});
|
|
17938
17982
|
}
|
|
@@ -17957,6 +18001,7 @@ var require_OpenCodeAskOrchestrator = __commonJS({
|
|
|
17957
18001
|
}
|
|
17958
18002
|
async ask(request) {
|
|
17959
18003
|
const { outputPath, projectId, chatHistory } = request;
|
|
18004
|
+
this.emitEvent("start:ask", { outputPath });
|
|
17960
18005
|
this.emitEvent("opencode:start", { outputPath });
|
|
17961
18006
|
const start = Date.now();
|
|
17962
18007
|
const result = await (0, opencode_integration_1.runOpenCodeAsk)({
|
|
@@ -17982,6 +18027,7 @@ var require_OpenCodeAskOrchestrator = __commonJS({
|
|
|
17982
18027
|
});
|
|
17983
18028
|
}
|
|
17984
18029
|
this.emitEvent("opencode:done", { durationMs });
|
|
18030
|
+
this.emitEvent("finish:ask", { durationMs });
|
|
17985
18031
|
return result;
|
|
17986
18032
|
}
|
|
17987
18033
|
};
|
|
@@ -18013,10 +18059,13 @@ var require_opencode_ask = __commonJS({
|
|
|
18013
18059
|
jobId: store.jobId,
|
|
18014
18060
|
taskId: store.taskId
|
|
18015
18061
|
};
|
|
18016
|
-
|
|
18017
|
-
|
|
18062
|
+
logger_12.logger.info("[OpenCode Ask] Starting task", {
|
|
18063
|
+
taskId: localJobContext.taskId
|
|
18064
|
+
});
|
|
18018
18065
|
await codeGenerationService_12.codeGenerationService.updateTask(localJobContext.jobId, localJobContext.taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
18019
|
-
|
|
18066
|
+
logger_12.logger.info("[OpenCode Ask] Marked task RUNNING", {
|
|
18067
|
+
taskId: localJobContext.taskId
|
|
18068
|
+
});
|
|
18020
18069
|
try {
|
|
18021
18070
|
const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
|
|
18022
18071
|
const askOrchestrator = new OpenCodeAskOrchestrator_1.OpenCodeAskOrchestrator();
|
|
@@ -18031,11 +18080,11 @@ var require_opencode_ask = __commonJS({
|
|
|
18031
18080
|
answer: result.answer
|
|
18032
18081
|
}
|
|
18033
18082
|
});
|
|
18034
|
-
|
|
18083
|
+
logger_12.logger.info("[OpenCode Ask] Completed task");
|
|
18035
18084
|
} catch (error) {
|
|
18036
18085
|
const codegenError = (0, ditto_codegen_types_2.toCodegenError)(error);
|
|
18037
18086
|
await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
|
|
18038
|
-
|
|
18087
|
+
logger_12.logger.error("[OpenCode Ask] Failed task", {
|
|
18039
18088
|
error: error instanceof Error ? error.message : String(error)
|
|
18040
18089
|
});
|
|
18041
18090
|
}
|
|
@@ -18072,23 +18121,20 @@ var require_job_cancellation_monitor = __commonJS({
|
|
|
18072
18121
|
try {
|
|
18073
18122
|
const job = await this.codeGenerationService.getJob(jobId);
|
|
18074
18123
|
if (!job) {
|
|
18075
|
-
logger_12.logger.warn("[Job] Job not found, stopping cancellation monitoring"
|
|
18076
|
-
jobId
|
|
18077
|
-
});
|
|
18124
|
+
logger_12.logger.warn("[Job] Job not found, stopping cancellation monitoring");
|
|
18078
18125
|
this.stop();
|
|
18079
18126
|
return;
|
|
18080
18127
|
}
|
|
18081
18128
|
if (job.status === ditto_codegen_types_12.Status.PENDING_CANCEL) {
|
|
18082
|
-
logger_12.logger.info("[Job] Detected cancellation request, exiting"
|
|
18129
|
+
logger_12.logger.info("[Job] Detected cancellation request, exiting");
|
|
18083
18130
|
await this.codeGenerationService.markJobAsCancelled(jobId);
|
|
18084
18131
|
await (0, utils_1.updateAllRunningTasks)(jobId, ditto_codegen_types_12.Status.CANCELLED);
|
|
18085
|
-
logger_12.logger.info("[Job] Marked job as CANCELLED"
|
|
18132
|
+
logger_12.logger.info("[Job] Marked job as CANCELLED");
|
|
18086
18133
|
process.exit();
|
|
18087
18134
|
}
|
|
18088
18135
|
this.start(jobId);
|
|
18089
18136
|
} catch (error) {
|
|
18090
18137
|
logger_12.logger.error("[Job] Error checking job status", {
|
|
18091
|
-
jobId,
|
|
18092
18138
|
error: error instanceof Error ? error.message : String(error)
|
|
18093
18139
|
});
|
|
18094
18140
|
this.start(jobId);
|
|
@@ -18127,20 +18173,16 @@ var require_job_timeout_monitor = __commonJS({
|
|
|
18127
18173
|
}
|
|
18128
18174
|
async handleTimeout(jobId) {
|
|
18129
18175
|
logger_12.logger.error("[Job] Job exceeded timeout", {
|
|
18130
|
-
jobId,
|
|
18131
18176
|
timeoutMs: exports2.JOB_TIMEOUT_MS
|
|
18132
18177
|
});
|
|
18133
18178
|
try {
|
|
18134
|
-
logger_12.logger.info("[Job] Timeout detected, exiting"
|
|
18179
|
+
logger_12.logger.info("[Job] Timeout detected, exiting");
|
|
18135
18180
|
await (0, utils_1.updateAllRunningTasks)(jobId, ditto_codegen_types_12.Status.FAILED, new ditto_codegen_types_12.TimeoutError(`Job exceeded timeout of ${exports2.JOB_TIMEOUT_MS}ms`));
|
|
18136
18181
|
await this.codeGenerationService.markJobAsCompleted(jobId);
|
|
18137
|
-
logger_12.logger.info("[Job] Marked job as completed, failed all running tasks"
|
|
18138
|
-
jobId
|
|
18139
|
-
});
|
|
18182
|
+
logger_12.logger.info("[Job] Marked job as completed, failed all running tasks");
|
|
18140
18183
|
process.exit();
|
|
18141
18184
|
} catch (error) {
|
|
18142
18185
|
logger_12.logger.error("[Job] Failed to mark timed-out job as completed", {
|
|
18143
|
-
jobId,
|
|
18144
18186
|
error: error instanceof Error ? error.message : String(error)
|
|
18145
18187
|
});
|
|
18146
18188
|
}
|
|
@@ -18194,7 +18236,8 @@ var require_skills_installer = __commonJS({
|
|
|
18194
18236
|
if (stderr && !stderr.includes("npm warn")) {
|
|
18195
18237
|
log.warn("[Skills] Installation stderr", { stderr });
|
|
18196
18238
|
}
|
|
18197
|
-
log
|
|
18239
|
+
console.log("[Skills] Skills installed successfully\n", stdout);
|
|
18240
|
+
log.debug("[Skills] Skills installed successfully", { stdout });
|
|
18198
18241
|
} catch (error) {
|
|
18199
18242
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
18200
18243
|
log.error("[Skills] Failed to install skills", { error: errorMessage });
|
|
@@ -18276,7 +18319,7 @@ var alwaysOnLoop = async () => {
|
|
|
18276
18319
|
continue;
|
|
18277
18320
|
}
|
|
18278
18321
|
const job = jobs[0];
|
|
18279
|
-
logger_1.logger.
|
|
18322
|
+
logger_1.logger.info("Job details", { job });
|
|
18280
18323
|
if (!job.id) {
|
|
18281
18324
|
throw new ditto_codegen_types_1.MissingJobIdError();
|
|
18282
18325
|
}
|
|
@@ -18305,7 +18348,9 @@ async function initOpenCode() {
|
|
|
18305
18348
|
}
|
|
18306
18349
|
async function main(ctx) {
|
|
18307
18350
|
logger_1.logger.info("[Startup] CodeGen CLI starting", {
|
|
18308
|
-
projectId: ctx.projectId
|
|
18351
|
+
projectId: ctx.projectId,
|
|
18352
|
+
appNameSpace: ctx.appNamespace,
|
|
18353
|
+
codeIdentifier: ctx.codeIdentifier
|
|
18309
18354
|
});
|
|
18310
18355
|
await initOpenCode();
|
|
18311
18356
|
await alwaysOnLoop();
|
|
@@ -18323,18 +18368,22 @@ async function processJob(job) {
|
|
|
18323
18368
|
logger_1.logger.warn("[Job] No initial task found, skipping", { jobId });
|
|
18324
18369
|
return;
|
|
18325
18370
|
}
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
|
|
18329
|
-
|
|
18330
|
-
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
jobLog.debug("Task Payload", { payload: task.payload });
|
|
18334
|
-
await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind }, async () => {
|
|
18371
|
+
await job_context_storage_1.jobContextStorage.run({ jobId, taskId: task.id, kind: task.kind }, async () => {
|
|
18372
|
+
logger_1.logger.info("[Job] Start processing", { taskKind: task.kind });
|
|
18373
|
+
context_1.ctx.setJobStatus(jobId, CodeGenService_1.Status.RUNNING);
|
|
18374
|
+
logger_1.logger.info("[Job] Marked job RUNNING", { initTaskId: task.id });
|
|
18375
|
+
jobCancellationMonitor.start(jobId);
|
|
18376
|
+
jobTimeoutMonitor.start(jobId);
|
|
18377
|
+
try {
|
|
18335
18378
|
const payload = task.payload ?? {};
|
|
18336
18379
|
const history = payload.history ?? [];
|
|
18337
18380
|
const blueprint = payload.blueprint;
|
|
18381
|
+
if (blueprint) {
|
|
18382
|
+
logger_1.logger.info("Task blueprint", { blueprint });
|
|
18383
|
+
}
|
|
18384
|
+
if (history.length > 0) {
|
|
18385
|
+
logger_1.logger.info("Task history", { history: history.slice(-5) });
|
|
18386
|
+
}
|
|
18338
18387
|
if (task.kind === CodeGenService_1.TaskKind.ASK_CODEGEN) {
|
|
18339
18388
|
await (0, opencode_ask_1.runOpencodeAskFlow)(history);
|
|
18340
18389
|
} else if (task.kind === CodeGenService_1.TaskKind.ITERATE_CODEGEN) {
|
|
@@ -18342,11 +18391,11 @@ async function processJob(job) {
|
|
|
18342
18391
|
} else if (task.kind === CodeGenService_1.TaskKind.INIT_CODEGEN && blueprint) {
|
|
18343
18392
|
await (0, opencode_init_1.runOpencodeInitFlow)(blueprint, history);
|
|
18344
18393
|
}
|
|
18345
|
-
}
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
}
|
|
18394
|
+
} finally {
|
|
18395
|
+
jobCancellationMonitor.stop();
|
|
18396
|
+
jobTimeoutMonitor.stop();
|
|
18397
|
+
}
|
|
18398
|
+
});
|
|
18350
18399
|
}
|
|
18351
18400
|
(0, context_1.initCtx)().then((ctx) => {
|
|
18352
18401
|
main(ctx);
|
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.285",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"@wix/ditto-codegen": "1.0.0",
|
|
28
28
|
"esbuild": "^0.27.2"
|
|
29
29
|
},
|
|
30
|
-
"falconPackageHash": "
|
|
30
|
+
"falconPackageHash": "82fdf19541855b8bcfaf5dc954f1d7afc0a2a0549bfbecd2e2ce7421"
|
|
31
31
|
}
|