@wix/ditto-codegen-public 1.0.436 → 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.
- package/dist/out.js +571 -172
- 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
|
|
547
|
-
dotenv_1.default.config({ path:
|
|
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
|
|
12043
|
+
var path_12 = require("path");
|
|
12033
12044
|
var logger_12 = require_logger();
|
|
12034
|
-
var GLOBAL_RULES_DIR = (0,
|
|
12045
|
+
var GLOBAL_RULES_DIR = (0, path_12.join)((0, os_1.homedir)(), ".config", "opencode", "rules");
|
|
12035
12046
|
function getRulePath(filename) {
|
|
12036
|
-
return (0,
|
|
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
|
|
12064
|
-
var
|
|
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,
|
|
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,
|
|
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
|
|
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,
|
|
13278
|
-
var readAsset = (name) => (0, fs_1.readFileSync)((0,
|
|
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",
|
|
@@ -13294,6 +13318,7 @@ var require_checkpoint = __commonJS({
|
|
|
13294
13318
|
return message.slice(0, MAX_COMMIT_MESSAGE_LENGTH - TRUNCATION_SUFFIX.length) + TRUNCATION_SUFFIX;
|
|
13295
13319
|
};
|
|
13296
13320
|
var CHECKPOINT_CONFLICT_CODE = "CHECKPOINT_CONFLICT";
|
|
13321
|
+
var FIX_GIT_CONFLICTS_TASK_KIND = "FIX_GIT_CONFLICTS";
|
|
13297
13322
|
var useCodeProjectOrchestrator = () => process.env.USE_CODE_PROJECT_ORCHESTRATOR === "true";
|
|
13298
13323
|
var collaboratorLiveSyncEnabled = () => process.env.STUDIO2_COLLABORATOR_LIVE_SYNC === "true";
|
|
13299
13324
|
var readApplicationErrorCode = (error) => {
|
|
@@ -13410,41 +13435,49 @@ var require_checkpoint = __commonJS({
|
|
|
13410
13435
|
} catch (error) {
|
|
13411
13436
|
if (useCodeProjectOrchestrator() && collaboratorLiveSyncEnabled() && job.siteBranchId && isCheckpointConflict(error)) {
|
|
13412
13437
|
const files = readConflictedFiles(error);
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
if (!conflictResolutionJobId) {
|
|
13416
|
-
throw new Error("resolveCheckpointConflict returned no conflict resolution job id");
|
|
13417
|
-
}
|
|
13418
|
-
outcome = {
|
|
13419
|
-
status: "resolvingGitConflicts",
|
|
13420
|
-
conflictResolutionJobId,
|
|
13421
|
-
conflictedFiles: files
|
|
13422
|
-
};
|
|
13423
|
-
await host.jobs.updatePayload({ jobId: job.jobId, taskId: job.taskId }, {
|
|
13424
|
-
checkpointStatus: "resolvingGitConflicts",
|
|
13425
|
-
conflictResolutionJobId,
|
|
13426
|
-
conflictedFiles: files
|
|
13427
|
-
}).catch((payloadError) => {
|
|
13428
|
-
host.logger.warn("[Checkpoint] failed to publish the resolving-conflicts state", {
|
|
13429
|
-
projectId: job.projectId,
|
|
13430
|
-
conflictResolutionJobId,
|
|
13431
|
-
error: payloadError instanceof Error ? payloadError.message : String(payloadError)
|
|
13432
|
-
});
|
|
13433
|
-
});
|
|
13434
|
-
host.logger.info("[Checkpoint] git conflicts handed to AI resolution", {
|
|
13438
|
+
if (job.kind === FIX_GIT_CONFLICTS_TASK_KIND) {
|
|
13439
|
+
host.logger.warn("[Checkpoint] conflict during a conflict-resolution run, skipping resolve", {
|
|
13435
13440
|
projectId: job.projectId,
|
|
13436
13441
|
siteBranchId: job.siteBranchId,
|
|
13437
|
-
conflictResolutionJobId,
|
|
13438
13442
|
files
|
|
13439
13443
|
});
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13444
|
+
} else {
|
|
13445
|
+
try {
|
|
13446
|
+
const conflictResolutionJobId = await callResolveCheckpointConflict(orchestratorHttpClient, job.siteBranchId);
|
|
13447
|
+
if (!conflictResolutionJobId) {
|
|
13448
|
+
throw new Error("resolveCheckpointConflict returned no conflict resolution job id");
|
|
13449
|
+
}
|
|
13450
|
+
outcome = {
|
|
13451
|
+
status: "resolvingGitConflicts",
|
|
13452
|
+
conflictResolutionJobId,
|
|
13453
|
+
conflictedFiles: files
|
|
13454
|
+
};
|
|
13455
|
+
await host.jobs.updatePayload({ jobId: job.jobId, taskId: job.taskId }, {
|
|
13456
|
+
checkpointStatus: "resolvingGitConflicts",
|
|
13457
|
+
conflictResolutionJobId,
|
|
13458
|
+
conflictedFiles: files
|
|
13459
|
+
}).catch((payloadError) => {
|
|
13460
|
+
host.logger.warn("[Checkpoint] failed to publish the resolving-conflicts state", {
|
|
13461
|
+
projectId: job.projectId,
|
|
13462
|
+
conflictResolutionJobId,
|
|
13463
|
+
error: payloadError instanceof Error ? payloadError.message : String(payloadError)
|
|
13464
|
+
});
|
|
13465
|
+
});
|
|
13466
|
+
host.logger.info("[Checkpoint] git conflicts handed to AI resolution", {
|
|
13467
|
+
projectId: job.projectId,
|
|
13468
|
+
siteBranchId: job.siteBranchId,
|
|
13469
|
+
conflictResolutionJobId,
|
|
13470
|
+
files
|
|
13471
|
+
});
|
|
13472
|
+
return;
|
|
13473
|
+
} catch (resolveError) {
|
|
13474
|
+
host.logger.error("[Checkpoint] git conflict resolution dispatch failed", {
|
|
13475
|
+
projectId: job.projectId,
|
|
13476
|
+
siteBranchId: job.siteBranchId,
|
|
13477
|
+
files,
|
|
13478
|
+
error: resolveError instanceof Error ? resolveError.message : String(resolveError)
|
|
13479
|
+
});
|
|
13480
|
+
}
|
|
13448
13481
|
}
|
|
13449
13482
|
}
|
|
13450
13483
|
outcome = { status: "failed", error };
|
|
@@ -14679,76 +14712,200 @@ var require_system_prompts = __commonJS({
|
|
|
14679
14712
|
}
|
|
14680
14713
|
});
|
|
14681
14714
|
|
|
14682
|
-
// ../codegen-common-logic/dist/site-data-layer
|
|
14683
|
-
var
|
|
14684
|
-
"../codegen-common-logic/dist/site-data-layer
|
|
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) {
|
|
14685
14718
|
"use strict";
|
|
14686
14719
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
14687
14720
|
exports2.SITE_DATA_LAYER_RULES = void 0;
|
|
14688
14721
|
exports2.SITE_DATA_LAYER_RULES = `# Site Data Layer Rules
|
|
14689
14722
|
|
|
14690
|
-
The agent operates on a live Wix site (METASITE_ID is in your prompt context).
|
|
14691
|
-
|
|
14692
|
-
## Mandatory for data persistence
|
|
14693
|
-
|
|
14694
14723
|
For any persistent-data need (CMS collections, tables, schemas, data models):
|
|
14695
14724
|
|
|
14696
|
-
1. **You MUST invoke the \`wix-site-data-collection\` skill
|
|
14697
|
-
2. **Do NOT**
|
|
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/*\`).
|
|
14698
14727
|
|
|
14699
|
-
\`wix-app\` is still correct for dashboard pages, modals, widgets, and UI
|
|
14728
|
+
\`wix-app\` is still correct for dashboard pages, modals, widgets, and UI; only the data layer is overridden here.`;
|
|
14700
14729
|
}
|
|
14701
14730
|
});
|
|
14702
14731
|
|
|
14703
|
-
// ../codegen-common-logic/dist/stores-catalog-version
|
|
14704
|
-
var
|
|
14705
|
-
"../codegen-common-logic/dist/stores-catalog-version
|
|
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) {
|
|
14706
14735
|
"use strict";
|
|
14707
14736
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
14708
14737
|
exports2.STORES_CATALOG_VERSION_RULES = void 0;
|
|
14709
14738
|
exports2.STORES_CATALOG_VERSION_RULES = `# Wix Stores Catalog Version Rules
|
|
14710
14739
|
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
## Mandatory before any Stores work
|
|
14714
|
-
|
|
14715
|
-
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.
|
|
14716
14741
|
|
|
14717
|
-
|
|
14718
|
-
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.
|
|
14719
|
-
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.
|
|
14720
|
-
|
|
14721
|
-
\`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.`;
|
|
14722
14743
|
}
|
|
14723
14744
|
});
|
|
14724
14745
|
|
|
14725
|
-
// ../codegen-common-logic/dist/
|
|
14726
|
-
var
|
|
14727
|
-
"../codegen-common-logic/dist/
|
|
14746
|
+
// ../codegen-common-logic/dist/rules/index.js
|
|
14747
|
+
var require_rules = __commonJS({
|
|
14748
|
+
"../codegen-common-logic/dist/rules/index.js"(exports2) {
|
|
14728
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
|
+
};
|
|
14729
14766
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
14730
|
-
exports2
|
|
14731
|
-
exports2
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
- **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.
|
|
14736
|
-
- The words "widget" and "custom element" in the prompt do **not** mean Custom Element \u2014 always implement them as Editor React Components.
|
|
14737
|
-
|
|
14738
|
-
## Studio 2 Site Plugin Restrictions
|
|
14767
|
+
__exportStar2(require_site_data_layer(), exports2);
|
|
14768
|
+
__exportStar2(require_stores_catalog_version(), exports2);
|
|
14769
|
+
}
|
|
14770
|
+
});
|
|
14739
14771
|
|
|
14740
|
-
|
|
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
|
+
});
|
|
14741
14789
|
|
|
14742
|
-
-
|
|
14743
|
-
|
|
14744
|
-
-
|
|
14745
|
-
|
|
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
|
+
});
|
|
14746
14814
|
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
-
|
|
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
|
+
});
|
|
14750
14885
|
|
|
14751
|
-
|
|
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);
|
|
14752
14909
|
}
|
|
14753
14910
|
});
|
|
14754
14911
|
|
|
@@ -14792,9 +14949,9 @@ var require_dist7 = __commonJS({
|
|
|
14792
14949
|
__exportStar2(require_commonUseCasesGuide(), exports2);
|
|
14793
14950
|
__exportStar2(require_availableSdks(), exports2);
|
|
14794
14951
|
__exportStar2(require_system_prompts(), exports2);
|
|
14795
|
-
__exportStar2(
|
|
14796
|
-
__exportStar2(
|
|
14797
|
-
__exportStar2(
|
|
14952
|
+
__exportStar2(require_site_environment(), exports2);
|
|
14953
|
+
__exportStar2(require_rules(), exports2);
|
|
14954
|
+
__exportStar2(require_tool_policies2(), exports2);
|
|
14798
14955
|
}
|
|
14799
14956
|
});
|
|
14800
14957
|
|
|
@@ -14807,19 +14964,13 @@ var require_dist8 = __commonJS({
|
|
|
14807
14964
|
var codegen_checkpoint_plugin_1 = require_dist6();
|
|
14808
14965
|
var codegen_common_logic_1 = require_dist7();
|
|
14809
14966
|
exports2.studio2CodegenConfig = {
|
|
14810
|
-
environmentIdentity:
|
|
14811
|
-
codegenRules:
|
|
14812
|
-
{ filename: "site-data-layer-rules.md", content: codegen_common_logic_1.SITE_DATA_LAYER_RULES },
|
|
14813
|
-
{
|
|
14814
|
-
filename: "stores-catalog-version-rules.md",
|
|
14815
|
-
content: codegen_common_logic_1.STORES_CATALOG_VERSION_RULES
|
|
14816
|
-
},
|
|
14817
|
-
{ filename: "studio-2-site-ui-rules.md", content: codegen_common_logic_1.STUDIO_2_SITE_UI_RULES }
|
|
14818
|
-
],
|
|
14967
|
+
environmentIdentity: codegen_common_logic_1.SITE_ENVIRONMENT_IDENTITY,
|
|
14968
|
+
codegenRules: codegen_common_logic_1.SITE_CODEGEN_RULES,
|
|
14819
14969
|
askRules: [],
|
|
14820
14970
|
gitConflictsRules: [],
|
|
14821
14971
|
decisionCheckers: [],
|
|
14822
14972
|
plugins: [codegen_checkpoint_plugin_1.checkpointPluginFactory],
|
|
14973
|
+
toolPolicies: [...codegen_common_logic_1.SITE_POLICIES, ...codegen_common_logic_1.STUDIO_2_POLICIES],
|
|
14823
14974
|
chargingMode: "app"
|
|
14824
14975
|
};
|
|
14825
14976
|
}
|
|
@@ -15016,7 +15167,7 @@ var require_feature_vibe_save = __commonJS({
|
|
|
15016
15167
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15017
15168
|
exports2.featureVibePluginFactory = void 0;
|
|
15018
15169
|
var fs_1 = require("fs");
|
|
15019
|
-
var
|
|
15170
|
+
var path_12 = require("path");
|
|
15020
15171
|
var http_1 = require_http_impl4();
|
|
15021
15172
|
var http_client_1 = require_index_node();
|
|
15022
15173
|
var FALLBACK_COMMIT_MESSAGE = "Auto-save";
|
|
@@ -15024,8 +15175,8 @@ var require_feature_vibe_save = __commonJS({
|
|
|
15024
15175
|
var MAX_COMMIT_MESSAGE_LENGTH = 1e3;
|
|
15025
15176
|
var TRUNCATION_SUFFIX = "\u2026";
|
|
15026
15177
|
var FEATURE_VIBE_BASE_URL = "https://editor.wix.com";
|
|
15027
|
-
var ASSETS_DIR = (0,
|
|
15028
|
-
var readAsset = (name) => (0, fs_1.readFileSync)((0,
|
|
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");
|
|
15029
15180
|
var buildSaveRules = () => [
|
|
15030
15181
|
{
|
|
15031
15182
|
filename: "save-commit-message.md",
|
|
@@ -15165,18 +15316,13 @@ var require_dist10 = __commonJS({
|
|
|
15165
15316
|
var codegen_feature_vibe_plugin_1 = require_dist9();
|
|
15166
15317
|
var codegen_common_logic_1 = require_dist7();
|
|
15167
15318
|
exports2.harmonyCodegenConfig = {
|
|
15168
|
-
environmentIdentity:
|
|
15169
|
-
codegenRules:
|
|
15170
|
-
{ filename: "site-data-layer-rules.md", content: codegen_common_logic_1.SITE_DATA_LAYER_RULES },
|
|
15171
|
-
{
|
|
15172
|
-
filename: "stores-catalog-version-rules.md",
|
|
15173
|
-
content: codegen_common_logic_1.STORES_CATALOG_VERSION_RULES
|
|
15174
|
-
}
|
|
15175
|
-
],
|
|
15319
|
+
environmentIdentity: codegen_common_logic_1.SITE_ENVIRONMENT_IDENTITY,
|
|
15320
|
+
codegenRules: codegen_common_logic_1.SITE_CODEGEN_RULES,
|
|
15176
15321
|
askRules: [],
|
|
15177
15322
|
gitConflictsRules: [],
|
|
15178
15323
|
decisionCheckers: [],
|
|
15179
15324
|
plugins: [codegen_feature_vibe_plugin_1.featureVibePluginFactory],
|
|
15325
|
+
toolPolicies: codegen_common_logic_1.SITE_POLICIES,
|
|
15180
15326
|
chargingMode: "app"
|
|
15181
15327
|
};
|
|
15182
15328
|
}
|
|
@@ -15611,6 +15757,13 @@ var require_config = __commonJS({
|
|
|
15611
15757
|
var READABLE_EXTERNAL_DIRS = {
|
|
15612
15758
|
"/root/.agents/**": "allow",
|
|
15613
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",
|
|
15614
15767
|
"/root/.opencode/**": "allow",
|
|
15615
15768
|
"/tmp/**": "allow"
|
|
15616
15769
|
};
|
|
@@ -15748,19 +15901,14 @@ var require_subagent_tool_logger = __commonJS({
|
|
|
15748
15901
|
"dist/opencode-integration/subagent-tool-logger.js"(exports2) {
|
|
15749
15902
|
"use strict";
|
|
15750
15903
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15751
|
-
exports2.
|
|
15904
|
+
exports2.SUBAGENT_STARTED_EVENT_TYPE = exports2.SUBAGENT_TOOL_EVENT_TYPE = void 0;
|
|
15752
15905
|
exports2.buildSubagentToolLoggerPluginSource = buildSubagentToolLoggerPluginSource;
|
|
15753
15906
|
exports2.writeSubagentToolLoggerPlugin = writeSubagentToolLoggerPlugin;
|
|
15754
|
-
var
|
|
15755
|
-
var os_1 = require("os");
|
|
15756
|
-
var path_1 = require("path");
|
|
15757
|
-
var logger_12 = require_logger();
|
|
15907
|
+
var generated_plugins_1 = require_generated_plugins();
|
|
15758
15908
|
var subagents_1 = require_subagents();
|
|
15759
15909
|
exports2.SUBAGENT_TOOL_EVENT_TYPE = "subagent_tool_use";
|
|
15760
15910
|
exports2.SUBAGENT_STARTED_EVENT_TYPE = "subagent_started";
|
|
15761
|
-
var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
|
|
15762
15911
|
var PLUGIN_FILENAME = "subagent-tool-logger.ts";
|
|
15763
|
-
exports2.SUBAGENT_TOOL_LOGGER_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, PLUGIN_FILENAME);
|
|
15764
15912
|
function buildSubagentToolLoggerPluginSource() {
|
|
15765
15913
|
return `// Generated by @wix/ditto-codegen (subagent-tool-logger) \u2014 do not edit.
|
|
15766
15914
|
const EVENT_TYPE = ${JSON.stringify(exports2.SUBAGENT_TOOL_EVENT_TYPE)};
|
|
@@ -15874,11 +16022,7 @@ export const SubagentToolLogger = async () => {
|
|
|
15874
16022
|
`;
|
|
15875
16023
|
}
|
|
15876
16024
|
async function writeSubagentToolLoggerPlugin() {
|
|
15877
|
-
await (0,
|
|
15878
|
-
await (0, promises_1.writeFile)(exports2.SUBAGENT_TOOL_LOGGER_PLUGIN_PATH, buildSubagentToolLoggerPluginSource(), "utf-8");
|
|
15879
|
-
logger_12.logger.info("[OpenCode] Wrote subagent tool logger plugin", {
|
|
15880
|
-
path: exports2.SUBAGENT_TOOL_LOGGER_PLUGIN_PATH
|
|
15881
|
-
});
|
|
16025
|
+
await (0, generated_plugins_1.writeGeneratedPlugin)(PLUGIN_FILENAME, buildSubagentToolLoggerPluginSource());
|
|
15882
16026
|
}
|
|
15883
16027
|
}
|
|
15884
16028
|
});
|
|
@@ -17292,14 +17436,14 @@ var require_collect_extensions_created = __commonJS({
|
|
|
17292
17436
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17293
17437
|
exports2.collectInsertedExtensionsMetadata = collectInsertedExtensionsMetadata;
|
|
17294
17438
|
exports2.buildExtensionsJobPayload = buildExtensionsJobPayload;
|
|
17295
|
-
var
|
|
17439
|
+
var path_12 = require("path");
|
|
17296
17440
|
var promises_1 = require("fs/promises");
|
|
17297
17441
|
var ditto_codegen_types_12 = require_dist4();
|
|
17298
17442
|
var constants_1 = require_constants5();
|
|
17299
17443
|
var DATA_COLLECTION_MARKER = /import\s+(?:type\s+)?\{[^}]*\bDataCollection\b[^}]*\}\s+from\s+['"](?:@wix\/astro\/builders|@wix\/custom-extensions)['"]/;
|
|
17300
|
-
var getExtensionDirectory = (extensionDefinitionPath) => `${
|
|
17444
|
+
var getExtensionDirectory = (extensionDefinitionPath) => `${path_12.posix.dirname(extensionDefinitionPath)}/`;
|
|
17301
17445
|
var isFileInExtensionFolder = (filePath, extensionDefinitionPath) => filePath === extensionDefinitionPath || filePath.startsWith(getExtensionDirectory(extensionDefinitionPath));
|
|
17302
|
-
var resolveFilePath = (outputPath, filePath) => (0,
|
|
17446
|
+
var resolveFilePath = (outputPath, filePath) => (0, path_12.isAbsolute)(filePath) ? filePath : (0, path_12.join)(outputPath, filePath);
|
|
17303
17447
|
var buildJobExtension = (definitionPath, extensionType, contentForTitle, titlePath, files) => ({
|
|
17304
17448
|
path: definitionPath,
|
|
17305
17449
|
extensionType,
|
|
@@ -17460,38 +17604,38 @@ var require_agent_io = __commonJS({
|
|
|
17460
17604
|
exports2.writeAgentInput = writeAgentInput;
|
|
17461
17605
|
exports2.readAgentOutput = readAgentOutput;
|
|
17462
17606
|
var fs_1 = __importDefault2(require("fs"));
|
|
17463
|
-
var
|
|
17607
|
+
var path_12 = __importDefault2(require("path"));
|
|
17464
17608
|
var logger_12 = require_logger();
|
|
17465
|
-
var AGENT_INPUT_DIR =
|
|
17466
|
-
var AGENT_OUTPUT_DIR =
|
|
17609
|
+
var AGENT_INPUT_DIR = path_12.default.join(".wix", "agentInput");
|
|
17610
|
+
var AGENT_OUTPUT_DIR = path_12.default.join(".wix", "agentOutput");
|
|
17467
17611
|
function ensureEmptyJsonDir(dir) {
|
|
17468
17612
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
17469
17613
|
for (const file of fs_1.default.readdirSync(dir)) {
|
|
17470
17614
|
if (file.endsWith(".json")) {
|
|
17471
|
-
fs_1.default.unlinkSync(
|
|
17615
|
+
fs_1.default.unlinkSync(path_12.default.join(dir, file));
|
|
17472
17616
|
}
|
|
17473
17617
|
}
|
|
17474
17618
|
}
|
|
17475
17619
|
function writeAgentInput(outputPath, agentData) {
|
|
17476
|
-
const inputDir =
|
|
17477
|
-
const outputDir =
|
|
17620
|
+
const inputDir = path_12.default.join(outputPath, AGENT_INPUT_DIR);
|
|
17621
|
+
const outputDir = path_12.default.join(outputPath, AGENT_OUTPUT_DIR);
|
|
17478
17622
|
ensureEmptyJsonDir(inputDir);
|
|
17479
17623
|
ensureEmptyJsonDir(outputDir);
|
|
17480
17624
|
if (!agentData)
|
|
17481
17625
|
return;
|
|
17482
17626
|
for (const [key, value] of Object.entries(agentData)) {
|
|
17483
|
-
fs_1.default.writeFileSync(
|
|
17627
|
+
fs_1.default.writeFileSync(path_12.default.join(inputDir, `${key}.json`), JSON.stringify({ [key]: value }));
|
|
17484
17628
|
}
|
|
17485
17629
|
}
|
|
17486
17630
|
function readAgentOutput(outputPath) {
|
|
17487
|
-
const outputDir =
|
|
17631
|
+
const outputDir = path_12.default.join(outputPath, AGENT_OUTPUT_DIR);
|
|
17488
17632
|
if (!fs_1.default.existsSync(outputDir))
|
|
17489
17633
|
return {};
|
|
17490
17634
|
const merged = {};
|
|
17491
17635
|
for (const file of fs_1.default.readdirSync(outputDir)) {
|
|
17492
17636
|
if (!file.endsWith(".json"))
|
|
17493
17637
|
continue;
|
|
17494
|
-
const filePath =
|
|
17638
|
+
const filePath = path_12.default.join(outputDir, file);
|
|
17495
17639
|
const raw = fs_1.default.readFileSync(filePath, "utf-8").trim();
|
|
17496
17640
|
if (!raw)
|
|
17497
17641
|
continue;
|
|
@@ -17521,7 +17665,7 @@ var require_codegen_flow_helpers = __commonJS({
|
|
|
17521
17665
|
exports2.buildFailedRunPayload = buildFailedRunPayload;
|
|
17522
17666
|
exports2.updateParentTaskStatus = updateParentTaskStatus;
|
|
17523
17667
|
exports2.getOutputPath = getOutputPath;
|
|
17524
|
-
var
|
|
17668
|
+
var path_12 = __importDefault2(require("path"));
|
|
17525
17669
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
17526
17670
|
var git_file_changes_1 = require_git_file_changes();
|
|
17527
17671
|
var collect_extensions_created_1 = require_collect_extensions_created();
|
|
@@ -17549,7 +17693,7 @@ var require_codegen_flow_helpers = __commonJS({
|
|
|
17549
17693
|
}
|
|
17550
17694
|
function getOutputPath() {
|
|
17551
17695
|
const outputDir = process.env.OUTPUT_PATH || DEFAULT_OUTPUT_PATH;
|
|
17552
|
-
return outputDir.startsWith("/") ? outputDir :
|
|
17696
|
+
return outputDir.startsWith("/") ? outputDir : path_12.default.join(process.cwd(), outputDir);
|
|
17553
17697
|
}
|
|
17554
17698
|
}
|
|
17555
17699
|
});
|
|
@@ -17561,12 +17705,12 @@ var require_inject_created_by = __commonJS({
|
|
|
17561
17705
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17562
17706
|
exports2.injectCreatedByIntoExtensionFiles = injectCreatedByIntoExtensionFiles;
|
|
17563
17707
|
var promises_1 = require("fs/promises");
|
|
17564
|
-
var
|
|
17708
|
+
var path_12 = require("path");
|
|
17565
17709
|
var logger_12 = require_logger();
|
|
17566
17710
|
var constants_1 = require_constants5();
|
|
17567
17711
|
async function injectCreatedByIntoExtensionFiles(cwd, createdExtensions) {
|
|
17568
17712
|
for (const { path: filePath } of createdExtensions) {
|
|
17569
|
-
const absolutePath = (0,
|
|
17713
|
+
const absolutePath = (0, path_12.join)(cwd, filePath);
|
|
17570
17714
|
try {
|
|
17571
17715
|
const original = await (0, promises_1.readFile)(absolutePath, "utf-8");
|
|
17572
17716
|
const injected = (0, constants_1.injectCreatedBy)(original);
|
|
@@ -23621,9 +23765,9 @@ var require_skills_installer = __commonJS({
|
|
|
23621
23765
|
exports2.applySkillsOverride = applySkillsOverride;
|
|
23622
23766
|
exports2.ensureSkillsReady = ensureSkillsReady;
|
|
23623
23767
|
var fs_1 = require("fs");
|
|
23624
|
-
var
|
|
23768
|
+
var path_12 = require("path");
|
|
23625
23769
|
var ditto_codegen_types_12 = require_dist4();
|
|
23626
|
-
var
|
|
23770
|
+
var skills_override_12 = require_skills_override();
|
|
23627
23771
|
function hasSkills(dir) {
|
|
23628
23772
|
return (0, fs_1.existsSync)(dir) && (0, fs_1.readdirSync)(dir).length > 0;
|
|
23629
23773
|
}
|
|
@@ -23634,8 +23778,8 @@ var require_skills_installer = __commonJS({
|
|
|
23634
23778
|
return;
|
|
23635
23779
|
}
|
|
23636
23780
|
try {
|
|
23637
|
-
const overrides = (0,
|
|
23638
|
-
await (0,
|
|
23781
|
+
const overrides = (0, skills_override_12.parseSkillsOverrides)(skillsOverride);
|
|
23782
|
+
await (0, skills_override_12.overrideSkills)(overrides, outputPath, log);
|
|
23639
23783
|
} catch (error) {
|
|
23640
23784
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
23641
23785
|
log.error("[Skills] Branch override failed", { error: errorMessage });
|
|
@@ -23646,13 +23790,13 @@ var require_skills_installer = __commonJS({
|
|
|
23646
23790
|
}
|
|
23647
23791
|
}
|
|
23648
23792
|
async function ensureSkillsReady(outputPath, log, { timeoutMs = 6e4, intervalMs = 1e3 } = {}) {
|
|
23649
|
-
const projectSkillsDir = (0,
|
|
23650
|
-
const skillsPresent = () => hasSkills(
|
|
23793
|
+
const projectSkillsDir = (0, path_12.join)(outputPath, ".agents", "skills");
|
|
23794
|
+
const skillsPresent = () => hasSkills(skills_override_12.SKILLS_DIR) || hasSkills(projectSkillsDir);
|
|
23651
23795
|
if (skillsPresent()) {
|
|
23652
23796
|
return;
|
|
23653
23797
|
}
|
|
23654
23798
|
log.info("[Skills] Not present yet \u2014 waiting for the startup install", {
|
|
23655
|
-
globalSkillsDir:
|
|
23799
|
+
globalSkillsDir: skills_override_12.SKILLS_DIR,
|
|
23656
23800
|
projectSkillsDir,
|
|
23657
23801
|
timeoutMs
|
|
23658
23802
|
});
|
|
@@ -23665,7 +23809,7 @@ var require_skills_installer = __commonJS({
|
|
|
23665
23809
|
}
|
|
23666
23810
|
}
|
|
23667
23811
|
log.error("[Skills] No skills available after waiting", {
|
|
23668
|
-
globalSkillsDir:
|
|
23812
|
+
globalSkillsDir: skills_override_12.SKILLS_DIR,
|
|
23669
23813
|
projectSkillsDir,
|
|
23670
23814
|
environment: process.env.CODEGEN_ENVIRONMENT,
|
|
23671
23815
|
timeoutMs
|
|
@@ -23683,17 +23827,17 @@ var require_tools_writer = __commonJS({
|
|
|
23683
23827
|
exports2.writeToolFiles = writeToolFiles;
|
|
23684
23828
|
var promises_1 = require("fs/promises");
|
|
23685
23829
|
var os_1 = require("os");
|
|
23686
|
-
var
|
|
23830
|
+
var path_12 = require("path");
|
|
23687
23831
|
var logger_12 = require_logger();
|
|
23688
|
-
var GLOBAL_TOOLS_DIR = (0,
|
|
23689
|
-
var OPENCODE_TOOLS_DIR = (0,
|
|
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");
|
|
23690
23834
|
async function writeToolFiles(pluginTools = []) {
|
|
23691
23835
|
await (0, promises_1.mkdir)(GLOBAL_TOOLS_DIR, { recursive: true });
|
|
23692
23836
|
const entries = await (0, promises_1.readdir)(OPENCODE_TOOLS_DIR);
|
|
23693
23837
|
const alwaysOnTools = entries.filter((f) => f.endsWith(".ts"));
|
|
23694
23838
|
await Promise.all([
|
|
23695
|
-
...alwaysOnTools.map((file) => (0, promises_1.copyFile)((0,
|
|
23696
|
-
...pluginTools.map((tool) => (0, promises_1.writeFile)((0,
|
|
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"))
|
|
23697
23841
|
]);
|
|
23698
23842
|
logger_12.logger.info("[OpenCode] Wrote global tool files", {
|
|
23699
23843
|
targetDir: GLOBAL_TOOLS_DIR,
|
|
@@ -23704,20 +23848,266 @@ var require_tools_writer = __commonJS({
|
|
|
23704
23848
|
}
|
|
23705
23849
|
});
|
|
23706
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
|
+
|
|
23707
24100
|
// dist/opencode-integration/generated-files-guard.js
|
|
23708
24101
|
var require_generated_files_guard = __commonJS({
|
|
23709
24102
|
"dist/opencode-integration/generated-files-guard.js"(exports2) {
|
|
23710
24103
|
"use strict";
|
|
23711
24104
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23712
|
-
exports2.
|
|
24105
|
+
exports2.GUARD_MESSAGE = void 0;
|
|
23713
24106
|
exports2.isEditorComponentManifest = isEditorComponentManifest;
|
|
23714
24107
|
exports2.extractWritePaths = extractWritePaths;
|
|
23715
24108
|
exports2.buildGeneratedFilesGuardSource = buildGeneratedFilesGuardSource;
|
|
23716
24109
|
exports2.writeGeneratedFilesGuardPlugin = writeGeneratedFilesGuardPlugin;
|
|
23717
|
-
var
|
|
23718
|
-
var os_1 = require("os");
|
|
23719
|
-
var path_1 = require("path");
|
|
23720
|
-
var logger_12 = require_logger();
|
|
24110
|
+
var generated_plugins_1 = require_generated_plugins();
|
|
23721
24111
|
var ERC_MANIFEST_RE = /(^|\/)src\/extensions\/site\/components\/.+\.generated\.tsx?$/;
|
|
23722
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.";
|
|
23723
24113
|
function isEditorComponentManifest(path) {
|
|
@@ -23732,9 +24122,7 @@ var require_generated_files_guard = __commonJS({
|
|
|
23732
24122
|
return [];
|
|
23733
24123
|
return list.map((item) => item.path).filter((p) => typeof p === "string");
|
|
23734
24124
|
}
|
|
23735
|
-
var GLOBAL_PLUGIN_DIR = (0, path_1.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
|
|
23736
24125
|
var GUARD_PLUGIN_FILENAME = "generated-files-guard.ts";
|
|
23737
|
-
exports2.GENERATED_FILES_GUARD_PLUGIN_PATH = (0, path_1.join)(GLOBAL_PLUGIN_DIR, GUARD_PLUGIN_FILENAME);
|
|
23738
24126
|
function buildGeneratedFilesGuardSource() {
|
|
23739
24127
|
return `// Generated by @wix/ditto-codegen (generated-files-guard). Do not edit.
|
|
23740
24128
|
const ERC_MANIFEST_RE = /${ERC_MANIFEST_RE.source}/;
|
|
@@ -23765,11 +24153,7 @@ export const GeneratedFilesGuard = async () => ({
|
|
|
23765
24153
|
`;
|
|
23766
24154
|
}
|
|
23767
24155
|
async function writeGeneratedFilesGuardPlugin() {
|
|
23768
|
-
await (0,
|
|
23769
|
-
await (0, promises_1.writeFile)(exports2.GENERATED_FILES_GUARD_PLUGIN_PATH, buildGeneratedFilesGuardSource(), "utf-8");
|
|
23770
|
-
logger_12.logger.info("[OpenCode] Wrote generated-files guard plugin", {
|
|
23771
|
-
path: exports2.GENERATED_FILES_GUARD_PLUGIN_PATH
|
|
23772
|
-
});
|
|
24156
|
+
await (0, generated_plugins_1.writeGeneratedPlugin)(GUARD_PLUGIN_FILENAME, buildGeneratedFilesGuardSource());
|
|
23773
24157
|
}
|
|
23774
24158
|
}
|
|
23775
24159
|
});
|
|
@@ -23806,6 +24190,7 @@ var require_plugin_artifacts = __commonJS({
|
|
|
23806
24190
|
function collectPluginArtifacts(envConfig) {
|
|
23807
24191
|
const rules = [];
|
|
23808
24192
|
const tools = [];
|
|
24193
|
+
const toolPolicies = [];
|
|
23809
24194
|
const host = (0, plugin_host_12.buildPluginHost)();
|
|
23810
24195
|
for (const factory of envConfig.plugins) {
|
|
23811
24196
|
const plugin = factory({ host });
|
|
@@ -23813,8 +24198,10 @@ var require_plugin_artifacts = __commonJS({
|
|
|
23813
24198
|
rules.push(...plugin.rules);
|
|
23814
24199
|
if (plugin.tools)
|
|
23815
24200
|
tools.push(...plugin.tools);
|
|
24201
|
+
if (plugin.toolPolicies)
|
|
24202
|
+
toolPolicies.push(...plugin.toolPolicies);
|
|
23816
24203
|
}
|
|
23817
|
-
return { rules, tools };
|
|
24204
|
+
return { rules, tools, toolPolicies };
|
|
23818
24205
|
}
|
|
23819
24206
|
}
|
|
23820
24207
|
});
|
|
@@ -23834,12 +24221,15 @@ var job_cancellation_monitor_1 = require_job_cancellation_monitor();
|
|
|
23834
24221
|
var job_timeout_monitor_1 = require_job_timeout_monitor();
|
|
23835
24222
|
var codeGenerationService_1 = require_codeGenerationService();
|
|
23836
24223
|
var crypto_1 = require("crypto");
|
|
24224
|
+
var path_1 = require("path");
|
|
23837
24225
|
var ditto_codegen_types_1 = require_dist4();
|
|
23838
24226
|
var logger_1 = require_logger();
|
|
23839
24227
|
var skills_installer_1 = require_skills_installer();
|
|
23840
24228
|
var rules_writer_1 = require_rules_writer();
|
|
23841
24229
|
var tools_writer_1 = require_tools_writer();
|
|
23842
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();
|
|
23843
24233
|
var generated_files_guard_1 = require_generated_files_guard();
|
|
23844
24234
|
var subagent_tool_logger_1 = require_subagent_tool_logger();
|
|
23845
24235
|
var plugin_artifacts_1 = require_plugin_artifacts();
|
|
@@ -23906,6 +24296,10 @@ var alwaysOnLoop = async () => {
|
|
|
23906
24296
|
async function initOpenCode() {
|
|
23907
24297
|
const envConfig = (0, environments_1.getCodegenEnvironmentConfig)();
|
|
23908
24298
|
const pluginArtifacts = (0, plugin_artifacts_1.collectPluginArtifacts)(envConfig);
|
|
24299
|
+
const toolPolicies = [
|
|
24300
|
+
...envConfig.toolPolicies ?? [],
|
|
24301
|
+
...pluginArtifacts.toolPolicies
|
|
24302
|
+
];
|
|
23909
24303
|
await Promise.all([
|
|
23910
24304
|
(0, rules_writer_1.writeRuleFiles)([
|
|
23911
24305
|
...envConfig.codegenRules,
|
|
@@ -23917,7 +24311,12 @@ async function initOpenCode() {
|
|
|
23917
24311
|
(0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
|
|
23918
24312
|
(0, node_modules_guard_1.writeGuardPlugin)(),
|
|
23919
24313
|
(0, generated_files_guard_1.writeGeneratedFilesGuardPlugin)(),
|
|
23920
|
-
(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")
|
|
23921
24320
|
]);
|
|
23922
24321
|
}
|
|
23923
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.
|
|
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": "
|
|
32
|
+
"falconPackageHash": "505e7fd77b8402842416d269ee4d6800b6ad3e313ae5d985dfd48792"
|
|
33
33
|
}
|