@wix/ditto-codegen-public 1.0.437 → 1.0.438

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 +531 -141
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -543,8 +543,8 @@ var require_context = __commonJS({
543
543
  exports2.initCtx = exports2.ctx = void 0;
544
544
  var types_1 = require_types_impl();
545
545
  var dotenv_1 = __importDefault2(require_main());
546
- var path_1 = __importDefault2(require("path"));
547
- dotenv_1.default.config({ path: path_1.default.join(__dirname, "../.env"), override: true });
546
+ var path_12 = __importDefault2(require("path"));
547
+ dotenv_1.default.config({ path: path_12.default.join(__dirname, "../.env"), override: true });
548
548
  var HistoryManager = class {
549
549
  constructor() {
550
550
  this.history = [];
@@ -10949,6 +10949,16 @@ var require_plugins2 = __commonJS({
10949
10949
  }
10950
10950
  });
10951
10951
 
10952
+ // ../codegen-types/dist/types/tool-policies.js
10953
+ var require_tool_policies = __commonJS({
10954
+ "../codegen-types/dist/types/tool-policies.js"(exports2) {
10955
+ "use strict";
10956
+ Object.defineProperty(exports2, "__esModule", { value: true });
10957
+ exports2.OVERRIDE_AUTHORITY_NOTE = void 0;
10958
+ exports2.OVERRIDE_AUTHORITY_NOTE = `This override intentionally supersedes the wix-app reference docs and the Wix CLI schema output; do not spend turns re-verifying it against them.`;
10959
+ }
10960
+ });
10961
+
10952
10962
  // ../codegen-types/dist/types/job-payload.js
10953
10963
  var require_job_payload = __commonJS({
10954
10964
  "../codegen-types/dist/types/job-payload.js"(exports2) {
@@ -11010,6 +11020,7 @@ var require_dist4 = __commonJS({
11010
11020
  __exportStar2(require_decision(), exports2);
11011
11021
  __exportStar2(require_environment(), exports2);
11012
11022
  __exportStar2(require_plugins2(), exports2);
11023
+ __exportStar2(require_tool_policies(), exports2);
11013
11024
  __exportStar2(require_job_payload(), exports2);
11014
11025
  __exportStar2(require_logger2(), exports2);
11015
11026
  __exportStar2(require_ai(), exports2);
@@ -12029,11 +12040,11 @@ var require_rules_writer = __commonJS({
12029
12040
  exports2.writeRuleFiles = writeRuleFiles;
12030
12041
  var promises_1 = require("fs/promises");
12031
12042
  var os_1 = require("os");
12032
- var path_1 = require("path");
12043
+ var path_12 = require("path");
12033
12044
  var logger_12 = require_logger();
12034
- var GLOBAL_RULES_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "rules");
12045
+ var GLOBAL_RULES_DIR = (0, path_12.join)((0, os_1.homedir)(), ".config", "opencode", "rules");
12035
12046
  function getRulePath(filename) {
12036
- return (0, path_1.join)(GLOBAL_RULES_DIR, filename);
12047
+ return (0, path_12.join)(GLOBAL_RULES_DIR, filename);
12037
12048
  }
12038
12049
  async function writeRuleFiles(rules) {
12039
12050
  if (rules.length === 0) {
@@ -12051,6 +12062,26 @@ var require_rules_writer = __commonJS({
12051
12062
  }
12052
12063
  });
12053
12064
 
12065
+ // dist/opencode-integration/generated-plugins.js
12066
+ var require_generated_plugins = __commonJS({
12067
+ "dist/opencode-integration/generated-plugins.js"(exports2) {
12068
+ "use strict";
12069
+ Object.defineProperty(exports2, "__esModule", { value: true });
12070
+ exports2.OPENCODE_PLUGIN_DIR = void 0;
12071
+ exports2.writeGeneratedPlugin = writeGeneratedPlugin;
12072
+ var promises_1 = require("fs/promises");
12073
+ var os_1 = require("os");
12074
+ var path_12 = require("path");
12075
+ var logger_12 = require_logger();
12076
+ exports2.OPENCODE_PLUGIN_DIR = (0, path_12.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
12077
+ async function writeGeneratedPlugin(filename, source) {
12078
+ await (0, promises_1.mkdir)(exports2.OPENCODE_PLUGIN_DIR, { recursive: true });
12079
+ await (0, promises_1.writeFile)((0, path_12.join)(exports2.OPENCODE_PLUGIN_DIR, filename), source, "utf-8");
12080
+ logger_12.logger.info("[OpenCode] Wrote generated plugin", { plugin: filename });
12081
+ }
12082
+ }
12083
+ });
12084
+
12054
12085
  // dist/opencode-integration/node-modules-guard.js
12055
12086
  var require_node_modules_guard = __commonJS({
12056
12087
  "dist/opencode-integration/node-modules-guard.js"(exports2) {
@@ -12060,10 +12091,8 @@ var require_node_modules_guard = __commonJS({
12060
12091
  exports2.isSpelunkCommand = isSpelunkCommand;
12061
12092
  exports2.buildGuardPluginSource = buildGuardPluginSource;
12062
12093
  exports2.writeGuardPlugin = writeGuardPlugin;
12063
- var promises_1 = require("fs/promises");
12064
- var os_1 = require("os");
12065
- var path_1 = require("path");
12066
- var logger_12 = require_logger();
12094
+ var path_12 = require("path");
12095
+ var generated_plugins_1 = require_generated_plugins();
12067
12096
  var READ_VERB_RE = /(^|[\s|;&(])(grep|rg|cat|head|tail|sed|awk|less|more|strings|find)\b/;
12068
12097
  var SDK_INTERNALS_RE = /node_modules\/(@wix|vite|astro)\b/;
12069
12098
  exports2.MAX_SPELUNK_CALLS = 2;
@@ -12074,9 +12103,8 @@ For anything more (CSS-module/asset typing, component config, etc.), re-read the
12074
12103
  function isSpelunkCommand(command) {
12075
12104
  return READ_VERB_RE.test(command) && SDK_INTERNALS_RE.test(command);
12076
12105
  }
12077
- var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
12078
12106
  var GUARD_PLUGIN_FILENAME = "node-modules-guard.ts";
12079
- exports2.GUARD_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, GUARD_PLUGIN_FILENAME);
12107
+ exports2.GUARD_PLUGIN_PATH = (0, path_12.join)(generated_plugins_1.OPENCODE_PLUGIN_DIR, GUARD_PLUGIN_FILENAME);
12080
12108
  function buildGuardPluginSource() {
12081
12109
  return `// Generated by @wix/ditto-codegen (node-modules-guard) \u2014 do not edit.
12082
12110
  const READ_VERB_RE = /${READ_VERB_RE.source}/;
@@ -12103,11 +12131,7 @@ export const NodeModulesGuard = async () => ({
12103
12131
  `;
12104
12132
  }
12105
12133
  async function writeGuardPlugin() {
12106
- await (0, promises_1.mkdir)(GLOBAL_PLUGIN_DIR, { recursive: true });
12107
- await (0, promises_1.writeFile)(exports2.GUARD_PLUGIN_PATH, buildGuardPluginSource(), "utf-8");
12108
- logger_12.logger.info("[OpenCode] Wrote node_modules guard plugin", {
12109
- path: exports2.GUARD_PLUGIN_PATH
12110
- });
12134
+ await (0, generated_plugins_1.writeGeneratedPlugin)(GUARD_PLUGIN_FILENAME, buildGuardPluginSource());
12111
12135
  }
12112
12136
  }
12113
12137
  });
@@ -13257,7 +13281,7 @@ var require_checkpoint = __commonJS({
13257
13281
  Object.defineProperty(exports2, "__esModule", { value: true });
13258
13282
  exports2.checkpointPluginFactory = void 0;
13259
13283
  var fs_1 = require("fs");
13260
- var path_1 = require("path");
13284
+ var path_12 = require("path");
13261
13285
  var http_1 = require_http_impl2();
13262
13286
  var http_2 = require_http_impl3();
13263
13287
  var types_1 = require_types_impl3();
@@ -13274,8 +13298,8 @@ var require_checkpoint = __commonJS({
13274
13298
  const mapping = process.env.CODEGEN_ENVIRONMENT ? COMMON_CONFIG_BY_ENVIRONMENT[process.env.CODEGEN_ENVIRONMENT] : void 0;
13275
13299
  return mapping ? encodeURIComponent(JSON.stringify(mapping)) : void 0;
13276
13300
  })();
13277
- var ASSETS_DIR = (0, path_1.join)(__dirname, "..", "assets");
13278
- var readAsset = (name) => (0, fs_1.readFileSync)((0, path_1.join)(ASSETS_DIR, name), "utf-8");
13301
+ var ASSETS_DIR = (0, path_12.join)(__dirname, "..", "assets");
13302
+ var readAsset = (name) => (0, fs_1.readFileSync)((0, path_12.join)(ASSETS_DIR, name), "utf-8");
13279
13303
  var buildCheckpointRules = () => [
13280
13304
  {
13281
13305
  filename: "checkpoint-commit-message.md",
@@ -14688,76 +14712,200 @@ var require_system_prompts = __commonJS({
14688
14712
  }
14689
14713
  });
14690
14714
 
14691
- // ../codegen-common-logic/dist/site-data-layer-rules.js
14692
- var require_site_data_layer_rules = __commonJS({
14693
- "../codegen-common-logic/dist/site-data-layer-rules.js"(exports2) {
14715
+ // ../codegen-common-logic/dist/rules/site-data-layer.js
14716
+ var require_site_data_layer = __commonJS({
14717
+ "../codegen-common-logic/dist/rules/site-data-layer.js"(exports2) {
14694
14718
  "use strict";
14695
14719
  Object.defineProperty(exports2, "__esModule", { value: true });
14696
14720
  exports2.SITE_DATA_LAYER_RULES = void 0;
14697
14721
  exports2.SITE_DATA_LAYER_RULES = `# Site Data Layer Rules
14698
14722
 
14699
- The agent operates on a live Wix site (METASITE_ID is in your prompt context).
14700
-
14701
- ## Mandatory for data persistence
14702
-
14703
14723
  For any persistent-data need (CMS collections, tables, schemas, data models):
14704
14724
 
14705
- 1. **You MUST invoke the \`wix-site-data-collection\` skill first** \u2014 before scaffolding or writing collection code.
14706
- 2. **Do NOT** run \`wix generate\` with \`extensionType: DATA_COLLECTION\`, and do not create data-collection CLI extension files manually (e.g. \`src/extensions/backend/data-collections/*\`).
14725
+ 1. **You MUST invoke the \`wix-site-data-collection\` skill before scaffolding or writing any collection code.**
14726
+ 2. **Do NOT** create data-collection CLI extension files manually (e.g. \`src/extensions/backend/data-collections/*\`).
14707
14727
 
14708
- \`wix-app\` is still correct for dashboard pages, modals, widgets, and UI \u2014 only the data layer is overridden here.`;
14728
+ \`wix-app\` is still correct for dashboard pages, modals, widgets, and UI; only the data layer is overridden here.`;
14709
14729
  }
14710
14730
  });
14711
14731
 
14712
- // ../codegen-common-logic/dist/stores-catalog-version-rules.js
14713
- var require_stores_catalog_version_rules = __commonJS({
14714
- "../codegen-common-logic/dist/stores-catalog-version-rules.js"(exports2) {
14732
+ // ../codegen-common-logic/dist/rules/stores-catalog-version.js
14733
+ var require_stores_catalog_version = __commonJS({
14734
+ "../codegen-common-logic/dist/rules/stores-catalog-version.js"(exports2) {
14715
14735
  "use strict";
14716
14736
  Object.defineProperty(exports2, "__esModule", { value: true });
14717
14737
  exports2.STORES_CATALOG_VERSION_RULES = void 0;
14718
14738
  exports2.STORES_CATALOG_VERSION_RULES = `# Wix Stores Catalog Version Rules
14719
14739
 
14720
- The agent operates on a live Wix site (METASITE_ID is in your prompt context), so the site's Stores catalog version is knowable at build time.
14721
-
14722
- ## Mandatory before any Stores work
14723
-
14724
- For any use of a Wix Stores API \u2014 products, variants, inventory, collections/categories, Stores webhooks, or any other part of the Stores catalog:
14740
+ This site runs exactly ONE Stores catalog version, detectable at build time.
14725
14741
 
14726
- 1. **You MUST invoke the \`wix-stores-catalog-version\` skill first** \u2014 before choosing imports, permission scopes, or webhook subscriptions.
14727
- 2. **Generate one version's code path only.** No \`catalogVersioning.getCatalogVersion()\` call in generated code, no branching on the version, and no adapter that normalizes V1 and V3 shapes into one type.
14728
- 3. **Do NOT tell the user their app must support both catalog versions**, and do not add Dev Center action items about confirming V1/V3 compatibility. That requirement applies to public App Market apps, not to a companion app targeting one known site.
14729
-
14730
- \`wix-app\` is still correct for dashboard pages, modals, widgets, and UI \u2014 and its \`STORES_VERSIONING.md\` remains the reference for the module map, permissions, field mappings, and gotchas. Only the dual-catalog requirement is overridden here.`;
14742
+ For ANY use of a Wix Stores API (products, variants, inventory, collections/categories, Stores webhooks): you MUST invoke the \`wix-stores-catalog-version\` skill before choosing imports, permission scopes, or webhook subscriptions. It detects this site's catalog version; generate that version's code path only.`;
14731
14743
  }
14732
14744
  });
14733
14745
 
14734
- // ../codegen-common-logic/dist/studio-2-site-ui-rules.js
14735
- var require_studio_2_site_ui_rules = __commonJS({
14736
- "../codegen-common-logic/dist/studio-2-site-ui-rules.js"(exports2) {
14746
+ // ../codegen-common-logic/dist/rules/index.js
14747
+ var require_rules = __commonJS({
14748
+ "../codegen-common-logic/dist/rules/index.js"(exports2) {
14737
14749
  "use strict";
14750
+ var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
14751
+ if (k2 === void 0) k2 = k;
14752
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14753
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14754
+ desc = { enumerable: true, get: function() {
14755
+ return m[k];
14756
+ } };
14757
+ }
14758
+ Object.defineProperty(o, k2, desc);
14759
+ }) : (function(o, m, k, k2) {
14760
+ if (k2 === void 0) k2 = k;
14761
+ o[k2] = m[k];
14762
+ }));
14763
+ var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
14764
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding2(exports3, m, p);
14765
+ };
14738
14766
  Object.defineProperty(exports2, "__esModule", { value: true });
14739
- exports2.STUDIO_2_SITE_UI_RULES = void 0;
14740
- exports2.STUDIO_2_SITE_UI_RULES = `# Studio 2 Site UI Rules
14741
-
14742
- In the **Studio 2** environment, all site UI MUST be built as **Editor React Components** (\`extensionType: EDITOR_REACT_COMPONENT\`).
14743
-
14744
- - **Never create a Custom Element / site widget** (\`extensionType: CUSTOM_ELEMENT\`, \`CUSTOM_ELEMENT_WIDGET\`). This rule overrides the prompt \u2014 even if the prompt explicitly says "custom element", build it as an Editor React Component instead.
14745
- - The words "widget" and "custom element" in the prompt do **not** mean Custom Element \u2014 always implement them as Editor React Components.
14746
-
14747
- ## Studio 2 Site Plugin Restrictions
14767
+ __exportStar2(require_site_data_layer(), exports2);
14768
+ __exportStar2(require_stores_catalog_version(), exports2);
14769
+ }
14770
+ });
14748
14771
 
14749
- The following pages **no longer support site plugins** in Studio 2. **This overrides the site plugin skills reference** \u2014 even if SLOTS.md lists these pages as supported, do NOT use a site plugin for them:
14772
+ // ../codegen-common-logic/dist/site-environment.js
14773
+ var require_site_environment = __commonJS({
14774
+ "../codegen-common-logic/dist/site-environment.js"(exports2) {
14775
+ "use strict";
14776
+ Object.defineProperty(exports2, "__esModule", { value: true });
14777
+ exports2.SITE_CODEGEN_RULES = exports2.SITE_ENVIRONMENT_IDENTITY = void 0;
14778
+ var rules_1 = require_rules();
14779
+ exports2.SITE_ENVIRONMENT_IDENTITY = "You generate code for the user's own live Wix site \u2014 to the user it's just their site, not a separate app they're aware of. Your changes are saved and applied to the site automatically; there is no separate release step.";
14780
+ exports2.SITE_CODEGEN_RULES = [
14781
+ { filename: "site-data-layer-rules.md", content: rules_1.SITE_DATA_LAYER_RULES },
14782
+ {
14783
+ filename: "stores-catalog-version-rules.md",
14784
+ content: rules_1.STORES_CATALOG_VERSION_RULES
14785
+ }
14786
+ ];
14787
+ }
14788
+ });
14750
14789
 
14751
- - **Product Page (New Version)** (Wix Stores)
14752
- - **Product Page (Old Version)** (Wix Stores)
14753
- - **Service Page** (Wix Bookings)
14754
- - **Event Details Page** (Wix Events)
14790
+ // ../codegen-common-logic/dist/tool-policies/site.js
14791
+ var require_site = __commonJS({
14792
+ "../codegen-common-logic/dist/tool-policies/site.js"(exports2) {
14793
+ "use strict";
14794
+ Object.defineProperty(exports2, "__esModule", { value: true });
14795
+ exports2.SITE_POLICIES = exports2.SITE_DATA_COLLECTION_GENERATE_POLICY = exports2.STORES_VERSIONING_POLICY = void 0;
14796
+ exports2.STORES_VERSIONING_POLICY = {
14797
+ type: "read",
14798
+ mode: "prepend",
14799
+ pathFragments: ["wix-app/references/STORES_VERSIONING"],
14800
+ message: `ENVIRONMENT OVERRIDE (live site, single catalog): this site runs exactly ONE Stores catalog version. Ignore every dual-catalog instruction in this document: do not call catalogVersioning.getCatalogVersion(), do not branch on V1/V3, and do not tell the user their app must support both versions. Invoke the wix-stores-catalog-version skill to detect this site's version, then apply only that version's guidance from this document.`,
14801
+ driftMarkers: ["must support both"]
14802
+ };
14803
+ exports2.SITE_DATA_COLLECTION_GENERATE_POLICY = {
14804
+ type: "generate",
14805
+ blockedExtensionTypes: ["DATA_COLLECTION"],
14806
+ message: `BLOCKED: DATA_COLLECTION extensions are not scaffolded in this environment. Invoke the wix-site-data-collection skill to create or change collections. Do not retry with wix generate.`
14807
+ };
14808
+ exports2.SITE_POLICIES = [
14809
+ exports2.STORES_VERSIONING_POLICY,
14810
+ exports2.SITE_DATA_COLLECTION_GENERATE_POLICY
14811
+ ];
14812
+ }
14813
+ });
14755
14814
 
14756
- Build the appropriate Studio 2 extension instead:
14757
- - **Need to render UI on the page** \u2192 Editor React Component (\`extensionType: EDITOR_REACT_COMPONENT\`)
14758
- - **Need to expose shared data or state to components on the page (no UI)** \u2192 Context Provider (use the \`wix-cli-context-provider\` skill)
14815
+ // ../codegen-common-logic/dist/tool-policies/studio-2.js
14816
+ var require_studio_2 = __commonJS({
14817
+ "../codegen-common-logic/dist/tool-policies/studio-2.js"(exports2) {
14818
+ "use strict";
14819
+ Object.defineProperty(exports2, "__esModule", { value: true });
14820
+ exports2.STUDIO_2_POLICIES = exports2.STUDIO_2_CUSTOM_ELEMENT_GENERATE_POLICY = exports2.STUDIO_2_SITE_PLUGIN_SLOTS_GENERATE_POLICY = exports2.SITE_PLUGIN_SCHEMA_COMMAND_POLICY = exports2.STUDIO_2_SKILL_ROUTING_POLICY = exports2.SITE_PLUGIN_PAGES_POLICY = exports2.SITE_PLUGIN_REDIRECT = exports2.SITE_PLUGIN_UNSUPPORTED_PAGES = exports2.CUSTOM_ELEMENT_REFERENCES_POLICY = void 0;
14821
+ exports2.CUSTOM_ELEMENT_REFERENCES_POLICY = {
14822
+ type: "read",
14823
+ mode: "block",
14824
+ pathFragments: [
14825
+ "wix-app/references/CUSTOM_ELEMENT_WIDGET",
14826
+ "wix-app/references/custom-element-widget/"
14827
+ ],
14828
+ message: `BLOCKED: Custom Element widgets are not available in this environment. All site UI must be an Editor React Component (extensionType: EDITOR_REACT_COMPONENT). Read wix-app's references/EDITOR_REACT_COMPONENT.md instead. Do not retry this read.`
14829
+ };
14830
+ exports2.SITE_PLUGIN_UNSUPPORTED_PAGES = `Product Page (New Version), Product Page (Old Version), Service Page (Wix Bookings), Event Details Page (Wix Events)`;
14831
+ exports2.SITE_PLUGIN_REDIRECT = `For UI on those pages build an Editor React Component; for shared data or state without UI use the wix-cli-context-provider skill. Site plugins remain supported on all other listed pages.`;
14832
+ var STUDIO_2_SITE_UI_ROUTING = `- All site UI MUST be an Editor React Component (\`extensionType: EDITOR_REACT_COMPONENT\`); Custom Elements (\`CUSTOM_ELEMENT\`, \`CUSTOM_ELEMENT_WIDGET\`) are unavailable in this environment, even if the prompt says "custom element" or "widget".
14833
+ - Site plugins are not supported on these pages: ${exports2.SITE_PLUGIN_UNSUPPORTED_PAGES}. ${exports2.SITE_PLUGIN_REDIRECT}`;
14834
+ exports2.SITE_PLUGIN_PAGES_POLICY = {
14835
+ type: "read",
14836
+ mode: "prepend",
14837
+ pathFragments: [
14838
+ "wix-app/references/SITE_PLUGIN",
14839
+ "wix-app/references/site-plugin/"
14840
+ ],
14841
+ message: `ENVIRONMENT OVERRIDE: site plugins are NOT supported on these pages in this environment, even where this document lists them: ${exports2.SITE_PLUGIN_UNSUPPORTED_PAGES}. ${exports2.SITE_PLUGIN_REDIRECT}`
14842
+ };
14843
+ exports2.STUDIO_2_SKILL_ROUTING_POLICY = {
14844
+ type: "skillContent",
14845
+ skillNames: ["wix-app"],
14846
+ message: `ENVIRONMENT OVERRIDE: this skill's extension-type routing does not fully apply in this environment. Where the content below says otherwise:
14847
+ ${STUDIO_2_SITE_UI_ROUTING}`
14848
+ };
14849
+ exports2.SITE_PLUGIN_SCHEMA_COMMAND_POLICY = {
14850
+ type: "commandOutput",
14851
+ commandFragments: ["wix schema generate", "SITE_PLUGIN"],
14852
+ message: `ENVIRONMENT OVERRIDE: this schema output includes slots on pages where site plugins are NOT supported in this environment: ${exports2.SITE_PLUGIN_UNSUPPORTED_PAGES}. Do not scaffold a site plugin into slots on those pages, even though the schema lists them. ${exports2.SITE_PLUGIN_REDIRECT}`
14853
+ };
14854
+ exports2.STUDIO_2_SITE_PLUGIN_SLOTS_GENERATE_POLICY = {
14855
+ type: "generate",
14856
+ blockedExtensionTypes: ["SITE_PLUGIN"],
14857
+ whenArgsInclude: [
14858
+ "6a25b678-53ec-4b37-a190-65fcd1ca1a63",
14859
+ // Product Page (New Version)
14860
+ "13a94f09-2766-3c40-4a32-8edb5acdd8bc",
14861
+ // Product Page (Old Version)
14862
+ "a91a0543-d4bd-4e6b-b315-9410aa27bcde",
14863
+ // Service Page (Wix Bookings)
14864
+ "14d2abc2-5350-6322-487d-8c16ff833c8a"
14865
+ // Event Details Page (Wix Events)
14866
+ ],
14867
+ driftSkill: "wix-app",
14868
+ message: `BLOCKED: site plugins are not supported on this page in this environment (${exports2.SITE_PLUGIN_UNSUPPORTED_PAGES}). ${exports2.SITE_PLUGIN_REDIRECT} Do not retry with another slot on the same page.`
14869
+ };
14870
+ exports2.STUDIO_2_CUSTOM_ELEMENT_GENERATE_POLICY = {
14871
+ type: "generate",
14872
+ blockedExtensionTypes: ["CUSTOM_ELEMENT", "CUSTOM_ELEMENT_WIDGET"],
14873
+ message: `BLOCKED: extensionType CUSTOM_ELEMENT / CUSTOM_ELEMENT_WIDGET cannot be generated in this environment. Build an Editor React Component (extensionType: EDITOR_REACT_COMPONENT) instead. Do not retry with a custom element type.`
14874
+ };
14875
+ exports2.STUDIO_2_POLICIES = [
14876
+ exports2.CUSTOM_ELEMENT_REFERENCES_POLICY,
14877
+ exports2.SITE_PLUGIN_PAGES_POLICY,
14878
+ exports2.SITE_PLUGIN_SCHEMA_COMMAND_POLICY,
14879
+ exports2.STUDIO_2_SKILL_ROUTING_POLICY,
14880
+ exports2.STUDIO_2_SITE_PLUGIN_SLOTS_GENERATE_POLICY,
14881
+ exports2.STUDIO_2_CUSTOM_ELEMENT_GENERATE_POLICY
14882
+ ];
14883
+ }
14884
+ });
14759
14885
 
14760
- Both can be combined when the use case requires rendering UI and sharing state.`;
14886
+ // ../codegen-common-logic/dist/tool-policies/index.js
14887
+ var require_tool_policies2 = __commonJS({
14888
+ "../codegen-common-logic/dist/tool-policies/index.js"(exports2) {
14889
+ "use strict";
14890
+ var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
14891
+ if (k2 === void 0) k2 = k;
14892
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14893
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14894
+ desc = { enumerable: true, get: function() {
14895
+ return m[k];
14896
+ } };
14897
+ }
14898
+ Object.defineProperty(o, k2, desc);
14899
+ }) : (function(o, m, k, k2) {
14900
+ if (k2 === void 0) k2 = k;
14901
+ o[k2] = m[k];
14902
+ }));
14903
+ var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) {
14904
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding2(exports3, m, p);
14905
+ };
14906
+ Object.defineProperty(exports2, "__esModule", { value: true });
14907
+ __exportStar2(require_site(), exports2);
14908
+ __exportStar2(require_studio_2(), exports2);
14761
14909
  }
14762
14910
  });
14763
14911
 
@@ -14801,9 +14949,9 @@ var require_dist7 = __commonJS({
14801
14949
  __exportStar2(require_commonUseCasesGuide(), exports2);
14802
14950
  __exportStar2(require_availableSdks(), exports2);
14803
14951
  __exportStar2(require_system_prompts(), exports2);
14804
- __exportStar2(require_site_data_layer_rules(), exports2);
14805
- __exportStar2(require_stores_catalog_version_rules(), exports2);
14806
- __exportStar2(require_studio_2_site_ui_rules(), exports2);
14952
+ __exportStar2(require_site_environment(), exports2);
14953
+ __exportStar2(require_rules(), exports2);
14954
+ __exportStar2(require_tool_policies2(), exports2);
14807
14955
  }
14808
14956
  });
14809
14957
 
@@ -14816,19 +14964,13 @@ var require_dist8 = __commonJS({
14816
14964
  var codegen_checkpoint_plugin_1 = require_dist6();
14817
14965
  var codegen_common_logic_1 = require_dist7();
14818
14966
  exports2.studio2CodegenConfig = {
14819
- environmentIdentity: "You generate code for the user's own live Wix site \u2014 to the user it's just their site, not a separate app they're aware of. Your changes are saved and applied to the site automatically; there is no separate release step.",
14820
- codegenRules: [
14821
- { filename: "site-data-layer-rules.md", content: codegen_common_logic_1.SITE_DATA_LAYER_RULES },
14822
- {
14823
- filename: "stores-catalog-version-rules.md",
14824
- content: codegen_common_logic_1.STORES_CATALOG_VERSION_RULES
14825
- },
14826
- { filename: "studio-2-site-ui-rules.md", content: codegen_common_logic_1.STUDIO_2_SITE_UI_RULES }
14827
- ],
14967
+ environmentIdentity: codegen_common_logic_1.SITE_ENVIRONMENT_IDENTITY,
14968
+ codegenRules: codegen_common_logic_1.SITE_CODEGEN_RULES,
14828
14969
  askRules: [],
14829
14970
  gitConflictsRules: [],
14830
14971
  decisionCheckers: [],
14831
14972
  plugins: [codegen_checkpoint_plugin_1.checkpointPluginFactory],
14973
+ toolPolicies: [...codegen_common_logic_1.SITE_POLICIES, ...codegen_common_logic_1.STUDIO_2_POLICIES],
14832
14974
  chargingMode: "app"
14833
14975
  };
14834
14976
  }
@@ -15025,7 +15167,7 @@ var require_feature_vibe_save = __commonJS({
15025
15167
  Object.defineProperty(exports2, "__esModule", { value: true });
15026
15168
  exports2.featureVibePluginFactory = void 0;
15027
15169
  var fs_1 = require("fs");
15028
- var path_1 = require("path");
15170
+ var path_12 = require("path");
15029
15171
  var http_1 = require_http_impl4();
15030
15172
  var http_client_1 = require_index_node();
15031
15173
  var FALLBACK_COMMIT_MESSAGE = "Auto-save";
@@ -15033,8 +15175,8 @@ var require_feature_vibe_save = __commonJS({
15033
15175
  var MAX_COMMIT_MESSAGE_LENGTH = 1e3;
15034
15176
  var TRUNCATION_SUFFIX = "\u2026";
15035
15177
  var FEATURE_VIBE_BASE_URL = "https://editor.wix.com";
15036
- var ASSETS_DIR = (0, path_1.join)(__dirname, "..", "assets");
15037
- var readAsset = (name) => (0, fs_1.readFileSync)((0, path_1.join)(ASSETS_DIR, name), "utf-8");
15178
+ var ASSETS_DIR = (0, path_12.join)(__dirname, "..", "assets");
15179
+ var readAsset = (name) => (0, fs_1.readFileSync)((0, path_12.join)(ASSETS_DIR, name), "utf-8");
15038
15180
  var buildSaveRules = () => [
15039
15181
  {
15040
15182
  filename: "save-commit-message.md",
@@ -15174,18 +15316,13 @@ var require_dist10 = __commonJS({
15174
15316
  var codegen_feature_vibe_plugin_1 = require_dist9();
15175
15317
  var codegen_common_logic_1 = require_dist7();
15176
15318
  exports2.harmonyCodegenConfig = {
15177
- environmentIdentity: "You generate code for the user's own live Wix site \u2014 to the user it's just their site, not a separate app they're aware of. Your changes are saved and applied to the site automatically; there is no separate release step.",
15178
- codegenRules: [
15179
- { filename: "site-data-layer-rules.md", content: codegen_common_logic_1.SITE_DATA_LAYER_RULES },
15180
- {
15181
- filename: "stores-catalog-version-rules.md",
15182
- content: codegen_common_logic_1.STORES_CATALOG_VERSION_RULES
15183
- }
15184
- ],
15319
+ environmentIdentity: codegen_common_logic_1.SITE_ENVIRONMENT_IDENTITY,
15320
+ codegenRules: codegen_common_logic_1.SITE_CODEGEN_RULES,
15185
15321
  askRules: [],
15186
15322
  gitConflictsRules: [],
15187
15323
  decisionCheckers: [],
15188
15324
  plugins: [codegen_feature_vibe_plugin_1.featureVibePluginFactory],
15325
+ toolPolicies: codegen_common_logic_1.SITE_POLICIES,
15189
15326
  chargingMode: "app"
15190
15327
  };
15191
15328
  }
@@ -15620,6 +15757,13 @@ var require_config = __commonJS({
15620
15757
  var READABLE_EXTERNAL_DIRS = {
15621
15758
  "/root/.agents/**": "allow",
15622
15759
  "/root/.claude/**": "allow",
15760
+ // Our generated rule files. Their content is already inlined into the system
15761
+ // prompt (via `instructions`) with the source path visible, so agents
15762
+ // sometimes read the file back "to verify the rule". Denying that read
15763
+ // auto-rejects in headless mode, which the retry loop classifies as a
15764
+ // session error and restarts the whole session, an expensive failure for a
15765
+ // harmless read.
15766
+ "/root/.config/opencode/rules/**": "allow",
15623
15767
  "/root/.opencode/**": "allow",
15624
15768
  "/tmp/**": "allow"
15625
15769
  };
@@ -15757,19 +15901,14 @@ var require_subagent_tool_logger = __commonJS({
15757
15901
  "dist/opencode-integration/subagent-tool-logger.js"(exports2) {
15758
15902
  "use strict";
15759
15903
  Object.defineProperty(exports2, "__esModule", { value: true });
15760
- exports2.SUBAGENT_TOOL_LOGGER_PLUGIN_PATH = exports2.SUBAGENT_STARTED_EVENT_TYPE = exports2.SUBAGENT_TOOL_EVENT_TYPE = void 0;
15904
+ exports2.SUBAGENT_STARTED_EVENT_TYPE = exports2.SUBAGENT_TOOL_EVENT_TYPE = void 0;
15761
15905
  exports2.buildSubagentToolLoggerPluginSource = buildSubagentToolLoggerPluginSource;
15762
15906
  exports2.writeSubagentToolLoggerPlugin = writeSubagentToolLoggerPlugin;
15763
- var promises_1 = require("fs/promises");
15764
- var os_1 = require("os");
15765
- var path_1 = require("path");
15766
- var logger_12 = require_logger();
15907
+ var generated_plugins_1 = require_generated_plugins();
15767
15908
  var subagents_1 = require_subagents();
15768
15909
  exports2.SUBAGENT_TOOL_EVENT_TYPE = "subagent_tool_use";
15769
15910
  exports2.SUBAGENT_STARTED_EVENT_TYPE = "subagent_started";
15770
- var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
15771
15911
  var PLUGIN_FILENAME = "subagent-tool-logger.ts";
15772
- exports2.SUBAGENT_TOOL_LOGGER_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, PLUGIN_FILENAME);
15773
15912
  function buildSubagentToolLoggerPluginSource() {
15774
15913
  return `// Generated by @wix/ditto-codegen (subagent-tool-logger) \u2014 do not edit.
15775
15914
  const EVENT_TYPE = ${JSON.stringify(exports2.SUBAGENT_TOOL_EVENT_TYPE)};
@@ -15883,11 +16022,7 @@ export const SubagentToolLogger = async () => {
15883
16022
  `;
15884
16023
  }
15885
16024
  async function writeSubagentToolLoggerPlugin() {
15886
- await (0, promises_1.mkdir)(GLOBAL_PLUGIN_DIR, { recursive: true });
15887
- await (0, promises_1.writeFile)(exports2.SUBAGENT_TOOL_LOGGER_PLUGIN_PATH, buildSubagentToolLoggerPluginSource(), "utf-8");
15888
- logger_12.logger.info("[OpenCode] Wrote subagent tool logger plugin", {
15889
- path: exports2.SUBAGENT_TOOL_LOGGER_PLUGIN_PATH
15890
- });
16025
+ await (0, generated_plugins_1.writeGeneratedPlugin)(PLUGIN_FILENAME, buildSubagentToolLoggerPluginSource());
15891
16026
  }
15892
16027
  }
15893
16028
  });
@@ -17301,14 +17436,14 @@ var require_collect_extensions_created = __commonJS({
17301
17436
  Object.defineProperty(exports2, "__esModule", { value: true });
17302
17437
  exports2.collectInsertedExtensionsMetadata = collectInsertedExtensionsMetadata;
17303
17438
  exports2.buildExtensionsJobPayload = buildExtensionsJobPayload;
17304
- var path_1 = require("path");
17439
+ var path_12 = require("path");
17305
17440
  var promises_1 = require("fs/promises");
17306
17441
  var ditto_codegen_types_12 = require_dist4();
17307
17442
  var constants_1 = require_constants5();
17308
17443
  var DATA_COLLECTION_MARKER = /import\s+(?:type\s+)?\{[^}]*\bDataCollection\b[^}]*\}\s+from\s+['"](?:@wix\/astro\/builders|@wix\/custom-extensions)['"]/;
17309
- var getExtensionDirectory = (extensionDefinitionPath) => `${path_1.posix.dirname(extensionDefinitionPath)}/`;
17444
+ var getExtensionDirectory = (extensionDefinitionPath) => `${path_12.posix.dirname(extensionDefinitionPath)}/`;
17310
17445
  var isFileInExtensionFolder = (filePath, extensionDefinitionPath) => filePath === extensionDefinitionPath || filePath.startsWith(getExtensionDirectory(extensionDefinitionPath));
17311
- var resolveFilePath = (outputPath, filePath) => (0, path_1.isAbsolute)(filePath) ? filePath : (0, path_1.join)(outputPath, filePath);
17446
+ var resolveFilePath = (outputPath, filePath) => (0, path_12.isAbsolute)(filePath) ? filePath : (0, path_12.join)(outputPath, filePath);
17312
17447
  var buildJobExtension = (definitionPath, extensionType, contentForTitle, titlePath, files) => ({
17313
17448
  path: definitionPath,
17314
17449
  extensionType,
@@ -17469,38 +17604,38 @@ var require_agent_io = __commonJS({
17469
17604
  exports2.writeAgentInput = writeAgentInput;
17470
17605
  exports2.readAgentOutput = readAgentOutput;
17471
17606
  var fs_1 = __importDefault2(require("fs"));
17472
- var path_1 = __importDefault2(require("path"));
17607
+ var path_12 = __importDefault2(require("path"));
17473
17608
  var logger_12 = require_logger();
17474
- var AGENT_INPUT_DIR = path_1.default.join(".wix", "agentInput");
17475
- var AGENT_OUTPUT_DIR = path_1.default.join(".wix", "agentOutput");
17609
+ var AGENT_INPUT_DIR = path_12.default.join(".wix", "agentInput");
17610
+ var AGENT_OUTPUT_DIR = path_12.default.join(".wix", "agentOutput");
17476
17611
  function ensureEmptyJsonDir(dir) {
17477
17612
  fs_1.default.mkdirSync(dir, { recursive: true });
17478
17613
  for (const file of fs_1.default.readdirSync(dir)) {
17479
17614
  if (file.endsWith(".json")) {
17480
- fs_1.default.unlinkSync(path_1.default.join(dir, file));
17615
+ fs_1.default.unlinkSync(path_12.default.join(dir, file));
17481
17616
  }
17482
17617
  }
17483
17618
  }
17484
17619
  function writeAgentInput(outputPath, agentData) {
17485
- const inputDir = path_1.default.join(outputPath, AGENT_INPUT_DIR);
17486
- const outputDir = path_1.default.join(outputPath, AGENT_OUTPUT_DIR);
17620
+ const inputDir = path_12.default.join(outputPath, AGENT_INPUT_DIR);
17621
+ const outputDir = path_12.default.join(outputPath, AGENT_OUTPUT_DIR);
17487
17622
  ensureEmptyJsonDir(inputDir);
17488
17623
  ensureEmptyJsonDir(outputDir);
17489
17624
  if (!agentData)
17490
17625
  return;
17491
17626
  for (const [key, value] of Object.entries(agentData)) {
17492
- fs_1.default.writeFileSync(path_1.default.join(inputDir, `${key}.json`), JSON.stringify({ [key]: value }));
17627
+ fs_1.default.writeFileSync(path_12.default.join(inputDir, `${key}.json`), JSON.stringify({ [key]: value }));
17493
17628
  }
17494
17629
  }
17495
17630
  function readAgentOutput(outputPath) {
17496
- const outputDir = path_1.default.join(outputPath, AGENT_OUTPUT_DIR);
17631
+ const outputDir = path_12.default.join(outputPath, AGENT_OUTPUT_DIR);
17497
17632
  if (!fs_1.default.existsSync(outputDir))
17498
17633
  return {};
17499
17634
  const merged = {};
17500
17635
  for (const file of fs_1.default.readdirSync(outputDir)) {
17501
17636
  if (!file.endsWith(".json"))
17502
17637
  continue;
17503
- const filePath = path_1.default.join(outputDir, file);
17638
+ const filePath = path_12.default.join(outputDir, file);
17504
17639
  const raw = fs_1.default.readFileSync(filePath, "utf-8").trim();
17505
17640
  if (!raw)
17506
17641
  continue;
@@ -17530,7 +17665,7 @@ var require_codegen_flow_helpers = __commonJS({
17530
17665
  exports2.buildFailedRunPayload = buildFailedRunPayload;
17531
17666
  exports2.updateParentTaskStatus = updateParentTaskStatus;
17532
17667
  exports2.getOutputPath = getOutputPath;
17533
- var path_1 = __importDefault2(require("path"));
17668
+ var path_12 = __importDefault2(require("path"));
17534
17669
  var codeGenerationService_12 = require_codeGenerationService();
17535
17670
  var git_file_changes_1 = require_git_file_changes();
17536
17671
  var collect_extensions_created_1 = require_collect_extensions_created();
@@ -17558,7 +17693,7 @@ var require_codegen_flow_helpers = __commonJS({
17558
17693
  }
17559
17694
  function getOutputPath() {
17560
17695
  const outputDir = process.env.OUTPUT_PATH || DEFAULT_OUTPUT_PATH;
17561
- return outputDir.startsWith("/") ? outputDir : path_1.default.join(process.cwd(), outputDir);
17696
+ return outputDir.startsWith("/") ? outputDir : path_12.default.join(process.cwd(), outputDir);
17562
17697
  }
17563
17698
  }
17564
17699
  });
@@ -17570,12 +17705,12 @@ var require_inject_created_by = __commonJS({
17570
17705
  Object.defineProperty(exports2, "__esModule", { value: true });
17571
17706
  exports2.injectCreatedByIntoExtensionFiles = injectCreatedByIntoExtensionFiles;
17572
17707
  var promises_1 = require("fs/promises");
17573
- var path_1 = require("path");
17708
+ var path_12 = require("path");
17574
17709
  var logger_12 = require_logger();
17575
17710
  var constants_1 = require_constants5();
17576
17711
  async function injectCreatedByIntoExtensionFiles(cwd, createdExtensions) {
17577
17712
  for (const { path: filePath } of createdExtensions) {
17578
- const absolutePath = (0, path_1.join)(cwd, filePath);
17713
+ const absolutePath = (0, path_12.join)(cwd, filePath);
17579
17714
  try {
17580
17715
  const original = await (0, promises_1.readFile)(absolutePath, "utf-8");
17581
17716
  const injected = (0, constants_1.injectCreatedBy)(original);
@@ -23630,9 +23765,9 @@ var require_skills_installer = __commonJS({
23630
23765
  exports2.applySkillsOverride = applySkillsOverride;
23631
23766
  exports2.ensureSkillsReady = ensureSkillsReady;
23632
23767
  var fs_1 = require("fs");
23633
- var path_1 = require("path");
23768
+ var path_12 = require("path");
23634
23769
  var ditto_codegen_types_12 = require_dist4();
23635
- var skills_override_1 = require_skills_override();
23770
+ var skills_override_12 = require_skills_override();
23636
23771
  function hasSkills(dir) {
23637
23772
  return (0, fs_1.existsSync)(dir) && (0, fs_1.readdirSync)(dir).length > 0;
23638
23773
  }
@@ -23643,8 +23778,8 @@ var require_skills_installer = __commonJS({
23643
23778
  return;
23644
23779
  }
23645
23780
  try {
23646
- const overrides = (0, skills_override_1.parseSkillsOverrides)(skillsOverride);
23647
- await (0, skills_override_1.overrideSkills)(overrides, outputPath, log);
23781
+ const overrides = (0, skills_override_12.parseSkillsOverrides)(skillsOverride);
23782
+ await (0, skills_override_12.overrideSkills)(overrides, outputPath, log);
23648
23783
  } catch (error) {
23649
23784
  const errorMessage = error instanceof Error ? error.message : String(error);
23650
23785
  log.error("[Skills] Branch override failed", { error: errorMessage });
@@ -23655,13 +23790,13 @@ var require_skills_installer = __commonJS({
23655
23790
  }
23656
23791
  }
23657
23792
  async function ensureSkillsReady(outputPath, log, { timeoutMs = 6e4, intervalMs = 1e3 } = {}) {
23658
- const projectSkillsDir = (0, path_1.join)(outputPath, ".agents", "skills");
23659
- const skillsPresent = () => hasSkills(skills_override_1.SKILLS_DIR) || hasSkills(projectSkillsDir);
23793
+ const projectSkillsDir = (0, path_12.join)(outputPath, ".agents", "skills");
23794
+ const skillsPresent = () => hasSkills(skills_override_12.SKILLS_DIR) || hasSkills(projectSkillsDir);
23660
23795
  if (skillsPresent()) {
23661
23796
  return;
23662
23797
  }
23663
23798
  log.info("[Skills] Not present yet \u2014 waiting for the startup install", {
23664
- globalSkillsDir: skills_override_1.SKILLS_DIR,
23799
+ globalSkillsDir: skills_override_12.SKILLS_DIR,
23665
23800
  projectSkillsDir,
23666
23801
  timeoutMs
23667
23802
  });
@@ -23674,7 +23809,7 @@ var require_skills_installer = __commonJS({
23674
23809
  }
23675
23810
  }
23676
23811
  log.error("[Skills] No skills available after waiting", {
23677
- globalSkillsDir: skills_override_1.SKILLS_DIR,
23812
+ globalSkillsDir: skills_override_12.SKILLS_DIR,
23678
23813
  projectSkillsDir,
23679
23814
  environment: process.env.CODEGEN_ENVIRONMENT,
23680
23815
  timeoutMs
@@ -23692,17 +23827,17 @@ var require_tools_writer = __commonJS({
23692
23827
  exports2.writeToolFiles = writeToolFiles;
23693
23828
  var promises_1 = require("fs/promises");
23694
23829
  var os_1 = require("os");
23695
- var path_1 = require("path");
23830
+ var path_12 = require("path");
23696
23831
  var logger_12 = require_logger();
23697
- var GLOBAL_TOOLS_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "tools");
23698
- var OPENCODE_TOOLS_DIR = (0, path_1.join)(__dirname, "opencode-tools");
23832
+ var GLOBAL_TOOLS_DIR = (0, path_12.join)((0, os_1.homedir)(), ".config", "opencode", "tools");
23833
+ var OPENCODE_TOOLS_DIR = (0, path_12.join)(__dirname, "opencode-tools");
23699
23834
  async function writeToolFiles(pluginTools = []) {
23700
23835
  await (0, promises_1.mkdir)(GLOBAL_TOOLS_DIR, { recursive: true });
23701
23836
  const entries = await (0, promises_1.readdir)(OPENCODE_TOOLS_DIR);
23702
23837
  const alwaysOnTools = entries.filter((f) => f.endsWith(".ts"));
23703
23838
  await Promise.all([
23704
- ...alwaysOnTools.map((file) => (0, promises_1.copyFile)((0, path_1.join)(OPENCODE_TOOLS_DIR, file), (0, path_1.join)(GLOBAL_TOOLS_DIR, file))),
23705
- ...pluginTools.map((tool) => (0, promises_1.writeFile)((0, path_1.join)(GLOBAL_TOOLS_DIR, tool.filename), tool.source, "utf-8"))
23839
+ ...alwaysOnTools.map((file) => (0, promises_1.copyFile)((0, path_12.join)(OPENCODE_TOOLS_DIR, file), (0, path_12.join)(GLOBAL_TOOLS_DIR, file))),
23840
+ ...pluginTools.map((tool) => (0, promises_1.writeFile)((0, path_12.join)(GLOBAL_TOOLS_DIR, tool.filename), tool.source, "utf-8"))
23706
23841
  ]);
23707
23842
  logger_12.logger.info("[OpenCode] Wrote global tool files", {
23708
23843
  targetDir: GLOBAL_TOOLS_DIR,
@@ -23713,20 +23848,266 @@ var require_tools_writer = __commonJS({
23713
23848
  }
23714
23849
  });
23715
23850
 
23851
+ // dist/opencode-integration/tool-policies.js
23852
+ var require_tool_policies3 = __commonJS({
23853
+ "dist/opencode-integration/tool-policies.js"(exports2) {
23854
+ "use strict";
23855
+ Object.defineProperty(exports2, "__esModule", { value: true });
23856
+ exports2.TOOL_POLICIES_PLUGIN_FILENAME = exports2.GENERATE_CMD_RE = void 0;
23857
+ exports2.policyMatchesPath = policyMatchesPath;
23858
+ exports2.skillRootOf = skillRootOf;
23859
+ exports2.buildToolPoliciesPluginSource = buildToolPoliciesPluginSource;
23860
+ exports2.writeToolPoliciesPlugin = writeToolPoliciesPlugin;
23861
+ exports2.validateToolPolicies = validateToolPolicies;
23862
+ var promises_1 = require("fs/promises");
23863
+ var path_12 = require("path");
23864
+ var ditto_codegen_types_12 = require_dist4();
23865
+ var logger_12 = require_logger();
23866
+ var generated_plugins_1 = require_generated_plugins();
23867
+ var skills_override_12 = require_skills_override();
23868
+ exports2.GENERATE_CMD_RE = /\bwix\s+(schema\s+)?generate\b/;
23869
+ function policyMatchesPath(policy, path) {
23870
+ return policy.pathFragments.some((fragment) => path.includes(fragment));
23871
+ }
23872
+ function skillRootOf(fragment) {
23873
+ return fragment.split("/")[0];
23874
+ }
23875
+ exports2.TOOL_POLICIES_PLUGIN_FILENAME = "tool-policies.ts";
23876
+ function buildToolPoliciesPluginSource(policies) {
23877
+ const emitKind = (type, toRuntime, extraFilter = () => true) => JSON.stringify(policies.filter((policy) => policy.type === type).filter(extraFilter).map(toRuntime));
23878
+ const emitReads = (mode) => emitKind("read", ({ pathFragments, message }) => ({ pathFragments, message }), (policy) => policy.mode === mode);
23879
+ const generatePolicies = emitKind("generate", ({ blockedExtensionTypes, whenArgsInclude, message }) => ({
23880
+ blockedExtensionTypes,
23881
+ whenArgsInclude,
23882
+ message
23883
+ }));
23884
+ const commandPrepends = emitKind("commandOutput", ({ commandFragments, message }) => ({
23885
+ commandFragments,
23886
+ message
23887
+ }));
23888
+ const skillPrepends = emitKind("skillContent", ({ skillNames, message }) => ({
23889
+ skillNames,
23890
+ message
23891
+ }));
23892
+ return `// Generated by @wix/ditto-codegen (tool-policies). Do not edit.
23893
+ const BLOCK_READS = ${emitReads("block")};
23894
+ const PREPEND_READS = ${emitReads("prepend")};
23895
+ const GENERATE_POLICIES = ${generatePolicies};
23896
+ const COMMAND_PREPENDS = ${commandPrepends};
23897
+ const SKILL_PREPENDS = ${skillPrepends};
23898
+ // Appended once after every prepend banner (see OVERRIDE_AUTHORITY_NOTE):
23899
+ // part of the override contract, so no policy can ship without it.
23900
+ const AUTHORITY_NOTE = ${JSON.stringify(ditto_codegen_types_12.OVERRIDE_AUTHORITY_NOTE)};
23901
+ const GENERATE_CMD_RE = /${exports2.GENERATE_CMD_RE.source}/;
23902
+
23903
+ function extractReadPaths(tool, args) {
23904
+ if (tool === "${"read"}") {
23905
+ return typeof args.filePath === "string" ? [args.filePath] : [];
23906
+ }
23907
+ if (tool === "${"batch-read"}" && Array.isArray(args.paths)) {
23908
+ return args.paths.filter((path) => typeof path === "string");
23909
+ }
23910
+ return [];
23911
+ }
23912
+
23913
+ function matchingPolicies(policies, paths) {
23914
+ return policies.filter((policy) =>
23915
+ policy.pathFragments.some((fragment) =>
23916
+ paths.some((path) => path.includes(fragment)),
23917
+ ),
23918
+ );
23919
+ }
23920
+
23921
+ function generateArgsMatch(policy, haystack) {
23922
+ return (
23923
+ !policy.whenArgsInclude ||
23924
+ policy.whenArgsInclude.some((fragment) => haystack.includes(fragment))
23925
+ );
23926
+ }
23927
+
23928
+ export const ToolPolicies = async () => ({
23929
+ "tool.execute.before": async (input, output) => {
23930
+ const args = output.args ?? {};
23931
+ const blocked = matchingPolicies(
23932
+ BLOCK_READS,
23933
+ extractReadPaths(input.tool, args),
23934
+ )[0];
23935
+ if (blocked) throw new Error(blocked.message);
23936
+
23937
+ if (GENERATE_POLICIES.length === 0) return;
23938
+ if (input.tool === "${"wix-generate"}" && Array.isArray(args.extensions)) {
23939
+ for (const extension of args.extensions) {
23940
+ const type = extension?.params?.extensionType;
23941
+ if (typeof type !== "string") continue;
23942
+ const params = JSON.stringify(extension.params);
23943
+ for (const policy of GENERATE_POLICIES) {
23944
+ if (
23945
+ policy.blockedExtensionTypes.includes(type) &&
23946
+ generateArgsMatch(policy, params)
23947
+ ) {
23948
+ throw new Error(policy.message);
23949
+ }
23950
+ }
23951
+ }
23952
+ }
23953
+ if (
23954
+ input.tool === "${"bash"}" &&
23955
+ typeof args.command === "string" &&
23956
+ GENERATE_CMD_RE.test(args.command)
23957
+ ) {
23958
+ for (const policy of GENERATE_POLICIES) {
23959
+ if (
23960
+ policy.blockedExtensionTypes.some((type) => args.command.includes(type)) &&
23961
+ generateArgsMatch(policy, args.command)
23962
+ ) {
23963
+ throw new Error(policy.message);
23964
+ }
23965
+ }
23966
+ }
23967
+ },
23968
+ "tool.execute.after": async (input, output) => {
23969
+ if (typeof output.output !== "string") return;
23970
+ const args = input.args ?? {};
23971
+ const matched = matchingPolicies(
23972
+ PREPEND_READS,
23973
+ extractReadPaths(input.tool, args),
23974
+ );
23975
+ if (input.tool === "${"bash"}" && typeof args.command === "string") {
23976
+ matched.push(
23977
+ ...COMMAND_PREPENDS.filter((policy) =>
23978
+ policy.commandFragments.every((fragment) => args.command.includes(fragment)),
23979
+ ),
23980
+ );
23981
+ }
23982
+ if (input.tool === "${"skill"}" && typeof args.name === "string") {
23983
+ matched.push(
23984
+ ...SKILL_PREPENDS.filter((policy) => policy.skillNames.includes(args.name)),
23985
+ );
23986
+ }
23987
+ if (matched.length === 0) return;
23988
+ output.output = [
23989
+ ...matched.map((policy) => policy.message),
23990
+ AUTHORITY_NOTE,
23991
+ output.output,
23992
+ ].join("\\n\\n");
23993
+ },
23994
+ });
23995
+ `;
23996
+ }
23997
+ async function writeToolPoliciesPlugin(policies) {
23998
+ await (0, generated_plugins_1.writeGeneratedPlugin)(exports2.TOOL_POLICIES_PLUGIN_FILENAME, buildToolPoliciesPluginSource(policies));
23999
+ }
24000
+ async function walkFiles(dir, depth = 6) {
24001
+ if (depth === 0)
24002
+ return [];
24003
+ let entries;
24004
+ try {
24005
+ entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
24006
+ } catch {
24007
+ return [];
24008
+ }
24009
+ const nested = await Promise.all(entries.map(async (entry) => {
24010
+ const full = (0, path_12.join)(dir, entry.name);
24011
+ let isDirectory = entry.isDirectory();
24012
+ let isFile = entry.isFile();
24013
+ if (entry.isSymbolicLink()) {
24014
+ try {
24015
+ const stats = await (0, promises_1.stat)(full);
24016
+ isDirectory = stats.isDirectory();
24017
+ isFile = stats.isFile();
24018
+ } catch {
24019
+ return [];
24020
+ }
24021
+ }
24022
+ if (isDirectory)
24023
+ return walkFiles(full, depth - 1);
24024
+ return isFile ? [full] : [];
24025
+ }));
24026
+ return nested.flat();
24027
+ }
24028
+ async function validateToolPolicies(policies, skillsDirs = [skills_override_12.SKILLS_DIR]) {
24029
+ const reads = policies.filter((policy) => policy.type === "read");
24030
+ const argChecks = policies.flatMap((policy) => policy.type === "generate" && policy.whenArgsInclude?.length && policy.driftSkill ? [{ skill: policy.driftSkill, argFragments: policy.whenArgsInclude }] : []);
24031
+ const skillNames = policies.flatMap((policy) => policy.type === "skillContent" ? policy.skillNames : []);
24032
+ if (reads.length === 0 && argChecks.length === 0 && skillNames.length === 0) {
24033
+ return;
24034
+ }
24035
+ try {
24036
+ const files = (await Promise.all(skillsDirs.map((dir) => walkFiles(dir)))).flat();
24037
+ const fragments = reads.flatMap((policy) => policy.pathFragments.map((fragment) => ({ fragment, policy })));
24038
+ const isInstalled = (root) => files.some((file) => file.includes(`/${root}/`));
24039
+ const missingRoots = [
24040
+ ...new Set([
24041
+ ...fragments.map(({ fragment }) => skillRootOf(fragment)),
24042
+ ...argChecks.map(({ skill }) => skill),
24043
+ ...skillNames
24044
+ ].filter((root) => !isInstalled(root)))
24045
+ ];
24046
+ if (missingRoots.length > 0) {
24047
+ logger_12.logger.info("[ToolPolicies] Skill not installed (yet); skipping its drift check", { skills: missingRoots, skillsDirs });
24048
+ }
24049
+ const checkable = fragments.filter(({ fragment }) => isInstalled(skillRootOf(fragment)));
24050
+ for (const { fragment, policy } of checkable) {
24051
+ if (!files.some((file) => file.includes(fragment))) {
24052
+ logger_12.logger.warn("[ToolPolicies] Path fragment matched no installed skill file (stale policy?)", { fragment, mode: policy.mode });
24053
+ }
24054
+ }
24055
+ const docCache = /* @__PURE__ */ new Map();
24056
+ const readDoc = (file) => {
24057
+ let content = docCache.get(file);
24058
+ if (!content) {
24059
+ content = (0, promises_1.readFile)(file, "utf-8").catch(() => "");
24060
+ docCache.set(file, content);
24061
+ }
24062
+ return content;
24063
+ };
24064
+ const argFragmentSweep = Promise.all(argChecks.filter(({ skill }) => isInstalled(skill)).map(async ({ skill, argFragments }) => {
24065
+ const docs = files.filter((file) => file.endsWith(".md") && file.includes(`/${skill}/`));
24066
+ const contents = await Promise.all(docs.map(readDoc));
24067
+ for (const fragment of argFragments) {
24068
+ if (!contents.some((content) => content.includes(fragment))) {
24069
+ logger_12.logger.warn("[ToolPolicies] Generate arg fragment not found in the drift skill's docs (stale policy?)", { fragment, skill });
24070
+ }
24071
+ }
24072
+ }));
24073
+ const markers = reads.flatMap((policy) => policy.driftMarkers ?? []);
24074
+ const markerSweep = (async () => {
24075
+ if (markers.length === 0 || checkable.length === 0)
24076
+ return;
24077
+ const sweptRoots = [
24078
+ ...new Set(checkable.map(({ fragment }) => skillRootOf(fragment)))
24079
+ ];
24080
+ const uncoveredDocs = files.filter((file) => file.endsWith(".md") && sweptRoots.some((root) => file.includes(`/${root}/`)) && !reads.some((policy) => policyMatchesPath(policy, file)));
24081
+ await Promise.all(uncoveredDocs.map(async (file) => {
24082
+ const content = await readDoc(file);
24083
+ for (const marker of markers) {
24084
+ if (content.includes(marker)) {
24085
+ logger_12.logger.warn("[ToolPolicies] Drift marker found in a file no policy covers (content moved?)", { marker, file });
24086
+ }
24087
+ }
24088
+ }));
24089
+ })();
24090
+ await Promise.all([argFragmentSweep, markerSweep]);
24091
+ } catch (error) {
24092
+ logger_12.logger.warn("[ToolPolicies] Validation failed; continuing", {
24093
+ error: error instanceof Error ? error.message : String(error)
24094
+ });
24095
+ }
24096
+ }
24097
+ }
24098
+ });
24099
+
23716
24100
  // dist/opencode-integration/generated-files-guard.js
23717
24101
  var require_generated_files_guard = __commonJS({
23718
24102
  "dist/opencode-integration/generated-files-guard.js"(exports2) {
23719
24103
  "use strict";
23720
24104
  Object.defineProperty(exports2, "__esModule", { value: true });
23721
- exports2.GENERATED_FILES_GUARD_PLUGIN_PATH = exports2.GUARD_MESSAGE = void 0;
24105
+ exports2.GUARD_MESSAGE = void 0;
23722
24106
  exports2.isEditorComponentManifest = isEditorComponentManifest;
23723
24107
  exports2.extractWritePaths = extractWritePaths;
23724
24108
  exports2.buildGeneratedFilesGuardSource = buildGeneratedFilesGuardSource;
23725
24109
  exports2.writeGeneratedFilesGuardPlugin = writeGeneratedFilesGuardPlugin;
23726
- var promises_1 = require("fs/promises");
23727
- var os_1 = require("os");
23728
- var path_1 = require("path");
23729
- var logger_12 = require_logger();
24110
+ var generated_plugins_1 = require_generated_plugins();
23730
24111
  var ERC_MANIFEST_RE = /(^|\/)src\/extensions\/site\/components\/.+\.generated\.tsx?$/;
23731
24112
  exports2.GUARD_MESSAGE = "BLOCKED: *.generated.ts is an auto-generated manifest. Do not create or edit it by hand. It is derived from the component's React markup (*.tsx) and CSS module (*.module.css) and regenerated by running `npx wix build && npx wix generate manifest`. To change it, edit the *.tsx / *.module.css / *.props.ts source and regenerate; to override manifest values, edit the component's *.extension.ts. Do not retry this write.";
23732
24113
  function isEditorComponentManifest(path) {
@@ -23741,9 +24122,7 @@ var require_generated_files_guard = __commonJS({
23741
24122
  return [];
23742
24123
  return list.map((item) => item.path).filter((p) => typeof p === "string");
23743
24124
  }
23744
- var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
23745
24125
  var GUARD_PLUGIN_FILENAME = "generated-files-guard.ts";
23746
- exports2.GENERATED_FILES_GUARD_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, GUARD_PLUGIN_FILENAME);
23747
24126
  function buildGeneratedFilesGuardSource() {
23748
24127
  return `// Generated by @wix/ditto-codegen (generated-files-guard). Do not edit.
23749
24128
  const ERC_MANIFEST_RE = /${ERC_MANIFEST_RE.source}/;
@@ -23774,11 +24153,7 @@ export const GeneratedFilesGuard = async () => ({
23774
24153
  `;
23775
24154
  }
23776
24155
  async function writeGeneratedFilesGuardPlugin() {
23777
- await (0, promises_1.mkdir)(GLOBAL_PLUGIN_DIR, { recursive: true });
23778
- await (0, promises_1.writeFile)(exports2.GENERATED_FILES_GUARD_PLUGIN_PATH, buildGeneratedFilesGuardSource(), "utf-8");
23779
- logger_12.logger.info("[OpenCode] Wrote generated-files guard plugin", {
23780
- path: exports2.GENERATED_FILES_GUARD_PLUGIN_PATH
23781
- });
24156
+ await (0, generated_plugins_1.writeGeneratedPlugin)(GUARD_PLUGIN_FILENAME, buildGeneratedFilesGuardSource());
23782
24157
  }
23783
24158
  }
23784
24159
  });
@@ -23815,6 +24190,7 @@ var require_plugin_artifacts = __commonJS({
23815
24190
  function collectPluginArtifacts(envConfig) {
23816
24191
  const rules = [];
23817
24192
  const tools = [];
24193
+ const toolPolicies = [];
23818
24194
  const host = (0, plugin_host_12.buildPluginHost)();
23819
24195
  for (const factory of envConfig.plugins) {
23820
24196
  const plugin = factory({ host });
@@ -23822,8 +24198,10 @@ var require_plugin_artifacts = __commonJS({
23822
24198
  rules.push(...plugin.rules);
23823
24199
  if (plugin.tools)
23824
24200
  tools.push(...plugin.tools);
24201
+ if (plugin.toolPolicies)
24202
+ toolPolicies.push(...plugin.toolPolicies);
23825
24203
  }
23826
- return { rules, tools };
24204
+ return { rules, tools, toolPolicies };
23827
24205
  }
23828
24206
  }
23829
24207
  });
@@ -23843,12 +24221,15 @@ var job_cancellation_monitor_1 = require_job_cancellation_monitor();
23843
24221
  var job_timeout_monitor_1 = require_job_timeout_monitor();
23844
24222
  var codeGenerationService_1 = require_codeGenerationService();
23845
24223
  var crypto_1 = require("crypto");
24224
+ var path_1 = require("path");
23846
24225
  var ditto_codegen_types_1 = require_dist4();
23847
24226
  var logger_1 = require_logger();
23848
24227
  var skills_installer_1 = require_skills_installer();
23849
24228
  var rules_writer_1 = require_rules_writer();
23850
24229
  var tools_writer_1 = require_tools_writer();
23851
24230
  var node_modules_guard_1 = require_node_modules_guard();
24231
+ var tool_policies_1 = require_tool_policies3();
24232
+ var skills_override_1 = require_skills_override();
23852
24233
  var generated_files_guard_1 = require_generated_files_guard();
23853
24234
  var subagent_tool_logger_1 = require_subagent_tool_logger();
23854
24235
  var plugin_artifacts_1 = require_plugin_artifacts();
@@ -23915,6 +24296,10 @@ var alwaysOnLoop = async () => {
23915
24296
  async function initOpenCode() {
23916
24297
  const envConfig = (0, environments_1.getCodegenEnvironmentConfig)();
23917
24298
  const pluginArtifacts = (0, plugin_artifacts_1.collectPluginArtifacts)(envConfig);
24299
+ const toolPolicies = [
24300
+ ...envConfig.toolPolicies ?? [],
24301
+ ...pluginArtifacts.toolPolicies
24302
+ ];
23918
24303
  await Promise.all([
23919
24304
  (0, rules_writer_1.writeRuleFiles)([
23920
24305
  ...envConfig.codegenRules,
@@ -23926,7 +24311,12 @@ async function initOpenCode() {
23926
24311
  (0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
23927
24312
  (0, node_modules_guard_1.writeGuardPlugin)(),
23928
24313
  (0, generated_files_guard_1.writeGeneratedFilesGuardPlugin)(),
23929
- (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)()
24314
+ (0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)(),
24315
+ (0, tool_policies_1.writeToolPoliciesPlugin)(toolPolicies)
24316
+ ]);
24317
+ void (0, tool_policies_1.validateToolPolicies)(toolPolicies, [
24318
+ skills_override_1.SKILLS_DIR,
24319
+ (0, path_1.join)((0, codegen_flow_helpers_1.getOutputPath)(), ".agents", "skills")
23930
24320
  ]);
23931
24321
  }
23932
24322
  async function main(ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.437",
3
+ "version": "1.0.438",
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": "fa7b527ce78aed885889951926ab8c492e1b9f58e57ba82962990fbf"
32
+ "falconPackageHash": "505e7fd77b8402842416d269ee4d6800b6ad3e313ae5d985dfd48792"
33
33
  }