@leitwerk-dev/coding 0.2.1 → 0.3.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.
- package/README.md +18 -12
- package/dist/actions.d.ts +0 -5
- package/dist/actions.d.ts.map +1 -1
- package/dist/auto-work-branch-internal.d.ts +2 -18
- package/dist/auto-work-branch-internal.d.ts.map +1 -1
- package/dist/auto-work-branch.d.ts +1 -2
- package/dist/auto-work-branch.d.ts.map +1 -1
- package/dist/auto-work-branch.js +17 -94
- package/dist/auto-work-branch.js.map +1 -1
- package/dist/chunk-GO44KCUS.js +154 -0
- package/dist/chunk-GO44KCUS.js.map +1 -0
- package/dist/finalization-git-internal.d.ts +6 -45
- package/dist/finalization-git-internal.d.ts.map +1 -1
- package/dist/finalization-git.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -91
- package/dist/index.js.map +1 -1
- package/dist/repository-change-launch-internal.d.ts +3 -84
- package/dist/repository-change-launch-internal.d.ts.map +1 -1
- package/dist/repository-change-launch.d.ts +2 -2
- package/dist/repository-change-launch.d.ts.map +1 -1
- package/dist/repository-change-launch.js +2 -159
- package/dist/repository-change-launch.js.map +1 -1
- package/dist/repository-change-process.d.ts +7 -19
- package/dist/repository-change-process.d.ts.map +1 -1
- package/dist/repository-change-publication.d.ts +229 -0
- package/dist/repository-change-publication.d.ts.map +1 -0
- package/dist/repository-change-publication.js +368 -0
- package/dist/repository-change-publication.js.map +1 -0
- package/dist/repository-change-state-internal.d.ts +2 -11
- package/dist/repository-change-state-internal.d.ts.map +1 -1
- package/dist/repository-change-state.d.ts +0 -1
- package/dist/repository-change-state.d.ts.map +1 -1
- package/dist/repository-change-state.js +0 -7
- package/package.json +10 -4
- package/src/actions.ts +0 -13
- package/src/auto-work-branch-internal.ts +22 -130
- package/src/auto-work-branch.ts +1 -7
- package/src/finalization-git-internal.ts +60 -697
- package/src/index.ts +0 -1
- package/src/repository-change-launch-internal.ts +4 -268
- package/src/repository-change-launch.ts +1 -6
- package/src/repository-change-process.ts +8 -126
- package/src/repository-change-publication.ts +689 -0
- package/src/repository-change-state-internal.ts +4 -34
- package/src/repository-change-state.ts +0 -1
- package/dist/chunk-HUVXPZSF.js +0 -61
- package/dist/chunk-HUVXPZSF.js.map +0 -1
- package/dist/chunk-MY6XFGHM.js +0 -614
- package/dist/chunk-MY6XFGHM.js.map +0 -1
- package/dist/chunk-OERAYSVI.js +0 -27
- package/dist/chunk-OERAYSVI.js.map +0 -1
- package/dist/turns/resolve-merge-conflict.d.ts +0 -4
- package/dist/turns/resolve-merge-conflict.d.ts.map +0 -1
- package/dist/turns/resolve-merge-conflict.js +0 -8
- package/dist/turns/resolve-merge-conflict.js.map +0 -1
- package/src/turns/resolve-merge-conflict.ts +0 -26
package/src/index.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { parseRepoLocator, trimString } from "@leitwerk-dev/domain";
|
|
2
|
-
import type {
|
|
3
|
-
Codec,
|
|
4
|
-
LauncherValidationError,
|
|
5
|
-
ProcessLaunchConfig,
|
|
6
|
-
ProcessLauncherDefinition,
|
|
7
|
-
UiLauncherDefinition,
|
|
8
|
-
} from "@leitwerk-dev/process-sdk";
|
|
9
|
-
|
|
10
|
-
/** @internal */
|
|
11
|
-
export type RepositoryChangeLaunchKind = "requested_change" | "imported_plan";
|
|
2
|
+
import type { Codec } from "@leitwerk-dev/process-sdk";
|
|
12
3
|
|
|
13
4
|
/** @public */
|
|
14
5
|
export interface RepositoryChangeParamsBase {
|
|
@@ -20,32 +11,14 @@ export interface RepositoryChangeParamsBase {
|
|
|
20
11
|
workBranch: string;
|
|
21
12
|
/** @public */
|
|
22
13
|
prompt: string;
|
|
23
|
-
/** @internal */
|
|
24
|
-
launchKind: RepositoryChangeLaunchKind;
|
|
25
|
-
/** @internal */
|
|
26
|
-
importedPlanMarkdown?: string;
|
|
27
14
|
}
|
|
28
15
|
|
|
29
16
|
/** @public */
|
|
30
17
|
export type RepositoryChangeLaunchParams<TExtra extends object = Record<never, never>> = TExtra &
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
| {
|
|
34
|
-
/** @public */
|
|
35
|
-
launchKind: "requested_change";
|
|
36
|
-
}
|
|
37
|
-
| {
|
|
38
|
-
/** @public */
|
|
39
|
-
launchKind: "imported_plan";
|
|
40
|
-
/** @internal */
|
|
41
|
-
importedPlanMarkdown: string;
|
|
42
|
-
}
|
|
43
|
-
);
|
|
18
|
+
RepositoryChangeParamsBase;
|
|
44
19
|
|
|
45
20
|
/** @public */
|
|
46
21
|
export interface NormalizedRepositoryChangeParamsInput {
|
|
47
|
-
/** @internal */
|
|
48
|
-
launchKind: string;
|
|
49
22
|
/** @internal */
|
|
50
23
|
repoLocator: string;
|
|
51
24
|
/** @internal */
|
|
@@ -54,8 +27,6 @@ export interface NormalizedRepositoryChangeParamsInput {
|
|
|
54
27
|
workBranch: string;
|
|
55
28
|
/** @internal */
|
|
56
29
|
prompt: string;
|
|
57
|
-
/** @internal */
|
|
58
|
-
importedPlanMarkdown: string;
|
|
59
30
|
}
|
|
60
31
|
|
|
61
32
|
/** @public */
|
|
@@ -77,252 +48,17 @@ export function normalizeRepositoryChangeParamsInput(
|
|
|
77
48
|
const record = repositoryChangeParamsRecord(value, displayName);
|
|
78
49
|
const rawRepoLocator = trimString(record.repoLocator);
|
|
79
50
|
return {
|
|
80
|
-
launchKind: trimString(record.launchKind),
|
|
81
51
|
repoLocator: parseRepoLocator(rawRepoLocator)?.value ?? rawRepoLocator,
|
|
82
52
|
baseBranch: trimString(record.baseBranch) || "main",
|
|
83
53
|
workBranch: trimString(record.workBranch),
|
|
84
54
|
prompt: trimString(record.prompt),
|
|
85
|
-
importedPlanMarkdown: trimString(record.importedPlanMarkdown),
|
|
86
55
|
};
|
|
87
56
|
}
|
|
88
57
|
|
|
89
58
|
/** @public */
|
|
90
59
|
export function createRepositoryChangeParamsCodec<T extends RepositoryChangeParamsBase>(input: {
|
|
91
60
|
/** @public */
|
|
92
|
-
|
|
93
|
-
/** @public */
|
|
94
|
-
normalize(
|
|
95
|
-
value: unknown,
|
|
96
|
-
): NormalizedRepositoryChangeParamsInput & Omit<T, keyof RepositoryChangeParamsBase>;
|
|
61
|
+
normalize(value: unknown): T;
|
|
97
62
|
}): Codec<T> {
|
|
98
|
-
return {
|
|
99
|
-
parse(value) {
|
|
100
|
-
const { importedPlanMarkdown, ...shared } = input.normalize(value);
|
|
101
|
-
if (shared.launchKind === "requested_change") return shared as T;
|
|
102
|
-
if (shared.launchKind === "imported_plan") {
|
|
103
|
-
return { ...shared, launchKind: shared.launchKind, importedPlanMarkdown } as T;
|
|
104
|
-
}
|
|
105
|
-
throw new Error(`${input.displayName} params require a valid launchKind`);
|
|
106
|
-
},
|
|
107
|
-
serialize: (value) => value,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** @internal */
|
|
112
|
-
export interface RepositoryChangeLaunchPlannerInput {
|
|
113
|
-
/** @internal */
|
|
114
|
-
input: Record<string, unknown>;
|
|
115
|
-
/** @internal */
|
|
116
|
-
metadata?: Record<string, unknown> | null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** @internal */
|
|
120
|
-
export type RepositoryChangeLaunchResolution<T extends RepositoryChangeParamsBase> =
|
|
121
|
-
| {
|
|
122
|
-
/** @internal */
|
|
123
|
-
ok: true;
|
|
124
|
-
/** @internal */
|
|
125
|
-
launchConfig: ProcessLaunchConfig<T>;
|
|
126
|
-
}
|
|
127
|
-
| {
|
|
128
|
-
/** @internal */
|
|
129
|
-
ok: false;
|
|
130
|
-
/** @internal */
|
|
131
|
-
errors: readonly LauncherValidationError[];
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/** @internal */
|
|
135
|
-
export interface RepositoryChangeLaunchPlanner<T extends RepositoryChangeParamsBase> {
|
|
136
|
-
/** @internal */
|
|
137
|
-
plan(input: RepositoryChangeLaunchPlannerInput): RepositoryChangeLaunchResolution<T>;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/** @internal */
|
|
141
|
-
export function formatRepositoryChangeLaunchErrors(
|
|
142
|
-
errors: readonly LauncherValidationError[],
|
|
143
|
-
): string {
|
|
144
|
-
return errors.map((error) => `${error.fieldId ?? "launch"}: ${error.message}`).join("; ");
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** @internal */
|
|
148
|
-
export function createRepositoryChangeLaunchPlanner<T extends RepositoryChangeParamsBase>(config: {
|
|
149
|
-
/** @internal */
|
|
150
|
-
processId: string;
|
|
151
|
-
/** @internal */
|
|
152
|
-
normalize(input: Record<string, unknown>): T & {
|
|
153
|
-
/** @internal */
|
|
154
|
-
importedPlanMarkdown?: string;
|
|
155
|
-
};
|
|
156
|
-
/** @internal */
|
|
157
|
-
validateRepoLocator(repoLocator: string): string | null;
|
|
158
|
-
/** @internal */
|
|
159
|
-
validate?(input: Record<string, unknown>, params: T): readonly LauncherValidationError[];
|
|
160
|
-
/** @internal */
|
|
161
|
-
prepare?(params: T): T;
|
|
162
|
-
/** @internal */
|
|
163
|
-
deferWithoutWorkBranch?: boolean;
|
|
164
|
-
}): RepositoryChangeLaunchPlanner<T> {
|
|
165
|
-
return {
|
|
166
|
-
plan({ input, metadata }) {
|
|
167
|
-
const params = config.normalize(input);
|
|
168
|
-
const errors: LauncherValidationError[] = [];
|
|
169
|
-
if (params.launchKind !== "requested_change" && params.launchKind !== "imported_plan") {
|
|
170
|
-
errors.push({
|
|
171
|
-
code: "custom_rule",
|
|
172
|
-
fieldId: "launchKind",
|
|
173
|
-
message: "launchKind must be requested_change or imported_plan",
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
const locatorError = config.validateRepoLocator(params.repoLocator);
|
|
177
|
-
if (locatorError) {
|
|
178
|
-
errors.push({
|
|
179
|
-
code: "invalid_repo_locator",
|
|
180
|
-
fieldId: "repoLocator",
|
|
181
|
-
message: locatorError,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if (params.workBranch && params.workBranch === params.baseBranch) {
|
|
185
|
-
errors.push({
|
|
186
|
-
code: "custom_rule",
|
|
187
|
-
fieldId: "workBranch",
|
|
188
|
-
message: "workBranch cannot match baseBranch",
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
if (!params.prompt) {
|
|
192
|
-
errors.push({ code: "required", fieldId: "prompt", message: "prompt is required" });
|
|
193
|
-
}
|
|
194
|
-
if (params.launchKind === "imported_plan" && !params.importedPlanMarkdown) {
|
|
195
|
-
errors.push({
|
|
196
|
-
code: "required",
|
|
197
|
-
fieldId: "importedPlanMarkdown",
|
|
198
|
-
message: "importedPlanMarkdown is required for imported_plan launches",
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
if (params.launchKind === "requested_change" && "importedPlanMarkdown" in input) {
|
|
202
|
-
errors.push({
|
|
203
|
-
code: "custom_rule",
|
|
204
|
-
fieldId: "importedPlanMarkdown",
|
|
205
|
-
message: "importedPlanMarkdown is not allowed for requested_change launches",
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
errors.push(...(config.validate?.(input, params) ?? []));
|
|
209
|
-
if (errors.length > 0) return { ok: false, errors };
|
|
210
|
-
|
|
211
|
-
const prepared = config.prepare?.(params) ?? params;
|
|
212
|
-
const hasWorkBranch = prepared.workBranch !== "";
|
|
213
|
-
return {
|
|
214
|
-
ok: true,
|
|
215
|
-
launchConfig: {
|
|
216
|
-
processId: config.processId,
|
|
217
|
-
params: prepared,
|
|
218
|
-
startTurnId:
|
|
219
|
-
config.deferWithoutWorkBranch && !hasWorkBranch
|
|
220
|
-
? null
|
|
221
|
-
: prepared.launchKind === "imported_plan"
|
|
222
|
-
? "import_plan"
|
|
223
|
-
: "generate_plan",
|
|
224
|
-
titleSourceFields: [{ label: "Requested change", value: prepared.prompt }],
|
|
225
|
-
metadata: metadata ?? null,
|
|
226
|
-
projects: [
|
|
227
|
-
{
|
|
228
|
-
key: "repo",
|
|
229
|
-
repoLocator: prepared.repoLocator,
|
|
230
|
-
baseBranch: prepared.baseBranch,
|
|
231
|
-
workBranch: hasWorkBranch ? prepared.workBranch : null,
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
},
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** @internal */
|
|
241
|
-
export function createRepositoryChangeUiLauncher<T extends RepositoryChangeParamsBase>(config: {
|
|
242
|
-
/** @internal */
|
|
243
|
-
id: string;
|
|
244
|
-
/** @internal */
|
|
245
|
-
formId: string;
|
|
246
|
-
/** @internal */
|
|
247
|
-
title: string;
|
|
248
|
-
/** @internal */
|
|
249
|
-
workBranchDescription: string;
|
|
250
|
-
/** @internal */
|
|
251
|
-
sshCredentials?: boolean;
|
|
252
|
-
/** @internal */
|
|
253
|
-
resolveRelaunchInput?: UiLauncherDefinition<T>["resolveRelaunchInput"];
|
|
254
|
-
/** @internal */
|
|
255
|
-
resolveLaunchConfig: UiLauncherDefinition<T>["resolveLaunchConfig"];
|
|
256
|
-
}): ProcessLauncherDefinition<T> {
|
|
257
|
-
return {
|
|
258
|
-
id: config.id,
|
|
259
|
-
label: config.title,
|
|
260
|
-
description: "Plan, implement, review, and finalize a change in a single git repository",
|
|
261
|
-
visibility: "ui",
|
|
262
|
-
ui: {
|
|
263
|
-
card: {
|
|
264
|
-
title: config.title,
|
|
265
|
-
description:
|
|
266
|
-
"Run a plan → implement → review → finalize loop against any local or remote git repository.",
|
|
267
|
-
},
|
|
268
|
-
launchConfigSchema: {
|
|
269
|
-
id: config.formId,
|
|
270
|
-
title: config.title,
|
|
271
|
-
fields: [
|
|
272
|
-
{
|
|
273
|
-
id: "repoLocator",
|
|
274
|
-
label: "Repository path or URL",
|
|
275
|
-
kind: "text",
|
|
276
|
-
required: true,
|
|
277
|
-
placeholder: "/path/to/repo or https://git.example.com/team/repo.git",
|
|
278
|
-
description: "Use a local checkout path or a remote Git URL.",
|
|
279
|
-
rememberRecentValues: true,
|
|
280
|
-
},
|
|
281
|
-
...(config.sshCredentials
|
|
282
|
-
? [
|
|
283
|
-
{
|
|
284
|
-
id: "sshCredentialRef",
|
|
285
|
-
label: "SSH credential profile",
|
|
286
|
-
kind: "text" as const,
|
|
287
|
-
required: true,
|
|
288
|
-
placeholder: "default",
|
|
289
|
-
description: "Profile from extensions.git-ssh.credentials.",
|
|
290
|
-
},
|
|
291
|
-
]
|
|
292
|
-
: []),
|
|
293
|
-
{
|
|
294
|
-
id: "baseBranch",
|
|
295
|
-
label: "Base branch",
|
|
296
|
-
kind: "text",
|
|
297
|
-
placeholder: "main",
|
|
298
|
-
description: "Leave this as main unless the change should merge somewhere else.",
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
id: "workBranch",
|
|
302
|
-
label: "Work branch",
|
|
303
|
-
kind: "text",
|
|
304
|
-
placeholder: "feature/my-change",
|
|
305
|
-
description: config.workBranchDescription,
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
id: "prompt",
|
|
309
|
-
label: "Requested change",
|
|
310
|
-
kind: "textarea",
|
|
311
|
-
required: true,
|
|
312
|
-
placeholder: "Describe the change this process should plan, implement, and review.",
|
|
313
|
-
},
|
|
314
|
-
],
|
|
315
|
-
submitLabel: "Start change",
|
|
316
|
-
},
|
|
317
|
-
resolveDefaults: () => ({
|
|
318
|
-
repoLocator: "",
|
|
319
|
-
...(config.sshCredentials ? { sshCredentialRef: "default" } : {}),
|
|
320
|
-
baseBranch: "main",
|
|
321
|
-
workBranch: "",
|
|
322
|
-
prompt: "",
|
|
323
|
-
}),
|
|
324
|
-
resolveRelaunchInput: config.resolveRelaunchInput,
|
|
325
|
-
resolveLaunchConfig: config.resolveLaunchConfig,
|
|
326
|
-
},
|
|
327
|
-
};
|
|
63
|
+
return { parse: input.normalize, serialize: (value) => value };
|
|
328
64
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
export type {
|
|
2
2
|
NormalizedRepositoryChangeParamsInput,
|
|
3
|
-
RepositoryChangeLaunchKind,
|
|
4
3
|
RepositoryChangeLaunchParams,
|
|
5
|
-
|
|
6
|
-
RepositoryChangeLaunchResolution,
|
|
4
|
+
RepositoryChangeParamsBase,
|
|
7
5
|
} from "./repository-change-launch-internal.js";
|
|
8
6
|
export {
|
|
9
|
-
createRepositoryChangeLaunchPlanner,
|
|
10
7
|
createRepositoryChangeParamsCodec,
|
|
11
|
-
createRepositoryChangeUiLauncher,
|
|
12
|
-
formatRepositoryChangeLaunchErrors,
|
|
13
8
|
normalizeRepositoryChangeParamsInput,
|
|
14
9
|
repositoryChangeParamsRecord,
|
|
15
10
|
} from "./repository-change-launch-internal.js";
|
|
@@ -19,13 +19,11 @@ import {
|
|
|
19
19
|
requestReviewChangesForm,
|
|
20
20
|
requestRevisionForm,
|
|
21
21
|
} from "./actions.js";
|
|
22
|
-
import { runDeterministicFinalization } from "./finalization-git-internal.js";
|
|
23
22
|
import {
|
|
24
23
|
clearReviewRefs,
|
|
25
24
|
createEmptyRepositoryChangeFinalizationState,
|
|
26
25
|
type RepositoryChangeState,
|
|
27
26
|
repositoryChangeStateCodec,
|
|
28
|
-
resetRepositoryChangeFinalizationState,
|
|
29
27
|
} from "./repository-change-state-internal.js";
|
|
30
28
|
import {
|
|
31
29
|
buildGenerateCommitMessagePrompt,
|
|
@@ -33,18 +31,12 @@ import {
|
|
|
33
31
|
} from "./turns/generate-commit-message.js";
|
|
34
32
|
import { buildGeneratePlanPrompt } from "./turns/generate-plan.js";
|
|
35
33
|
import { buildImplementPrompt } from "./turns/implement.js";
|
|
36
|
-
import { buildResolveMergeConflictPrompt } from "./turns/resolve-merge-conflict.js";
|
|
37
34
|
import { buildReviewImplementationPrompt } from "./turns/review-implementation.js";
|
|
38
35
|
import { buildReviewPlanPrompt } from "./turns/review-plan.js";
|
|
39
36
|
import { buildSimplifyImplementationPrompt } from "./turns/simplify-implementation.js";
|
|
40
37
|
|
|
41
38
|
/** @public */
|
|
42
|
-
export type RepositoryChangeParams =
|
|
43
|
-
/** @internal */
|
|
44
|
-
launchKind: "requested_change" | "imported_plan";
|
|
45
|
-
/** @internal */
|
|
46
|
-
importedPlanMarkdown?: string;
|
|
47
|
-
};
|
|
39
|
+
export type RepositoryChangeParams = object;
|
|
48
40
|
|
|
49
41
|
/** @public */
|
|
50
42
|
export interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeParams> {
|
|
@@ -61,8 +53,6 @@ export interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeP
|
|
|
61
53
|
/** @public */
|
|
62
54
|
finalizeForm: FormDefinition;
|
|
63
55
|
/** @public */
|
|
64
|
-
finalizationDescription: string;
|
|
65
|
-
/** @public */
|
|
66
56
|
repositoryCredentials?(input: {
|
|
67
57
|
/** @public */
|
|
68
58
|
params: TParams;
|
|
@@ -70,7 +60,7 @@ export interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeP
|
|
|
70
60
|
projects: readonly RepositoryCredentialProject[];
|
|
71
61
|
}): readonly RepositoryCredentialRequirement[];
|
|
72
62
|
/** @public */
|
|
73
|
-
publication
|
|
63
|
+
publication: {
|
|
74
64
|
/** @public */
|
|
75
65
|
entryTurnId: string;
|
|
76
66
|
/** @public */
|
|
@@ -85,7 +75,6 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
85
75
|
config: RepositoryChangeProcessConfig<TParams>,
|
|
86
76
|
) {
|
|
87
77
|
const turnIds = {
|
|
88
|
-
importPlan: "import_plan",
|
|
89
78
|
generatePlan: "generate_plan",
|
|
90
79
|
planDecision: "plan_decision",
|
|
91
80
|
reviewPlan: "review_plan",
|
|
@@ -97,8 +86,6 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
97
86
|
simplifyImplementation: "simplify_implementation",
|
|
98
87
|
simplificationDecision: "simplification_decision",
|
|
99
88
|
generateCommitMessage: "generate_commit_message",
|
|
100
|
-
commitAndMerge: "commit_and_merge",
|
|
101
|
-
resolveMergeConflict: "resolve_merge_conflict",
|
|
102
89
|
} as const;
|
|
103
90
|
|
|
104
91
|
const products = {
|
|
@@ -106,22 +93,11 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
106
93
|
review: "review",
|
|
107
94
|
simplificationPlan: "simplification-plan",
|
|
108
95
|
implementationSummary: "implementation-summary",
|
|
109
|
-
mergeResolutionSummary: "merge-resolution-summary",
|
|
110
96
|
commitMessage: "commit-message",
|
|
111
97
|
} as const;
|
|
112
98
|
|
|
113
99
|
const implementationTurnAvailableTools = ["read", "bash", "edit", "write"] as const;
|
|
114
100
|
|
|
115
|
-
function resetFinalizationAfterMessage(
|
|
116
|
-
state: RepositoryChangeState,
|
|
117
|
-
overrides: Partial<RepositoryChangeState["finalization"]> = {},
|
|
118
|
-
) {
|
|
119
|
-
return resetRepositoryChangeFinalizationState({
|
|
120
|
-
generatedCommitMessage: state.finalization.generatedCommitMessage,
|
|
121
|
-
...overrides,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
101
|
function hasResolvedTurnRecordRef(
|
|
126
102
|
ref: RepositoryChangeState["semanticEntryRefs"][keyof RepositoryChangeState["semanticEntryRefs"]],
|
|
127
103
|
): ref is { entryId: string; turnRecordId: string } {
|
|
@@ -337,7 +313,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
337
313
|
},
|
|
338
314
|
],
|
|
339
315
|
commentary:
|
|
340
|
-
"
|
|
316
|
+
"Publish this implementation, request another pass, simplify it, or run an automated review.",
|
|
341
317
|
actions: {
|
|
342
318
|
[codingActionIds.finalizeChange]: {
|
|
343
319
|
label: config.finalizeLabel,
|
|
@@ -489,34 +465,6 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
489
465
|
},
|
|
490
466
|
});
|
|
491
467
|
|
|
492
|
-
const importPlanTurn = flow
|
|
493
|
-
.automatic<TParams, RepositoryChangeState>(turnIds.importPlan)
|
|
494
|
-
.description("Import handoff plan")
|
|
495
|
-
.run((ctx) => {
|
|
496
|
-
const planMarkdown =
|
|
497
|
-
ctx.params.launchKind === "imported_plan"
|
|
498
|
-
? normalizeOptionalMarkdown(ctx.params.importedPlanMarkdown)
|
|
499
|
-
: null;
|
|
500
|
-
if (!planMarkdown) {
|
|
501
|
-
throw new Error("No importedPlanMarkdown is available to import");
|
|
502
|
-
}
|
|
503
|
-
return {
|
|
504
|
-
outcome: "imported",
|
|
505
|
-
params: { plan: planMarkdown },
|
|
506
|
-
markdown: planMarkdown,
|
|
507
|
-
};
|
|
508
|
-
})
|
|
509
|
-
.outcome("imported", (outcome) =>
|
|
510
|
-
outcome
|
|
511
|
-
.description("Imported a handoff plan and skipped replanning")
|
|
512
|
-
.markdown("plan", { description: "Imported handoff plan", publish: true })
|
|
513
|
-
.to(turnIds.implement)
|
|
514
|
-
.effect(({ ctx }) => ({
|
|
515
|
-
processPatch: { planRevision: ctx.process.planRevision + 1 },
|
|
516
|
-
state: clearReviewState(ctx.state),
|
|
517
|
-
})),
|
|
518
|
-
);
|
|
519
|
-
|
|
520
468
|
const generatePlanTurn = flow
|
|
521
469
|
.llm<TParams, RepositoryChangeState>(turnIds.generatePlan)
|
|
522
470
|
.description("Plan")
|
|
@@ -656,7 +604,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
656
604
|
.consume(products.plan)
|
|
657
605
|
.buildPrompt(buildGenerateCommitMessagePrompt)
|
|
658
606
|
.publish(products.commitMessage)
|
|
659
|
-
.to(config.publication
|
|
607
|
+
.to(config.publication.entryTurnId)
|
|
660
608
|
.state(({ ctx }) =>
|
|
661
609
|
patchRepositoryChangeState(ctx.state, {
|
|
662
610
|
finalization: {
|
|
@@ -666,70 +614,8 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
666
614
|
}),
|
|
667
615
|
);
|
|
668
616
|
|
|
669
|
-
const commitAndMergeTurn = flow
|
|
670
|
-
.automatic<TParams, RepositoryChangeState>(turnIds.commitAndMerge)
|
|
671
|
-
.description(config.finalizationDescription)
|
|
672
|
-
.run(runDeterministicFinalization)
|
|
673
|
-
.outcome("merge_conflict", (outcome) =>
|
|
674
|
-
outcome
|
|
675
|
-
.description("Deterministic merge hit conflicts and needs conflict resolution")
|
|
676
|
-
.requiredString("headSha", "The current HEAD sha while the merge conflict is active")
|
|
677
|
-
.stringArray("conflictedFiles", "Conflicted files that need resolution")
|
|
678
|
-
.string("fetchedBaseSha", "The fetched origin/<baseBranch> sha when available")
|
|
679
|
-
.to(turnIds.resolveMergeConflict)
|
|
680
|
-
.state(({ ctx }) =>
|
|
681
|
-
patchRepositoryChangeState(ctx.state, {
|
|
682
|
-
finalization: resetFinalizationAfterMessage(ctx.state),
|
|
683
|
-
}),
|
|
684
|
-
),
|
|
685
|
-
)
|
|
686
|
-
.outcome("finalized", (outcome) =>
|
|
687
|
-
outcome
|
|
688
|
-
.description("Deterministic finalization succeeded")
|
|
689
|
-
.requiredString("headSha", "The final HEAD sha")
|
|
690
|
-
.requiredString("mergeMode", "How origin/<baseBranch> was integrated")
|
|
691
|
-
.requiredString("pushTarget", "The final base-branch publish target")
|
|
692
|
-
.requiredBoolean("usedConflictResolution", "Whether the merge required conflict resolution")
|
|
693
|
-
.complete()
|
|
694
|
-
.state(({ ctx, event }) =>
|
|
695
|
-
patchRepositoryChangeState(ctx.state, {
|
|
696
|
-
finalization: resetFinalizationAfterMessage(ctx.state, {
|
|
697
|
-
usedConflictResolution:
|
|
698
|
-
event.params.usedConflictResolution === true ||
|
|
699
|
-
ctx.state.finalization.usedConflictResolution,
|
|
700
|
-
finalizationSummaryMarkdown: normalizeOptionalMarkdown(ctx.output?.content),
|
|
701
|
-
finalizedHeadSha: normalizeMessage(event.params.headSha),
|
|
702
|
-
}),
|
|
703
|
-
}),
|
|
704
|
-
),
|
|
705
|
-
);
|
|
706
|
-
|
|
707
|
-
const resolveMergeConflictTurn = flow
|
|
708
|
-
.llm<TParams, RepositoryChangeState>(turnIds.resolveMergeConflict)
|
|
709
|
-
.description("Resolve merge conflict")
|
|
710
|
-
.tools("read", "bash", "edit", "write")
|
|
711
|
-
.fullPrimary()
|
|
712
|
-
.startFromRoot()
|
|
713
|
-
.buildPrompt(buildResolveMergeConflictPrompt)
|
|
714
|
-
.outcomeTool("clean", (tool) =>
|
|
715
|
-
tool
|
|
716
|
-
.description("The merge conflict was resolved and the repository is clean")
|
|
717
|
-
.requiredString("headSha", "The post-resolution HEAD sha")
|
|
718
|
-
.to(turnIds.commitAndMerge)
|
|
719
|
-
.state(({ ctx, event }) =>
|
|
720
|
-
patchRepositoryChangeState(ctx.state, {
|
|
721
|
-
finalization: resetFinalizationAfterMessage(ctx.state, {
|
|
722
|
-
expectedPostConflictHeadSha: normalizeMessage(event.params.headSha),
|
|
723
|
-
usedConflictResolution: true,
|
|
724
|
-
}),
|
|
725
|
-
}),
|
|
726
|
-
),
|
|
727
|
-
)
|
|
728
|
-
.publish(products.mergeResolutionSummary);
|
|
729
|
-
|
|
730
617
|
const planFlow = flow
|
|
731
618
|
.fragment<TParams, RepositoryChangeState>("plan")
|
|
732
|
-
.turn(importPlanTurn)
|
|
733
619
|
.turn(generatePlanTurn)
|
|
734
620
|
.turn({ id: turnIds.planDecision, definition: planDecisionSpec })
|
|
735
621
|
.turn(reviewPlanTurn)
|
|
@@ -750,20 +636,16 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
750
636
|
const finalizationFlow = flow
|
|
751
637
|
.fragment<TParams, RepositoryChangeState>("finalization")
|
|
752
638
|
.turn(generateCommitMessageTurn);
|
|
753
|
-
if (!config.publication) {
|
|
754
|
-
finalizationFlow.turn(commitAndMergeTurn).turn(resolveMergeConflictTurn);
|
|
755
|
-
}
|
|
756
639
|
|
|
757
640
|
const builder = flow
|
|
758
641
|
.process<TParams, RepositoryChangeState>(config.processId)
|
|
759
642
|
.displayName(config.displayName)
|
|
760
643
|
.entry(turnIds.generatePlan)
|
|
761
|
-
.alternateEntry(turnIds.importPlan)
|
|
762
644
|
.happyPath(
|
|
763
645
|
turnIds.generatePlan,
|
|
764
646
|
turnIds.implement,
|
|
765
647
|
turnIds.generateCommitMessage,
|
|
766
|
-
...(config.publication
|
|
648
|
+
...(config.publication.happyPath ?? [config.publication.entryTurnId]),
|
|
767
649
|
)
|
|
768
650
|
.piConfig({ sessionCwdTemplate: "{{{projectKey}}}" })
|
|
769
651
|
.codecs({
|
|
@@ -778,17 +660,17 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
778
660
|
.use(planFlow)
|
|
779
661
|
.use(implementationFlow)
|
|
780
662
|
.use(finalizationFlow);
|
|
781
|
-
|
|
663
|
+
builder.use(config.publication.fragment);
|
|
782
664
|
if (config.repositoryCredentials) builder.repositoryCredentials(config.repositoryCredentials);
|
|
783
665
|
if (config.launcher) builder.launcher(config.launcher);
|
|
784
666
|
const process = builder.define();
|
|
785
667
|
const decision = (id: string) =>
|
|
786
668
|
({
|
|
669
|
+
/** @public */
|
|
787
670
|
id,
|
|
788
671
|
...(process.turns.get(id)?.definition as HumanTurnDefinition),
|
|
789
672
|
}) as HumanTurnDefinition & {
|
|
790
|
-
/** @
|
|
791
|
-
id: string;
|
|
673
|
+
/** @public */ id: string;
|
|
792
674
|
};
|
|
793
675
|
return {
|
|
794
676
|
/** @public */
|