@wix/ditto-codegen-public 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/out.js CHANGED
@@ -119054,6 +119054,117 @@ Generate diverse, realistic sample data that would be appropriate for this type
119054
119054
  }
119055
119055
  });
119056
119056
 
119057
+ // dist/system-prompts/site/siteComponentPrompt.js
119058
+ var require_siteComponentPrompt = __commonJS({
119059
+ "dist/system-prompts/site/siteComponentPrompt.js"(exports2) {
119060
+ "use strict";
119061
+ Object.defineProperty(exports2, "__esModule", { value: true });
119062
+ exports2.siteComponentPrompt = void 0;
119063
+ var siteComponentPrompt = async () => {
119064
+ return `
119065
+ <WIXCLI_SITE_COMPONENT_SYSTEM_PROMPT>
119066
+ <role>
119067
+ You are a senior Wix CLI App Developer and React expert. Your job is to produce a beautiful, production\u2011quality site component quickly and correctly.
119068
+ </role>
119069
+
119070
+ <rules>
119071
+ - Return ONLY a JSON object matching the schema { path, content, type } (no prose, no markdown)
119072
+ - type must be "typescript"; content must be the COMPLETE file source
119073
+ - Do NOT add dependencies; do NOT use @wix/design-system or @wix/wix-ui-icons-common
119074
+ - Do NOT invent types/modules/props; use only what exists in the scaffold and standard libs
119075
+ </rules>
119076
+
119077
+ <style_guidelines>
119078
+ - Prefer simple, elegant UI using inline styles (no CSS imports)
119079
+ - Use semantic HTML and accessible patterns (aria-*, roles, focus styles)
119080
+ - Favor flex layouts, spacing, readable typography; avoid visual clutter
119081
+ - Keep responsiveness lightweight (flex/wrap/percentages); avoid heavy logic
119082
+ </style_guidelines>
119083
+
119084
+ <engineering_guidelines>
119085
+ - Implement a functional React + TypeScript component with a typed Props interface
119086
+ - Keep the component small, pure, and readable; remove dead code/unused imports
119087
+ - Use React hooks where needed; avoid unnecessary re-renders
119088
+ - Name things clearly; avoid magic numbers; extract tiny helpers if it improves clarity
119089
+ </engineering_guidelines>
119090
+
119091
+ <typescript_quality_guidelines>
119092
+ - Generated code MUST compile with zero TypeScript errors under strict settings:
119093
+ strict, noImplicitAny, strictNullChecks, exactOptionalPropertyTypes, noUncheckedIndexedAccess
119094
+ - Prefer type-narrowing and exhaustive logic over assertions; avoid non-null assertions (!) and unsafe casts (as any)
119095
+ - Treat optional values, refs, and array indexing results as possibly undefined and handle them explicitly
119096
+ - Use exhaustive checks for unions (e.g., switch with a never check) and return total values (no implicit undefined)
119097
+ - Do NOT use // @ts-ignore or // @ts-expect-error; fix the types or add guards instead
119098
+ </typescript_quality_guidelines>
119099
+
119100
+ </WIXCLI_SITE_COMPONENT_SYSTEM_PROMPT>
119101
+ `;
119102
+ };
119103
+ exports2.siteComponentPrompt = siteComponentPrompt;
119104
+ }
119105
+ });
119106
+
119107
+ // dist/agents/SiteComponentAgent.js
119108
+ var require_SiteComponentAgent = __commonJS({
119109
+ "dist/agents/SiteComponentAgent.js"(exports2) {
119110
+ "use strict";
119111
+ Object.defineProperty(exports2, "__esModule", { value: true });
119112
+ exports2.SiteComponentAgent = void 0;
119113
+ var anthropic_1 = require_dist5();
119114
+ var ai_1 = require_dist7();
119115
+ var utils_1 = require_utils14();
119116
+ var siteComponentPrompt_1 = require_siteComponentPrompt();
119117
+ var SiteComponentAgent = class {
119118
+ constructor(apiKey) {
119119
+ this.apiKey = apiKey;
119120
+ this.name = "SiteComponentAgent";
119121
+ }
119122
+ async buildSystemPrompt() {
119123
+ return (0, siteComponentPrompt_1.siteComponentPrompt)();
119124
+ }
119125
+ async generate(extension, blueprint, scaffold) {
119126
+ const systemPrompt = `${await this.buildSystemPrompt()}`;
119127
+ const userMessage = `Customize the Wix CLI dashboard page scaffolding for the app "${blueprint.appName}":
119128
+ Extension Name: ${extension.name}
119129
+ Extension Description: ${extension.description}
119130
+ App Summary: ${blueprint.summary}
119131
+
119132
+ ## CURRENT SCAFFOLDED FILE
119133
+ Path: ${scaffold.path}
119134
+ \`\`\`
119135
+ ${scaffold.content}
119136
+ \`\`\``;
119137
+ const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-sonnet-4-20250514");
119138
+ const result = await (0, ai_1.generateObject)({
119139
+ model,
119140
+ schema: utils_1.FileSchema,
119141
+ messages: [
119142
+ {
119143
+ role: "system",
119144
+ content: systemPrompt,
119145
+ providerOptions: (0, utils_1.withCaching)("1h")
119146
+ },
119147
+ {
119148
+ role: "user",
119149
+ content: userMessage
119150
+ }
119151
+ ],
119152
+ experimental_telemetry: {
119153
+ isEnabled: true,
119154
+ functionId: this.name
119155
+ },
119156
+ maxOutputTokens: 1e4,
119157
+ maxRetries: 3,
119158
+ temperature: 0
119159
+ });
119160
+ return result.object;
119161
+ }
119162
+ };
119163
+ exports2.SiteComponentAgent = SiteComponentAgent;
119164
+ exports2.default = SiteComponentAgent;
119165
+ }
119166
+ });
119167
+
119057
119168
  // dist/agents/AgentsFactory.js
119058
119169
  var require_AgentsFactory = __commonJS({
119059
119170
  "dist/agents/AgentsFactory.js"(exports2) {
@@ -119069,6 +119180,7 @@ var require_AgentsFactory = __commonJS({
119069
119180
  var PlannerAgent_1 = __importDefault2(require_PlannerAgent());
119070
119181
  var CMSAgent_1 = require_CMSAgent();
119071
119182
  var CMSDataAgent_1 = require_CMSDataAgent();
119183
+ var SiteComponentAgent_1 = __importDefault2(require_SiteComponentAgent());
119072
119184
  var AgentsFactory = class {
119073
119185
  constructor(apiKey) {
119074
119186
  this.apiKey = apiKey;
@@ -119085,6 +119197,8 @@ var require_AgentsFactory = __commonJS({
119085
119197
  return new CMSDataAgent_1.CMSDataAgent(this.apiKey);
119086
119198
  case "PLANNER":
119087
119199
  return new PlannerAgent_1.default(this.apiKey);
119200
+ case types_1.ExtensionType.SITE_COMPONENT:
119201
+ return new SiteComponentAgent_1.default(this.apiKey);
119088
119202
  default:
119089
119203
  throw new Error(`Unsupported extension type for AI customization: ${extension.type}`);
119090
119204
  }
@@ -119207,9 +119321,9 @@ var require_tools = __commonJS({
119207
119321
  return [destPath];
119208
119322
  }
119209
119323
  }
119210
- function copyScaffolding(scaffoldingSubPath, outputPath, excludePatterns = ["node_modules", ".git"]) {
119324
+ function copyScaffolding(scaffoldingSubPath, outputPath, excludePatterns = ["node_modules", ".git"], outputFolder) {
119211
119325
  const sourcePath = path_1.default.join(scaffoldingBasePath, scaffoldingSubPath);
119212
- const destPath = path_1.default.join(outputPath, scaffoldingSubPath);
119326
+ const destPath = path_1.default.join(outputPath, outputFolder ?? scaffoldingSubPath);
119213
119327
  console.log(`\u{1F4E6} Copying scaffolding from: ${scaffoldingSubPath}`);
119214
119328
  return copyRecursive(sourcePath, destPath, excludePatterns);
119215
119329
  }
@@ -119275,11 +119389,20 @@ var require_scaffolding = __commonJS({
119275
119389
  return copyBackendApiScaffolding(extension, outputPath);
119276
119390
  case types_1.ExtensionType.BACKEND_EVENT:
119277
119391
  return copyBackendEventScaffolding(extension, outputPath);
119392
+ case types_1.ExtensionType.SITE_COMPONENT:
119393
+ return copySiteComponentScaffolding(extension, outputPath);
119278
119394
  default:
119279
119395
  console.log(` \u26A0\uFE0F Unsupported extension type: ${extension.type}`);
119280
119396
  return [];
119281
119397
  }
119282
119398
  }
119399
+ async function copySiteComponentScaffolding(extension, outputPath) {
119400
+ const componentName = extension.name ?? "my-component";
119401
+ const scaffoldingSubPath = `src/site/components/my-component`;
119402
+ const componentSubPath = `src/site/components/${toKebabCase(componentName)}`;
119403
+ console.log(` \u{1F3A8} Copying site component scaffolding from: ${scaffoldingSubPath} to ${componentSubPath}`);
119404
+ return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath, [], componentSubPath);
119405
+ }
119283
119406
  async function copyServicePluginScaffolding(extension, outputPath) {
119284
119407
  if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
119285
119408
  throw new Error("Service plugin extension must have related SPIs");
@@ -119330,6 +119453,9 @@ var require_scaffolding = __commonJS({
119330
119453
  console.log(` \u26A1 Copying backend event scaffolding from: ${scaffoldingSubPath}`);
119331
119454
  return (0, tools_1.copyScaffolding)(scaffoldingSubPath, outputPath);
119332
119455
  }
119456
+ function toKebabCase(name) {
119457
+ return name.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/-+/g, "-").toLowerCase();
119458
+ }
119333
119459
  }
119334
119460
  });
119335
119461
 
@@ -119414,6 +119540,26 @@ var require_extensions_file = __commonJS({
119414
119540
  routePath: '${routePath}',
119415
119541
  title: '${title}',
119416
119542
  })`);
119543
+ } else if (types_1.ExtensionType.SITE_COMPONENT) {
119544
+ const componentName = ext.name ?? "my-component";
119545
+ const kebabCaseComponentName = toKebabCase(componentName);
119546
+ const id = (0, crypto_1.randomUUID)();
119547
+ blocks.push(` extensions.siteComponent({
119548
+ id: '${id}',
119549
+ description: '${ext.name}',
119550
+ type: 'platform.builder.c8493d19-9d3f-4233-9c2c-7305ac567af3_8fccccee-ee75-4b29-a0e6-e5bd67e9184b',
119551
+
119552
+ editorElement: {
119553
+ displayName: '${componentName}',
119554
+ selector: '${kebabCaseComponentName}',
119555
+ },
119556
+
119557
+ resources: {
119558
+ client: {
119559
+ component: './site/components/${kebabCaseComponentName}/component.tsx',
119560
+ },
119561
+ },
119562
+ })`);
119417
119563
  }
119418
119564
  }
119419
119565
  const imports = `import { app } from '@wix/astro/builders';
@@ -119432,6 +119578,9 @@ ${b}
119432
119578
  fs_1.default.writeFileSync(filePath, content);
119433
119579
  console.log(`\u{1F4DD} Generated: ${path_1.default.relative(outputPath, filePath)}`);
119434
119580
  }
119581
+ function toKebabCase(name) {
119582
+ return name.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/-+/g, "-").toLowerCase();
119583
+ }
119435
119584
  }
119436
119585
  });
119437
119586
 
@@ -0,0 +1,20 @@
1
+ import type { FC } from 'react';
2
+ import s from './styles.module.css';
3
+
4
+ interface Props {
5
+ className: string;
6
+ id: string;
7
+ text?: string;
8
+ }
9
+
10
+ const Button: FC<Props> = (props) => {
11
+ return (
12
+ <div className={props.className} id={props.id}>
13
+ <button className={`btn ${s.btn}`}>
14
+ <span className={s.text}>{props.text ?? '[Default] Click Me HMR'}</span>
15
+ </button>
16
+ </div>
17
+ );
18
+ };
19
+
20
+ export default Button;
@@ -0,0 +1,17 @@
1
+ .btn {
2
+ background-color: #007bff;
3
+ border: none;
4
+ color: white;
5
+ padding: 10px 20px;
6
+ text-align: center;
7
+ text-decoration: none;
8
+ display: inline-block;
9
+ font-size: 16px;
10
+ margin: 4px 2px;
11
+ cursor: pointer;
12
+ }
13
+
14
+ .text {
15
+ color: #333;
16
+ font-size: 14px;
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -24,5 +24,5 @@
24
24
  "@wix/ditto-codegen": "1.0.0",
25
25
  "esbuild": "^0.25.9"
26
26
  },
27
- "falconPackageHash": "56bac02b80b787701c852c60753c9636582a74af53844b56851d4ca5"
27
+ "falconPackageHash": "8ddfeb0447ecad792ac842099f8b1b9f7ff9a88a00c7dffe496475c3"
28
28
  }