@wix/ditto-codegen-public 1.0.383 → 1.0.384

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 +403 -95
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -11299,12 +11299,33 @@ var require_ask_prompt = __commonJS({
11299
11299
  }
11300
11300
  });
11301
11301
 
11302
+ // dist/opencode-integration/prompts/git-conflicts-prompt.js
11303
+ var require_git_conflicts_prompt = __commonJS({
11304
+ "dist/opencode-integration/prompts/git-conflicts-prompt.js"(exports2) {
11305
+ "use strict";
11306
+ Object.defineProperty(exports2, "__esModule", { value: true });
11307
+ exports2.buildGitConflictsPrompt = buildGitConflictsPrompt;
11308
+ var prompt_utils_1 = require_prompt_utils();
11309
+ function buildGitConflictsPrompt(history) {
11310
+ const { currentUserRequest } = (0, prompt_utils_1.extractUserRequestAndFilteredHistory)(history);
11311
+ const base = "Fix all Git merge conflicts in the current project. Resolve every conflict marker (<<<<<<<, =======, >>>>>>>) so the code compiles correctly.";
11312
+ const sections = [
11313
+ base,
11314
+ currentUserRequest ? `Additional context from user: "${currentUserRequest}"` : "",
11315
+ (0, prompt_utils_1.formatChatHistory)(history.slice(-5), "CONVERSATION CONTEXT"),
11316
+ (0, prompt_utils_1.buildAppContext)()
11317
+ ];
11318
+ return sections.filter(Boolean).join("\n\n");
11319
+ }
11320
+ }
11321
+ });
11322
+
11302
11323
  // dist/opencode-integration/prompts/index.js
11303
11324
  var require_prompts = __commonJS({
11304
11325
  "dist/opencode-integration/prompts/index.js"(exports2) {
11305
11326
  "use strict";
11306
11327
  Object.defineProperty(exports2, "__esModule", { value: true });
11307
- exports2.buildAskPrompt = exports2.buildIterationPrompt = exports2.buildRecoveryPrompt = exports2.buildInitPrompt = void 0;
11328
+ exports2.buildGitConflictsPrompt = exports2.buildAskPrompt = exports2.buildIterationPrompt = exports2.buildRecoveryPrompt = exports2.buildInitPrompt = void 0;
11308
11329
  var codegen_prompt_1 = require_codegen_prompt();
11309
11330
  Object.defineProperty(exports2, "buildInitPrompt", { enumerable: true, get: function() {
11310
11331
  return codegen_prompt_1.buildInitPrompt;
@@ -11320,6 +11341,10 @@ var require_prompts = __commonJS({
11320
11341
  Object.defineProperty(exports2, "buildAskPrompt", { enumerable: true, get: function() {
11321
11342
  return ask_prompt_1.buildAskPrompt;
11322
11343
  } });
11344
+ var git_conflicts_prompt_1 = require_git_conflicts_prompt();
11345
+ Object.defineProperty(exports2, "buildGitConflictsPrompt", { enumerable: true, get: function() {
11346
+ return git_conflicts_prompt_1.buildGitConflictsPrompt;
11347
+ } });
11323
11348
  }
11324
11349
  });
11325
11350
 
@@ -11489,6 +11514,9 @@ var require_rules_writer = __commonJS({
11489
11514
  return (0, path_1.join)(GLOBAL_RULES_DIR, filename);
11490
11515
  }
11491
11516
  async function writeRuleFiles(rules) {
11517
+ if (rules.length === 0) {
11518
+ return [];
11519
+ }
11492
11520
  await (0, promises_1.mkdir)(GLOBAL_RULES_DIR, { recursive: true });
11493
11521
  const paths = rules.map((rule) => getRulePath(rule.filename));
11494
11522
  await Promise.all(rules.map((rule) => (0, promises_1.writeFile)(getRulePath(rule.filename), rule.content, "utf-8")));
@@ -11674,6 +11702,7 @@ var require_dist5 = __commonJS({
11674
11702
  exports2.appBuilderCodegenConfig = {
11675
11703
  codegenRules: [],
11676
11704
  askRules: [],
11705
+ gitConflictsRules: [],
11677
11706
  decisionCheckers: [],
11678
11707
  plugins: []
11679
11708
  };
@@ -13904,6 +13933,7 @@ var require_dist8 = __commonJS({
13904
13933
  { filename: "site-data-layer-rules.md", content: codegen_common_logic_1.SITE_DATA_LAYER_RULES }
13905
13934
  ],
13906
13935
  askRules: [],
13936
+ gitConflictsRules: [],
13907
13937
  decisionCheckers: [],
13908
13938
  plugins: [codegen_checkpoint_plugin_1.checkpointPluginFactory]
13909
13939
  };
@@ -14254,6 +14284,7 @@ var require_dist10 = __commonJS({
14254
14284
  { filename: "site-data-layer-rules.md", content: codegen_common_logic_1.SITE_DATA_LAYER_RULES }
14255
14285
  ],
14256
14286
  askRules: [],
14287
+ gitConflictsRules: [],
14257
14288
  decisionCheckers: [],
14258
14289
  plugins: [codegen_feature_vibe_plugin_1.featureVibePluginFactory]
14259
14290
  };
@@ -14379,6 +14410,61 @@ DEBUGGING GUIDANCE:
14379
14410
  }
14380
14411
  });
14381
14412
 
14413
+ // dist/opencode-integration/rules/git-conflicts-rules.js
14414
+ var require_git_conflicts_rules = __commonJS({
14415
+ "dist/opencode-integration/rules/git-conflicts-rules.js"(exports2) {
14416
+ "use strict";
14417
+ Object.defineProperty(exports2, "__esModule", { value: true });
14418
+ exports2.GIT_CONFLICTS_RULES = void 0;
14419
+ exports2.GIT_CONFLICTS_RULES = `CORE PRINCIPLES:
14420
+ - You are a Git merge conflict resolver. Your ONLY job is to fix merge conflict markers in files.
14421
+ - Do NOT generate new features, refactor code, or make changes beyond resolving conflicts.
14422
+ - NEVER use mocks, placeholders, or TODOs.
14423
+
14424
+ UNDERSTAND INTENT FIRST:
14425
+ - Before resolving a conflict, understand WHAT each side was trying to accomplish and WHY \u2014 not just which lines differ. Read enough of the surrounding file (and the imports/usages the conflict touches) to know the intent of both sides.
14426
+ - When the change is non-trivial, inspect recent history to learn what the incoming branch refactored: \`git log -p -n 3 -- <file>\` and \`git diff\` are READ-ONLY and safe. NEVER run \`git merge\`, \`git rebase\`, \`git checkout\`, \`git reset\`, \`git add\`, or \`git commit\` \u2014 only the agent's edit tools change files; git state is managed by the host.
14427
+
14428
+ CONFLICT RESOLUTION STRATEGY:
14429
+ - Identify all files containing conflict markers: <<<<<<<, =======, >>>>>>>
14430
+ - The HEAD (OURS) section (between <<<<<<< and =======) represents the current branch's changes \u2014 preserve this code.
14431
+ - The incoming (THEIRS) section (between ======= and >>>>>>>) represents the changes being merged in.
14432
+ - Resolve each conflict by merging both sides logically \u2014 judge by SEMANTIC meaning, not line-by-line text:
14433
+ - If both sides add independent, non-overlapping code \u2014 include both.
14434
+ - If they modify the same logic \u2014 prefer HEAD (OURS) and incorporate non-conflicting parts from THEIRS.
14435
+ - If THEIRS deletes something that HEAD modifies \u2014 keep HEAD's version.
14436
+ - De-duplicate when merging both sides: combine and dedupe additive changes such as imports, exports, list/array entries, object keys, and config \u2014 NEVER leave two copies of the same import or declaration.
14437
+ - After resolving, remove ALL conflict markers. The final file must contain zero conflict markers.
14438
+ - Do NOT revert or undo any working code that existed before the conflict.
14439
+
14440
+ SEMANTIC CORRECTNESS \u2014 beyond removing markers:
14441
+ - A clean merge has NO markers AND is logically coherent. Watch for semantic conflicts: code that compiles after the markers are gone but is contradictory or broken (duplicate/clashing declarations, a variable renamed on one side but still referenced by the other, a function signature changed on one side but called the old way on the other, half-merged statements).
14442
+ - After merging, re-read the resolved region in context to confirm both sides' intent is preserved and the result type-checks. This is what the \`validate\` step exists to catch \u2014 fix anything it surfaces.
14443
+
14444
+ MINIMIZE TEXT OUTPUT \u2014 CRITICAL:
14445
+ - Do NOT narrate your actions or explain your decisions.
14446
+ - Every text token costs money. Use tools, not words.
14447
+
14448
+ TOOL USAGE:
14449
+ - \`validate\` for all validation (tsc + build). Run it after resolving the conflicts to make sure nothing breaks.
14450
+ - Package dependencies \u2014 \`npm install <pkg>\` any package not already in \`package.json\` BEFORE the first \`validate\` (do NOT wait for \`TS2307\`); install all needed packages in ONE command. Do NOT hand-edit \`package.json\` for deps unless npm cannot be used.
14451
+ - File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
14452
+ - \`batch-read\` to read N files in one call. NEVER call \`read\` more than once per turn \u2014 use batch-read instead.
14453
+ - \`multi-edit\` to apply N find-and-replace edits across one or more files in one call. NEVER call \`edit\` more than once per turn \u2014 use multi-edit instead. \`edit\` is reserved for a single edit to one file. When resolving conflicts across N files, use ONE \`multi-edit\` with all N edits.
14454
+ - \`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.
14455
+ - Tool arguments are strict JSON. For multiline strings in \`write\`, \`edit\`, \`batch-write\`, and \`multi-edit\`, use JSON escape sequences (\`\\n\`, \`\\t\`, \`\\"\`) \u2014 do NOT put raw (unescaped) newlines inside JSON string values (that breaks parsing). \`batch-write\` and \`multi-edit\` also normalize literal two-character escape sequences before writing; prefer proper JSON escapes.
14456
+ - For tools where no batch variant exists (e.g. \`grep\`, \`glob\`), still emit MULTIPLE \`tool_use\` blocks in a SINGLE response when the calls are independent. Sequential turns waste a model round-trip per call.
14457
+ - NEVER run preview, dev, release, or promote commands.
14458
+
14459
+ WORKFLOW:
14460
+ 1. **Find**: Use \`grep\` to locate all files containing "<<<<<<<".
14461
+ 2. **Resolve**: Read (\`batch-read\`) and fix all conflicts using \`multi-edit\`. Do NOT add new logic \u2014 only remove markers and merge the two sides.
14462
+ 3. **Verify markers**: Run \`grep\` again to confirm zero conflict markers remain.
14463
+ 4. **Validate**: Run \`validate\` (typecheck only). Fix any errors and re-validate until tsc passes, then run \`validate({ runBuild: true })\` ONCE to confirm the resolution did not break the build. Pass \`installDeps: true\` ONLY when \`package.json\` changed without already running \`npm install <package-name>\` in this iteration; otherwise omit it (node_modules is pre-installed).
14464
+ 5. **Stop**: STOP immediately after validation passes. Do NOT refactor or make changes beyond resolving conflicts.`;
14465
+ }
14466
+ });
14467
+
14382
14468
  // dist/job-decision-manager.js
14383
14469
  var require_job_decision_manager = __commonJS({
14384
14470
  "dist/job-decision-manager.js"(exports2) {
@@ -14487,6 +14573,7 @@ var require_environments = __commonJS({
14487
14573
  var codegen_harmony_config_1 = require_dist10();
14488
14574
  var codegen_rules_1 = require_codegen_rules();
14489
14575
  var ask_rules_1 = require_ask_rules();
14576
+ var git_conflicts_rules_1 = require_git_conflicts_rules();
14490
14577
  var job_decision_manager_1 = require_job_decision_manager();
14491
14578
  var logger_12 = require_logger();
14492
14579
  var SHARED_CODEGEN_RULE = {
@@ -14497,10 +14584,15 @@ var require_environments = __commonJS({
14497
14584
  filename: "ask-instructions.md",
14498
14585
  content: ask_rules_1.ASK_RULES
14499
14586
  };
14587
+ var SHARED_GIT_CONFLICTS_RULE = {
14588
+ filename: "git-conflicts-instructions.md",
14589
+ content: git_conflicts_rules_1.GIT_CONFLICTS_RULES
14590
+ };
14500
14591
  var withSharedRules = (env) => ({
14501
14592
  ...env,
14502
14593
  codegenRules: [SHARED_CODEGEN_RULE, ...env.codegenRules],
14503
- askRules: [SHARED_ASK_RULE, ...env.askRules]
14594
+ askRules: [SHARED_ASK_RULE, ...env.askRules],
14595
+ gitConflictsRules: [SHARED_GIT_CONFLICTS_RULE, ...env.gitConflictsRules]
14504
14596
  });
14505
14597
  function getCodegenEnvironmentConfig() {
14506
14598
  switch (process.env.CODEGEN_ENVIRONMENT) {
@@ -14541,6 +14633,7 @@ var require_config = __commonJS({
14541
14633
  var rules_writer_12 = require_rules_writer();
14542
14634
  var node_modules_guard_12 = require_node_modules_guard();
14543
14635
  var environments_12 = require_environments();
14636
+ var CodeGenService_12 = require_CodeGenService();
14544
14637
  exports2.DEFAULT_TIMEOUT_MS = 20 * 60 * 1e3;
14545
14638
  exports2.DEFAULT_MODEL = "anthropic/claude-sonnet-4-6";
14546
14639
  exports2.DEFAULT_SMALL_MODEL = "anthropic/claude-haiku-4-5-20251001";
@@ -14599,93 +14692,96 @@ var require_config = __commonJS({
14599
14692
  enabled: true
14600
14693
  }
14601
14694
  };
14602
- function getOpenCodeConfig(instructionPaths) {
14695
+ var READABLE_EXTERNAL_DIRS = {
14696
+ "/root/.agents/**": "allow",
14697
+ "/root/.claude/**": "allow",
14698
+ "/root/.opencode/**": "allow",
14699
+ "/tmp/**": "allow"
14700
+ };
14701
+ var PLANNING_TOOLS_DENIED = {
14702
+ task: "deny",
14703
+ [
14704
+ "todowrite"
14705
+ /* OpenCodeTool.TodoWrite */
14706
+ ]: "deny",
14707
+ [
14708
+ "todoread"
14709
+ /* OpenCodeTool.TodoRead */
14710
+ ]: "deny"
14711
+ };
14712
+ var CODEGEN_PERMISSIONS = {
14713
+ ...PLANNING_TOOLS_DENIED,
14714
+ [
14715
+ "skill"
14716
+ /* OpenCodeTool.Skill */
14717
+ ]: { "*": "allow" },
14718
+ doom_loop: "allow",
14719
+ external_directory: READABLE_EXTERNAL_DIRS
14720
+ };
14721
+ var GIT_CONFLICTS_PERMISSIONS = {
14722
+ ...CODEGEN_PERMISSIONS,
14723
+ [
14724
+ "progress"
14725
+ /* OpenCodeTool.Progress */
14726
+ ]: "deny",
14727
+ [
14728
+ "uuid"
14729
+ /* OpenCodeTool.Uuid */
14730
+ ]: "deny",
14731
+ [
14732
+ "wix-generate"
14733
+ /* OpenCodeTool.WixGenerate */
14734
+ ]: "deny",
14735
+ [
14736
+ "required-permissions"
14737
+ /* OpenCodeTool.RequiredPermissions */
14738
+ ]: "deny",
14739
+ [
14740
+ "user-actions"
14741
+ /* OpenCodeTool.UserActions */
14742
+ ]: "deny"
14743
+ };
14744
+ var ASK_PERMISSIONS = {
14745
+ ...PLANNING_TOOLS_DENIED,
14746
+ [
14747
+ "edit"
14748
+ /* OpenCodeTool.Edit */
14749
+ ]: "deny",
14750
+ [
14751
+ "bash"
14752
+ /* OpenCodeTool.Bash */
14753
+ ]: "deny",
14754
+ [
14755
+ "batch-write"
14756
+ /* OpenCodeTool.BatchWrite */
14757
+ ]: "deny",
14758
+ [
14759
+ "multi-edit"
14760
+ /* OpenCodeTool.MultiEdit */
14761
+ ]: "deny",
14762
+ [
14763
+ "validate"
14764
+ /* OpenCodeTool.Validate */
14765
+ ]: "deny",
14766
+ [
14767
+ "uuid"
14768
+ /* OpenCodeTool.Uuid */
14769
+ ]: "deny",
14770
+ external_directory: READABLE_EXTERNAL_DIRS
14771
+ };
14772
+ function buildConfig(instructionPaths, permission, { guardNodeModules = false } = {}) {
14603
14773
  return {
14604
14774
  model: exports2.DEFAULT_MODEL,
14605
14775
  small_model: exports2.DEFAULT_SMALL_MODEL,
14606
14776
  provider: getProviderConfig(),
14607
14777
  compaction: { prune: true },
14608
14778
  // drop old tool outputs so --continue replays stay bounded
14609
- permission: {
14610
- [
14611
- "skill"
14612
- /* OpenCodeTool.Skill */
14613
- ]: {
14614
- "*": "allow"
14615
- },
14616
- task: "deny",
14617
- doom_loop: "allow",
14618
- [
14619
- "todowrite"
14620
- /* OpenCodeTool.TodoWrite */
14621
- ]: "deny",
14622
- [
14623
- "todoread"
14624
- /* OpenCodeTool.TodoRead */
14625
- ]: "deny",
14626
- external_directory: {
14627
- "/root/.agents/**": "allow",
14628
- "/root/.claude/**": "allow",
14629
- "/root/.opencode/**": "allow",
14630
- "/tmp/**": "allow"
14631
- }
14632
- },
14779
+ permission,
14633
14780
  instructions: instructionPaths,
14634
- // Blocks node_modules SDK-spelunking bash turns after a small exploratory
14635
- // budget and steers back to the loaded references (see node-modules-guard.ts).
14636
- plugin: [node_modules_guard_12.GUARD_PLUGIN_PATH],
14637
- autoupdate: false,
14638
- share: "disabled",
14639
14781
  lsp: false,
14640
14782
  mcp: WIX_MCP_CONFIG,
14641
- watcher: { ignore: WATCHER_IGNORE_PATTERNS }
14642
- };
14643
- }
14644
- function getOpenCodeAskConfig(instructionPaths) {
14645
- return {
14646
- model: exports2.DEFAULT_MODEL,
14647
- small_model: exports2.DEFAULT_SMALL_MODEL,
14648
- provider: getProviderConfig(),
14649
- compaction: { prune: true },
14650
- permission: {
14651
- [
14652
- "edit"
14653
- /* OpenCodeTool.Edit */
14654
- ]: "deny",
14655
- [
14656
- "bash"
14657
- /* OpenCodeTool.Bash */
14658
- ]: "deny",
14659
- task: "deny",
14660
- [
14661
- "todowrite"
14662
- /* OpenCodeTool.TodoWrite */
14663
- ]: "deny",
14664
- [
14665
- "todoread"
14666
- /* OpenCodeTool.TodoRead */
14667
- ]: "deny",
14668
- [
14669
- "batch-write"
14670
- /* OpenCodeTool.BatchWrite */
14671
- ]: "deny",
14672
- [
14673
- "multi-edit"
14674
- /* OpenCodeTool.MultiEdit */
14675
- ]: "deny",
14676
- [
14677
- "validate"
14678
- /* OpenCodeTool.Validate */
14679
- ]: "deny",
14680
- [
14681
- "uuid"
14682
- /* OpenCodeTool.Uuid */
14683
- ]: "deny"
14684
- },
14685
- instructions: instructionPaths,
14686
- lsp: false,
14687
- mcp: WIX_MCP_CONFIG,
14688
- watcher: { ignore: WATCHER_IGNORE_PATTERNS }
14783
+ watcher: { ignore: WATCHER_IGNORE_PATTERNS },
14784
+ ...guardNodeModules ? { plugin: [node_modules_guard_12.GUARD_PLUGIN_PATH], autoupdate: false, share: "disabled" } : {}
14689
14785
  };
14690
14786
  }
14691
14787
  function ensureOpenCodeInPath() {
@@ -14708,12 +14804,24 @@ var require_config = __commonJS({
14708
14804
  OPENCODE_DISABLE_FILETIME_CHECK: "true"
14709
14805
  };
14710
14806
  }
14711
- function getOpenCodeEnv(projectId, isAsk = false) {
14712
- const envConfig = (0, environments_12.getCodegenEnvironmentConfig)();
14713
- const rules = isAsk ? envConfig.askRules : envConfig.codegenRules;
14714
- const paths = rules.map((r) => (0, rules_writer_12.getRulePath)(r.filename));
14715
- const config = isAsk ? getOpenCodeAskConfig(paths) : getOpenCodeConfig(paths);
14716
- return buildOpenCodeEnv(projectId, config);
14807
+ function getOpenCodeEnv(projectId, kind) {
14808
+ return buildOpenCodeEnv(projectId, buildConfigForKind(kind));
14809
+ }
14810
+ function buildConfigForKind(kind) {
14811
+ const env = (0, environments_12.getCodegenEnvironmentConfig)();
14812
+ const paths = (rules) => rules.map((r) => (0, rules_writer_12.getRulePath)(r.filename));
14813
+ switch (kind) {
14814
+ case CodeGenService_12.TaskKind.ASK_CODEGEN:
14815
+ return buildConfig(paths(env.askRules), ASK_PERMISSIONS);
14816
+ case CodeGenService_12.TaskKind.FIX_GIT_CONFLICTS:
14817
+ return buildConfig(paths(env.gitConflictsRules), GIT_CONFLICTS_PERMISSIONS, {
14818
+ guardNodeModules: true
14819
+ });
14820
+ default:
14821
+ return buildConfig(paths(env.codegenRules), CODEGEN_PERMISSIONS, {
14822
+ guardNodeModules: true
14823
+ });
14824
+ }
14717
14825
  }
14718
14826
  }
14719
14827
  });
@@ -15528,8 +15636,7 @@ var require_executor = __commonJS({
15528
15636
  return finalResult;
15529
15637
  }
15530
15638
  async function logOpenCodeStats(options) {
15531
- const isAsk = job_context_storage_12.jobContextStorage.getStore()?.kind === ditto_codegen_types_12.TaskKind.ASK_CODEGEN;
15532
- const env = (0, config_12.getOpenCodeEnv)(options.projectId, isAsk);
15639
+ const env = (0, config_12.getOpenCodeEnv)(options.projectId, job_context_storage_12.jobContextStorage.getStore()?.kind);
15533
15640
  const stats = await (0, cost_tracker_1.fetchOpenCodeStats)(options.outputPath, env);
15534
15641
  if (stats) {
15535
15642
  console.log("[OpenCode] Stats\n", stats);
@@ -15581,8 +15688,7 @@ var require_executor = __commonJS({
15581
15688
  continueSession
15582
15689
  });
15583
15690
  logger_12.logger.debug("[OpenCode] Full prompt", { prompt });
15584
- const isAsk = job_context_storage_12.jobContextStorage.getStore()?.kind === ditto_codegen_types_12.TaskKind.ASK_CODEGEN;
15585
- const env = (0, config_12.getOpenCodeEnv)(projectId, isAsk);
15691
+ const env = (0, config_12.getOpenCodeEnv)(projectId, job_context_storage_12.jobContextStorage.getStore()?.kind);
15586
15692
  ctx.child = (0, child_process_1.spawn)("opencode", args, {
15587
15693
  cwd: outputPath,
15588
15694
  env,
@@ -15625,6 +15731,7 @@ var require_opencode_runner = __commonJS({
15625
15731
  exports2.runOpenCodeInit = runOpenCodeInit;
15626
15732
  exports2.runOpenCodeIteration = runOpenCodeIteration;
15627
15733
  exports2.runOpenCodeAsk = runOpenCodeAsk;
15734
+ exports2.runOpenCodeGitConflicts = runOpenCodeGitConflicts;
15628
15735
  var prompts_1 = require_prompts();
15629
15736
  var executor_1 = require_executor();
15630
15737
  var parser_1 = require_parser();
@@ -15672,6 +15779,18 @@ var require_opencode_runner = __commonJS({
15672
15779
  error: result.error
15673
15780
  };
15674
15781
  }
15782
+ async function runOpenCodeGitConflicts(options) {
15783
+ const { outputPath, projectId, chatHistory, gitBaseline, onStdout, onStderr } = options;
15784
+ const prompt = (0, prompts_1.buildGitConflictsPrompt)(chatHistory);
15785
+ return (0, executor_1.executeOpenCode)({
15786
+ prompt,
15787
+ outputPath,
15788
+ projectId,
15789
+ gitBaseline,
15790
+ onStdout,
15791
+ onStderr
15792
+ });
15793
+ }
15675
15794
  }
15676
15795
  });
15677
15796
 
@@ -15749,7 +15868,7 @@ var require_opencode_integration = __commonJS({
15749
15868
  "dist/opencode-integration/index.js"(exports2) {
15750
15869
  "use strict";
15751
15870
  Object.defineProperty(exports2, "__esModule", { value: true });
15752
- exports2.collectInsertedExtensionsMetadata = exports2.buildExtensionsJobPayload = exports2.OpenCodeTaskTracker = exports2.runOpenCodeAsk = exports2.runOpenCodeIteration = exports2.runOpenCodeInit = void 0;
15871
+ exports2.collectInsertedExtensionsMetadata = exports2.buildExtensionsJobPayload = exports2.OpenCodeTaskTracker = exports2.runOpenCodeGitConflicts = exports2.runOpenCodeAsk = exports2.runOpenCodeIteration = exports2.runOpenCodeInit = void 0;
15753
15872
  var opencode_runner_1 = require_opencode_runner();
15754
15873
  Object.defineProperty(exports2, "runOpenCodeInit", { enumerable: true, get: function() {
15755
15874
  return opencode_runner_1.runOpenCodeInit;
@@ -15760,6 +15879,9 @@ var require_opencode_integration = __commonJS({
15760
15879
  Object.defineProperty(exports2, "runOpenCodeAsk", { enumerable: true, get: function() {
15761
15880
  return opencode_runner_1.runOpenCodeAsk;
15762
15881
  } });
15882
+ Object.defineProperty(exports2, "runOpenCodeGitConflicts", { enumerable: true, get: function() {
15883
+ return opencode_runner_1.runOpenCodeGitConflicts;
15884
+ } });
15763
15885
  var task_tracker_1 = require_task_tracker2();
15764
15886
  Object.defineProperty(exports2, "OpenCodeTaskTracker", { enumerable: true, get: function() {
15765
15887
  return task_tracker_1.OpenCodeTaskTracker;
@@ -21528,6 +21650,185 @@ var require_opencode_ask = __commonJS({
21528
21650
  }
21529
21651
  });
21530
21652
 
21653
+ // dist/OpenCodeGitConflictsOrchestrator.js
21654
+ var require_OpenCodeGitConflictsOrchestrator = __commonJS({
21655
+ "dist/OpenCodeGitConflictsOrchestrator.js"(exports2) {
21656
+ "use strict";
21657
+ Object.defineProperty(exports2, "__esModule", { value: true });
21658
+ exports2.OpenCodeGitConflictsOrchestrator = void 0;
21659
+ var ditto_codegen_types_12 = require_dist4();
21660
+ var DittoEventEmitter_1 = require_DittoEventEmitter();
21661
+ var opencode_integration_1 = require_opencode_integration();
21662
+ var logger_12 = require_logger();
21663
+ var OpenCodeGitConflictsOrchestrator = class extends DittoEventEmitter_1.DittoEventEmitter {
21664
+ constructor() {
21665
+ super();
21666
+ }
21667
+ async fixConflicts(request) {
21668
+ const { outputPath, projectId, chatHistory, gitBaseline } = request;
21669
+ this.emitEvent("start:git-conflicts", { outputPath });
21670
+ this.emitEvent("opencode:start", { outputPath });
21671
+ const start = Date.now();
21672
+ const result = await (0, opencode_integration_1.runOpenCodeGitConflicts)({
21673
+ outputPath,
21674
+ projectId,
21675
+ chatHistory,
21676
+ gitBaseline,
21677
+ onStdout: (data) => {
21678
+ this.emitEvent("opencode:output", { data });
21679
+ },
21680
+ onStderr: (data) => {
21681
+ logger_12.logger.error("[OpenCode Git Conflicts] stderr", { output: data });
21682
+ }
21683
+ });
21684
+ this.lastUsage = result.usage;
21685
+ const durationMs = Date.now() - start;
21686
+ if (!result.success) {
21687
+ this.emitEvent("opencode:error", {
21688
+ error: result.error?.message,
21689
+ exitCode: result.exitCode,
21690
+ durationMs
21691
+ });
21692
+ throw result.error ?? new ditto_codegen_types_12.ProcessExecutionError("Git conflicts flow failed", {
21693
+ processType: ditto_codegen_types_12.ProcessType.EXECUTION,
21694
+ exitCode: result.exitCode ?? void 0
21695
+ });
21696
+ }
21697
+ this.emitEvent("opencode:done", { durationMs });
21698
+ this.emitEvent("finish:git-conflicts", { outputPath, durationMs });
21699
+ return result;
21700
+ }
21701
+ };
21702
+ exports2.OpenCodeGitConflictsOrchestrator = OpenCodeGitConflictsOrchestrator;
21703
+ }
21704
+ });
21705
+
21706
+ // dist/flows/opencode-fix-git-conflicts.js
21707
+ var require_opencode_fix_git_conflicts = __commonJS({
21708
+ "dist/flows/opencode-fix-git-conflicts.js"(exports2) {
21709
+ "use strict";
21710
+ Object.defineProperty(exports2, "__esModule", { value: true });
21711
+ exports2.runOpencodeGitConflictsFlow = void 0;
21712
+ var codeGenerationService_12 = require_codeGenerationService();
21713
+ var cli_listeners_1 = require_cli_listeners();
21714
+ var job_context_storage_12 = require_job_context_storage();
21715
+ var ditto_codegen_types_12 = require_dist4();
21716
+ var OpenCodeGitConflictsOrchestrator_1 = require_OpenCodeGitConflictsOrchestrator();
21717
+ var types_1 = require_types_impl();
21718
+ var codegen_flow_helpers_12 = require_codegen_flow_helpers();
21719
+ var context_12 = require_context();
21720
+ var logger_12 = require_logger();
21721
+ var config_12 = require_config();
21722
+ var git_file_changes_1 = require_git_file_changes();
21723
+ var collect_extensions_created_1 = require_collect_extensions_created();
21724
+ var biEvents_1 = require_biEvents();
21725
+ var plugins_runtime_1 = require_plugins_runtime();
21726
+ var runOpencodeGitConflictsFlow = async (chatHistory) => {
21727
+ const store = job_context_storage_12.jobContextStorage.getStore();
21728
+ if (!store?.jobId || !store?.taskId) {
21729
+ throw new Error("Job context not available - jobId and taskId are required");
21730
+ }
21731
+ const { jobId, taskId, kind } = store;
21732
+ const localJobContext = { jobId, taskId };
21733
+ const environment = process.env.CODEGEN_ENVIRONMENT ?? types_1.Environment.UNKNOWN_ENVIRONMENT;
21734
+ const flowStartTime = Date.now();
21735
+ store.flowStartTime = flowStartTime;
21736
+ const biBase = {
21737
+ jobId,
21738
+ taskId,
21739
+ appId: context_12.ctx.projectId,
21740
+ devMachineSessionId: process.env.CODEGEN_SESSION_ID,
21741
+ runKind: kind,
21742
+ jobInput: JSON.stringify(chatHistory),
21743
+ environment
21744
+ };
21745
+ logger_12.logger.info("[OpenCode Git Conflicts] Starting task", { taskId });
21746
+ await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
21747
+ logger_12.logger.info("[OpenCode Git Conflicts] Marked task RUNNING", { taskId });
21748
+ await (0, biEvents_1.reportSessionStart)({
21749
+ ...biBase,
21750
+ taskModel: config_12.DEFAULT_MODEL,
21751
+ taskType: kind
21752
+ });
21753
+ const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
21754
+ const gitBaseline = await (0, git_file_changes_1.captureGitBaseline)(outputPath);
21755
+ const orchestrator = new OpenCodeGitConflictsOrchestrator_1.OpenCodeGitConflictsOrchestrator();
21756
+ let caughtError;
21757
+ try {
21758
+ (0, cli_listeners_1.attachOrchestratorListeners)(orchestrator);
21759
+ const result = await orchestrator.fixConflicts({
21760
+ outputPath,
21761
+ projectId: context_12.ctx.projectId,
21762
+ chatHistory,
21763
+ gitBaseline
21764
+ });
21765
+ const files = await (0, git_file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
21766
+ const extensions = await (0, collect_extensions_created_1.buildExtensionsJobPayload)(outputPath, files);
21767
+ await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
21768
+ requiredPermissions: result.requiredPermissions,
21769
+ files,
21770
+ extensions
21771
+ });
21772
+ await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, {
21773
+ taskOutput: { files }
21774
+ });
21775
+ await (0, biEvents_1.reportSessionEnd)({
21776
+ ...biBase,
21777
+ taskModel: config_12.DEFAULT_MODEL,
21778
+ taskType: kind,
21779
+ taskCost: Math.round(result.usage.cost * 1e6),
21780
+ taskStatus: ditto_codegen_types_12.Status.COMPLETED,
21781
+ agentOutput: JSON.stringify({ files }),
21782
+ jobDuration: String(Date.now() - flowStartTime),
21783
+ skillsUsed: result.skillsUsed
21784
+ });
21785
+ logger_12.logger.info("[OpenCode Git Conflicts] Completed task", { taskId });
21786
+ } catch (error) {
21787
+ caughtError = error;
21788
+ const codegenError = (0, ditto_codegen_types_12.toCodegenError)(error);
21789
+ const files = await (0, git_file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
21790
+ const extensions = await (0, collect_extensions_created_1.buildExtensionsJobPayload)(outputPath, files);
21791
+ await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
21792
+ requiredPermissions: [],
21793
+ error: codegenError,
21794
+ files,
21795
+ extensions
21796
+ });
21797
+ await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
21798
+ const taskCost = orchestrator.lastUsage ? Math.round(orchestrator.lastUsage.cost * 1e6) : void 0;
21799
+ await (0, biEvents_1.reportSessionEnd)({
21800
+ ...biBase,
21801
+ taskModel: config_12.DEFAULT_MODEL,
21802
+ taskType: kind,
21803
+ taskCost,
21804
+ taskStatus: ditto_codegen_types_12.Status.FAILED,
21805
+ agentOutput: JSON.stringify({ files }),
21806
+ jobDuration: String(Date.now() - flowStartTime)
21807
+ });
21808
+ await (0, biEvents_1.reportSessionError)({
21809
+ ...biBase,
21810
+ taskModel: config_12.DEFAULT_MODEL,
21811
+ taskType: kind,
21812
+ agentOutput: JSON.stringify(codegenError),
21813
+ errorDesc: codegenError.errorType,
21814
+ errorMessage: codegenError.message,
21815
+ errorJson: JSON.stringify(codegenError),
21816
+ isRetryable: codegenError.retryable,
21817
+ isExpected: codegenError.expected,
21818
+ validationType: codegenError.validationType
21819
+ });
21820
+ logger_12.logger.error("[OpenCode Git Conflicts] Failed task", {
21821
+ taskId,
21822
+ error: error instanceof Error ? error.message : String(error)
21823
+ });
21824
+ } finally {
21825
+ await (0, plugins_runtime_1.runOnFlowEnd)((0, plugins_runtime_1.getActivePlugins)(), { codegenFailed: caughtError !== void 0, codegenError: caughtError }, logger_12.logger);
21826
+ }
21827
+ };
21828
+ exports2.runOpencodeGitConflictsFlow = runOpencodeGitConflictsFlow;
21829
+ }
21830
+ });
21831
+
21531
21832
  // dist/job-cancellation-monitor.js
21532
21833
  var require_job_cancellation_monitor = __commonJS({
21533
21834
  "dist/job-cancellation-monitor.js"(exports2) {
@@ -21861,6 +22162,7 @@ var job_context_storage_1 = require_job_context_storage();
21861
22162
  var opencode_init_1 = require_opencode_init();
21862
22163
  var opencode_iterate_1 = require_opencode_iterate();
21863
22164
  var opencode_ask_1 = require_opencode_ask();
22165
+ var opencode_fix_git_conflicts_1 = require_opencode_fix_git_conflicts();
21864
22166
  var codegen_flow_helpers_1 = require_codegen_flow_helpers();
21865
22167
  var job_cancellation_monitor_1 = require_job_cancellation_monitor();
21866
22168
  var job_timeout_monitor_1 = require_job_timeout_monitor();
@@ -21927,8 +22229,12 @@ async function initOpenCode() {
21927
22229
  const envConfig = (0, environments_1.getCodegenEnvironmentConfig)();
21928
22230
  const pluginArtifacts = (0, plugin_artifacts_1.collectPluginArtifacts)(envConfig);
21929
22231
  await Promise.all([
21930
- (0, rules_writer_1.writeRuleFiles)([...envConfig.codegenRules, ...pluginArtifacts.rules]),
21931
- (0, rules_writer_1.writeRuleFiles)(envConfig.askRules),
22232
+ (0, rules_writer_1.writeRuleFiles)([
22233
+ ...envConfig.codegenRules,
22234
+ ...pluginArtifacts.rules,
22235
+ ...envConfig.askRules,
22236
+ ...envConfig.gitConflictsRules
22237
+ ]),
21932
22238
  (0, skills_installer_1.applySkillsOverride)((0, codegen_flow_helpers_1.getOutputPath)(), logger_1.logger),
21933
22239
  (0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
21934
22240
  (0, node_modules_guard_1.writeGuardPlugin)()
@@ -21948,7 +22254,7 @@ var getFirstTask = (job) => {
21948
22254
  return job.tasks?.[0];
21949
22255
  };
21950
22256
  function buildPluginsForTask(jobId, taskId, kind, payload) {
21951
- if (kind !== CodeGenService_1.TaskKind.INIT_CODEGEN && kind !== CodeGenService_1.TaskKind.ITERATE_CODEGEN) {
22257
+ if (kind !== CodeGenService_1.TaskKind.INIT_CODEGEN && kind !== CodeGenService_1.TaskKind.ITERATE_CODEGEN && kind !== CodeGenService_1.TaskKind.FIX_GIT_CONFLICTS) {
21952
22258
  return void 0;
21953
22259
  }
21954
22260
  const userInput = extractUserInput(kind, payload);
@@ -21969,7 +22275,7 @@ function extractUserInput(kind, payload) {
21969
22275
  if (kind === CodeGenService_1.TaskKind.INIT_CODEGEN) {
21970
22276
  return payload.blueprint?.summary?.trim() || void 0;
21971
22277
  }
21972
- if (kind === CodeGenService_1.TaskKind.ITERATE_CODEGEN) {
22278
+ if (kind === CodeGenService_1.TaskKind.ITERATE_CODEGEN || kind === CodeGenService_1.TaskKind.FIX_GIT_CONFLICTS) {
21973
22279
  const history = payload.history ?? [];
21974
22280
  for (let i = history.length - 1; i >= 0; i--) {
21975
22281
  if (history[i].role === "USER") {
@@ -22019,6 +22325,8 @@ async function processJob(job) {
22019
22325
  await (0, opencode_iterate_1.runOpencodeIterateFlow)(history, agentData);
22020
22326
  } else if (task.kind === CodeGenService_1.TaskKind.INIT_CODEGEN && blueprint) {
22021
22327
  await (0, opencode_init_1.runOpencodeInitFlow)(blueprint, history, agentData);
22328
+ } else if (task.kind === CodeGenService_1.TaskKind.FIX_GIT_CONFLICTS) {
22329
+ await (0, opencode_fix_git_conflicts_1.runOpencodeGitConflictsFlow)(history);
22022
22330
  }
22023
22331
  } finally {
22024
22332
  jobCancellationMonitor.stop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.383",
3
+ "version": "1.0.384",
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": "9eeb81c88135bb782b2dba1cee39f9a4a74efce788a4e05022ca7519"
32
+ "falconPackageHash": "9b169b82fd27ad66070b5b9211071a3775eed2985a3006f2f89789fb"
33
33
  }