@wix/ditto-codegen-public 1.0.400 → 1.0.402

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.
Files changed (2) hide show
  1. package/dist/out.js +116 -10
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -6594,6 +6594,7 @@ var require_http_impl = __commonJS({
6594
6594
  exports2.stopGeneration = stopGeneration;
6595
6595
  exports2.submitUserDecision = submitUserDecision;
6596
6596
  exports2.cleanupStaleJobs = cleanupStaleJobs;
6597
+ exports2.handleValidationErrors = handleValidationErrors;
6597
6598
  var metro_runtime_1 = require_build();
6598
6599
  var ambassador_1 = require_ambassador_index();
6599
6600
  var metro_runtime_2 = require_build();
@@ -6605,6 +6606,8 @@ var require_http_impl = __commonJS({
6605
6606
  var _createTaskResponse = { job: "_job" };
6606
6607
  var _getJobRequest = {};
6607
6608
  var _getJobResponse = { job: "_job" };
6609
+ var _handleValidationErrorsRequest = { costUsd: "DOUBLE" };
6610
+ var _handleValidationErrorsResponse = {};
6608
6611
  var _job = {
6609
6612
  createdAt: "google.protobuf.Timestamp",
6610
6613
  updatedAt: "google.protobuf.Timestamp",
@@ -7025,6 +7028,33 @@ var require_http_impl = __commonJS({
7025
7028
  __cleanupStaleJobs.__isAmbassador = true;
7026
7029
  return __cleanupStaleJobs;
7027
7030
  }
7031
+ function handleValidationErrors(payload) {
7032
+ var _a = (0, ambassador_1.serializer)(_handleValidationErrorsRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
7033
+ var fromRes = (0, ambassador_1.serializer)(_handleValidationErrorsResponse, {}).fromJSON;
7034
+ function __handleValidationErrors(_a2) {
7035
+ var host = _a2.host;
7036
+ var serializedData = toReq(payload);
7037
+ var metadata = {
7038
+ entityFqdn: "wix.ctp.codegen_job_service.v1.job",
7039
+ method: "POST",
7040
+ methodFqn: "com.wixpress.ditto.codegen_job_service.api.CodegenJobService.HandleValidationErrors",
7041
+ migrationOptions: {
7042
+ optInTransformResponse: true
7043
+ },
7044
+ url: resolveComWixpressDittoCodegenJobServiceApiCodegenJobServiceUrl({
7045
+ protoPath: "/v1/validation-errors",
7046
+ data: serializedData,
7047
+ host
7048
+ }),
7049
+ data: serializedData,
7050
+ transformResponse: fromRes
7051
+ };
7052
+ return metadata;
7053
+ }
7054
+ __handleValidationErrors.fromReq = fromReq;
7055
+ __handleValidationErrors.__isAmbassador = true;
7056
+ return __handleValidationErrors;
7057
+ }
7028
7058
  }
7029
7059
  });
7030
7060
 
@@ -11054,6 +11084,16 @@ var require_CodeGenService = __commonJS({
11054
11084
  }));
11055
11085
  return resp.data?.job ?? null;
11056
11086
  };
11087
+ this.handleValidationErrors = async (output, context) => {
11088
+ await this.request((0, http_1.handleValidationErrors)({
11089
+ output,
11090
+ jobId: context?.jobId ?? "",
11091
+ projectId: this.projectId,
11092
+ metasiteId: context?.metasiteId ?? "",
11093
+ costUsd: context?.costUsd,
11094
+ durationMs: context?.durationMs != null ? String(context.durationMs) : void 0
11095
+ }));
11096
+ };
11057
11097
  if (httpClient) {
11058
11098
  this.httpClient = httpClient;
11059
11099
  return;
@@ -11524,16 +11564,16 @@ var require_subagents = __commonJS({
11524
11564
  "dist/opencode-integration/subagents.js"(exports2) {
11525
11565
  "use strict";
11526
11566
  Object.defineProperty(exports2, "__esModule", { value: true });
11527
- exports2.PRIMARY_AGENT_NAME = void 0;
11567
+ exports2.VALIDATOR_SUBAGENT_NAME = exports2.PRIMARY_AGENT_NAME = void 0;
11528
11568
  exports2.getAgentConfig = getAgentConfig;
11529
11569
  var types_1 = require_types4();
11530
11570
  var constants_1 = require_constants5();
11531
11571
  exports2.PRIMARY_AGENT_NAME = "codegen";
11532
- var VALIDATOR_SUBAGENT_NAME = "codegen-validator";
11572
+ exports2.VALIDATOR_SUBAGENT_NAME = "codegen-validator";
11533
11573
  var WIX_DOCS_SUBAGENT_NAME = "codegen-wix-docs";
11534
11574
  var WDS_DOCS_SUBAGENT_NAME = "codegen-wds-docs";
11535
11575
  var VALIDATOR_DESCRIPTION = `Runs validate (tsc + wix build) and fixes the reported errors, consulting the
11536
- wix-app skill / wix-mcp for SDK-shape errors; returns when the build is clean
11576
+ skills or wix-mcp for SDK-shape errors; returns when the build is clean
11537
11577
  or reports what it couldn't fix. Validation step only \u2014 never generates features.`;
11538
11578
  var VALIDATOR_PROMPT = `Run 'validate({ runBuild: true })', fix the errors it reports, and re-run until
11539
11579
  it passes. You are fixing EXISTING code \u2014 do NOT add features or rewrite whole
@@ -11542,12 +11582,16 @@ files. NEVER force a green build by suppressing types: no 'as any', no
11542
11582
  'import { bookings } from "@wix/bookings"') to 'import * as' just to satisfy
11543
11583
  tsc \u2014 that ships code that compiles but breaks at runtime. A type error on a
11544
11584
  Wix SDK method/namespace/parameter means the call is WRONG: look up the correct
11545
- usage via the 'wix-app' skill or wix-mcp ('SearchWixSDKDocumentation' \u2192
11585
+ usage via skills or wix-mcp ('SearchWixSDKDocumentation' \u2192
11546
11586
  'ReadFullDocsMethodSchema') and fix it to the real exported method + its options
11547
11587
  object. Work in a bounded number of fix cycles \u2014 if the build isn't converging
11548
11588
  after a few attempts, STOP and return the remaining errors verbatim rather than
11549
- looping; never silence them.`;
11550
- var WIX_DOCS_DESCRIPTION = `Use ONLY to discover a Wix SDK you don't know and that the wix-app skill +
11589
+ looping; never silence them.
11590
+
11591
+ When done, summarize each error: message, file, root cause, fix. No diffs.
11592
+ If you fixed 2+ errors or any remain unfixed, add exactly: NEEDS_INVESTIGATION
11593
+ (This triggers a team alert to improve codegen for future runs.)`;
11594
+ var WIX_DOCS_DESCRIPTION = `Use ONLY to discover a Wix SDK you don't know and that the skills +
11551
11595
  KNOWN WIX APIS don't cover. Send ONE complete question; returns the import path
11552
11596
  + exported namespace/method + runtime context + full signature + any required
11553
11597
  scope/permission IDs + a short usage example (not a link). Don't fetch a doc you
@@ -11570,9 +11614,9 @@ the API is limited to one context, say so. For a required scope/permission,
11570
11614
  return the EXACT scope-ID string from the docs (never a guessed format); if none
11571
11615
  is documented, say so.`;
11572
11616
  var WDS_DOCS_DESCRIPTION = `Use ONLY when building dashboard UI and you need a Wix Design System
11573
- component/prop/example you don't know and the wix-app skill doesn't cover.
11617
+ component/prop/example you don't know and the skills don't cover.
11574
11618
  Returns the component name + props + a short usage example. Not for layouts the
11575
- wix-app skill already covers. Read-only.`;
11619
+ skills already cover. Read-only.`;
11576
11620
  var SUBAGENT_DENIED_TOOLS = {
11577
11621
  [
11578
11622
  "task"
@@ -11672,13 +11716,13 @@ wix-app skill already covers. Read-only.`;
11672
11716
  /* OpenCodeTool.Task */
11673
11717
  ]: {
11674
11718
  [types_1.PERMISSION_WILDCARD]: "deny",
11675
- [VALIDATOR_SUBAGENT_NAME]: "allow",
11719
+ [exports2.VALIDATOR_SUBAGENT_NAME]: "allow",
11676
11720
  [WIX_DOCS_SUBAGENT_NAME]: "allow",
11677
11721
  [WDS_DOCS_SUBAGENT_NAME]: "allow"
11678
11722
  }
11679
11723
  }
11680
11724
  },
11681
- [VALIDATOR_SUBAGENT_NAME]: {
11725
+ [exports2.VALIDATOR_SUBAGENT_NAME]: {
11682
11726
  mode: "subagent",
11683
11727
  model: smallModel,
11684
11728
  steps: 40,
@@ -15226,8 +15270,11 @@ var require_parser = __commonJS({
15226
15270
  exports2.parseUsageStats = parseUsageStats;
15227
15271
  exports2.mergeUsageStats = mergeUsageStats;
15228
15272
  exports2.hasSessionError = hasSessionError;
15273
+ exports2.shouldReportValidatorOutput = shouldReportValidatorOutput;
15274
+ exports2.parseValidatorTaskOutputs = parseValidatorTaskOutputs;
15229
15275
  exports2.summarizeOpenCodeLine = summarizeOpenCodeLine;
15230
15276
  var types_1 = require_types4();
15277
+ var subagents_1 = require_subagents();
15231
15278
  function parseRequiredPermissions(output) {
15232
15279
  let permissions = [];
15233
15280
  const lines = output.split("\n");
@@ -15345,6 +15392,26 @@ var require_parser = __commonJS({
15345
15392
  ...input.description && { description: truncate(input.description) }
15346
15393
  };
15347
15394
  }
15395
+ function shouldReportValidatorOutput(output) {
15396
+ return output.includes("NEEDS_INVESTIGATION");
15397
+ }
15398
+ function parseValidatorTaskOutputs(stdout) {
15399
+ const outputs = [];
15400
+ for (const line of stdout.split("\n")) {
15401
+ if (!line.trim())
15402
+ continue;
15403
+ const event = (0, types_1.tryParseJson)(line);
15404
+ if (!event || event.type !== "tool_use" || event.part?.tool !== "task" || event.part?.state?.status !== "completed") {
15405
+ continue;
15406
+ }
15407
+ const { title, output, input } = event.part.state;
15408
+ const isValidator = input?.subagent_type === subagents_1.VALIDATOR_SUBAGENT_NAME || title?.includes(subagents_1.VALIDATOR_SUBAGENT_NAME);
15409
+ if (isValidator && output) {
15410
+ outputs.push(output.trim());
15411
+ }
15412
+ }
15413
+ return outputs;
15414
+ }
15348
15415
  function summarizeOpenCodeLine(line) {
15349
15416
  if (line.type !== "tool_use") {
15350
15417
  return line;
@@ -15927,6 +15994,7 @@ var require_executor = __commonJS({
15927
15994
  var config_12 = require_config();
15928
15995
  var job_context_storage_12 = require_job_context_storage();
15929
15996
  var parser_1 = require_parser();
15997
+ var codeGenerationService_12 = require_codeGenerationService();
15930
15998
  var prompts_1 = require_prompts();
15931
15999
  var git_file_changes_1 = require_git_file_changes();
15932
16000
  var cost_tracker_1 = require_cost_tracker();
@@ -15935,6 +16003,42 @@ var require_executor = __commonJS({
15935
16003
  var process_handlers_1 = require_process_handlers();
15936
16004
  var logger_12 = require_logger();
15937
16005
  var MAX_RETRIES = 5;
16006
+ async function notifyValidatorOutputsToSlack(stdout, costUsd) {
16007
+ try {
16008
+ const store = job_context_storage_12.jobContextStorage.getStore();
16009
+ const outputs = (0, parser_1.parseValidatorTaskOutputs)(stdout);
16010
+ if (outputs.length === 0)
16011
+ return;
16012
+ const durationMs = store?.flowStartTime ? Date.now() - store.flowStartTime : void 0;
16013
+ const context = {
16014
+ jobId: store?.jobId,
16015
+ metasiteId: store?.metasiteId,
16016
+ costUsd: costUsd > 0 ? costUsd : void 0,
16017
+ durationMs
16018
+ };
16019
+ logger_12.logger.info("[OpenCode] Reporting validator outputs to Slack via server", {
16020
+ count: outputs.length,
16021
+ ...context
16022
+ });
16023
+ for (const output of outputs) {
16024
+ if (!(0, parser_1.shouldReportValidatorOutput)(output)) {
16025
+ logger_12.logger.info("[OpenCode] Skipping validator output \u2014 clean build or too few errors");
16026
+ continue;
16027
+ }
16028
+ try {
16029
+ await codeGenerationService_12.codeGenerationService.handleValidationErrors(output, context);
16030
+ } catch (err) {
16031
+ logger_12.logger.warn("[OpenCode] Failed to report validator output to Slack", {
16032
+ error: err instanceof Error ? err.message : String(err)
16033
+ });
16034
+ }
16035
+ }
16036
+ } catch (err) {
16037
+ logger_12.logger.warn("[OpenCode] Unexpected error in notifyValidatorOutputsToSlack", {
16038
+ error: err instanceof Error ? err.message : String(err)
16039
+ });
16040
+ }
16041
+ }
15938
16042
  async function executeOpenCode(options) {
15939
16043
  let lastResult = null;
15940
16044
  let accumulatedUsage = (0, parser_1.createEmptyUsageStats)();
@@ -15969,6 +16073,7 @@ var require_executor = __commonJS({
15969
16073
  skillsUsed: accumulatedSkills
15970
16074
  };
15971
16075
  logger_12.logger.info("[OpenCode] Usage summary", { usage: finalResult2.usage });
16076
+ void notifyValidatorOutputsToSlack(result.stdout, accumulatedUsage.cost);
15972
16077
  return finalResult2;
15973
16078
  }
15974
16079
  lastResult = result;
@@ -15989,6 +16094,7 @@ var require_executor = __commonJS({
15989
16094
  skillsUsed: Array.from(accumulatedSkills)
15990
16095
  };
15991
16096
  logger_12.logger.info("[OpenCode] Usage summary", { usage: finalResult.usage });
16097
+ void notifyValidatorOutputsToSlack(lastResult.stdout, accumulatedUsage.cost);
15992
16098
  return finalResult;
15993
16099
  }
15994
16100
  async function resolveFinalRunCost(usage, options, baselineCost) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.400",
3
+ "version": "1.0.402",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -29,5 +29,5 @@
29
29
  "esbuild": "^0.27.2",
30
30
  "vitest": "^4.0.16"
31
31
  },
32
- "falconPackageHash": "56e2d6ea84efd7e94a772c5ef8b1a809a34753f4fb8c03d8f7f07f84"
32
+ "falconPackageHash": "8556d9204c6f708d61f1eea28d679376b18a7da3a41be6f4bcfdbffe"
33
33
  }