@leitwerk-dev/coding 0.1.8 → 0.2.0

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 (50) hide show
  1. package/README.md +7 -2
  2. package/dist/auto-work-branch.js +86 -86
  3. package/dist/auto-work-branch.js.map +1 -1
  4. package/dist/{chunk-YWGLBUFT.js → chunk-73LKROYK.js} +162 -154
  5. package/dist/chunk-73LKROYK.js.map +1 -0
  6. package/dist/{chunk-RZ54IVY5.js → chunk-EP3ZC37F.js} +1 -4
  7. package/dist/chunk-EP3ZC37F.js.map +1 -0
  8. package/dist/{chunk-RWCLBBB2.js → chunk-WQEPA35Z.js} +1 -4
  9. package/dist/chunk-WQEPA35Z.js.map +1 -0
  10. package/dist/finalization-git.d.ts +6 -1
  11. package/dist/finalization-git.d.ts.map +1 -1
  12. package/dist/finalization-git.js +13 -559
  13. package/dist/finalization-git.js.map +1 -1
  14. package/dist/index.js +650 -6
  15. package/dist/index.js.map +1 -1
  16. package/dist/repository-change-launch.js +17 -182
  17. package/dist/repository-change-launch.js.map +1 -1
  18. package/dist/repository-change-process.d.ts.map +1 -1
  19. package/dist/repository-change-state.js +12 -51
  20. package/dist/repository-change-state.js.map +1 -1
  21. package/dist/turns/generate-commit-message.js +9 -38
  22. package/dist/turns/generate-commit-message.js.map +1 -1
  23. package/dist/turns/generate-plan.js +7 -19
  24. package/dist/turns/generate-plan.js.map +1 -1
  25. package/dist/turns/implement.js +7 -17
  26. package/dist/turns/implement.js.map +1 -1
  27. package/dist/turns/resolve-merge-conflict.js +7 -21
  28. package/dist/turns/resolve-merge-conflict.js.map +1 -1
  29. package/dist/turns/review-implementation.d.ts +0 -1
  30. package/dist/turns/review-implementation.d.ts.map +1 -1
  31. package/dist/turns/review-implementation.js +7 -27
  32. package/dist/turns/review-implementation.js.map +1 -1
  33. package/dist/turns/review-plan.d.ts +0 -1
  34. package/dist/turns/review-plan.d.ts.map +1 -1
  35. package/dist/turns/review-plan.js +7 -21
  36. package/dist/turns/review-plan.js.map +1 -1
  37. package/dist/turns/simplify-implementation.js +7 -7
  38. package/dist/turns/simplify-implementation.js.map +1 -1
  39. package/package.json +5 -4
  40. package/src/finalization-git.ts +209 -166
  41. package/src/repository-change-process.ts +85 -249
  42. package/src/turns/review-implementation.ts +0 -3
  43. package/src/turns/review-plan.ts +0 -3
  44. package/dist/actions.js +0 -45
  45. package/dist/actions.js.map +0 -1
  46. package/dist/chunk-RWCLBBB2.js.map +0 -1
  47. package/dist/chunk-RZ54IVY5.js.map +0 -1
  48. package/dist/chunk-YWGLBUFT.js.map +0 -1
  49. package/dist/repository-change-process.js +0 -757
  50. package/dist/repository-change-process.js.map +0 -1
@@ -49,9 +49,18 @@ function gitConfigIdentityEnv() {
49
49
  delete env[key];
50
50
  return env;
51
51
  }
52
- function runGit(repoPath, args) {
52
+ function gitIdentityArgs(identity) {
53
+ const name = trimToNull(identity.name);
54
+ const email = trimToNull(identity.email);
55
+ if (!name || !email || /[\r\n\0]/.test(name) || /[\r\n\0]/.test(email)) {
56
+ throw new DeterministicGitError("Git identity requires a valid name and email");
57
+ }
58
+ return ["-c", `user.name=${name}`, "-c", `user.email=${email}`];
59
+ }
60
+ function runGit(repoPath, args, identity) {
61
+ const trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;
53
62
  try {
54
- const stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(args), {
63
+ const stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {
55
64
  cwd: repoPath,
56
65
  encoding: "utf8",
57
66
  env: gitConfigIdentityEnv(),
@@ -60,27 +69,29 @@ function runGit(repoPath, args) {
60
69
  return {
61
70
  ok: true,
62
71
  stdout,
63
- stderr: "",
64
- status: 0
72
+ stderr: ""
65
73
  };
66
74
  } catch (error) {
67
75
  const execError = error;
68
76
  return {
69
77
  ok: false,
70
- stdout: typeof execError.stdout === "string" ? execError.stdout : execError.stdout ? execError.stdout.toString("utf8") : "",
71
- stderr: typeof execError.stderr === "string" ? execError.stderr : execError.stderr ? execError.stderr.toString("utf8") : trimToNull(execError.message) ?? "",
72
- status: execError.status ?? null
78
+ stdout: execError.stdout?.toString() ?? "",
79
+ stderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? ""
73
80
  };
74
81
  }
75
82
  }
76
- function git(repoPath, ...args) {
77
- const result = runGit(repoPath, args);
83
+ function gitFailureDetail(result) {
84
+ return trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error";
85
+ }
86
+ function checkedGit(repoPath, args, failureMessage, identity) {
87
+ const result = runGit(repoPath, args, identity);
78
88
  if (!result.ok) {
79
- throw new DeterministicGitError(
80
- `git ${args.join(" ")} failed in '${repoPath}': ${trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error"}`
81
- );
89
+ throw new DeterministicGitError(`${failureMessage}: ${gitFailureDetail(result)}`);
82
90
  }
83
- return result.stdout.trim();
91
+ return result.stdout;
92
+ }
93
+ function git(repoPath, ...args) {
94
+ return checkedGit(repoPath, args, `git ${args.join(" ")} failed in '${repoPath}'`).trim();
84
95
  }
85
96
  function gitOrNull(repoPath, ...args) {
86
97
  const result = runGit(repoPath, args);
@@ -149,8 +160,7 @@ function resolveLocalSourceRepo(repoPath) {
149
160
  }
150
161
  function workingTreeStatus(repoPath) {
151
162
  const rawStatus = gitOrNull(repoPath, "status", "--porcelain");
152
- const dirtyFiles = (rawStatus ?? "").split(/\r?\n/).map((line) => line.replace(/\s+$/, "")).filter((line) => line !== "").map((line) => line.slice(2).trim()).filter((line) => line !== "");
153
- return { dirtyFiles };
163
+ return (rawStatus ?? "").split(/\r?\n/).map((line) => line.replace(/\s+$/, "")).filter((line) => line !== "").map((line) => line.slice(2).trim()).filter((line) => line !== "");
154
164
  }
155
165
  function conflictedFiles(repoPath) {
156
166
  return normalizeLines(gitOrNull(repoPath, "diff", "--name-only", "--diff-filter=U"));
@@ -170,44 +180,47 @@ function assertExpectedCheckout(repoPath, workBranch) {
170
180
  );
171
181
  }
172
182
  }
173
- function assertGitIdentity(repoPath) {
174
- const author = runGit(repoPath, ["var", "GIT_AUTHOR_IDENT"]);
175
- const committer = runGit(repoPath, ["var", "GIT_COMMITTER_IDENT"]);
176
- if (!author.ok || !committer.ok) {
183
+ function assertFinalizationCheckout(input) {
184
+ if (!repoExists(input.repoPath)) {
177
185
  throw new DeterministicGitError(
178
- "Git author/committer identity is not configured. Configure user.name and user.email in this repository or the operator's global Git config, then retry finalization."
186
+ `Repository workspace '${input.repoPath}' does not exist or is not a git repository`
179
187
  );
180
188
  }
181
- }
182
- function commitDirtyWorktree(repoPath, commitMessage) {
183
- assertGitIdentity(repoPath);
184
- const addResult = runGit(repoPath, ["add", "--all"]);
185
- if (!addResult.ok) {
186
- throw new DeterministicGitError(
187
- `Failed to stage the completed change: ${trimToNull(addResult.stderr) ?? trimToNull(addResult.stdout) ?? "unknown git error"}`
188
- );
189
+ assertExpectedCheckout(input.repoPath, input.workBranch);
190
+ if (!trimToNull(input.commitMessage)) {
191
+ throw new DeterministicGitError(input.missingCommitMessage);
189
192
  }
190
- const commitResult = runGit(repoPath, [
191
- "-c",
192
- "core.hooksPath=/dev/null",
193
- "commit",
194
- "--no-gpg-sign",
195
- "-m",
196
- commitMessage
197
- ]);
198
- if (!commitResult.ok) {
193
+ }
194
+ function assertGitIdentity(repoPath, identity) {
195
+ const author = runGit(repoPath, ["var", "GIT_AUTHOR_IDENT"], identity);
196
+ const committer = runGit(repoPath, ["var", "GIT_COMMITTER_IDENT"], identity);
197
+ if (!author.ok || !committer.ok) {
199
198
  throw new DeterministicGitError(
200
- `Failed to commit the completed change: ${trimToNull(commitResult.stderr) ?? trimToNull(commitResult.stdout) ?? "unknown git error"}`
199
+ "Git author/committer identity is not configured. Configure user.name and user.email in this repository or the operator's global Git config, then retry finalization."
201
200
  );
202
201
  }
202
+ }
203
+ function commitDirtyWorktree(repoPath, commitMessage, identity) {
204
+ assertGitIdentity(repoPath, identity);
205
+ checkedGit(repoPath, ["add", "--all"], "Failed to stage the completed change");
206
+ checkedGit(
207
+ repoPath,
208
+ ["-c", "core.hooksPath=/dev/null", "commit", "--no-gpg-sign", "-m", commitMessage],
209
+ "Failed to commit the completed change",
210
+ identity
211
+ );
203
212
  const remaining = workingTreeStatus(repoPath);
204
- if (remaining.dirtyFiles.length > 0) {
213
+ if (remaining.length > 0) {
205
214
  throw new DeterministicGitError(
206
- `Deterministic commit left uncommitted changes: ${remaining.dirtyFiles.join(", ")}`
215
+ `Deterministic commit left uncommitted changes: ${remaining.join(", ")}`
207
216
  );
208
217
  }
209
218
  return currentHeadSha(repoPath);
210
219
  }
220
+ function commitIfDirty(input) {
221
+ const status = workingTreeStatus(input.repoPath);
222
+ return status.length > 0 ? commitDirtyWorktree(input.repoPath, input.commitMessage, input.gitIdentity) : currentHeadSha(input.repoPath);
223
+ }
211
224
  function assertPostConflictCheckpoint(input, repoPath) {
212
225
  if (!trimToNull(input.expectedPostConflictHeadSha)) {
213
226
  return;
@@ -218,20 +231,15 @@ function assertPostConflictCheckpoint(input, repoPath) {
218
231
  );
219
232
  }
220
233
  const status = workingTreeStatus(repoPath);
221
- if (status.dirtyFiles.length > 0) {
234
+ if (status.length > 0) {
222
235
  throw new DeterministicGitError(
223
- `Conflict-resolution helper reported a clean merge, but the repository still has uncommitted changes: ${status.dirtyFiles.join(", ")}`
236
+ `Conflict-resolution helper reported a clean merge, but the repository still has uncommitted changes: ${status.join(", ")}`
224
237
  );
225
238
  }
226
239
  }
227
240
  function fetchOriginBase(repoPath, baseBranch) {
228
241
  const ref = originBaseRef(baseBranch);
229
- const fetchResult = runGit(repoPath, ["fetch", "origin", baseBranch]);
230
- if (!fetchResult.ok) {
231
- throw new DeterministicGitError(
232
- `Failed to fetch '${ref}': ${trimToNull(fetchResult.stderr) ?? trimToNull(fetchResult.stdout) ?? "unknown git error"}`
233
- );
234
- }
242
+ checkedGit(repoPath, ["fetch", "origin", baseBranch], `Failed to fetch '${ref}'`);
235
243
  const baseSha = gitOrNull(repoPath, "rev-parse", ref);
236
244
  if (!baseSha) {
237
245
  throw new DeterministicGitError(`Fetched '${ref}' but could not resolve its commit sha`);
@@ -250,27 +258,19 @@ function deterministicMerge(input) {
250
258
  return { ok: true, mergeMode: "noop", headSha: headBefore };
251
259
  }
252
260
  if (headIsAncestorOfBase) {
253
- const ffResult = runGit(repoPath, ["merge", "--ff-only", ref]);
254
- if (!ffResult.ok) {
255
- throw new DeterministicGitError(
256
- `Fast-forward merge from '${ref}' failed: ${trimToNull(ffResult.stderr) ?? trimToNull(ffResult.stdout) ?? "unknown git error"}`
257
- );
258
- }
261
+ checkedGit(repoPath, ["merge", "--ff-only", ref], `Fast-forward merge from '${ref}' failed`);
259
262
  return {
260
263
  ok: true,
261
264
  mergeMode: "fast_forward",
262
265
  headSha: currentHeadSha(repoPath)
263
266
  };
264
267
  }
265
- assertGitIdentity(repoPath);
266
- const mergeResult = runGit(repoPath, [
267
- "-c",
268
- "core.hooksPath=/dev/null",
269
- "merge",
270
- "--no-edit",
271
- "--no-gpg-sign",
272
- ref
273
- ]);
268
+ assertGitIdentity(repoPath, input.gitIdentity);
269
+ const mergeResult = runGit(
270
+ repoPath,
271
+ ["-c", "core.hooksPath=/dev/null", "merge", "--no-edit", "--no-gpg-sign", ref],
272
+ input.gitIdentity
273
+ );
274
274
  if (!mergeResult.ok) {
275
275
  const conflicts = conflictedFiles(repoPath);
276
276
  if (mergeInProgress(repoPath) || conflicts.length > 0) {
@@ -282,7 +282,7 @@ function deterministicMerge(input) {
282
282
  };
283
283
  }
284
284
  throw new DeterministicGitError(
285
- `Deterministic merge from '${ref}' failed: ${trimToNull(mergeResult.stderr) ?? trimToNull(mergeResult.stdout) ?? "unknown git error"}`
285
+ `Deterministic merge from '${ref}' failed: ${gitFailureDetail(mergeResult)}`
286
286
  );
287
287
  }
288
288
  const headAfter = currentHeadSha(repoPath);
@@ -295,12 +295,17 @@ function deterministicMerge(input) {
295
295
  function branchRef(branch) {
296
296
  return `refs/heads/${branch}`;
297
297
  }
298
- function pushHeadToBranch(repoPath, branch) {
298
+ function pushAndVerify(repoPath, branch, expectedHeadSha) {
299
299
  const pushTarget = `origin/${branch}`;
300
- const pushResult = runGit(repoPath, ["push", "origin", `HEAD:${branchRef(branch)}`]);
301
- if (!pushResult.ok) {
300
+ checkedGit(
301
+ repoPath,
302
+ ["push", "origin", `HEAD:${branchRef(branch)}`],
303
+ `Failed to push HEAD to '${pushTarget}'`
304
+ );
305
+ const remoteHead = gitOrNull(repoPath, "ls-remote", "--heads", "origin", branchRef(branch))?.split(/\s+/)[0]?.trim();
306
+ if (remoteHead !== expectedHeadSha) {
302
307
  throw new DeterministicGitError(
303
- `Failed to push HEAD to '${pushTarget}': ${trimToNull(pushResult.stderr) ?? trimToNull(pushResult.stdout) ?? "unknown git error"}`
308
+ `Published '${pushTarget}' resolved to '${remoteHead ?? "missing"}', expected '${expectedHeadSha}'`
304
309
  );
305
310
  }
306
311
  return pushTarget;
@@ -339,12 +344,11 @@ function pushLocalSourceBaseBranchToOriginIfPresent(input) {
339
344
  });
340
345
  const ref = branchRef(input.baseBranch);
341
346
  const pushTarget = originBaseRef(input.baseBranch);
342
- const pushResult = runGit(input.localSourceRepoPath, ["push", "origin", `${ref}:${ref}`]);
343
- if (!pushResult.ok) {
344
- throw new DeterministicGitError(
345
- `Failed to push local source repo '${input.localSourceRepoPath}' base branch '${input.baseBranch}' to '${pushTarget}': ${trimToNull(pushResult.stderr) ?? trimToNull(pushResult.stdout) ?? "unknown git error"}`
346
- );
347
- }
347
+ checkedGit(
348
+ input.localSourceRepoPath,
349
+ ["push", "origin", `${ref}:${ref}`],
350
+ `Failed to push local source repo '${input.localSourceRepoPath}' base branch '${input.baseBranch}' to '${pushTarget}'`
351
+ );
348
352
  return pushTarget;
349
353
  }
350
354
  function assertLocalBaseRepoReady(localBaseRepoPath, baseBranch, expectedBaseSha) {
@@ -360,9 +364,9 @@ function assertLocalBaseRepoReady(localBaseRepoPath, baseBranch, expectedBaseSha
360
364
  );
361
365
  }
362
366
  const status = workingTreeStatus(localBaseRepoPath);
363
- if (status.dirtyFiles.length > 0) {
367
+ if (status.length > 0) {
364
368
  throw new DeterministicGitError(
365
- `Local source repo '${localBaseRepoPath}' must be clean before finalization updates '${baseBranch}': ${status.dirtyFiles.join(", ")}`
369
+ `Local source repo '${localBaseRepoPath}' must be clean before finalization updates '${baseBranch}': ${status.join(", ")}`
366
370
  );
367
371
  }
368
372
  const actualBaseSha = currentHeadSha(localBaseRepoPath);
@@ -374,16 +378,11 @@ function assertLocalBaseRepoReady(localBaseRepoPath, baseBranch, expectedBaseSha
374
378
  }
375
379
  function mergeWorkBranchIntoLocalBaseRepo(input) {
376
380
  assertLocalBaseRepoReady(input.localBaseRepoPath, input.baseBranch, input.expectedBaseSha);
377
- const mergeResult = runGit(input.localBaseRepoPath, [
378
- "merge",
379
- "--ff-only",
380
- `refs/heads/${input.workBranch}`
381
- ]);
382
- if (!mergeResult.ok) {
383
- throw new DeterministicGitError(
384
- `Failed to fast-forward local source repo '${input.localBaseRepoPath}' branch '${input.baseBranch}' from '${input.workBranch}': ${trimToNull(mergeResult.stderr) ?? trimToNull(mergeResult.stdout) ?? "unknown git error"}`
385
- );
386
- }
381
+ checkedGit(
382
+ input.localBaseRepoPath,
383
+ ["merge", "--ff-only", `refs/heads/${input.workBranch}`],
384
+ `Failed to fast-forward local source repo '${input.localBaseRepoPath}' branch '${input.baseBranch}' from '${input.workBranch}'`
385
+ );
387
386
  const actualHeadSha = currentHeadSha(input.localBaseRepoPath);
388
387
  if (actualHeadSha !== input.expectedHeadSha) {
389
388
  throw new DeterministicGitError(
@@ -396,12 +395,11 @@ function updateLocalBaseRef(repoPath, baseBranch) {
396
395
  if (branch === baseBranch) {
397
396
  return;
398
397
  }
399
- const updateResult = runGit(repoPath, ["branch", "--force", baseBranch, "HEAD"]);
400
- if (!updateResult.ok) {
401
- throw new DeterministicGitError(
402
- `Failed to update the local '${baseBranch}' ref to the finalized HEAD: ${trimToNull(updateResult.stderr) ?? trimToNull(updateResult.stdout) ?? "unknown git error"}`
403
- );
404
- }
398
+ checkedGit(
399
+ repoPath,
400
+ ["branch", "--force", baseBranch, "HEAD"],
401
+ `Failed to update the local '${baseBranch}' ref to the finalized HEAD`
402
+ );
405
403
  }
406
404
  function buildFinalizationMarkdown(input) {
407
405
  const lines = [
@@ -440,39 +438,43 @@ function buildFinalizationMarkdown(input) {
440
438
  }
441
439
  function commitAndPushWorkBranch(input) {
442
440
  const repoPath = path.resolve(input.repoPath);
443
- if (!repoExists(repoPath)) {
444
- throw new DeterministicGitError(
445
- `Repository workspace '${repoPath}' does not exist or is not a git repository`
446
- );
447
- }
448
- assertExpectedCheckout(repoPath, input.workBranch);
449
- if (!trimToNull(input.commitMessage)) {
450
- throw new DeterministicGitError("A generated commit message is required before publication");
451
- }
441
+ assertFinalizationCheckout({
442
+ repoPath,
443
+ workBranch: input.workBranch,
444
+ commitMessage: input.commitMessage,
445
+ missingCommitMessage: "A generated commit message is required before publication"
446
+ });
452
447
  const conflicts = conflictedFiles(repoPath);
453
448
  if (mergeInProgress(repoPath) || conflicts.length > 0) {
454
449
  throw new DeterministicGitError(
455
450
  `Cannot publish a work branch with unresolved conflicts: ${conflicts.join(", ") || "merge in progress"}`
456
451
  );
457
452
  }
458
- const dirty = workingTreeStatus(repoPath).dirtyFiles.length > 0;
459
- const headSha = dirty ? commitDirtyWorktree(repoPath, input.commitMessage) : currentHeadSha(repoPath);
460
- const pushTarget = pushHeadToBranch(repoPath, input.workBranch);
461
- const remoteHead = gitOrNull(
453
+ const headSha = commitIfDirty({
462
454
  repoPath,
463
- "ls-remote",
464
- "--heads",
465
- "origin",
466
- branchRef(input.workBranch)
467
- )?.split(/\s+/)[0]?.trim();
468
- if (remoteHead !== headSha) {
469
- throw new DeterministicGitError(
470
- `Published '${pushTarget}' resolved to '${remoteHead ?? "missing"}', expected '${headSha}'`
471
- );
472
- }
455
+ commitMessage: input.commitMessage,
456
+ gitIdentity: input.gitIdentity
457
+ });
458
+ const pushTarget = pushAndVerify(repoPath, input.workBranch, headSha);
473
459
  return { headSha, pushTarget };
474
460
  }
475
- function runDeterministicFinalization(ctx) {
461
+ function runDeterministicFinalization(ctx, gitIdentity) {
462
+ const progressSteps = [
463
+ ["validate_checkout", "Validate the repository checkout"],
464
+ ["fetch_base", "Fetch and verify the latest base branch"],
465
+ ["commit_merge", "Commit changes and integrate the base branch"],
466
+ ["publish", "Push the finalized branch"]
467
+ ];
468
+ const reportProgress = (activeIndex, completedCount, failure) => ctx.reportProgress?.({
469
+ title: "Finalization progress",
470
+ steps: progressSteps.map(([id, label], index) => ({
471
+ id,
472
+ label,
473
+ status: index === failure?.index ? "failed" : index < completedCount ? "completed" : index === activeIndex ? "in_progress" : "incomplete",
474
+ ...index === failure?.index ? { detail: failure.detail } : {}
475
+ }))
476
+ });
477
+ reportProgress(0, 0);
476
478
  const repo = ctx.repo.get("repo");
477
479
  const input = {
478
480
  repoPath: repo.fsPath,
@@ -481,24 +483,25 @@ function runDeterministicFinalization(ctx) {
481
483
  workBranch: repo.workBranch,
482
484
  expectedPostConflictHeadSha: ctx.state.finalization.expectedPostConflictHeadSha,
483
485
  usedConflictResolution: ctx.state.finalization.usedConflictResolution,
484
- commitMessage: ctx.state.finalization.generatedCommitMessage ?? ""
486
+ commitMessage: ctx.state.finalization.generatedCommitMessage ?? "",
487
+ gitIdentity
485
488
  };
486
489
  const repoPath = path.resolve(input.repoPath);
487
- if (!repoExists(repoPath)) {
488
- throw new DeterministicGitError(
489
- `Repository workspace '${repoPath}' does not exist or is not a git repository`
490
- );
491
- }
492
- assertExpectedCheckout(repoPath, input.workBranch);
493
- if (!trimToNull(input.commitMessage)) {
494
- throw new DeterministicGitError(
495
- "No generated commit message is available; retry commit-message generation before finalization"
496
- );
497
- }
490
+ assertFinalizationCheckout({
491
+ repoPath,
492
+ workBranch: input.workBranch,
493
+ commitMessage: input.commitMessage,
494
+ missingCommitMessage: "No generated commit message is available; retry commit-message generation before finalization"
495
+ });
498
496
  assertPostConflictCheckpoint(input, repoPath);
497
+ reportProgress(1, 1);
499
498
  let headSha = currentHeadSha(repoPath);
500
499
  const conflicts = conflictedFiles(repoPath);
501
500
  if (mergeInProgress(repoPath) || conflicts.length > 0) {
501
+ reportProgress(null, 1, {
502
+ index: 2,
503
+ detail: "The checkout already contains merge conflicts"
504
+ });
502
505
  return {
503
506
  outcome: "merge_conflict",
504
507
  params: {
@@ -515,17 +518,24 @@ function runDeterministicFinalization(ctx) {
515
518
  } else if (localSourceRepo?.kind === "bare") {
516
519
  assertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
517
520
  }
518
- const status = workingTreeStatus(repoPath);
519
- if (status.dirtyFiles.length > 0) {
520
- headSha = commitDirtyWorktree(repoPath, input.commitMessage);
521
- }
521
+ reportProgress(2, 2);
522
+ headSha = commitIfDirty({
523
+ repoPath,
524
+ commitMessage: input.commitMessage,
525
+ gitIdentity: input.gitIdentity
526
+ });
522
527
  const mergeResult = deterministicMerge({
523
528
  repoPath,
524
529
  baseBranch: input.baseBranch,
525
530
  headBefore: headSha,
526
- baseSha
531
+ baseSha,
532
+ gitIdentity: input.gitIdentity
527
533
  });
528
534
  if (!mergeResult.ok) {
535
+ reportProgress(null, 2, {
536
+ index: 2,
537
+ detail: "Base integration produced merge conflicts"
538
+ });
529
539
  return {
530
540
  outcome: "merge_conflict",
531
541
  params: {
@@ -535,39 +545,37 @@ function runDeterministicFinalization(ctx) {
535
545
  }
536
546
  };
537
547
  }
548
+ reportProgress(3, 3);
538
549
  let pushTarget;
539
550
  let workspacePushTarget = null;
540
551
  let sourceOriginPushTarget = null;
541
- if (localSourceRepo?.kind === "non_bare") {
542
- assertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
543
- workspacePushTarget = pushHeadToBranch(repoPath, input.workBranch);
544
- mergeWorkBranchIntoLocalBaseRepo({
545
- localBaseRepoPath: localSourceRepo.path,
546
- baseBranch: input.baseBranch,
547
- workBranch: input.workBranch,
548
- expectedBaseSha: baseSha,
549
- expectedHeadSha: mergeResult.headSha
550
- });
552
+ if (localSourceRepo) {
553
+ if (localSourceRepo.kind === "non_bare") {
554
+ assertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
555
+ workspacePushTarget = pushAndVerify(repoPath, input.workBranch, mergeResult.headSha);
556
+ mergeWorkBranchIntoLocalBaseRepo({
557
+ localBaseRepoPath: localSourceRepo.path,
558
+ baseBranch: input.baseBranch,
559
+ workBranch: input.workBranch,
560
+ expectedBaseSha: baseSha,
561
+ expectedHeadSha: mergeResult.headSha
562
+ });
563
+ } else {
564
+ assertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
565
+ workspacePushTarget = pushAndVerify(repoPath, input.baseBranch, mergeResult.headSha);
566
+ }
551
567
  sourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({
552
568
  localSourceRepoPath: localSourceRepo.path,
553
569
  baseBranch: input.baseBranch,
554
570
  expectedHeadSha: mergeResult.headSha
555
571
  });
556
572
  pushTarget = sourceOriginPushTarget ?? originBaseRef(input.baseBranch);
557
- } else if (localSourceRepo?.kind === "bare") {
558
- assertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);
559
- workspacePushTarget = pushHeadToBranch(repoPath, input.baseBranch);
560
- sourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({
561
- localSourceRepoPath: localSourceRepo.path,
562
- baseBranch: input.baseBranch,
563
- expectedHeadSha: mergeResult.headSha
564
- });
565
- pushTarget = sourceOriginPushTarget ?? workspacePushTarget;
566
573
  } else {
567
- pushTarget = pushHeadToBranch(repoPath, input.baseBranch);
574
+ pushTarget = pushAndVerify(repoPath, input.baseBranch, mergeResult.headSha);
568
575
  }
569
576
  updateLocalBaseRef(repoPath, input.baseBranch);
570
577
  const finalHeadSha = currentHeadSha(repoPath);
578
+ reportProgress(null, 4);
571
579
  return {
572
580
  outcome: "finalized",
573
581
  params: {
@@ -605,4 +613,4 @@ export {
605
613
  runDeterministicFinalization,
606
614
  readMergeMessage
607
615
  };
608
- //# sourceMappingURL=chunk-YWGLBUFT.js.map
616
+ //# sourceMappingURL=chunk-73LKROYK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/finalization-git.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detectRepoLocatorKind, trimToNull, type WorkerErrorClass } from \"@leitwerk-dev/domain\";\nimport {\n\ttype FlowAutomaticRunContext,\n\trepositoryGitArgs,\n\trepositoryGitSubprocessEnv,\n\ttype StructuralProcessState,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\n\nexport type DeterministicFinalizationMergeMode = \"noop\" | \"fast_forward\" | \"merge_commit\";\n\nexport interface GitIdentity {\n\tname: string;\n\temail: string;\n}\n\ninterface DeterministicFinalizationInput {\n\trepoPath: string;\n\tworkspaceClonePath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\texpectedPostConflictHeadSha?: string | null;\n\tusedConflictResolution?: boolean;\n\tcommitMessage: string;\n\tgitIdentity?: GitIdentity;\n}\n\nexport type DeterministicFinalizationResult =\n\t| {\n\t\t\toutcome: \"merge_conflict\";\n\t\t\tparams: {\n\t\t\t\theadSha: string;\n\t\t\t\tconflictedFiles: string[];\n\t\t\t\tfetchedBaseSha: string | null;\n\t\t\t};\n\t }\n\t| {\n\t\t\toutcome: \"finalized\";\n\t\t\tparams: {\n\t\t\t\theadSha: string;\n\t\t\t\tmergeMode: DeterministicFinalizationMergeMode;\n\t\t\t\tpushTarget: string;\n\t\t\t\tusedConflictResolution: boolean;\n\t\t\t};\n\t\t\tmarkdown: string;\n\t };\n\nexport class DeterministicGitError extends Error {\n\treadonly errorClass: WorkerErrorClass = \"git_error\";\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"DeterministicGitError\";\n\t}\n}\n\ninterface GitExecResult {\n\tok: boolean;\n\tstdout: string;\n\tstderr: string;\n}\n\ninterface LocalSourceRepo {\n\tpath: string;\n\tkind: \"bare\" | \"non_bare\";\n}\n\nfunction normalizeLines(value: string | null | undefined): string[] {\n\tif (!value) {\n\t\treturn [];\n\t}\n\treturn value\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\");\n}\n\nfunction abbreviateSha(sha: string): string {\n\treturn sha.slice(0, 12);\n}\n\nfunction describeMergeMode(mode: DeterministicFinalizationMergeMode): string {\n\tswitch (mode) {\n\t\tcase \"noop\":\n\t\t\treturn \"Already up to date\";\n\t\tcase \"fast_forward\":\n\t\t\treturn \"Fast-forwarded from origin\";\n\t\tcase \"merge_commit\":\n\t\t\treturn \"Created a merge commit\";\n\t}\n}\n\nfunction gitConfigIdentityEnv(): NodeJS.ProcessEnv {\n\tconst env = repositoryGitSubprocessEnv(\"repo\", { GIT_TERMINAL_PROMPT: \"0\" });\n\t// Identity is operator-owned repository/global Git configuration, never an\n\t// ambient worker identity or a Leitwerk override.\n\tfor (const key of [\n\t\t\"GIT_AUTHOR_NAME\",\n\t\t\"GIT_AUTHOR_EMAIL\",\n\t\t\"GIT_AUTHOR_DATE\",\n\t\t\"GIT_COMMITTER_NAME\",\n\t\t\"GIT_COMMITTER_EMAIL\",\n\t\t\"GIT_COMMITTER_DATE\",\n\t])\n\t\tdelete env[key];\n\treturn env;\n}\n\nfunction gitIdentityArgs(identity: GitIdentity): string[] {\n\tconst name = trimToNull(identity.name);\n\tconst email = trimToNull(identity.email);\n\tif (!name || !email || /[\\r\\n\\0]/.test(name) || /[\\r\\n\\0]/.test(email)) {\n\t\tthrow new DeterministicGitError(\"Git identity requires a valid name and email\");\n\t}\n\treturn [\"-c\", `user.name=${name}`, \"-c\", `user.email=${email}`];\n}\n\nfunction runGit(repoPath: string, args: readonly string[], identity?: GitIdentity): GitExecResult {\n\tconst trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;\n\ttry {\n\t\tconst stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {\n\t\t\tcwd: repoPath,\n\t\t\tencoding: \"utf8\",\n\t\t\tenv: gitConfigIdentityEnv(),\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\t\treturn {\n\t\t\tok: true,\n\t\t\tstdout,\n\t\t\tstderr: \"\",\n\t\t};\n\t} catch (error) {\n\t\tconst execError = error as {\n\t\t\tstdout?: string | Buffer;\n\t\t\tstderr?: string | Buffer;\n\t\t\tmessage?: string;\n\t\t};\n\t\treturn {\n\t\t\tok: false,\n\t\t\tstdout: execError.stdout?.toString() ?? \"\",\n\t\t\tstderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? \"\",\n\t\t};\n\t}\n}\n\nfunction gitFailureDetail(result: GitExecResult): string {\n\treturn trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? \"unknown git error\";\n}\n\nfunction checkedGit(\n\trepoPath: string,\n\targs: readonly string[],\n\tfailureMessage: string,\n\tidentity?: GitIdentity,\n): string {\n\tconst result = runGit(repoPath, args, identity);\n\tif (!result.ok) {\n\t\tthrow new DeterministicGitError(`${failureMessage}: ${gitFailureDetail(result)}`);\n\t}\n\treturn result.stdout;\n}\n\nfunction git(repoPath: string, ...args: string[]): string {\n\treturn checkedGit(repoPath, args, `git ${args.join(\" \")} failed in '${repoPath}'`).trim();\n}\n\nfunction gitOrNull(repoPath: string, ...args: string[]): string | null {\n\tconst result = runGit(repoPath, args);\n\tif (!result.ok) {\n\t\treturn null;\n\t}\n\treturn trimToNull(result.stdout);\n}\n\nfunction repoExists(repoPath: string): boolean {\n\treturn existsSync(repoPath) && existsSync(path.join(repoPath, \".git\"));\n}\n\nfunction gitRepositoryExists(repoPath: string): boolean {\n\treturn existsSync(repoPath) && runGit(repoPath, [\"rev-parse\", \"--git-dir\"]).ok;\n}\n\nfunction currentBranch(repoPath: string): string {\n\treturn git(repoPath, \"branch\", \"--show-current\");\n}\n\nfunction currentHeadSha(repoPath: string): string {\n\treturn git(repoPath, \"rev-parse\", \"HEAD\");\n}\n\nfunction originBaseRef(baseBranch: string): string {\n\treturn `origin/${baseBranch}`;\n}\n\nfunction remoteOriginUrl(repoPath: string): string {\n\tconst remoteUrl = gitOrNull(repoPath, \"remote\", \"get-url\", \"origin\");\n\tif (!remoteUrl) {\n\t\tthrow new DeterministicGitError(`Repository '${repoPath}' does not have an 'origin' remote`);\n\t}\n\treturn remoteUrl;\n}\n\nfunction expandHomePath(value: string): string {\n\tif (value === \"~\") {\n\t\treturn homedir();\n\t}\n\tif (value.startsWith(\"~/\")) {\n\t\treturn path.join(homedir(), value.slice(2));\n\t}\n\treturn value;\n}\n\nfunction resolveLocalRepoPath(repoPath: string, repoLocator: string): string | null {\n\tif (detectRepoLocatorKind(repoLocator) !== \"local_path\") {\n\t\treturn null;\n\t}\n\tif (repoLocator.startsWith(\"file://\")) {\n\t\ttry {\n\t\t\treturn fileURLToPath(repoLocator);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn path.resolve(repoPath, expandHomePath(repoLocator));\n}\n\nfunction isBareRepository(repoPath: string): boolean {\n\treturn git(repoPath, \"rev-parse\", \"--is-bare-repository\") === \"true\";\n}\n\nfunction resolveLocalSourceRepo(repoPath: string): LocalSourceRepo | null {\n\tconst remoteUrl = remoteOriginUrl(repoPath);\n\tconst localRepoPath = resolveLocalRepoPath(repoPath, remoteUrl);\n\tif (!localRepoPath || !gitRepositoryExists(localRepoPath)) {\n\t\treturn null;\n\t}\n\treturn {\n\t\tpath: localRepoPath,\n\t\tkind: isBareRepository(localRepoPath) ? \"bare\" : \"non_bare\",\n\t};\n}\n\nfunction workingTreeStatus(repoPath: string): string[] {\n\tconst rawStatus = gitOrNull(repoPath, \"status\", \"--porcelain\");\n\treturn (rawStatus ?? \"\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.replace(/\\s+$/, \"\"))\n\t\t.filter((line) => line !== \"\")\n\t\t.map((line) => line.slice(2).trim())\n\t\t.filter((line) => line !== \"\");\n}\n\nfunction conflictedFiles(repoPath: string): string[] {\n\treturn normalizeLines(gitOrNull(repoPath, \"diff\", \"--name-only\", \"--diff-filter=U\"));\n}\n\nfunction mergeHeadPath(repoPath: string): string {\n\tconst gitDir = git(repoPath, \"rev-parse\", \"--git-dir\");\n\treturn path.resolve(repoPath, gitDir, \"MERGE_HEAD\");\n}\n\nfunction mergeInProgress(repoPath: string): boolean {\n\treturn existsSync(mergeHeadPath(repoPath));\n}\n\nfunction assertExpectedCheckout(repoPath: string, workBranch: string): void {\n\tconst branch = currentBranch(repoPath);\n\tif (branch !== workBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected '${repoPath}' to be checked out on '${workBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n}\n\nfunction assertFinalizationCheckout(input: {\n\trepoPath: string;\n\tworkBranch: string;\n\tcommitMessage: string;\n\tmissingCommitMessage: string;\n}): void {\n\tif (!repoExists(input.repoPath)) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Repository workspace '${input.repoPath}' does not exist or is not a git repository`,\n\t\t);\n\t}\n\tassertExpectedCheckout(input.repoPath, input.workBranch);\n\tif (!trimToNull(input.commitMessage)) {\n\t\tthrow new DeterministicGitError(input.missingCommitMessage);\n\t}\n}\n\nfunction assertGitIdentity(repoPath: string, identity?: GitIdentity): void {\n\tconst author = runGit(repoPath, [\"var\", \"GIT_AUTHOR_IDENT\"], identity);\n\tconst committer = runGit(repoPath, [\"var\", \"GIT_COMMITTER_IDENT\"], identity);\n\tif (!author.ok || !committer.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t\"Git author/committer identity is not configured. Configure user.name and user.email in this repository or the operator's global Git config, then retry finalization.\",\n\t\t);\n\t}\n}\n\nfunction commitDirtyWorktree(\n\trepoPath: string,\n\tcommitMessage: string,\n\tidentity?: GitIdentity,\n): string {\n\tassertGitIdentity(repoPath, identity);\n\tcheckedGit(repoPath, [\"add\", \"--all\"], \"Failed to stage the completed change\");\n\tcheckedGit(\n\t\trepoPath,\n\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"commit\", \"--no-gpg-sign\", \"-m\", commitMessage],\n\t\t\"Failed to commit the completed change\",\n\t\tidentity,\n\t);\n\tconst remaining = workingTreeStatus(repoPath);\n\tif (remaining.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Deterministic commit left uncommitted changes: ${remaining.join(\", \")}`,\n\t\t);\n\t}\n\treturn currentHeadSha(repoPath);\n}\n\nfunction commitIfDirty(input: {\n\trepoPath: string;\n\tcommitMessage: string;\n\tgitIdentity?: GitIdentity;\n}): string {\n\tconst status = workingTreeStatus(input.repoPath);\n\treturn status.length > 0\n\t\t? commitDirtyWorktree(input.repoPath, input.commitMessage, input.gitIdentity)\n\t\t: currentHeadSha(input.repoPath);\n}\n\nfunction assertPostConflictCheckpoint(\n\tinput: DeterministicFinalizationInput,\n\trepoPath: string,\n): void {\n\tif (!trimToNull(input.expectedPostConflictHeadSha)) {\n\t\treturn;\n\t}\n\tif (mergeInProgress(repoPath) || conflictedFiles(repoPath).length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t\"Conflict-resolution helper reported a clean merge, but the repository is still in a merge-conflict state\",\n\t\t);\n\t}\n\tconst status = workingTreeStatus(repoPath);\n\tif (status.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Conflict-resolution helper reported a clean merge, but the repository still has uncommitted changes: ${status.join(\", \")}`,\n\t\t);\n\t}\n}\n\nfunction fetchOriginBase(repoPath: string, baseBranch: string): string {\n\tconst ref = originBaseRef(baseBranch);\n\tcheckedGit(repoPath, [\"fetch\", \"origin\", baseBranch], `Failed to fetch '${ref}'`);\n\tconst baseSha = gitOrNull(repoPath, \"rev-parse\", ref);\n\tif (!baseSha) {\n\t\tthrow new DeterministicGitError(`Fetched '${ref}' but could not resolve its commit sha`);\n\t}\n\treturn baseSha;\n}\n\nfunction isAncestor(repoPath: string, olderRef: string, newerRef: string): boolean {\n\treturn runGit(repoPath, [\"merge-base\", \"--is-ancestor\", olderRef, newerRef]).ok;\n}\n\nfunction deterministicMerge(input: {\n\trepoPath: string;\n\tbaseBranch: string;\n\theadBefore: string;\n\tbaseSha: string;\n\tgitIdentity?: GitIdentity;\n}):\n\t| { ok: true; mergeMode: DeterministicFinalizationMergeMode; headSha: string }\n\t| { ok: false; conflict: true; headSha: string; conflictedFiles: string[] } {\n\tconst { repoPath, baseBranch, headBefore, baseSha } = input;\n\tconst ref = originBaseRef(baseBranch);\n\tconst headIsAncestorOfBase = isAncestor(repoPath, headBefore, ref);\n\tconst baseIsAncestorOfHead = isAncestor(repoPath, ref, headBefore);\n\n\tif (baseIsAncestorOfHead) {\n\t\treturn { ok: true, mergeMode: \"noop\", headSha: headBefore };\n\t}\n\n\tif (headIsAncestorOfBase) {\n\t\tcheckedGit(repoPath, [\"merge\", \"--ff-only\", ref], `Fast-forward merge from '${ref}' failed`);\n\t\treturn {\n\t\t\tok: true,\n\t\t\tmergeMode: \"fast_forward\",\n\t\t\theadSha: currentHeadSha(repoPath),\n\t\t};\n\t}\n\n\tassertGitIdentity(repoPath, input.gitIdentity);\n\tconst mergeResult = runGit(\n\t\trepoPath,\n\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"merge\", \"--no-edit\", \"--no-gpg-sign\", ref],\n\t\tinput.gitIdentity,\n\t);\n\tif (!mergeResult.ok) {\n\t\tconst conflicts = conflictedFiles(repoPath);\n\t\tif (mergeInProgress(repoPath) || conflicts.length > 0) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tconflict: true,\n\t\t\t\theadSha: currentHeadSha(repoPath),\n\t\t\t\tconflictedFiles: conflicts,\n\t\t\t};\n\t\t}\n\t\tthrow new DeterministicGitError(\n\t\t\t`Deterministic merge from '${ref}' failed: ${gitFailureDetail(mergeResult)}`,\n\t\t);\n\t}\n\n\tconst headAfter = currentHeadSha(repoPath);\n\treturn {\n\t\tok: true,\n\t\tmergeMode: headAfter === baseSha ? \"fast_forward\" : \"merge_commit\",\n\t\theadSha: headAfter,\n\t};\n}\n\nfunction branchRef(branch: string): string {\n\treturn `refs/heads/${branch}`;\n}\n\nfunction pushAndVerify(repoPath: string, branch: string, expectedHeadSha: string): string {\n\tconst pushTarget = `origin/${branch}`;\n\tcheckedGit(\n\t\trepoPath,\n\t\t[\"push\", \"origin\", `HEAD:${branchRef(branch)}`],\n\t\t`Failed to push HEAD to '${pushTarget}'`,\n\t);\n\tconst remoteHead = gitOrNull(repoPath, \"ls-remote\", \"--heads\", \"origin\", branchRef(branch))\n\t\t?.split(/\\s+/)[0]\n\t\t?.trim();\n\tif (remoteHead !== expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Published '${pushTarget}' resolved to '${remoteHead ?? \"missing\"}', expected '${expectedHeadSha}'`,\n\t\t);\n\t}\n\treturn pushTarget;\n}\n\nfunction assertLocalSourceBaseRef(input: {\n\tlocalSourceRepoPath: string;\n\tbaseBranch: string;\n\texpectedHeadSha: string;\n\toperation: string;\n}): void {\n\tconst ref = branchRef(input.baseBranch);\n\tconst actualHeadSha = gitOrNull(input.localSourceRepoPath, \"rev-parse\", ref);\n\tif (!actualHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localSourceRepoPath}' does not have '${ref}' ${input.operation}`,\n\t\t);\n\t}\n\tif (actualHeadSha !== input.expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localSourceRepoPath}' has '${ref}' at '${actualHeadSha}', but expected '${input.expectedHeadSha}' ${input.operation}`,\n\t\t);\n\t}\n}\n\nfunction assertLocalBareSourceRepoReady(\n\tlocalSourceRepoPath: string,\n\tbaseBranch: string,\n\texpectedBaseSha: string,\n): void {\n\tassertLocalSourceBaseRef({\n\t\tlocalSourceRepoPath,\n\t\tbaseBranch,\n\t\texpectedHeadSha: expectedBaseSha,\n\t\toperation: \"before finalization could publish the workspace branch. Retry finalization.\",\n\t});\n}\n\nfunction pushLocalSourceBaseBranchToOriginIfPresent(input: {\n\tlocalSourceRepoPath: string;\n\tbaseBranch: string;\n\texpectedHeadSha: string;\n}): string | null {\n\tif (!runGit(input.localSourceRepoPath, [\"remote\", \"get-url\", \"origin\"]).ok) {\n\t\treturn null;\n\t}\n\tassertLocalSourceBaseRef({\n\t\tlocalSourceRepoPath: input.localSourceRepoPath,\n\t\tbaseBranch: input.baseBranch,\n\t\texpectedHeadSha: input.expectedHeadSha,\n\t\toperation: \"before pushing it to its origin remote\",\n\t});\n\tconst ref = branchRef(input.baseBranch);\n\tconst pushTarget = originBaseRef(input.baseBranch);\n\tcheckedGit(\n\t\tinput.localSourceRepoPath,\n\t\t[\"push\", \"origin\", `${ref}:${ref}`],\n\t\t`Failed to push local source repo '${input.localSourceRepoPath}' base branch '${input.baseBranch}' to '${pushTarget}'`,\n\t);\n\treturn pushTarget;\n}\n\nfunction assertLocalBaseRepoReady(\n\tlocalBaseRepoPath: string,\n\tbaseBranch: string,\n\texpectedBaseSha: string,\n): void {\n\tconst branch = currentBranch(localBaseRepoPath);\n\tif (branch !== baseBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected local source repo '${localBaseRepoPath}' to be checked out on '${baseBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n\tif (mergeInProgress(localBaseRepoPath) || conflictedFiles(localBaseRepoPath).length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' must not already be in a merge-conflict state before finalization updates '${baseBranch}'`,\n\t\t);\n\t}\n\tconst status = workingTreeStatus(localBaseRepoPath);\n\tif (status.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' must be clean before finalization updates '${baseBranch}': ${status.join(\", \")}`,\n\t\t);\n\t}\n\tconst actualBaseSha = currentHeadSha(localBaseRepoPath);\n\tif (actualBaseSha !== expectedBaseSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' moved on '${baseBranch}' from '${expectedBaseSha}' to '${actualBaseSha}' before finalization could continue. Retry finalization.`,\n\t\t);\n\t}\n}\n\nfunction mergeWorkBranchIntoLocalBaseRepo(input: {\n\tlocalBaseRepoPath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\texpectedBaseSha: string;\n\texpectedHeadSha: string;\n}): void {\n\tassertLocalBaseRepoReady(input.localBaseRepoPath, input.baseBranch, input.expectedBaseSha);\n\tcheckedGit(\n\t\tinput.localBaseRepoPath,\n\t\t[\"merge\", \"--ff-only\", `refs/heads/${input.workBranch}`],\n\t\t`Failed to fast-forward local source repo '${input.localBaseRepoPath}' branch '${input.baseBranch}' from '${input.workBranch}'`,\n\t);\n\tconst actualHeadSha = currentHeadSha(input.localBaseRepoPath);\n\tif (actualHeadSha !== input.expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localBaseRepoPath}' finished finalization at '${actualHeadSha}', but expected '${input.expectedHeadSha}' after merging '${input.workBranch}' into '${input.baseBranch}'`,\n\t\t);\n\t}\n}\n\nfunction updateLocalBaseRef(repoPath: string, baseBranch: string): void {\n\tconst branch = currentBranch(repoPath);\n\tif (branch === baseBranch) {\n\t\treturn;\n\t}\n\tcheckedGit(\n\t\trepoPath,\n\t\t[\"branch\", \"--force\", baseBranch, \"HEAD\"],\n\t\t`Failed to update the local '${baseBranch}' ref to the finalized HEAD`,\n\t);\n}\n\nfunction buildFinalizationMarkdown(input: {\n\tworkspaceClonePath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\theadSha: string;\n\tmergeMode: DeterministicFinalizationMergeMode;\n\tpushTarget: string;\n\tlocalSourceRepoPath: string | null;\n\tlocalSourceRepoKind: LocalSourceRepo[\"kind\"] | null;\n\tworkspacePushTarget: string | null;\n\tsourceOriginPushTarget: string | null;\n\tusedConflictResolution: boolean;\n}): string {\n\tconst lines = [\n\t\t\"## Finalized change\",\n\t\t\"\",\n\t\t`- Repository workspace: ${input.workspaceClonePath}`,\n\t\t`- Work branch: ${input.workBranch}`,\n\t\t`- Base branch: ${input.baseBranch}`,\n\t\t`- Merge result: ${describeMergeMode(input.mergeMode)}`,\n\t];\n\tif (input.localSourceRepoPath) {\n\t\tlines.push(\n\t\t\t`- Local source repo: ${input.localSourceRepoPath} (${input.localSourceRepoKind === \"bare\" ? \"bare\" : \"non-bare\"})`,\n\t\t);\n\t\tif (input.workspacePushTarget) {\n\t\t\tlines.push(`- Workspace publish: HEAD -> ${input.workspacePushTarget}`);\n\t\t}\n\t\tif (input.localSourceRepoKind === \"non_bare\") {\n\t\t\tlines.push(`- Base repo merge: ${input.workBranch} -> ${input.baseBranch}`);\n\t\t}\n\t\tif (input.sourceOriginPushTarget) {\n\t\t\tlines.push(\n\t\t\t\t`- Source origin push: ${branchRef(input.baseBranch)} -> ${input.sourceOriginPushTarget}`,\n\t\t\t);\n\t\t} else {\n\t\t\tlines.push(\"- Source origin push: skipped (local source repo has no origin remote)\");\n\t\t}\n\t} else {\n\t\tlines.push(`- Pushed: HEAD -> ${input.pushTarget}`);\n\t}\n\tlines.push(\n\t\t`- Final HEAD: \\`${abbreviateSha(input.headSha)}\\``,\n\t\t`- Conflict resolution used: ${input.usedConflictResolution ? \"yes\" : \"no\"}`,\n\t);\n\treturn lines.join(\"\\n\");\n}\n\nexport interface RepositoryChangeFinalizationContextState extends StructuralProcessState {\n\tfinalization: {\n\t\texpectedPostConflictHeadSha: string | null;\n\t\tusedConflictResolution: boolean;\n\t\tgeneratedCommitMessage: string | null;\n\t};\n}\n\n/** Commit the current workspace change and non-force push only the feature branch. */\nexport function commitAndPushWorkBranch(input: {\n\trepoPath: string;\n\tworkBranch: string;\n\tcommitMessage: string;\n\tgitIdentity: GitIdentity;\n}) {\n\tconst repoPath = path.resolve(input.repoPath);\n\tassertFinalizationCheckout({\n\t\trepoPath,\n\t\tworkBranch: input.workBranch,\n\t\tcommitMessage: input.commitMessage,\n\t\tmissingCommitMessage: \"A generated commit message is required before publication\",\n\t});\n\tconst conflicts = conflictedFiles(repoPath);\n\tif (mergeInProgress(repoPath) || conflicts.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Cannot publish a work branch with unresolved conflicts: ${conflicts.join(\", \") || \"merge in progress\"}`,\n\t\t);\n\t}\n\tconst headSha = commitIfDirty({\n\t\trepoPath,\n\t\tcommitMessage: input.commitMessage,\n\t\tgitIdentity: input.gitIdentity,\n\t});\n\tconst pushTarget = pushAndVerify(repoPath, input.workBranch, headSha);\n\treturn { headSha, pushTarget };\n}\n\nexport function runDeterministicFinalization<\n\tTParams,\n\tTState extends RepositoryChangeFinalizationContextState,\n>(\n\tctx: FlowAutomaticRunContext<TParams, TState>,\n\tgitIdentity?: GitIdentity,\n): DeterministicFinalizationResult {\n\tconst progressSteps = [\n\t\t[\"validate_checkout\", \"Validate the repository checkout\"],\n\t\t[\"fetch_base\", \"Fetch and verify the latest base branch\"],\n\t\t[\"commit_merge\", \"Commit changes and integrate the base branch\"],\n\t\t[\"publish\", \"Push the finalized branch\"],\n\t] as const;\n\tconst reportProgress = (\n\t\tactiveIndex: number | null,\n\t\tcompletedCount: number,\n\t\tfailure?: { index: number; detail: string },\n\t) =>\n\t\tctx.reportProgress?.({\n\t\t\ttitle: \"Finalization progress\",\n\t\t\tsteps: progressSteps.map(([id, label], index) => ({\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tstatus:\n\t\t\t\t\tindex === failure?.index\n\t\t\t\t\t\t? \"failed\"\n\t\t\t\t\t\t: index < completedCount\n\t\t\t\t\t\t\t? \"completed\"\n\t\t\t\t\t\t\t: index === activeIndex\n\t\t\t\t\t\t\t\t? \"in_progress\"\n\t\t\t\t\t\t\t\t: \"incomplete\",\n\t\t\t\t...(index === failure?.index ? { detail: failure.detail } : {}),\n\t\t\t})),\n\t\t});\n\treportProgress(0, 0);\n\tconst repo = ctx.repo.get(\"repo\");\n\tconst input: DeterministicFinalizationInput = {\n\t\trepoPath: repo.fsPath,\n\t\tworkspaceClonePath: repo.workspaceClonePath,\n\t\tbaseBranch: repo.baseBranch,\n\t\tworkBranch: repo.workBranch,\n\t\texpectedPostConflictHeadSha: ctx.state.finalization.expectedPostConflictHeadSha,\n\t\tusedConflictResolution: ctx.state.finalization.usedConflictResolution,\n\t\tcommitMessage: ctx.state.finalization.generatedCommitMessage ?? \"\",\n\t\tgitIdentity,\n\t};\n\tconst repoPath = path.resolve(input.repoPath);\n\tassertFinalizationCheckout({\n\t\trepoPath,\n\t\tworkBranch: input.workBranch,\n\t\tcommitMessage: input.commitMessage,\n\t\tmissingCommitMessage:\n\t\t\t\"No generated commit message is available; retry commit-message generation before finalization\",\n\t});\n\tassertPostConflictCheckpoint(input, repoPath);\n\treportProgress(1, 1);\n\n\tlet headSha = currentHeadSha(repoPath);\n\tconst conflicts = conflictedFiles(repoPath);\n\tif (mergeInProgress(repoPath) || conflicts.length > 0) {\n\t\treportProgress(null, 1, {\n\t\t\tindex: 2,\n\t\t\tdetail: \"The checkout already contains merge conflicts\",\n\t\t});\n\t\treturn {\n\t\t\toutcome: \"merge_conflict\",\n\t\t\tparams: {\n\t\t\t\theadSha,\n\t\t\t\tconflictedFiles: conflicts,\n\t\t\t\tfetchedBaseSha: null,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst baseSha = fetchOriginBase(repoPath, input.baseBranch);\n\tconst localSourceRepo = resolveLocalSourceRepo(repoPath);\n\tif (localSourceRepo?.kind === \"non_bare\") {\n\t\tassertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t} else if (localSourceRepo?.kind === \"bare\") {\n\t\tassertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t}\n\treportProgress(2, 2);\n\n\theadSha = commitIfDirty({\n\t\trepoPath,\n\t\tcommitMessage: input.commitMessage,\n\t\tgitIdentity: input.gitIdentity,\n\t});\n\tconst mergeResult = deterministicMerge({\n\t\trepoPath,\n\t\tbaseBranch: input.baseBranch,\n\t\theadBefore: headSha,\n\t\tbaseSha,\n\t\tgitIdentity: input.gitIdentity,\n\t});\n\tif (!mergeResult.ok) {\n\t\treportProgress(null, 2, {\n\t\t\tindex: 2,\n\t\t\tdetail: \"Base integration produced merge conflicts\",\n\t\t});\n\t\treturn {\n\t\t\toutcome: \"merge_conflict\",\n\t\t\tparams: {\n\t\t\t\theadSha: mergeResult.headSha,\n\t\t\t\tconflictedFiles: mergeResult.conflictedFiles,\n\t\t\t\tfetchedBaseSha: baseSha,\n\t\t\t},\n\t\t};\n\t}\n\n\treportProgress(3, 3);\n\tlet pushTarget: string;\n\tlet workspacePushTarget: string | null = null;\n\tlet sourceOriginPushTarget: string | null = null;\n\tif (localSourceRepo) {\n\t\tif (localSourceRepo.kind === \"non_bare\") {\n\t\t\tassertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t\t\tworkspacePushTarget = pushAndVerify(repoPath, input.workBranch, mergeResult.headSha);\n\t\t\tmergeWorkBranchIntoLocalBaseRepo({\n\t\t\t\tlocalBaseRepoPath: localSourceRepo.path,\n\t\t\t\tbaseBranch: input.baseBranch,\n\t\t\t\tworkBranch: input.workBranch,\n\t\t\t\texpectedBaseSha: baseSha,\n\t\t\t\texpectedHeadSha: mergeResult.headSha,\n\t\t\t});\n\t\t} else {\n\t\t\tassertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t\t\tworkspacePushTarget = pushAndVerify(repoPath, input.baseBranch, mergeResult.headSha);\n\t\t}\n\t\tsourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({\n\t\t\tlocalSourceRepoPath: localSourceRepo.path,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\texpectedHeadSha: mergeResult.headSha,\n\t\t});\n\t\tpushTarget = sourceOriginPushTarget ?? originBaseRef(input.baseBranch);\n\t} else {\n\t\tpushTarget = pushAndVerify(repoPath, input.baseBranch, mergeResult.headSha);\n\t}\n\tupdateLocalBaseRef(repoPath, input.baseBranch);\n\tconst finalHeadSha = currentHeadSha(repoPath);\n\treportProgress(null, 4);\n\treturn {\n\t\toutcome: \"finalized\",\n\t\tparams: {\n\t\t\theadSha: finalHeadSha,\n\t\t\tmergeMode: mergeResult.mergeMode,\n\t\t\tpushTarget,\n\t\t\tusedConflictResolution: input.usedConflictResolution === true,\n\t\t},\n\t\tmarkdown: buildFinalizationMarkdown({\n\t\t\tworkspaceClonePath: input.workspaceClonePath,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\tworkBranch: input.workBranch,\n\t\t\theadSha: finalHeadSha,\n\t\t\tmergeMode: mergeResult.mergeMode,\n\t\t\tpushTarget,\n\t\t\tlocalSourceRepoPath: localSourceRepo?.path ?? null,\n\t\t\tlocalSourceRepoKind: localSourceRepo?.kind ?? null,\n\t\t\tworkspacePushTarget,\n\t\t\tsourceOriginPushTarget,\n\t\t\tusedConflictResolution: input.usedConflictResolution === true,\n\t\t}),\n\t};\n}\n\nexport function readMergeMessage(repoPath: string): string | null {\n\tconst messagePath = path.resolve(repoPath, git(repoPath, \"rev-parse\", \"--git-dir\"), \"MERGE_MSG\");\n\tif (!existsSync(messagePath)) {\n\t\treturn null;\n\t}\n\treturn trimToNull(readFileSync(messagePath, \"utf8\"));\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,kBAAyC;AACzE;AAAA,EAEC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,wBAAwB;AAwC1B,IAAM,wBAAN,cAAoC,MAAM;AAAA,EACvC,aAA+B;AAAA,EAExC,YAAY,SAAiB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;A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,MACT,WAAW,YAAY;AAAA,MACvB;AAAA,MACA,wBAAwB,MAAM,2BAA2B;AAAA,IAC1D;AAAA,IACA,UAAU,0BAA0B;AAAA,MACnC,oBAAoB,MAAM;AAAA,MAC1B,YAAY,MAAM;AAAA,MAClB,YAAY,MAAM;AAAA,MAClB,SAAS;AAAA,MACT,WAAW,YAAY;AAAA,MACvB;AAAA,MACA,qBAAqB,iBAAiB,QAAQ;AAAA,MAC9C,qBAAqB,iBAAiB,QAAQ;AAAA,MAC9C;AAAA,MACA;AAAA,MACA,wBAAwB,MAAM,2BAA2B;AAAA,IAC1D,CAAC;AAAA,EACF;AACD;AAEO,SAAS,iBAAiB,UAAiC;AACjE,QAAM,cAAc,KAAK,QAAQ,UAAU,IAAI,UAAU,aAAa,WAAW,GAAG,WAAW;AAC/F,MAAI,CAAC,WAAW,WAAW,GAAG;AAC7B,WAAO;AAAA,EACR;AACA,SAAO,WAAW,aAAa,aAAa,MAAM,CAAC;AACpD;","names":[]}
@@ -1,6 +1,4 @@
1
1
  // src/turns/review-plan.ts
2
- import { createReviewSubject } from "@leitwerk-dev/domain";
3
- var planReviewSubject = createReviewSubject("plan");
4
2
  function buildReviewPlanPrompt(ctx) {
5
3
  return `Review the plan against this requested change:
6
4
  ${ctx.prompts.initial}
@@ -22,7 +20,6 @@ Rules:
22
20
  }
23
21
 
24
22
  export {
25
- planReviewSubject,
26
23
  buildReviewPlanPrompt
27
24
  };
28
- //# sourceMappingURL=chunk-RZ54IVY5.js.map
25
+ //# sourceMappingURL=chunk-EP3ZC37F.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/turns/review-plan.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\nexport function buildReviewPlanPrompt(\n\tctx: FlowPromptContext<unknown, StructuralProcessState, \"plan\">,\n): string {\n\treturn `Review the plan against this requested change:\n${ctx.prompts.initial}\n\nRepository root: . (the current working directory)\n\nPlan:\n${ctx.input.plan}\n\nRules:\n- review the plan only; do not rewrite the plan\n- if you inspect repository files for context, read only inside the current working directory\n- use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)\n- do not modify files, branches, commits, or git index state\n- do not read from or write to any original source repository path outside the process workspace\n- evaluate scope, sequencing, risks, and acceptance criteria\n- publish a short Markdown approval note when the plan is solid\n- publish concise, actionable Markdown feedback when the plan needs changes`;\n}\n"],"mappings":";AAEO,SAAS,sBACf,KACS;AACT,SAAO;AAAA,EACN,IAAI,QAAQ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,IAAI,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWhB;","names":[]}
@@ -1,6 +1,4 @@
1
1
  // src/turns/review-implementation.ts
2
- import { createReviewSubject } from "@leitwerk-dev/domain";
3
- var implementationReviewSubject = createReviewSubject("implementation");
4
2
  function buildReviewImplementationPrompt(ctx) {
5
3
  const repo = ctx.repo.get("repo");
6
4
  return `Repository root: . (the current working directory)
@@ -28,7 +26,6 @@ Rules:
28
26
  }
29
27
 
30
28
  export {
31
- implementationReviewSubject,
32
29
  buildReviewImplementationPrompt
33
30
  };
34
- //# sourceMappingURL=chunk-RWCLBBB2.js.map
31
+ //# sourceMappingURL=chunk-WQEPA35Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/turns/review-implementation.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\nexport function buildReviewImplementationPrompt(\n\tctx: FlowPromptContext<unknown, StructuralProcessState>,\n): string {\n\tconst repo = ctx.repo.get(\"repo\");\n\treturn `Repository root: . (the current working directory)\n\nReview the current implementation of this requested change:\n${ctx.prompts.initial}\n\nInspect the changes with \\`git diff --stat $(git merge-base ${repo.baseBranch} HEAD)\\`. Check for:\n- bugs and logic errors\n- security issues\n- error handling gaps\n- missing or misplaced tests\n- unnecessary abstractions, duplication, and other avoidable complexity\n\nFor each issue, give a concise fix.\n\nRules:\n- inspect code only inside the current working directory\n- treat . as the repository root for read-only inspection\n- use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)\n- do not modify files, branches, commits, or git index state\n- do not read from or write to any original source repository path outside the process workspace\n- publish a short Markdown approval note if the implementation is ready\n- publish concise, actionable Markdown feedback if the implementation needs changes`;\n}\n"],"mappings":";AAEO,SAAS,gCACf,KACS;AACT,QAAM,OAAO,IAAI,KAAK,IAAI,MAAM;AAChC,SAAO;AAAA;AAAA;AAAA,EAGN,IAAI,QAAQ,OAAO;AAAA;AAAA,8DAEyC,KAAK,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB7E;","names":[]}