@wix/ditto-codegen-public 1.0.506 → 1.0.508

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 CHANGED
@@ -13886,14 +13886,10 @@ var require_checkpoint = __commonJS({
13886
13886
  "use strict";
13887
13887
  Object.defineProperty(exports2, "__esModule", { value: true });
13888
13888
  exports2.checkpointPluginFactory = void 0;
13889
- var fs_1 = require("fs");
13890
- var path_12 = require("path");
13891
13889
  var http_1 = require_http_impl2();
13892
13890
  var types_1 = require_types_impl3();
13893
13891
  var http_client_1 = require_index_node();
13894
13892
  var ditto_codegen_types_12 = require_dist4();
13895
- var FALLBACK_COMMIT_MESSAGE = "Auto-save";
13896
- var SET_COMMIT_MESSAGE_TOOL = "set-commit-message";
13897
13893
  var MAX_CHECKPOINT_ERROR_LENGTH = 1e3;
13898
13894
  var TRUNCATION_SUFFIX = "\u2026";
13899
13895
  var COMMON_CONFIG_BY_ENVIRONMENT = {
@@ -13903,20 +13899,6 @@ var require_checkpoint = __commonJS({
13903
13899
  const mapping = process.env.CODEGEN_ENVIRONMENT ? COMMON_CONFIG_BY_ENVIRONMENT[process.env.CODEGEN_ENVIRONMENT] : void 0;
13904
13900
  return mapping ? encodeURIComponent(JSON.stringify(mapping)) : void 0;
13905
13901
  })();
13906
- var ASSETS_DIR = (0, path_12.join)(__dirname, "..", "assets");
13907
- var readAsset = (name) => (0, fs_1.readFileSync)((0, path_12.join)(ASSETS_DIR, name), "utf-8");
13908
- var buildCheckpointRules = () => [
13909
- {
13910
- filename: "checkpoint-commit-message.md",
13911
- content: readAsset("commit-message-rule.md")
13912
- }
13913
- ];
13914
- var buildCheckpointTools = () => [
13915
- {
13916
- filename: "set-commit-message.ts",
13917
- source: readAsset("set-commit-message.ts")
13918
- }
13919
- ];
13920
13902
  var truncate = (value, maxLength) => {
13921
13903
  if (value.length <= maxLength)
13922
13904
  return value;
@@ -14009,15 +13991,6 @@ Likely cause: a context provider's or function library's moduleSpecifier either
14009
13991
  }));
14010
13992
  return resp.data?.jobId ?? void 0;
14011
13993
  };
14012
- var readToolCommitMessage = (input) => {
14013
- if (typeof input !== "object" || input === null)
14014
- return void 0;
14015
- const value = input.commitMessage;
14016
- if (typeof value !== "string")
14017
- return void 0;
14018
- const trimmed = value.trim();
14019
- return trimmed.length > 0 ? trimmed : void 0;
14020
- };
14021
13994
  var checkpointPluginFactory = (ctx) => {
14022
13995
  const { host, job } = ctx;
14023
13996
  const accessToken = host.auth.getAccessToken();
@@ -14029,8 +14002,7 @@ Likely cause: a context provider's or function library's moduleSpecifier either
14029
14002
  }
14030
14003
  });
14031
14004
  let outcome;
14032
- let capturedCommitMessage;
14033
- const commitCheckpoint = async (commitMessage) => {
14005
+ const commitCheckpoint = async () => {
14034
14006
  if (!job)
14035
14007
  return;
14036
14008
  try {
@@ -14043,8 +14015,7 @@ Likely cause: a context provider's or function library's moduleSpecifier either
14043
14015
  projectId: job.projectId,
14044
14016
  checkpointId,
14045
14017
  commitHash,
14046
- overrideId,
14047
- commitMessage
14018
+ overrideId
14048
14019
  });
14049
14020
  } catch (error) {
14050
14021
  const checkpointExists = outcome?.status === "created";
@@ -14119,20 +14090,6 @@ Likely cause: a context provider's or function library's moduleSpecifier either
14119
14090
  };
14120
14091
  return {
14121
14092
  name: "checkpoint",
14122
- rules: buildCheckpointRules(),
14123
- tools: buildCheckpointTools(),
14124
- // The agent calls `set-commit-message` (registered as a host tool from
14125
- // the plugin's `tools` field) as the first thing it does. We capture the
14126
- // value here and use it for the checkpoint at flow end.
14127
- async onToolUse({ tool, state }) {
14128
- if (state.status === "error")
14129
- return;
14130
- if (tool !== SET_COMMIT_MESSAGE_TOOL)
14131
- return;
14132
- const message = readToolCommitMessage(state.input);
14133
- if (message)
14134
- capturedCommitMessage = message;
14135
- },
14136
14093
  // Creates the checkpoint once the flow is over. Throws on failure, which
14137
14094
  // the runner reports as a plugin failure. A conflict handed off to AI
14138
14095
  // resolution is not a failure.
@@ -14141,8 +14098,7 @@ Likely cause: a context provider's or function library's moduleSpecifier either
14141
14098
  return;
14142
14099
  if (!filesChanged)
14143
14100
  return;
14144
- const commitMessage = capturedCommitMessage ?? FALLBACK_COMMIT_MESSAGE;
14145
- await commitCheckpoint(commitMessage);
14101
+ await commitCheckpoint();
14146
14102
  }
14147
14103
  };
14148
14104
  };
@@ -14198,7 +14154,8 @@ var require_dist8 = __commonJS({
14198
14154
  plugins: [codegen_checkpoint_plugin_1.checkpointPluginFactory],
14199
14155
  toolPolicies: [...codegen_common_logic_1.SITE_POLICIES, ...codegen_common_logic_1.STUDIO_2_POLICIES],
14200
14156
  chargingMode: "app",
14201
- moduleSpecifierPrefix: ditto_codegen_types_12.COMPANION_APP_MODULE_SPECIFIER_PREFIX
14157
+ moduleSpecifierPrefix: ditto_codegen_types_12.COMPANION_APP_MODULE_SPECIFIER_PREFIX,
14158
+ requiredPermissions: false
14202
14159
  };
14203
14160
  }
14204
14161
  });
@@ -14553,7 +14510,8 @@ var require_dist10 = __commonJS({
14553
14510
  decisionCheckers: [],
14554
14511
  plugins: [codegen_feature_vibe_plugin_1.featureVibePluginFactory],
14555
14512
  toolPolicies: codegen_common_logic_1.SITE_POLICIES,
14556
- chargingMode: "app"
14513
+ chargingMode: "app",
14514
+ requiredPermissions: true
14557
14515
  };
14558
14516
  }
14559
14517
  });
@@ -14697,7 +14655,28 @@ var require_codegen_rules = __commonJS({
14697
14655
  toolRule: "- `validate` (tsc + build + editor-component manifests) \u2014 you call it yourself at step 5. Do NOT delegate it.",
14698
14656
  step: `5. **Validate**: Call \`validate({ runBuild: true })\` yourself \u2014 it typechecks, builds, and generates manifests when editor components exist (tsc runs first and fails fast before the build). Fix any errors and re-run until it passes. Pass installDeps: true only if package.json changed and npm install was not already run in this session. Do NOT delegate this to a subagent, and do NOT make a separate tsc-only call first \u2014 the single runBuild pass already fails fast on type errors. NEVER force a green build: no \`as any\`, no \`@ts-ignore\`, no NEW \`@ts-expect-error\`, no switching a correct named import to \`import * as\`, and no changing runtime behaviour (e.g. unwanted \`defaultProps\` values) or deleting the failing code just to satisfy tsc. Do NOT move on until validation is clean. Do NOT inspect extension types or run \`npx wix generate manifest\` directly; \`validate\` handles manifest generation when editor components exist. Once validation is clean, run any further post-build checks the skill requires; if one makes you change code, re-run \`validate\`.`
14699
14657
  };
14700
- var buildCoreRules = (validation) => `CORE PRINCIPLES:
14658
+ var DECLARED_PERMISSIONS = {
14659
+ toolRule: "- `required-permissions` \u2014 declare the Wix app permissions the generated code needs (when/whether to call: workflow step 6 + PERMISSIONS).\n",
14660
+ step: "6. **Declare permissions**: If the generated code requires Wix app permissions, call `required-permissions` ONCE with their SCOPE IDs (see PERMISSIONS below). Skip this step entirely if no permissions are needed.\n",
14661
+ reportDocsStep: 7,
14662
+ finalMessageRef: " (see PERMISSIONS)",
14663
+ section: `PERMISSIONS:
14664
+ When you call \`required-permissions\` (see workflow step 6 for when), use SCOPE ID format (not human-readable names). Examples:
14665
+ - \`@wix/data\` read \u2192 "SCOPE.DC-DATA.READ", write \u2192 "SCOPE.DC-DATA.WRITE"
14666
+ - Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
14667
+
14668
+ CRITICAL: Only include permissions you have explicitly seen in the Wix SDK documentation (via MCP or loaded skills) \u2014 NEVER guess or infer a scope ID. If you cannot point to where you saw it, do NOT include it. When in doubt, skip the call entirely. A fabricated scope ID will show an error to the user and confuse them; a missing permission is just a warning the user can fix.
14669
+
14670
+ The \`required-permissions\` tool records and surfaces permissions to the user automatically \u2014 NEVER mention permissions/scopes (IDs or names) in your output, or tell the user to grant them.`
14671
+ };
14672
+ var FULL_PERMISSIONS = {
14673
+ toolRule: "",
14674
+ step: "",
14675
+ reportDocsStep: 6,
14676
+ finalMessageRef: "",
14677
+ section: "Every Wix API permission scope is already granted on this site. Never declare, request or mention permission scopes. Still set collection permissions and use `auth.elevate()` where the code needs them."
14678
+ };
14679
+ var buildCoreRules = (validation, permissions) => `CORE PRINCIPLES:
14701
14680
  - Do NOT invent or assume new types, modules, functions, props, events, or imports.
14702
14681
  - Do NOT leave mocks, placeholders, debug logging, or TODOs in code the user did not ask for. When the user explicitly asks for logs, debug output, or mock/sample data, add them as requested.
14703
14682
  - ALWAYS implement complete, production-ready functionality.
@@ -14712,11 +14691,10 @@ TOOL USAGE:
14712
14691
  ${validation.toolRule}
14713
14692
  - \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
14714
14693
  - \`wix-generate\` to scaffold extensions non-interactively \u2014 prefer over hand-writing boilerplate; pass an array to scaffold several at once. It RETURNS every created file's contents, so trust that and do NOT \`read\`/\`batch-read\` them afterward. On a \`FAILED\` block, fix the params per the error and retry.
14715
- - \`required-permissions\` \u2014 declare the Wix app permissions the generated code needs (when/whether to call: workflow step 6 + PERMISSIONS).
14716
- ${(0, shared_rules_1.buildFileOperationsRules)("fixing type errors")}
14694
+ ${permissions.toolRule}${(0, shared_rules_1.buildFileOperationsRules)("fixing type errors")}
14717
14695
  - API discovery (shapes, method signatures, types) \u2014 in this order: (1) loaded skills + KNOWN WIX APIS, if they already cover the API; (2) wix-mcp, yourself: \`SearchWixSDKDocumentation\` to find the method, then \`ReadFullDocsMethodSchema\` for its exact exported name, options object, response fields, enum values and scope IDs \u2014 the schema is the source of truth; an article or its examples are not. Model the call on the SDK view, not REST, and use the direct form inside the extension: \`import { <namespace> } from "@wix/<pkg>"; await <namespace>.<method>(<options>)\` \u2014 never \`createClient\`. Note any setup the docs require from the user (an app to install, a dashboard setting to enable) for the final message. For WDS components/props, use the \`wix-design-system\` skill; (3) grepping \`node_modules\` ONLY as a last resort if the above return nothing \u2014 SDK internals are not a documentation source, and doing it first wastes turns, inflates context, and is unreliable.
14718
14696
  - NEVER write a Wix SDK method, field, or enum value you haven't seen in a skill or a method schema.
14719
- - \`report-wix-feedback\` \u2014 report problems with the Wix docs (dev.wix.com, via wix-mcp) or the wix-mcp tools to Wix (when: workflow step 7). NOT for skill references or your own code.
14697
+ - \`report-wix-feedback\` \u2014 report problems with the Wix docs (dev.wix.com, via wix-mcp) or the wix-mcp tools to Wix (when: workflow step ${permissions.reportDocsStep}). NOT for skill references or your own code.
14720
14698
  - NEVER run preview, dev, release, or promote commands.
14721
14699
  - The ONE exception to YOUR BOUNDARIES' ban on uploading files: when the \`wix-app\` skill tells you to run its \`upload-media.cjs\` script, run it. It puts the user's images into the site's Media Manager and prints the \`{ uri, url }\` an \`Image\` default needs, which makes it part of writing code. Run no other script that changes the site \u2014 publishing, releasing, deleting, and every other product/platform action stay off-limits.
14722
14700
 
@@ -14730,10 +14708,9 @@ IMPLEMENTATION WORKFLOW:
14730
14708
  3. **Build**: Write files incrementally \u2014 group by logical section, NOT all at once. For complex tasks (300+ total lines across files), split into multiple \`batch-write\` calls. NEVER hold back writing until all code is planned \u2014 write each logical piece as soon as it is ready. Build all extensions before registering.
14731
14709
  4. **Register**: Register all extensions in \`src/extensions.ts\`.
14732
14710
  ${validation.step}
14733
- 6. **Declare permissions**: If the generated code requires Wix app permissions, call \`required-permissions\` ONCE with their SCOPE IDs (see PERMISSIONS below). Skip this step entirely if no permissions are needed.
14734
- 7. **Report docs problems**: Skip this step if you already called \`report-wix-feedback\` this run. Otherwise look back at the run: if ANY of these happened, call it ONCE covering all of them: (a) you inspected \`node_modules\` to find a Wix SDK signature, shape, or type because the docs didn't give you one that compiles; (b) the validator fixed a Wix SDK call you wrote from a dev.wix.com doc \u2014 read its summary; (c) a dev.wix.com example, article, or schema contradicted the installed SDK types; (d) a search's top results were off-target, or a wix-mcp tool failed. For each: the dev.wix.com URL or search term, what it showed, and what actually worked. A gap in a skill reference is not a wix-mcp problem \u2014 don't report it here.
14735
- 8. **Final message**: Your last message is returned to the user as the codegen output \u2014 keep it short and plain (a sentence or two on what the app now does). Do NOT mention permissions/scopes here (see PERMISSIONS) and follow OUTPUT MESSAGE below.
14736
- 9. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
14711
+ ${permissions.step}${permissions.reportDocsStep}. **Report docs problems**: Skip this step if you already called \`report-wix-feedback\` this run. Otherwise look back at the run: if ANY of these happened, call it ONCE covering all of them: (a) you inspected \`node_modules\` to find a Wix SDK signature, shape, or type because the docs didn't give you one that compiles; (b) the validator fixed a Wix SDK call you wrote from a dev.wix.com doc \u2014 read its summary; (c) a dev.wix.com example, article, or schema contradicted the installed SDK types; (d) a search's top results were off-target, or a wix-mcp tool failed. For each: the dev.wix.com URL or search term, what it showed, and what actually worked. A gap in a skill reference is not a wix-mcp problem \u2014 don't report it here.
14712
+ ${permissions.reportDocsStep + 1}. **Final message**: Your last message is returned to the user as the codegen output \u2014 keep it short and plain (a sentence or two on what the app now does). Do NOT mention permissions/scopes here${permissions.finalMessageRef} and follow OUTPUT MESSAGE below.
14713
+ ${permissions.reportDocsStep + 2}. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
14737
14714
 
14738
14715
  FILE CREATION:
14739
14716
  - NEVER rewrite the same file twice. Once written, move on. Exception: see PORTING ATTACHED CODE.
@@ -14754,23 +14731,17 @@ GENERATED FILES:
14754
14731
  TYPESCRIPT:
14755
14732
  - The project enables \`verbatimModuleSyntax\`. Type-only imports MUST use \`import type\`.
14756
14733
 
14757
- PERMISSIONS:
14758
- When you call \`required-permissions\` (see workflow step 6 for when), use SCOPE ID format (not human-readable names). Examples:
14759
- - \`@wix/data\` read \u2192 "SCOPE.DC-DATA.READ", write \u2192 "SCOPE.DC-DATA.WRITE"
14760
- - Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
14761
-
14762
- CRITICAL: Only include permissions you have explicitly seen in the Wix SDK documentation (via MCP or loaded skills) \u2014 NEVER guess or infer a scope ID. If you cannot point to where you saw it, do NOT include it. When in doubt, skip the call entirely. A fabricated scope ID will show an error to the user and confuse them; a missing permission is just a warning the user can fix.
14763
-
14764
- The \`required-permissions\` tool records and surfaces permissions to the user automatically \u2014 NEVER mention permissions/scopes (IDs or names) in your output, or tell the user to grant them.`;
14734
+ ${permissions.section}`;
14765
14735
  function isValidatorSubagentSkipped() {
14766
14736
  return (0, model_knobs_1.readEnumEnv)("CODEGEN_RULES_NO_VALIDATOR", ["0", "1"]) !== "0";
14767
14737
  }
14768
- function buildCodegenRules(environmentIdentity) {
14738
+ function buildCodegenRules(environmentIdentity, isRequiredPermissionsStepOn) {
14769
14739
  const validation = isValidatorSubagentSkipped() ? DIRECT_VALIDATION : DELEGATED_VALIDATION;
14740
+ const permissions = isRequiredPermissionsStepOn ? DECLARED_PERMISSIONS : FULL_PERMISSIONS;
14770
14741
  return [
14771
14742
  (0, shared_rules_1.buildEnvironmentRules)(environmentIdentity),
14772
14743
  shared_rules_1.BOUNDARY_RULES,
14773
- buildCoreRules(validation),
14744
+ buildCoreRules(validation, permissions),
14774
14745
  `${shared_rules_1.OUTPUT_MESSAGE_RULES}
14775
14746
  ${shared_rules_1.OUTCOME_MESSAGE_RULES}`
14776
14747
  ].join("\n\n");
@@ -14994,6 +14965,7 @@ var require_environments = __commonJS({
14994
14965
  "dist/environments/index.js"(exports2) {
14995
14966
  "use strict";
14996
14967
  Object.defineProperty(exports2, "__esModule", { value: true });
14968
+ exports2.isRequiredPermissionsStepOn = isRequiredPermissionsStepOn;
14997
14969
  exports2.getValidatedCodegenEnvironment = getValidatedCodegenEnvironment;
14998
14970
  exports2.getModuleSpecifierPrefix = getModuleSpecifierPrefix;
14999
14971
  exports2.getCodegenEnvironmentConfig = getCodegenEnvironmentConfig;
@@ -15006,16 +14978,20 @@ var require_environments = __commonJS({
15006
14978
  var git_conflicts_rules_1 = require_git_conflicts_rules();
15007
14979
  var install_manifest_1 = require_install_manifest();
15008
14980
  var telemetry_tools_1 = require_telemetry_tools();
14981
+ var model_knobs_1 = require_model_knobs();
15009
14982
  var job_decision_manager_1 = require_job_decision_manager();
15010
14983
  var logger_12 = require_logger();
15011
14984
  var SHARED_GIT_CONFLICTS_RULE = {
15012
14985
  filename: "git-conflicts-instructions.md",
15013
14986
  content: git_conflicts_rules_1.GIT_CONFLICTS_RULES
15014
14987
  };
14988
+ function isRequiredPermissionsStepOn(env) {
14989
+ return (0, model_knobs_1.readEnumEnv)("CODEGEN_REQUIRED_PERMISSIONS", ["1"]) === "1" || env.requiredPermissions !== false;
14990
+ }
15015
14991
  var withSharedRules = (env) => {
15016
14992
  const sharedCodegenRule = {
15017
14993
  filename: install_manifest_1.SHARED_CODEGEN_RULE_FILENAME,
15018
- content: (0, codegen_rules_1.buildCodegenRules)(env.environmentIdentity)
14994
+ content: (0, codegen_rules_1.buildCodegenRules)(env.environmentIdentity, isRequiredPermissionsStepOn(env))
15019
14995
  };
15020
14996
  const sharedAskRule = {
15021
14997
  filename: "ask-instructions.md",
@@ -15732,6 +15708,13 @@ var require_config = __commonJS({
15732
15708
  doom_loop: "allow",
15733
15709
  external_directory: READABLE_EXTERNAL_DIRS
15734
15710
  };
15711
+ var CODEGEN_PERMISSIONS_WITHOUT_REQUIRED_PERMISSIONS = {
15712
+ ...CODEGEN_PERMISSIONS,
15713
+ [
15714
+ "required-permissions"
15715
+ /* OpenCodeTool.RequiredPermissions */
15716
+ ]: "deny"
15717
+ };
15735
15718
  var GIT_CONFLICTS_PERMISSIONS = {
15736
15719
  ...CODEGEN_PERMISSIONS,
15737
15720
  [
@@ -15858,7 +15841,7 @@ var require_config = __commonJS({
15858
15841
  withAgents: true
15859
15842
  });
15860
15843
  default:
15861
- return buildConfig(projectId, paths(env.codegenRules), CODEGEN_PERMISSIONS, {
15844
+ return buildConfig(projectId, paths(env.codegenRules), (0, environments_12.isRequiredPermissionsStepOn)(env) ? CODEGEN_PERMISSIONS : CODEGEN_PERMISSIONS_WITHOUT_REQUIRED_PERMISSIONS, {
15862
15845
  isCodeWritingFlow: true,
15863
15846
  withAgents: true
15864
15847
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.506",
3
+ "version": "1.0.508",
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": "b2f55e937e5a2443079e7546b98e2cb12825f8463d333faf94f47389"
32
+ "falconPackageHash": "3269b77fd09c5f5b225c740bf3fcf6668ad10d240b6b7ba42fc45b0e"
33
33
  }
@@ -1,23 +0,0 @@
1
- import { tool } from "@opencode-ai/plugin";
2
-
3
- export default tool({
4
- description:
5
- "Set the commit message for this codegen run. The message becomes the " +
6
- "subject of a real `git commit -m` for the run, visible to " +
7
- "non-technical users in their checkpoint history. Call this once, as " +
8
- "the first thing you do, before writing any code.",
9
- args: {
10
- commitMessage: tool.schema
11
- .string()
12
- .min(1)
13
- .describe(
14
- "One-line summary of the user's request. " +
15
- 'Imperative mood (e.g. "Add", "Fix", "Update"). ' +
16
- "No trailing period, no quotes, no prefix. " +
17
- "Ideally under 150 characters.",
18
- ),
19
- },
20
- async execute(args) {
21
- return `Commit message set: ${args.commitMessage}`;
22
- },
23
- });