@wix/ditto-codegen-public 1.0.349 → 1.0.351

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.
@@ -0,0 +1,23 @@
1
+ import { tool } from "@opencode-ai/plugin";
2
+
3
+ export default tool({
4
+ description:
5
+ "Declare the Wix app permissions the generated code requires. Call ONCE at the " +
6
+ "very end of your response, after all files are written and validated, and ONLY if " +
7
+ "the code actually requires permissions — do NOT call this tool when none are needed. " +
8
+ "Pass SCOPE ID format (not human-readable names), e.g. `@wix/data` read → 'SCOPE.DC-DATA.READ', " +
9
+ "write → 'SCOPE.DC-DATA.WRITE', embedded scripts → 'SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS'. " +
10
+ "Only include scope IDs you have explicitly seen in the Wix SDK documentation (via MCP or " +
11
+ "loaded skills) — NEVER guess or fabricate them. Omitting a permission is better than " +
12
+ "inventing one.",
13
+ args: {
14
+ permissions: tool.schema
15
+ .array(tool.schema.string())
16
+ .describe(
17
+ "The required permission SCOPE IDs, e.g. ['SCOPE.DC-DATA.READ', 'SCOPE.DC-DATA.WRITE'].",
18
+ ),
19
+ },
20
+ async execute(args) {
21
+ return `✓ recorded ${args.permissions.length} required permission(s)`;
22
+ },
23
+ });
package/dist/out.js CHANGED
@@ -12068,6 +12068,7 @@ TOOL USAGE:
12068
12068
  - "Building project"
12069
12069
  - \`validate\` for all validation (tsc + build).
12070
12070
  - \`uuid\` to generate UUIDs (supports count param for multiple). Do NOT use bash.
12071
+ - \`required-permissions\` to declare the Wix app permissions the generated code needs. Call it ONCE at the end, and ONLY if permissions are actually needed \u2014 don't call it otherwise (see PERMISSIONS).
12071
12072
  - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
12072
12073
  - \`batch-write\` to create N new files in one call. NEVER call \`write\` more than once per turn \u2014 use batch-write instead. \`write\` is reserved for single-file creation.
12073
12074
  - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
@@ -12084,7 +12085,8 @@ IMPLEMENTATION WORKFLOW:
12084
12085
  3. **Build**: Create every extension file in a SINGLE \`batch-write\` call. Build all extensions before registering. Include one \`progress\` call per extension type (e.g. "Creating dashboard page", "Creating service plugin").
12085
12086
  4. **Register**: Register all extensions in \`src/extensions.ts\`. Include a \`progress\` call (e.g. "Registering extensions").
12086
12087
  5. **Validate**: Run \`validate\` (typecheck only). Fix any errors and re-validate until tsc passes. Include a \`progress\` call (e.g. "Running type checks"). Then run \`validate({ runBuild: true })\` ONCE to verify the build. Pass \`installDeps: true\` ONLY when you added a new dependency to package.json in this iteration; otherwise omit it (node_modules is pre-installed). Include a \`progress\` call (e.g. "Building project").
12087
- 6. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
12088
+ 6. **Declare permissions**: If the generated code requires Wix app permissions, call \`required-permissions\` ONCE with their SCOPE IDs (see PERMISSIONS below). Skip this step entirely if no permissions are needed.
12089
+ 7. **Stop**: STOP immediately. Do NOT refactor, clean up, or verify.
12088
12090
 
12089
12091
  EFFICIENCY:
12090
12092
  - Always prefer the BATCH variant: \`batch-write\` over multiple \`write\`s, \`batch-read\` over multiple \`read\`s, \`multi-edit\` over multiple \`edit\`s.
@@ -12099,21 +12101,14 @@ TYPESCRIPT:
12099
12101
  - The project enables \`verbatimModuleSyntax\`. Type-only imports MUST use \`import type\`.
12100
12102
 
12101
12103
  PERMISSIONS:
12102
- At the end of your response, output the required Wix app permissions as a JSON block.
12104
+ After the final \`validate\` pass and before you Stop, if the generated code requires Wix app permissions, call the \`required-permissions\` tool ONCE with them. If no permissions are required, do NOT call the tool at all.
12103
12105
  Use SCOPE ID format (not human-readable names). Examples:
12104
12106
  - \`@wix/data\` read \u2192 "SCOPE.DC-DATA.READ", write \u2192 "SCOPE.DC-DATA.WRITE"
12105
12107
  - Embedded scripts \u2192 "SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS"
12106
12108
 
12107
12109
  CRITICAL: Only include permissions that you have explicitly seen in the Wix SDK documentation (via MCP or loaded skills). NEVER guess or fabricate permission scope IDs. If you are unsure which permission a feature requires, look it up in the docs first. Omitting a permission is better than inventing one that does not exist.
12108
12110
 
12109
- \`\`\`json:required-permissions
12110
- ["SCOPE.DC-DATA.READ", "SCOPE.DC-DATA.WRITE"]
12111
- \`\`\`
12112
-
12113
- If no permissions are required, output an empty array:
12114
- \`\`\`json:required-permissions
12115
- []
12116
- \`\`\``;
12111
+ Example: \`required-permissions({ permissions: ["SCOPE.DC-DATA.READ", "SCOPE.DC-DATA.WRITE"] })\``;
12117
12112
  }
12118
12113
  });
12119
12114
 
@@ -12515,26 +12510,21 @@ var require_parser = __commonJS({
12515
12510
  return output.split("\n").filter((line) => line.trim()).map((line) => (0, types_1.tryParseJson)(line)).filter((event) => event !== null && event.type === type);
12516
12511
  }
12517
12512
  function parseRequiredPermissions(output) {
12513
+ let permissions = [];
12518
12514
  const lines = output.split("\n");
12519
12515
  for (const line of lines) {
12520
12516
  if (!line.trim())
12521
12517
  continue;
12522
12518
  const event = (0, types_1.tryParseJson)(line);
12523
- if (!event || event.type !== "text" || !event.part?.text)
12524
- continue;
12525
- const text = event.part.text;
12526
- const match = text.match(/```json:required-permissions\s*\n?\s*(\[.*?\])\s*\n?```/s);
12527
- if (!match)
12528
- continue;
12529
- const parsed = (0, types_1.tryParseJson)(match[1]);
12530
- if (!Array.isArray(parsed))
12519
+ if (!event || event.type !== "tool_use" || event.part?.tool !== "required-permissions" || event.part.state?.status !== "completed") {
12531
12520
  continue;
12532
- const permissions = parsed.filter((p) => typeof p === "string");
12533
- if (permissions.length > 0) {
12534
- return permissions;
12535
12521
  }
12522
+ const declared = event.part.state.input?.permissions;
12523
+ if (!Array.isArray(declared))
12524
+ continue;
12525
+ permissions = declared.filter((p) => typeof p === "string");
12536
12526
  }
12537
- return [];
12527
+ return permissions;
12538
12528
  }
12539
12529
  function parseFilesChanged(output) {
12540
12530
  const filesChanged = [];
@@ -12572,13 +12562,6 @@ var require_parser = __commonJS({
12572
12562
  if (filePath) {
12573
12563
  addFileChange(filePath, operation);
12574
12564
  }
12575
- if (metadata?.diagnostics) {
12576
- for (const diagPath of Object.keys(metadata.diagnostics)) {
12577
- if (diagPath && !diagPath.includes("node_modules")) {
12578
- addFileChange(diagPath, ditto_codegen_types_12.ExtensionGenerationOperation.INSERT);
12579
- }
12580
- }
12581
- }
12582
12565
  }
12583
12566
  if (tool === "task" && event.part.state.metadata?.summary) {
12584
12567
  for (const item of event.part.state.metadata.summary) {
@@ -12994,16 +12977,11 @@ var require_result_builder = __commonJS({
12994
12977
  "dist/opencode-integration/result-builder.js"(exports2) {
12995
12978
  "use strict";
12996
12979
  Object.defineProperty(exports2, "__esModule", { value: true });
12997
- exports2.isCorruptedSessionError = isCorruptedSessionError;
12998
12980
  exports2.createTimeoutResult = createTimeoutResult;
12999
12981
  exports2.createSuccessResult = createSuccessResult;
13000
12982
  exports2.createSpawnErrorResult = createSpawnErrorResult;
13001
12983
  var ditto_codegen_types_12 = require_dist4();
13002
12984
  var parser_1 = require_parser();
13003
- function isCorruptedSessionError(result) {
13004
- const combined = `${result.stderr} ${result.stdout} ${result.error?.message || ""}`;
13005
- return !result.success && combined.includes("tool_use") && combined.includes("tool_result");
13006
- }
13007
12985
  function createTimeoutResult(message, stdout, stderr, startTime) {
13008
12986
  return {
13009
12987
  success: false,
@@ -13170,13 +13148,15 @@ var require_executor = __commonJS({
13170
13148
  let accumulatedUsage = (0, parser_1.createEmptyUsageStats)();
13171
13149
  const accumulatedSkills = [];
13172
13150
  let currentPrompt = options.prompt;
13151
+ let continueSession = options.continueSession ?? false;
13173
13152
  for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
13174
13153
  if (attempt > 1) {
13175
13154
  logger_12.logger.info(`[OpenCode] Retry attempt ${attempt}/${MAX_RETRIES} - starting fresh session with recovery context`);
13176
13155
  const filesChanged = (0, parser_1.parseFilesChanged)(accumulatedStdout);
13177
13156
  currentPrompt = (0, prompts_1.buildRecoveryPrompt)(options.prompt, filesChanged, lastResult?.error?.message || lastResult?.stderr || "Process timed out");
13157
+ continueSession = false;
13178
13158
  }
13179
- const result = await executeOpenCodeOnce({ ...options, prompt: currentPrompt }, attempt);
13159
+ const result = await executeOpenCodeOnce({ ...options, prompt: currentPrompt, continueSession }, attempt);
13180
13160
  accumulatedStdout += result.stdout;
13181
13161
  accumulatedUsage = (0, parser_1.mergeUsageStats)(accumulatedUsage, result.usage);
13182
13162
  accumulatedSkills.push(...result.skillsUsed);
@@ -13224,11 +13204,12 @@ var require_executor = __commonJS({
13224
13204
  logger_12.logger.debug("[OpenCode] Stats", { stats });
13225
13205
  }
13226
13206
  }
13227
- function buildArgs(prompt) {
13228
- return ["run", "--format", "json", prompt];
13207
+ function buildArgs(prompt, continueSession) {
13208
+ const sessionArgs = continueSession ? ["--continue"] : [];
13209
+ return ["run", ...sessionArgs, "--format", "json", prompt];
13229
13210
  }
13230
13211
  async function executeOpenCodeOnce(options, attempt) {
13231
- const { prompt, outputPath, projectId, onStdout, onStderr } = options;
13212
+ const { prompt, outputPath, projectId, onStdout, onStderr, continueSession = false } = options;
13232
13213
  const startTime = Date.now();
13233
13214
  const taskTracker = new task_tracker_1.OpenCodeTaskTracker(outputPath);
13234
13215
  return new Promise((resolve) => {
@@ -13260,11 +13241,12 @@ var require_executor = __commonJS({
13260
13241
  finalize
13261
13242
  };
13262
13243
  try {
13263
- const args = buildArgs(prompt);
13244
+ const args = buildArgs(prompt, continueSession);
13264
13245
  logger_12.logger.info("[OpenCode] Executing opencode run", {
13265
13246
  attempt,
13266
13247
  maxRetries: MAX_RETRIES,
13267
- workingDirectory: outputPath
13248
+ workingDirectory: outputPath,
13249
+ continueSession
13268
13250
  });
13269
13251
  logger_12.logger.debug("[OpenCode] Full prompt", { prompt });
13270
13252
  const isAsk = job_context_storage_12.jobContextStorage.getStore()?.kind === ditto_codegen_types_12.TaskKind.ASK_CODEGEN;
@@ -13326,6 +13308,7 @@ var require_opencode_runner = __commonJS({
13326
13308
  prompt,
13327
13309
  outputPath,
13328
13310
  projectId,
13311
+ continueSession: true,
13329
13312
  onStdout,
13330
13313
  onStderr
13331
13314
  });
@@ -13337,6 +13320,7 @@ var require_opencode_runner = __commonJS({
13337
13320
  prompt,
13338
13321
  outputPath,
13339
13322
  projectId,
13323
+ continueSession: true,
13340
13324
  onStdout,
13341
13325
  onStderr
13342
13326
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.349",
3
+ "version": "1.0.351",
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": "7bf8f9326f7820f00099545cc4aebcdd29a5edecaf96fb1f3cbd53c3"
32
+ "falconPackageHash": "3708d27949830337bd148a06d1b7efee98e5e018a789462083489bb3"
33
33
  }