@wix/ditto-codegen-public 1.0.500 → 1.0.501

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 +152 -65
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -14736,12 +14736,15 @@ ${validation.step}
14736
14736
 
14737
14737
  FILE CREATION:
14738
14738
  - NEVER rewrite the same file twice. Once written, move on. Exception: see PORTING ATTACHED CODE.
14739
- - Keep each file under 200 lines. Split into types.ts, utils.ts if needed.
14739
+ - Keep each file under 200 lines. Split into types.ts, utils.ts if needed. Exception: see PORTING ATTACHED CODE.
14740
14740
  - Do NOT output comments in code unless they explain non-obvious logic.
14741
14741
 
14742
14742
  PORTING ATTACHED CODE:
14743
14743
  Only when \`.wix/agentInput/userAttachments.json\` exists and the request builds the code from the files it lists.
14744
- - You may change a file you copied or wrote earlier in this run to turn the user's code into what the skill describes (e.g. move markup, content, colors and fonts out of a copied script into JSX, props and CSS). Use targeted \`edit\`/\`multi-edit\`/\`apply_patch\` hunks only: never \`write\`/\`batch-write\` the same path again, and don't read back files you wrote.
14744
+ - Port the user's component into the scaffold files the \`wix-app\` skill describes. Copy only the logic file it names (the engine); NEVER copy the component itself into a file of its own and render or import it from the scaffold.
14745
+ - The 200-line limit does not apply to a port: keep the component's React code whole in its scaffold file, or split it the way the user's code is split (one sub-component per file).
14746
+ - You may change a file you wrote earlier in this run to finish the port (e.g. move markup, content, colors and fonts out of the engine into JSX, props and CSS). Use targeted \`edit\`/\`multi-edit\`/\`apply_patch\` hunks only: never \`write\`/\`batch-write\` the same path again, and don't read back files you wrote.
14747
+ - \`validate({ runBuild: true })\` fails the first time the skill's user-source check finds the user's component copied: port it then, don't report it instead. If it is still copied on the next validation, validation passes so the run can finish; say so in the final message.
14745
14748
 
14746
14749
  GENERATED FILES:
14747
14750
  - \`src/extensions/site/components/**/*.generated.ts\` is an auto-generated editor-react-component manifest \u2014 NEVER hand-edit. Change a manifest VALUE in the component's \`*.extension.ts\`; change anything else in the \`*.tsx\` / \`*.module.css\` / \`*.props.ts\` source. \`validate({ runBuild: true })\` regenerates the manifest when editor components exist. No other \`.generated.ts\` path is affected.
@@ -16218,12 +16221,111 @@ var require_prepare_created_by = __commonJS({
16218
16221
  }
16219
16222
  });
16220
16223
 
16224
+ // dist/opencode-integration/skills/skills-override.js
16225
+ var require_skills_override = __commonJS({
16226
+ "dist/opencode-integration/skills/skills-override.js"(exports2) {
16227
+ "use strict";
16228
+ Object.defineProperty(exports2, "__esModule", { value: true });
16229
+ exports2.SKILLS_DIR = void 0;
16230
+ exports2.parseSkillsOverrides = parseSkillsOverrides;
16231
+ exports2.overrideSkills = overrideSkills;
16232
+ var child_process_1 = require("child_process");
16233
+ var util_1 = require("util");
16234
+ var execAsync = (0, util_1.promisify)(child_process_1.exec);
16235
+ exports2.SKILLS_DIR = "/root/.agents/skills";
16236
+ function tarballUrl(repo, branch) {
16237
+ return `https://github.com/${repo}/archive/refs/heads/${branch}.tar.gz`;
16238
+ }
16239
+ function buildListSkillsCommand(repo, branch) {
16240
+ return `curl -sL ${tarballUrl(repo, branch)} | tar tz --wildcards "*/skills/*" | sed 's|^.*/skills/||' | cut -d/ -f1 | grep -v '^$' | sort -u`;
16241
+ }
16242
+ function buildOverrideCommand(repo, branch) {
16243
+ return `tmp=$(mktemp -d) && curl -sL ${tarballUrl(repo, branch)} | tar xz -C $tmp --strip-components=1 && [ -d "$tmp/skills" ] && mkdir -p ${exports2.SKILLS_DIR} && cp -r "$tmp/skills"/. ${exports2.SKILLS_DIR}/ && rm -rf $tmp`;
16244
+ }
16245
+ function parseSkillsOverrides(value) {
16246
+ return value.split(",").map((entry) => entry.trim()).filter(Boolean).map((entry) => {
16247
+ const colonIndex = entry.lastIndexOf(":");
16248
+ if (colonIndex === -1) {
16249
+ throw new Error(`Invalid skills override entry "${entry}": expected format "repo:branch"`);
16250
+ }
16251
+ return {
16252
+ repo: entry.slice(0, colonIndex),
16253
+ branch: entry.slice(colonIndex + 1)
16254
+ };
16255
+ });
16256
+ }
16257
+ async function overrideSkills(overrides, outputPath, log) {
16258
+ for (const { repo, branch } of overrides) {
16259
+ log.info("[Skills] Listing skills from repo", { repo, branch });
16260
+ const { stdout } = await execAsync(buildListSkillsCommand(repo, branch));
16261
+ const skillNames = stdout.trim().split("\n").filter(Boolean);
16262
+ if (skillNames.length === 0) {
16263
+ log.warn("[Skills] No skills found in repo, skipping", { repo, branch });
16264
+ continue;
16265
+ }
16266
+ log.info("[Skills] Removing existing skills before override", {
16267
+ repo,
16268
+ branch,
16269
+ skillNames
16270
+ });
16271
+ const paths = skillNames.map((name) => `${exports2.SKILLS_DIR}/${name}`).join(" ");
16272
+ await execAsync(`rm -rf ${paths}`);
16273
+ log.info("[Skills] Extracting skills from repo", { repo, branch });
16274
+ await execAsync(buildOverrideCommand(repo, branch), {
16275
+ cwd: outputPath
16276
+ });
16277
+ log.info("[Skills] Skills overridden from repo successfully", {
16278
+ repo,
16279
+ branch
16280
+ });
16281
+ }
16282
+ }
16283
+ }
16284
+ });
16285
+
16286
+ // dist/validation/user-source-port.js
16287
+ var require_user_source_port = __commonJS({
16288
+ "dist/validation/user-source-port.js"(exports2) {
16289
+ "use strict";
16290
+ Object.defineProperty(exports2, "__esModule", { value: true });
16291
+ exports2.changedEditorComponents = changedEditorComponents;
16292
+ exports2.copiedComponentFindings = copiedComponentFindings;
16293
+ exports2.portCheckError = portCheckError;
16294
+ exports2.portCheckNote = portCheckNote;
16295
+ function changedEditorComponents(paths) {
16296
+ const prefix = "src/extensions/site/components/";
16297
+ const names = paths.filter((path) => path.startsWith(prefix)).map((path) => path.slice(prefix.length).split("/")[0]).filter((name) => Boolean(name));
16298
+ return [...new Set(names)].sort().map((name) => prefix + name);
16299
+ }
16300
+ function copiedComponentFindings(component, scanOutput) {
16301
+ let report;
16302
+ try {
16303
+ report = JSON.parse(scanOutput);
16304
+ } catch {
16305
+ return [];
16306
+ }
16307
+ const mainFile = `${component}/${component.split("/").pop()}.tsx`;
16308
+ return [...report?.failures ?? [], ...report?.warnings ?? []].filter((finding) => finding?.check === "copied-react-component" && typeof finding.file === "string" && finding.file !== mainFile).map((finding) => `- ${finding.file}: ${finding.message ?? ""}`);
16309
+ }
16310
+ function portCheckError(findings) {
16311
+ return [
16312
+ "FAILED at user-source port check:",
16313
+ ...findings,
16314
+ "The user's component was copied instead of ported, so the editor can't select or style its parts. Port it into the scaffold files as the wix-app skill's USER-SOURCES.md describes (copy only the engine logic), delete the copy, and validate again."
16315
+ ].join("\n");
16316
+ }
16317
+ function portCheckNote(components) {
16318
+ return `user-source port check: passed after one failure, but ${components.join(", ")} still copies the user's component. Say in your final message that its parts, colors and fonts can't be edited in the editor panels yet.`;
16319
+ }
16320
+ }
16321
+ });
16322
+
16221
16323
  // dist/opencode-integration/plugins/validation-state.js
16222
16324
  var require_validation_state = __commonJS({
16223
16325
  "dist/opencode-integration/plugins/validation-state.js"(exports2) {
16224
16326
  "use strict";
16225
16327
  Object.defineProperty(exports2, "__esModule", { value: true });
16226
- exports2.VALIDATION_NUDGE = exports2.VALIDATION_STATE_PLUGIN_FILENAME = exports2.VALIDATION_LOADED_EVENT_TYPE = exports2.VALIDATION_STATE_EVENT_TYPE = void 0;
16328
+ exports2.VALIDATION_NUDGE = exports2.USER_SOURCE_SCAN = exports2.USER_ATTACHMENTS_LIST = exports2.VALIDATION_STATE_PLUGIN_FILENAME = exports2.VALIDATION_LOADED_EVENT_TYPE = exports2.VALIDATION_STATE_EVENT_TYPE = void 0;
16227
16329
  exports2.isReadOnlyShellCommand = isReadOnlyShellCommand;
16228
16330
  exports2.buildValidationStateSource = buildValidationStateSource;
16229
16331
  exports2.writeValidationStatePlugin = writeValidationStatePlugin;
@@ -16231,12 +16333,16 @@ var require_validation_state = __commonJS({
16231
16333
  var detect_1 = require_detect();
16232
16334
  var prepare_created_by_1 = require_prepare_created_by();
16233
16335
  var repository_status_1 = require_repository_status();
16336
+ var skills_override_12 = require_skills_override();
16337
+ var user_source_port_1 = require_user_source_port();
16234
16338
  function isReadOnlyShellCommand(command) {
16235
16339
  return /^(?:ls|pwd|cat|head|tail|wc|grep)(?:[ \t]+[A-Za-z0-9_./:@%+=,-]+)*[ \t]*$/.test(command) || /^git[ \t]+(?:status|diff|log|show)(?:[ \t]+(?!--(?:output|ext-diff|textconv))[A-Za-z0-9_./:@%+=,-]+)*[ \t]*$/.test(command) || /^node[ \t]+(['"]?)\/root\/\.agents\/skills\/wix-app\/scripts\/(?:scan-a11y-(?:review|code|eslint|render)|scan-user-source|render-images)\.cjs\1(?:[ \t]+(?:[A-Za-z0-9_./:@%+=,-]+|'[^'\n]*'|"[^"\n$`\\]*"))*[ \t]*$/.test(command);
16236
16340
  }
16237
16341
  exports2.VALIDATION_STATE_EVENT_TYPE = "validation_state";
16238
16342
  exports2.VALIDATION_LOADED_EVENT_TYPE = "validation_loaded";
16239
16343
  exports2.VALIDATION_STATE_PLUGIN_FILENAME = "validation-state.ts";
16344
+ exports2.USER_ATTACHMENTS_LIST = ".wix/agentInput/userAttachments.json";
16345
+ exports2.USER_SOURCE_SCAN = `${skills_override_12.SKILLS_DIR}/wix-app/scripts/scan-user-source.cjs`;
16240
16346
  exports2.VALIDATION_NUDGE = "Project files need validation. Follow your validation workflow (delegate to codegen-validator if your instructions require it), run validate({ runBuild: true }), and fix any errors before finishing. Your last message is shown to the user: once validation passes, end with a short plain-language summary for them: what changed, and if there is something you could not do, why and what they need to do next. Do not mention validation.";
16241
16347
  function buildValidationStateSource() {
16242
16348
  return String.raw`// Generated by @wix/ditto-codegen (validation-state). Do not edit.
@@ -16248,6 +16354,12 @@ const injectCreatedBy = ${detect_1.injectCreatedBy.toString()};
16248
16354
  const prepareCreatedExtensionFiles = ${prepare_created_by_1.prepareCreatedExtensionFiles.toString()};
16249
16355
  const isMissingGitRepository = ${repository_status_1.isMissingGitRepository.toString()};
16250
16356
  const isReadOnlyShellCommand = ${isReadOnlyShellCommand.toString()};
16357
+ const USER_ATTACHMENTS_LIST = ${JSON.stringify(exports2.USER_ATTACHMENTS_LIST)};
16358
+ const USER_SOURCE_SCAN = ${JSON.stringify(exports2.USER_SOURCE_SCAN)};
16359
+ const changedEditorComponents = ${user_source_port_1.changedEditorComponents.toString()};
16360
+ const copiedComponentFindings = ${user_source_port_1.copiedComponentFindings.toString()};
16361
+ const portCheckError = ${user_source_port_1.portCheckError.toString()};
16362
+ const portCheckNote = ${user_source_port_1.portCheckNote.toString()};
16251
16363
  const MUTATING_TOOLS = new Set(["write", "edit", "apply_patch", "batch-write", "multi-edit", "wix-generate", "bash"]);
16252
16364
 
16253
16365
  export const ValidationState = async ({ client, directory, $ }) => {
@@ -16290,6 +16402,39 @@ export const ValidationState = async ({ client, directory, $ }) => {
16290
16402
  injectCreatedBy, BUILDERS);
16291
16403
  };
16292
16404
 
16405
+ const runUserSourceScan = async (component) => {
16406
+ const command = Object.assign(["node ", " ", ""], { raw: ["node ", " ", ""] });
16407
+ return await $(command, USER_SOURCE_SCAN, component).cwd(directory).nothrow().quiet();
16408
+ };
16409
+ // A copy blocks once per component: a run that never validates fails the whole job.
16410
+ const portBlocked = new Set();
16411
+ const checkUserSourcePort = async () => {
16412
+ if (!(await Bun.file(directory + "/" + USER_ATTACHMENTS_LIST).exists())) return undefined;
16413
+ if (!(await Bun.file(USER_SOURCE_SCAN).exists())) return undefined;
16414
+ const baseline = process.env.CODEGEN_VALIDATION_BASELINE;
16415
+ const components = changedEditorComponents([
16416
+ ...await git(baseline ? ["diff", "--name-only", "--no-renames", "-z", baseline] : ["ls-files", "--cached", "-z"]),
16417
+ ...await git(["ls-files", "--others", "--exclude-standard", "-z"]),
16418
+ ]);
16419
+ const findings = [];
16420
+ const stillCopied = [];
16421
+ for (const component of components) {
16422
+ const scan = await runUserSourceScan(component);
16423
+ // Exit 2: the scan couldn't run.
16424
+ if (scan.exitCode !== 0 && scan.exitCode !== 1) continue;
16425
+ const copied = copiedComponentFindings(component, scan.stdout.toString());
16426
+ if (copied.length === 0) continue;
16427
+ if (portBlocked.has(component)) stillCopied.push(component);
16428
+ else {
16429
+ portBlocked.add(component);
16430
+ findings.push(...copied);
16431
+ }
16432
+ }
16433
+ if (findings.length > 0) return portCheckError(findings);
16434
+ if (stillCopied.length > 0) return portCheckNote(stillCopied);
16435
+ return undefined;
16436
+ };
16437
+
16293
16438
  let cleanFingerprint = await snapshot();
16294
16439
  let currentFingerprint = cleanFingerprint;
16295
16440
  let hasValidationFailure = process.env.CODEGEN_REQUIRE_VALIDATION === "1";
@@ -16350,6 +16495,10 @@ export const ValidationState = async ({ client, directory, $ }) => {
16350
16495
  },
16351
16496
  "tool.execute.after": async (input, output) => {
16352
16497
  if (input.tool === "validate") {
16498
+ if (input.args?.runBuild === true && typeof output.output === "string" && !/^FAILED at/m.test(output.output)) {
16499
+ const port = await checkUserSourcePort().catch(() => undefined);
16500
+ if (port) output.output += "\n" + port;
16501
+ }
16353
16502
  const epoch = validations.get(key(input));
16354
16503
  validations.delete(key(input));
16355
16504
  const passed = typeof output.output === "string" && !/^FAILED at/m.test(output.output);
@@ -24887,68 +25036,6 @@ var require_job_timeout_monitor = __commonJS({
24887
25036
  }
24888
25037
  });
24889
25038
 
24890
- // dist/opencode-integration/skills/skills-override.js
24891
- var require_skills_override = __commonJS({
24892
- "dist/opencode-integration/skills/skills-override.js"(exports2) {
24893
- "use strict";
24894
- Object.defineProperty(exports2, "__esModule", { value: true });
24895
- exports2.SKILLS_DIR = void 0;
24896
- exports2.parseSkillsOverrides = parseSkillsOverrides;
24897
- exports2.overrideSkills = overrideSkills;
24898
- var child_process_1 = require("child_process");
24899
- var util_1 = require("util");
24900
- var execAsync = (0, util_1.promisify)(child_process_1.exec);
24901
- exports2.SKILLS_DIR = "/root/.agents/skills";
24902
- function tarballUrl(repo, branch) {
24903
- return `https://github.com/${repo}/archive/refs/heads/${branch}.tar.gz`;
24904
- }
24905
- function buildListSkillsCommand(repo, branch) {
24906
- return `curl -sL ${tarballUrl(repo, branch)} | tar tz --wildcards "*/skills/*" | sed 's|^.*/skills/||' | cut -d/ -f1 | grep -v '^$' | sort -u`;
24907
- }
24908
- function buildOverrideCommand(repo, branch) {
24909
- return `tmp=$(mktemp -d) && curl -sL ${tarballUrl(repo, branch)} | tar xz -C $tmp --strip-components=1 && [ -d "$tmp/skills" ] && mkdir -p ${exports2.SKILLS_DIR} && cp -r "$tmp/skills"/. ${exports2.SKILLS_DIR}/ && rm -rf $tmp`;
24910
- }
24911
- function parseSkillsOverrides(value) {
24912
- return value.split(",").map((entry) => entry.trim()).filter(Boolean).map((entry) => {
24913
- const colonIndex = entry.lastIndexOf(":");
24914
- if (colonIndex === -1) {
24915
- throw new Error(`Invalid skills override entry "${entry}": expected format "repo:branch"`);
24916
- }
24917
- return {
24918
- repo: entry.slice(0, colonIndex),
24919
- branch: entry.slice(colonIndex + 1)
24920
- };
24921
- });
24922
- }
24923
- async function overrideSkills(overrides, outputPath, log) {
24924
- for (const { repo, branch } of overrides) {
24925
- log.info("[Skills] Listing skills from repo", { repo, branch });
24926
- const { stdout } = await execAsync(buildListSkillsCommand(repo, branch));
24927
- const skillNames = stdout.trim().split("\n").filter(Boolean);
24928
- if (skillNames.length === 0) {
24929
- log.warn("[Skills] No skills found in repo, skipping", { repo, branch });
24930
- continue;
24931
- }
24932
- log.info("[Skills] Removing existing skills before override", {
24933
- repo,
24934
- branch,
24935
- skillNames
24936
- });
24937
- const paths = skillNames.map((name) => `${exports2.SKILLS_DIR}/${name}`).join(" ");
24938
- await execAsync(`rm -rf ${paths}`);
24939
- log.info("[Skills] Extracting skills from repo", { repo, branch });
24940
- await execAsync(buildOverrideCommand(repo, branch), {
24941
- cwd: outputPath
24942
- });
24943
- log.info("[Skills] Skills overridden from repo successfully", {
24944
- repo,
24945
- branch
24946
- });
24947
- }
24948
- }
24949
- }
24950
- });
24951
-
24952
25039
  // dist/opencode-integration/skills/skills-installer.js
24953
25040
  var require_skills_installer = __commonJS({
24954
25041
  "dist/opencode-integration/skills/skills-installer.js"(exports2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.500",
3
+ "version": "1.0.501",
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": "deebf315489e8a8ed2032567022bb2c084d386b869a1380c2a72e485"
32
+ "falconPackageHash": "b71f6f873710cf5eaac7318ce54b5f6c9cefe810435242a6a8792202"
33
33
  }