@leitwerk-dev/coding 0.3.1 → 0.4.1

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 (123) hide show
  1. package/README.md +154 -13
  2. package/dist/chunk-3WJRJ3Q7.js +220 -0
  3. package/dist/chunk-3WJRJ3Q7.js.map +1 -0
  4. package/dist/chunk-ABQH2WZT.js +36 -0
  5. package/dist/chunk-ABQH2WZT.js.map +1 -0
  6. package/dist/chunk-B3PE6DPF.js +820 -0
  7. package/dist/chunk-B3PE6DPF.js.map +1 -0
  8. package/dist/chunk-DNG7D77K.js +65 -0
  9. package/dist/chunk-DNG7D77K.js.map +1 -0
  10. package/dist/chunk-E3DB4TIZ.js +49 -0
  11. package/dist/chunk-E3DB4TIZ.js.map +1 -0
  12. package/dist/chunk-L2TFD72B.js +16320 -0
  13. package/dist/chunk-L2TFD72B.js.map +1 -0
  14. package/dist/chunk-M2VTUPFO.js +265 -0
  15. package/dist/chunk-M2VTUPFO.js.map +1 -0
  16. package/dist/{chunk-YSC5GEQJ.js → chunk-QD6FI4HR.js} +7 -3
  17. package/dist/chunk-QD6FI4HR.js.map +1 -0
  18. package/dist/chunk-SKGB4CZS.js +14 -0
  19. package/dist/chunk-SKGB4CZS.js.map +1 -0
  20. package/dist/chunk-SZ4WOGV2.js +120 -0
  21. package/dist/chunk-SZ4WOGV2.js.map +1 -0
  22. package/dist/finalization-git-internal.d.ts +9 -0
  23. package/dist/finalization-git-internal.d.ts.map +1 -1
  24. package/dist/finalization-git.d.ts +1 -1
  25. package/dist/finalization-git.d.ts.map +1 -1
  26. package/dist/finalization-git.js +6 -3
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +18 -591
  30. package/dist/index.js.map +1 -1
  31. package/dist/pull-request-publication-internal.d.ts +34 -24
  32. package/dist/pull-request-publication-internal.d.ts.map +1 -1
  33. package/dist/repository-change-launch-internal-BudnAfL7.d.ts +88 -0
  34. package/dist/repository-change-launch-internal.d.ts +32 -11
  35. package/dist/repository-change-launch-internal.d.ts.map +1 -1
  36. package/dist/repository-change-launch.d.ts +4 -3
  37. package/dist/repository-change-launch.d.ts.map +1 -1
  38. package/dist/repository-change-launch.js +162 -34
  39. package/dist/repository-change-launch.js.map +1 -1
  40. package/dist/repository-change-process-DlgF04fU.d.ts +69 -0
  41. package/dist/repository-change-process.d.ts +30 -25
  42. package/dist/repository-change-process.d.ts.map +1 -1
  43. package/dist/repository-change-publication.d.ts +76 -7
  44. package/dist/repository-change-publication.d.ts.map +1 -1
  45. package/dist/repository-change-publication.js +624 -136
  46. package/dist/repository-change-publication.js.map +1 -1
  47. package/dist/repository-change-state-internal.d.ts +18 -4
  48. package/dist/repository-change-state-internal.d.ts.map +1 -1
  49. package/dist/repository-change-ui-launcher-internal.d.ts +34 -22
  50. package/dist/repository-change-ui-launcher-internal.d.ts.map +1 -1
  51. package/dist/repository-publication-receipt.d.ts +23 -0
  52. package/dist/repository-publication-receipt.d.ts.map +1 -0
  53. package/dist/repository-rebase/git.d.ts +8 -0
  54. package/dist/repository-rebase/git.d.ts.map +1 -1
  55. package/dist/repository-reconciliation.d.ts +47 -0
  56. package/dist/repository-reconciliation.d.ts.map +1 -0
  57. package/dist/repository-record.d.ts +6 -0
  58. package/dist/repository-record.d.ts.map +1 -0
  59. package/dist/settings.d.ts +15 -0
  60. package/dist/settings.d.ts.map +1 -0
  61. package/dist/turns/commit-message-evidence.d.ts +35 -0
  62. package/dist/turns/commit-message-evidence.d.ts.map +1 -0
  63. package/dist/turns/commit-message-evidence.js +9 -0
  64. package/dist/turns/generate-commit-message.d.ts +4 -1
  65. package/dist/turns/generate-commit-message.d.ts.map +1 -1
  66. package/dist/turns/generate-commit-message.js +7 -5
  67. package/dist/turns/generate-plan.d.ts.map +1 -1
  68. package/dist/turns/generate-plan.js +1 -1
  69. package/dist/turns/git-inspection-profile.d.ts +25 -0
  70. package/dist/turns/git-inspection-profile.d.ts.map +1 -0
  71. package/dist/turns/git-inspection-profile.js +8 -0
  72. package/dist/turns/implement.d.ts +1 -1
  73. package/dist/turns/implement.d.ts.map +1 -1
  74. package/dist/turns/implement.js +1 -1
  75. package/dist/turns/simplify-implementation.d.ts +1 -1
  76. package/dist/turns/simplify-implementation.d.ts.map +1 -1
  77. package/dist/turns/simplify-implementation.js +3 -3
  78. package/package.json +5 -9
  79. package/src/finalization-git-internal.ts +186 -114
  80. package/src/finalization-git.ts +1 -1
  81. package/src/index.ts +4 -1
  82. package/src/pull-request-publication-internal.ts +158 -79
  83. package/src/repository-change-launch-internal.ts +119 -12
  84. package/src/repository-change-launch.ts +8 -4
  85. package/src/repository-change-process.ts +252 -524
  86. package/src/repository-change-publication.ts +702 -121
  87. package/src/repository-change-state-internal.ts +34 -20
  88. package/src/repository-change-ui-launcher-internal.ts +139 -56
  89. package/src/repository-publication-receipt.ts +71 -0
  90. package/src/repository-rebase/git.ts +108 -29
  91. package/src/repository-reconciliation.ts +600 -0
  92. package/src/repository-record.ts +14 -0
  93. package/src/settings.ts +79 -0
  94. package/src/turns/commit-message-evidence.ts +241 -0
  95. package/src/turns/generate-commit-message.ts +53 -23
  96. package/src/turns/generate-plan.ts +26 -12
  97. package/src/turns/git-inspection-profile.ts +134 -0
  98. package/src/turns/implement.ts +13 -3
  99. package/src/turns/simplify-implementation.ts +10 -6
  100. package/dist/chunk-34B3Q75M.js +0 -25
  101. package/dist/chunk-34B3Q75M.js.map +0 -1
  102. package/dist/chunk-F6CEEAFE.js +0 -13
  103. package/dist/chunk-F6CEEAFE.js.map +0 -1
  104. package/dist/chunk-GO44KCUS.js +0 -154
  105. package/dist/chunk-GO44KCUS.js.map +0 -1
  106. package/dist/chunk-R3UCUGY6.js +0 -31
  107. package/dist/chunk-R3UCUGY6.js.map +0 -1
  108. package/dist/chunk-W7VJT6AN.js +0 -25
  109. package/dist/chunk-W7VJT6AN.js.map +0 -1
  110. package/dist/chunk-WKHVLLKE.js +0 -45
  111. package/dist/chunk-WKHVLLKE.js.map +0 -1
  112. package/dist/chunk-YSC5GEQJ.js.map +0 -1
  113. package/dist/repository-change-launch-internal-Dd-AONUs.d.ts +0 -67
  114. package/dist/turns/review-implementation.d.ts +0 -4
  115. package/dist/turns/review-implementation.d.ts.map +0 -1
  116. package/dist/turns/review-implementation.js +0 -8
  117. package/dist/turns/review-plan.d.ts +0 -4
  118. package/dist/turns/review-plan.d.ts.map +0 -1
  119. package/dist/turns/review-plan.js +0 -8
  120. package/src/turns/review-implementation.ts +0 -30
  121. package/src/turns/review-plan.ts +0 -24
  122. /package/dist/turns/{review-implementation.js.map → commit-message-evidence.js.map} +0 -0
  123. /package/dist/turns/{review-plan.js.map → git-inspection-profile.js.map} +0 -0
@@ -4,6 +4,14 @@ import path from "node:path";
4
4
  import { trimToNull, type WorkerErrorClass } from "@leitwerk-dev/domain";
5
5
  import { repositoryGitArgs, repositoryGitSubprocessEnv } from "@leitwerk-dev/process-sdk";
6
6
  import { resolveGitBinary } from "@leitwerk-dev/process-sdk/git-binary";
7
+ import {
8
+ pushWasRejected,
9
+ type RepositoryPublicationReceipt,
10
+ readPublicationReceipt,
11
+ readRepositoryBinding,
12
+ repositoryBindingMatches,
13
+ savePublicationReceipt,
14
+ } from "./repository-publication-receipt.js";
7
15
 
8
16
  /** @public */
9
17
  export interface GitIdentity {
@@ -25,14 +33,21 @@ export class DeterministicGitError extends Error {
25
33
  }
26
34
  }
27
35
 
36
+ /** @internal */
37
+ export class RemoteBranchChangedError extends DeterministicGitError {
38
+ constructor() {
39
+ super("The remote source branch changed before publication; reconcile and validate again");
40
+ }
41
+ }
42
+
28
43
  interface GitExecResult {
29
44
  ok: boolean;
30
45
  stdout: string;
31
46
  stderr: string;
32
47
  }
33
48
 
34
- function gitConfigIdentityEnv(): NodeJS.ProcessEnv {
35
- const env = repositoryGitSubprocessEnv("repo", { GIT_TERMINAL_PROMPT: "0" });
49
+ function gitConfigIdentityEnv(projectKey: string): NodeJS.ProcessEnv {
50
+ const env = repositoryGitSubprocessEnv(projectKey, { GIT_TERMINAL_PROMPT: "0" });
36
51
  for (const key of [
37
52
  "GIT_AUTHOR_NAME",
38
53
  "GIT_AUTHOR_EMAIL",
@@ -54,126 +69,183 @@ function gitIdentityArgs(identity: GitIdentity): string[] {
54
69
  return ["-c", `user.name=${name}`, "-c", `user.email=${email}`];
55
70
  }
56
71
 
57
- function runGit(repoPath: string, args: readonly string[], identity?: GitIdentity): GitExecResult {
58
- const trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;
59
- try {
60
- const stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {
61
- cwd: repoPath,
62
- encoding: "utf8",
63
- env: gitConfigIdentityEnv(),
64
- stdio: ["ignore", "pipe", "pipe"],
65
- });
66
- return { ok: true, stdout, stderr: "" };
67
- } catch (error) {
68
- const execError = error as {
69
- stdout?: string | Buffer;
70
- stderr?: string | Buffer;
71
- message?: string;
72
- };
73
- return {
74
- ok: false,
75
- stdout: execError.stdout?.toString() ?? "",
76
- stderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? "",
77
- };
72
+ function repositoryGit(projectKey: string, repoPath: string) {
73
+ function runGit(args: readonly string[], identity?: GitIdentity): GitExecResult {
74
+ const trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;
75
+ try {
76
+ const stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {
77
+ cwd: repoPath,
78
+ encoding: "utf8",
79
+ env: gitConfigIdentityEnv(projectKey),
80
+ stdio: ["ignore", "pipe", "pipe"],
81
+ });
82
+ return { ok: true, stdout, stderr: "" };
83
+ } catch (error) {
84
+ const execError = error as {
85
+ stdout?: string | Buffer;
86
+ stderr?: string | Buffer;
87
+ message?: string;
88
+ };
89
+ return {
90
+ ok: false,
91
+ stdout: execError.stdout?.toString() ?? "",
92
+ stderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? "",
93
+ };
94
+ }
78
95
  }
79
- }
80
-
81
- function checkedGit(
82
- repoPath: string,
83
- args: readonly string[],
84
- failureMessage: string,
85
- identity?: GitIdentity,
86
- ): string {
87
- const result = runGit(repoPath, args, identity);
88
- if (!result.ok) {
89
- const detail = trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error";
90
- throw new DeterministicGitError(`${failureMessage}: ${detail}`);
91
- }
92
- return result.stdout.trim();
93
- }
94
96
 
95
- function git(repoPath: string, ...args: string[]): string {
96
- return checkedGit(repoPath, args, `git ${args.join(" ")} failed in '${repoPath}'`);
97
- }
97
+ function checkedGit(
98
+ args: readonly string[],
99
+ failureMessage: string,
100
+ identity?: GitIdentity,
101
+ ): string {
102
+ const result = runGit(args, identity);
103
+ if (!result.ok) {
104
+ const detail = trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error";
105
+ throw new DeterministicGitError(`${failureMessage}: ${detail}`);
106
+ }
107
+ return result.stdout.trim();
108
+ }
98
109
 
99
- function gitOrNull(repoPath: string, ...args: string[]): string | null {
100
- const result = runGit(repoPath, args);
101
- return result.ok ? trimToNull(result.stdout) : null;
102
- }
110
+ function git(...args: string[]): string {
111
+ return checkedGit(args, `git ${args.join(" ")} failed in '${repoPath}'`);
112
+ }
103
113
 
104
- function workingTreeStatus(repoPath: string): string[] {
105
- return (gitOrNull(repoPath, "status", "--porcelain") ?? "")
106
- .split(/\r?\n/)
107
- .map((line) => line.replace(/\s+$/, ""))
108
- .filter(Boolean)
109
- .map((line) => line.slice(2).trim())
110
- .filter(Boolean);
111
- }
114
+ function gitOrNull(...args: string[]): string | null {
115
+ const result = runGit(args);
116
+ return result.ok ? trimToNull(result.stdout) : null;
117
+ }
112
118
 
113
- function conflictedFiles(repoPath: string): string[] {
114
- return (gitOrNull(repoPath, "diff", "--name-only", "--diff-filter=U") ?? "")
115
- .split(/\r?\n/)
116
- .map((line) => line.trim())
117
- .filter(Boolean);
118
- }
119
+ function workingTreeStatus(): string[] {
120
+ return (gitOrNull("status", "--porcelain") ?? "")
121
+ .split(/\r?\n/)
122
+ .map((line) => line.replace(/\s+$/, ""))
123
+ .filter(Boolean)
124
+ .map((line) => line.slice(2).trim())
125
+ .filter(Boolean);
126
+ }
119
127
 
120
- function mergeInProgress(repoPath: string): boolean {
121
- const gitDir = git(repoPath, "rev-parse", "--git-dir");
122
- return existsSync(path.resolve(repoPath, gitDir, "MERGE_HEAD"));
123
- }
128
+ function conflictedFiles(): string[] {
129
+ return (gitOrNull("diff", "--name-only", "--diff-filter=U") ?? "")
130
+ .split(/\r?\n/)
131
+ .map((line) => line.trim())
132
+ .filter(Boolean);
133
+ }
124
134
 
125
- function assertGitIdentity(repoPath: string, identity: GitIdentity): void {
126
- if (
127
- !runGit(repoPath, ["var", "GIT_AUTHOR_IDENT"], identity).ok ||
128
- !runGit(repoPath, ["var", "GIT_COMMITTER_IDENT"], identity).ok
129
- ) {
130
- throw new DeterministicGitError("Git author/committer identity is not configured");
135
+ function mergeInProgress(): boolean {
136
+ const gitDir = git("rev-parse", "--git-dir");
137
+ return existsSync(path.resolve(repoPath, gitDir, "MERGE_HEAD"));
131
138
  }
132
- }
133
139
 
134
- function commitIfDirty(input: {
135
- /** @public */
136
- repoPath: string;
137
- /** @public */
138
- commitMessage: string;
139
- /** @public */
140
- gitIdentity: GitIdentity;
141
- }): string {
142
- if (workingTreeStatus(input.repoPath).length === 0)
143
- return git(input.repoPath, "rev-parse", "HEAD");
144
- assertGitIdentity(input.repoPath, input.gitIdentity);
145
- checkedGit(input.repoPath, ["add", "--all"], "Failed to stage the completed change");
146
- checkedGit(
147
- input.repoPath,
148
- ["-c", "core.hooksPath=/dev/null", "commit", "--no-gpg-sign", "-m", input.commitMessage],
149
- "Failed to commit the completed change",
150
- input.gitIdentity,
151
- );
152
- const remaining = workingTreeStatus(input.repoPath);
153
- if (remaining.length > 0) {
154
- throw new DeterministicGitError(`Commit left uncommitted changes: ${remaining.join(", ")}`);
140
+ function assertGitIdentity(identity: GitIdentity): void {
141
+ if (
142
+ !runGit(["var", "GIT_AUTHOR_IDENT"], identity).ok ||
143
+ !runGit(["var", "GIT_COMMITTER_IDENT"], identity).ok
144
+ ) {
145
+ throw new DeterministicGitError("Git author/committer identity is not configured");
146
+ }
155
147
  }
156
- return git(input.repoPath, "rev-parse", "HEAD");
157
- }
158
148
 
159
- function pushAndVerify(repoPath: string, branch: string, expectedHeadSha: string): string {
160
- const ref = `refs/heads/${branch}`;
161
- const pushTarget = `origin/${branch}`;
162
- checkedGit(repoPath, ["push", "origin", `HEAD:${ref}`], `Failed to push HEAD to '${pushTarget}'`);
163
- const remoteHead = gitOrNull(repoPath, "ls-remote", "--heads", "origin", ref)
164
- ?.split(/\s+/)[0]
165
- ?.trim();
166
- if (remoteHead !== expectedHeadSha) {
167
- throw new DeterministicGitError(
168
- `Published '${pushTarget}' resolved to '${remoteHead ?? "missing"}', expected '${expectedHeadSha}'`,
149
+ function commitIfDirty(commitMessage: string, identity: GitIdentity): string {
150
+ if (workingTreeStatus().length === 0) return git("rev-parse", "HEAD");
151
+ assertGitIdentity(identity);
152
+ checkedGit(["add", "--all"], "Failed to stage the completed change");
153
+ checkedGit(
154
+ ["-c", "core.hooksPath=/dev/null", "commit", "--no-gpg-sign", "-m", commitMessage],
155
+ "Failed to commit the completed change",
156
+ identity,
169
157
  );
158
+ const remaining = workingTreeStatus();
159
+ if (remaining.length > 0) {
160
+ throw new DeterministicGitError(`Commit left uncommitted changes: ${remaining.join(", ")}`);
161
+ }
162
+ return git("rev-parse", "HEAD");
170
163
  }
171
- return pushTarget;
164
+
165
+ function pushAndVerify(
166
+ branch: string,
167
+ expectedHeadSha: string,
168
+ expectedRemoteHead?: string | null,
169
+ ): string {
170
+ const ref = `refs/heads/${branch}`;
171
+ const pushTarget = `origin/${branch}`;
172
+ const observed = git("ls-remote", "--heads", "origin", ref).split(/\s+/)[0] || null;
173
+ const lease = expectedRemoteHead === undefined ? observed : expectedRemoteHead;
174
+ const directory = git("rev-parse", "--absolute-git-dir");
175
+ const binding = readRepositoryBinding(git, branch);
176
+ if (binding.origin !== binding.pushOrigin)
177
+ throw new DeterministicGitError("Fetch and push endpoints must match for publication");
178
+ const previous = readPublicationReceipt(directory);
179
+ if (!repositoryBindingMatches(previous, binding))
180
+ throw new DeterministicGitError("Repository publication receipt binding changed");
181
+ const receipt: RepositoryPublicationReceipt = {
182
+ ...binding,
183
+ expectedHead: lease,
184
+ candidate: expectedHeadSha,
185
+ status: "attempting",
186
+ };
187
+ // Recover a successful push whose acknowledgement was lost.
188
+ if (observed === expectedHeadSha) {
189
+ savePublicationReceipt(directory, { ...receipt, status: "accepted" });
190
+ return pushTarget;
191
+ }
192
+ if (previous?.status === "attempting")
193
+ throw new DeterministicGitError(
194
+ "A prior publication is unresolved; retain local work and reconcile its exact candidate first",
195
+ );
196
+ if (previous?.status === "accepted" && previous.candidate === expectedHeadSha)
197
+ throw new RemoteBranchChangedError();
198
+ if (observed !== lease) throw new RemoteBranchChangedError();
199
+ if (lease && !runGit(["merge-base", "--is-ancestor", lease, expectedHeadSha]).ok)
200
+ throw new DeterministicGitError(
201
+ "Ordinary publication must preserve the captured remote head",
202
+ );
203
+ savePublicationReceipt(directory, receipt);
204
+ const pushed = runGit([
205
+ "push",
206
+ "--porcelain",
207
+ "--no-follow-tags",
208
+ "--recurse-submodules=no",
209
+ `--force-with-lease=${ref}:${lease ?? ""}`,
210
+ "origin",
211
+ `${expectedHeadSha}:${ref}`,
212
+ ]);
213
+ if (!pushed.ok) {
214
+ if (pushWasRejected(pushed.stdout))
215
+ savePublicationReceipt(directory, { ...receipt, status: "rejected" });
216
+ const latest = git("ls-remote", "--heads", "origin", ref).split(/\s+/)[0] || null;
217
+ if (latest === expectedHeadSha) {
218
+ savePublicationReceipt(directory, { ...receipt, status: "accepted" });
219
+ return pushTarget;
220
+ }
221
+ if (latest !== lease) throw new RemoteBranchChangedError();
222
+ throw new DeterministicGitError(`Failed to push HEAD to '${pushTarget}': ${pushed.stderr}`);
223
+ }
224
+ savePublicationReceipt(directory, { ...receipt, status: "accepted" });
225
+ const remoteHead = gitOrNull("ls-remote", "--heads", "origin", ref)?.split(/\s+/)[0]?.trim();
226
+ if (remoteHead !== expectedHeadSha) throw new RemoteBranchChangedError();
227
+ return pushTarget;
228
+ }
229
+
230
+ return { runGit, git, conflictedFiles, mergeInProgress, commitIfDirty, pushAndVerify };
231
+ }
232
+
233
+ /** Inspect staged, unstaged, untracked, and already committed unpublished changes. @public */
234
+ export function repositoryHasChanges(
235
+ repoPath: string,
236
+ baseBranch: string,
237
+ projectKey = "repo",
238
+ ): boolean {
239
+ const { git } = repositoryGit(projectKey, repoPath);
240
+ return Boolean(
241
+ git("status", "--porcelain") || git("diff", "--name-only", `origin/${baseBranch}...HEAD`),
242
+ );
172
243
  }
173
244
 
174
245
  /** Commit the current workspace change and non-force push only the feature branch. */
175
246
  /** @public */
176
247
  export function commitAndPushWorkBranch(input: {
248
+ /** @public */ projectKey?: string;
177
249
  /** @public */
178
250
  repoPath: string;
179
251
  /** @public */
@@ -182,14 +254,18 @@ export function commitAndPushWorkBranch(input: {
182
254
  commitMessage: string;
183
255
  /** @public */
184
256
  gitIdentity: GitIdentity;
257
+ /** Captured remote head; null requires branch creation. @internal */
258
+ expectedRemoteHead?: string | null;
185
259
  }) {
186
260
  const repoPath = path.resolve(input.repoPath);
187
- if (!existsSync(repoPath) || !runGit(repoPath, ["rev-parse", "--git-dir"]).ok) {
261
+ const { runGit, git, conflictedFiles, mergeInProgress, commitIfDirty, pushAndVerify } =
262
+ repositoryGit(input.projectKey ?? "repo", repoPath);
263
+ if (!existsSync(repoPath) || !runGit(["rev-parse", "--git-dir"]).ok) {
188
264
  throw new DeterministicGitError(
189
265
  `Repository workspace '${repoPath}' does not exist or is not a git repository`,
190
266
  );
191
267
  }
192
- const branch = git(repoPath, "branch", "--show-current");
268
+ const branch = git("branch", "--show-current");
193
269
  if (branch !== input.workBranch) {
194
270
  throw new DeterministicGitError(
195
271
  `Expected '${repoPath}' to be checked out on '${input.workBranch}', but found '${branch || "detached HEAD"}'`,
@@ -198,21 +274,17 @@ export function commitAndPushWorkBranch(input: {
198
274
  if (!trimToNull(input.commitMessage)) {
199
275
  throw new DeterministicGitError("A generated commit message is required before publication");
200
276
  }
201
- const conflicts = conflictedFiles(repoPath);
202
- if (mergeInProgress(repoPath) || conflicts.length > 0) {
277
+ const conflicts = conflictedFiles();
278
+ if (mergeInProgress() || conflicts.length > 0) {
203
279
  throw new DeterministicGitError(
204
280
  `Cannot publish a work branch with unresolved conflicts: ${conflicts.join(", ") || "merge in progress"}`,
205
281
  );
206
282
  }
207
- const headSha = commitIfDirty({
208
- repoPath,
209
- commitMessage: input.commitMessage,
210
- gitIdentity: input.gitIdentity,
211
- });
283
+ const headSha = commitIfDirty(input.commitMessage, input.gitIdentity);
212
284
  return {
213
285
  /** @public */
214
286
  headSha,
215
287
  /** @internal */
216
- pushTarget: pushAndVerify(repoPath, input.workBranch, headSha),
288
+ pushTarget: pushAndVerify(input.workBranch, headSha, input.expectedRemoteHead),
217
289
  };
218
290
  }
@@ -1,2 +1,2 @@
1
1
  export type { GitIdentity } from "./finalization-git-internal.js";
2
- export { commitAndPushWorkBranch } from "./finalization-git-internal.js";
2
+ export { commitAndPushWorkBranch, repositoryHasChanges } from "./finalization-git-internal.js";
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
2
+ import { codingSettings } from "./settings.js";
2
3
 
3
4
  /** @internal */
4
5
  const manifest = {
@@ -8,7 +9,7 @@ const manifest = {
8
9
  version: "0.1.0",
9
10
  } as const;
10
11
  /** @public */
11
- const extension: LeitwerkExtensionModule = { manifest };
12
+ const extension: LeitwerkExtensionModule = { manifest, scopedSettings: codingSettings };
12
13
  export default extension;
13
14
 
14
15
  export {
@@ -18,3 +19,5 @@ export {
18
19
  requestRevisionForm,
19
20
  } from "./actions.js";
20
21
  export { createRepositoryChangeProcess } from "./repository-change-process.js";
22
+
23
+ export { codingPurposes, codingSettings } from "./settings.js";