@wix/ditto-codegen-public 1.0.486 → 1.0.488

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 +118 -32
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -13884,7 +13884,7 @@ var require_site = __commonJS({
13884
13884
  "../codegen-common-logic/dist/tool-policies/site.js"(exports2) {
13885
13885
  "use strict";
13886
13886
  Object.defineProperty(exports2, "__esModule", { value: true });
13887
- exports2.SITE_POLICIES = exports2.SITE_PACKAGE_LOCK_POLICY = exports2.SITE_DATA_COLLECTION_GENERATE_POLICY = exports2.STORES_VERSIONING_POLICY = void 0;
13887
+ exports2.SITE_POLICIES = exports2.BACKEND_MONITORING_READ_POLICY = exports2.BACKEND_MONITORING_GENERATE_POLICY = exports2.SITE_PACKAGE_LOCK_POLICY = exports2.SITE_DATA_COLLECTION_GENERATE_POLICY = exports2.STORES_VERSIONING_POLICY = void 0;
13888
13888
  exports2.STORES_VERSIONING_POLICY = {
13889
13889
  type: "read",
13890
13890
  mode: "prepend",
@@ -13907,10 +13907,31 @@ var require_site = __commonJS({
13907
13907
  ],
13908
13908
  message: `BLOCKED: do not disable the package lockfile (--package-lock=false, --package-lock false, --no-package-lock). Run the install without it; if the packages are heavy, install them in several smaller commands (the sandbox has a memory limit).`
13909
13909
  };
13910
+ var BACKEND_MONITORING_MESSAGE = `BACKEND MONITORING: if this job writes or edits a backend extension (service plugin, backend event or backend API endpoint), invoke the wix-backend-monitoring skill before writing its handler code and follow it: every handler is wrapped with its monitoring helper, and your final message tells the user about the monitoring logs.`;
13911
+ exports2.BACKEND_MONITORING_GENERATE_POLICY = {
13912
+ type: "generateOutput",
13913
+ extensionTypes: ["SERVICE_PLUGIN", "EVENT", "HTTP_ENDPOINT"],
13914
+ message: BACKEND_MONITORING_MESSAGE
13915
+ };
13916
+ exports2.BACKEND_MONITORING_READ_POLICY = {
13917
+ type: "read",
13918
+ mode: "prepend",
13919
+ isInstruction: true,
13920
+ pathFragments: [
13921
+ "wix-app/references/SERVICE_PLUGIN",
13922
+ "wix-app/references/service-plugin/",
13923
+ "wix-app/references/BACKEND_EVENT",
13924
+ "wix-app/references/backend-event/",
13925
+ "wix-app/references/BACKEND_API"
13926
+ ],
13927
+ message: BACKEND_MONITORING_MESSAGE
13928
+ };
13910
13929
  exports2.SITE_POLICIES = [
13911
13930
  exports2.STORES_VERSIONING_POLICY,
13912
13931
  exports2.SITE_DATA_COLLECTION_GENERATE_POLICY,
13913
- exports2.SITE_PACKAGE_LOCK_POLICY
13932
+ exports2.SITE_PACKAGE_LOCK_POLICY,
13933
+ exports2.BACKEND_MONITORING_GENERATE_POLICY,
13934
+ exports2.BACKEND_MONITORING_READ_POLICY
13914
13935
  ];
13915
13936
  }
13916
13937
  });
@@ -15412,6 +15433,16 @@ var require_config = __commonJS({
15412
15433
  function usesOpenAiProvider() {
15413
15434
  return (0, model_knobs_1.isOpenAiModel)((0, model_knobs_1.getModel)()) || (0, model_knobs_1.isOpenAiModel)((0, model_knobs_1.getSmallModel)());
15414
15435
  }
15436
+ function getModelStubs(provider) {
15437
+ const prefix = `${provider}/`;
15438
+ const stubs = {};
15439
+ for (const model of [(0, model_knobs_1.getModel)(), (0, model_knobs_1.getSmallModel)()]) {
15440
+ if (model.startsWith(prefix)) {
15441
+ stubs[model.slice(prefix.length)] = {};
15442
+ }
15443
+ }
15444
+ return stubs;
15445
+ }
15415
15446
  function usesGoogleProvider() {
15416
15447
  return (0, model_knobs_1.isGoogleModel)((0, model_knobs_1.getModel)()) || (0, model_knobs_1.isGoogleModel)((0, model_knobs_1.getSmallModel)());
15417
15448
  }
@@ -15453,6 +15484,7 @@ var require_config = __commonJS({
15453
15484
  // authorize the project.
15454
15485
  ...currentAccessToken ? { Authorization: `Bearer ${currentAccessToken}` } : {}
15455
15486
  };
15487
+ const anthropicModels = getModelStubs("anthropic");
15456
15488
  const provider = {
15457
15489
  anthropic: {
15458
15490
  options: {
@@ -15460,7 +15492,8 @@ var require_config = __commonJS({
15460
15492
  cacheControl: true,
15461
15493
  headers,
15462
15494
  chunkTimeout: exports2.PROVIDER_CHUNK_TIMEOUT_MS
15463
- }
15495
+ },
15496
+ ...Object.keys(anthropicModels).length > 0 ? { models: anthropicModels } : {}
15464
15497
  }
15465
15498
  };
15466
15499
  if (usesOpenAiProvider()) {
@@ -15473,7 +15506,8 @@ var require_config = __commonJS({
15473
15506
  baseURL: getOpenAiBaseUrl(projectId),
15474
15507
  headers,
15475
15508
  chunkTimeout: exports2.PROVIDER_CHUNK_TIMEOUT_MS
15476
- }
15509
+ },
15510
+ models: getModelStubs("openai")
15477
15511
  };
15478
15512
  }
15479
15513
  if (usesGoogleProvider()) {
@@ -15496,7 +15530,8 @@ var require_config = __commonJS({
15496
15530
  "gemini-3.1-flash-lite": {},
15497
15531
  "gemini-2.5-pro": {},
15498
15532
  "gemini-2.5-flash": {},
15499
- "gemini-2.5-flash-lite": {}
15533
+ "gemini-2.5-flash-lite": {},
15534
+ ...getModelStubs("google")
15500
15535
  }
15501
15536
  };
15502
15537
  }
@@ -17817,7 +17852,16 @@ var require_executor = __commonJS({
17817
17852
  }
17818
17853
  function buildArgs(prompt, continueSession) {
17819
17854
  const sessionArgs = continueSession ? ["--continue"] : [];
17820
- return ["run", ...sessionArgs, "--format", "json", prompt];
17855
+ return [
17856
+ "run",
17857
+ ...sessionArgs,
17858
+ "--print-logs",
17859
+ "--log-level",
17860
+ "ERROR",
17861
+ "--format",
17862
+ "json",
17863
+ prompt
17864
+ ];
17821
17865
  }
17822
17866
  async function executeOpenCodeOnce(options, attempt, maxAttempts, toolUsage) {
17823
17867
  const { prompt, outputPath, projectId, onStdout, onStderr, continueSession = false } = options;
@@ -25002,16 +25046,21 @@ var require_tool_policies3 = __commonJS({
25002
25046
  "dist/opencode-integration/plugins/tool-policies.js"(exports2) {
25003
25047
  "use strict";
25004
25048
  Object.defineProperty(exports2, "__esModule", { value: true });
25005
- exports2.TOOL_POLICIES_FILENAME = exports2.GENERATE_CMD_RE = void 0;
25049
+ exports2.TOOL_POLICIES_FILENAME = exports2.SCAFFOLD_CMD_RE = exports2.GENERATE_CMD_RE = void 0;
25006
25050
  exports2.buildToolPoliciesPluginSource = buildToolPoliciesPluginSource;
25007
25051
  exports2.writeToolPoliciesPlugin = writeToolPoliciesPlugin;
25008
25052
  var ditto_codegen_types_12 = require_dist4();
25009
25053
  var write_plugin_1 = require_write_plugin();
25010
25054
  exports2.GENERATE_CMD_RE = /\bwix\s+(schema\s+)?generate\b/;
25055
+ exports2.SCAFFOLD_CMD_RE = /\bwix\s+generate\b/;
25011
25056
  exports2.TOOL_POLICIES_FILENAME = "tool-policies.ts";
25012
25057
  function buildToolPoliciesPluginSource(policies) {
25013
25058
  const emitKind = (type, toRuntime, extraFilter = () => true) => JSON.stringify(policies.filter((policy) => policy.type === type).filter(extraFilter).map(toRuntime));
25014
- const emitReads = (mode) => emitKind("read", ({ pathFragments, message }) => ({ pathFragments, message }), (policy) => policy.mode === mode);
25059
+ const emitReads = (mode) => emitKind("read", ({ pathFragments, isInstruction, message }) => ({
25060
+ pathFragments,
25061
+ isInstruction,
25062
+ message
25063
+ }), (policy) => policy.mode === mode);
25015
25064
  const generatePolicies = emitKind("generate", ({ blockedExtensionTypes, whenArgsInclude, message }) => ({
25016
25065
  blockedExtensionTypes,
25017
25066
  whenArgsInclude,
@@ -25026,6 +25075,7 @@ var require_tool_policies3 = __commonJS({
25026
25075
  skillNames,
25027
25076
  message
25028
25077
  }));
25078
+ const generateOutputPrepends = emitKind("generateOutput", ({ extensionTypes, message }) => ({ extensionTypes, message }));
25029
25079
  return `// Generated by @wix/ditto-codegen (tool-policies). Do not edit.
25030
25080
  const BLOCK_READS = ${emitReads("block")};
25031
25081
  const PREPEND_READS = ${emitReads("prepend")};
@@ -25033,10 +25083,11 @@ const GENERATE_POLICIES = ${generatePolicies};
25033
25083
  const COMMAND_PREPENDS = ${commandPrepends};
25034
25084
  const COMMAND_BLOCKS = ${commandBlocks};
25035
25085
  const SKILL_PREPENDS = ${skillPrepends};
25036
- // Appended once after every prepend banner (see OVERRIDE_AUTHORITY_NOTE):
25037
- // part of the override contract, so no policy can ship without it.
25086
+ const GENERATE_OUTPUT_PREPENDS = ${generateOutputPrepends};
25087
+ // See OVERRIDE_AUTHORITY_NOTE.
25038
25088
  const AUTHORITY_NOTE = ${JSON.stringify(ditto_codegen_types_12.OVERRIDE_AUTHORITY_NOTE)};
25039
25089
  const GENERATE_CMD_RE = /${exports2.GENERATE_CMD_RE.source}/;
25090
+ const SCAFFOLD_CMD_RE = /${exports2.SCAFFOLD_CMD_RE.source}/;
25040
25091
 
25041
25092
  function extractReadPaths(tool, args) {
25042
25093
  if (tool === "${"read"}") {
@@ -25056,6 +25107,26 @@ function matchingPolicies(policies, paths) {
25056
25107
  );
25057
25108
  }
25058
25109
 
25110
+ // Params of every extension a wix-generate call scaffolds, skipping entries
25111
+ // with no extension type.
25112
+ function wixGenerateParams(tool, args) {
25113
+ if (tool !== "${"wix-generate"}" || !Array.isArray(args.extensions)) {
25114
+ return [];
25115
+ }
25116
+ return args.extensions
25117
+ .map((extension) => extension?.params)
25118
+ .filter((params) => typeof params?.extensionType === "string");
25119
+ }
25120
+
25121
+ // The bash command when it is a \`wix generate\` / \`wix schema generate\` call.
25122
+ function generateCommandOf(tool, args) {
25123
+ return tool === "${"bash"}" &&
25124
+ typeof args.command === "string" &&
25125
+ GENERATE_CMD_RE.test(args.command)
25126
+ ? args.command
25127
+ : null;
25128
+ }
25129
+
25059
25130
  function generateArgsMatch(policy, haystack) {
25060
25131
  return (
25061
25132
  !policy.whenArgsInclude ||
@@ -25081,30 +25152,23 @@ export const ToolPolicies = async () => ({
25081
25152
  }
25082
25153
 
25083
25154
  if (GENERATE_POLICIES.length === 0) return;
25084
- if (input.tool === "${"wix-generate"}" && Array.isArray(args.extensions)) {
25085
- for (const extension of args.extensions) {
25086
- const type = extension?.params?.extensionType;
25087
- if (typeof type !== "string") continue;
25088
- const params = JSON.stringify(extension.params);
25089
- for (const policy of GENERATE_POLICIES) {
25090
- if (
25091
- policy.blockedExtensionTypes.includes(type) &&
25092
- generateArgsMatch(policy, params)
25093
- ) {
25094
- throw new Error(policy.message);
25095
- }
25155
+ for (const params of wixGenerateParams(input.tool, args)) {
25156
+ const serialized = JSON.stringify(params);
25157
+ for (const policy of GENERATE_POLICIES) {
25158
+ if (
25159
+ policy.blockedExtensionTypes.includes(params.extensionType) &&
25160
+ generateArgsMatch(policy, serialized)
25161
+ ) {
25162
+ throw new Error(policy.message);
25096
25163
  }
25097
25164
  }
25098
25165
  }
25099
- if (
25100
- input.tool === "${"bash"}" &&
25101
- typeof args.command === "string" &&
25102
- GENERATE_CMD_RE.test(args.command)
25103
- ) {
25166
+ const generateCommand = generateCommandOf(input.tool, args);
25167
+ if (generateCommand) {
25104
25168
  for (const policy of GENERATE_POLICIES) {
25105
25169
  if (
25106
- policy.blockedExtensionTypes.some((type) => args.command.includes(type)) &&
25107
- generateArgsMatch(policy, args.command)
25170
+ policy.blockedExtensionTypes.some((type) => generateCommand.includes(type)) &&
25171
+ generateArgsMatch(policy, generateCommand)
25108
25172
  ) {
25109
25173
  throw new Error(policy.message);
25110
25174
  }
@@ -25130,10 +25194,32 @@ export const ToolPolicies = async () => ({
25130
25194
  ...SKILL_PREPENDS.filter((policy) => policy.skillNames.includes(args.name)),
25131
25195
  );
25132
25196
  }
25133
- if (matched.length === 0) return;
25197
+ const scaffoldedTypes = wixGenerateParams(input.tool, args).map(
25198
+ (params) => params.extensionType,
25199
+ );
25200
+ // Each \`wix generate\` in a chained command, never \`wix schema generate\`.
25201
+ const scaffoldCommands = (generateCommandOf(input.tool, args) ?? "")
25202
+ .replace(/\\\\\\n/g, " ")
25203
+ .split(/&&|\\|\\||[;|\\n]/)
25204
+ .filter((command) => SCAFFOLD_CMD_RE.test(command));
25205
+ // The type as a whole token, so EVENT doesn't match EVENT_BANNER, myEVENT or my-EVENT.
25206
+ const commandScaffolds = (type) =>
25207
+ scaffoldCommands.some((command) =>
25208
+ new RegExp("(^|[^A-Za-z0-9_-])" + type + "($|[^A-Za-z0-9_-])").test(command),
25209
+ );
25210
+ const notes = GENERATE_OUTPUT_PREPENDS.filter((policy) =>
25211
+ policy.extensionTypes.some(
25212
+ (type) => scaffoldedTypes.includes(type) || commandScaffolds(type),
25213
+ ),
25214
+ );
25215
+ if (matched.length === 0 && notes.length === 0) return;
25216
+ const overrides = matched.filter((policy) => !policy.isInstruction);
25217
+ const instructions = matched.filter((policy) => policy.isInstruction);
25134
25218
  output.output = [
25135
- ...matched.map((policy) => policy.message),
25136
- AUTHORITY_NOTE,
25219
+ ...overrides.map((policy) => policy.message),
25220
+ ...(overrides.length > 0 ? [AUTHORITY_NOTE] : []),
25221
+ ...instructions.map((policy) => policy.message),
25222
+ ...notes.map((policy) => policy.message),
25137
25223
  output.output,
25138
25224
  ].join("\\n\\n");
25139
25225
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.486",
3
+ "version": "1.0.488",
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": "1b494ad5c94e590dd50dee8ea922629e3834489ac04d797778b3ccd4"
32
+ "falconPackageHash": "c37b983430cb070a2e2715a56d16e90b778a276e1ff7416661982b2b"
33
33
  }