@leitwerk-dev/coding 0.1.9 → 0.2.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.
- package/README.md +19 -2
- package/dist/actions.d.ts +14 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/auto-work-branch-internal.d.ts +20 -0
- package/dist/auto-work-branch-internal.d.ts.map +1 -0
- package/dist/auto-work-branch.d.ts +2 -12
- package/dist/auto-work-branch.d.ts.map +1 -1
- package/dist/auto-work-branch.js +84 -86
- package/dist/auto-work-branch.js.map +1 -1
- package/dist/{chunk-EP3ZC37F.js → chunk-34B3Q75M.js} +1 -1
- package/dist/chunk-34B3Q75M.js.map +1 -0
- package/dist/{chunk-OFDNIT5X.js → chunk-F6CEEAFE.js} +1 -1
- package/dist/chunk-F6CEEAFE.js.map +1 -0
- package/dist/{chunk-YIP4MP64.js → chunk-HUVXPZSF.js} +2 -2
- package/dist/chunk-HUVXPZSF.js.map +1 -0
- package/dist/{chunk-R3S5KR3J.js → chunk-MY6XFGHM.js} +146 -168
- package/dist/chunk-MY6XFGHM.js.map +1 -0
- package/dist/{chunk-5LVPKVI2.js → chunk-OERAYSVI.js} +1 -1
- package/dist/chunk-OERAYSVI.js.map +1 -0
- package/dist/{chunk-WQEPA35Z.js → chunk-R3UCUGY6.js} +1 -1
- package/dist/chunk-R3UCUGY6.js.map +1 -0
- package/dist/{chunk-67YKGZLM.js → chunk-W7VJT6AN.js} +1 -1
- package/dist/chunk-W7VJT6AN.js.map +1 -0
- package/dist/{chunk-NIJCT4VK.js → chunk-WKHVLLKE.js} +1 -1
- package/dist/chunk-WKHVLLKE.js.map +1 -0
- package/dist/{chunk-UBVLJV3V.js → chunk-YSC5GEQJ.js} +1 -1
- package/dist/chunk-YSC5GEQJ.js.map +1 -0
- package/dist/finalization-git-internal.d.ts +72 -0
- package/dist/finalization-git-internal.d.ts.map +1 -0
- package/dist/finalization-git.d.ts +2 -42
- package/dist/finalization-git.d.ts.map +1 -1
- package/dist/finalization-git.js +7 -593
- package/dist/finalization-git.js.map +1 -1
- package/dist/index.d.ts +3 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +654 -6
- package/dist/index.js.map +1 -1
- package/dist/repository-change-launch-internal.d.ts +116 -0
- package/dist/repository-change-launch-internal.d.ts.map +1 -0
- package/dist/repository-change-launch.d.ts +2 -64
- package/dist/repository-change-launch.d.ts.map +1 -1
- package/dist/repository-change-launch.js +177 -174
- package/dist/repository-change-launch.js.map +1 -1
- package/dist/repository-change-process.d.ts +32 -2
- package/dist/repository-change-process.d.ts.map +1 -1
- package/dist/repository-change-state-internal.d.ts +30 -0
- package/dist/repository-change-state-internal.d.ts.map +1 -0
- package/dist/repository-change-state.d.ts +2 -17
- package/dist/repository-change-state.d.ts.map +1 -1
- package/dist/repository-change-state.js +6 -51
- package/dist/repository-change-state.js.map +1 -1
- package/dist/turns/generate-commit-message.d.ts +2 -0
- package/dist/turns/generate-commit-message.d.ts.map +1 -1
- package/dist/turns/generate-commit-message.js +9 -38
- package/dist/turns/generate-commit-message.js.map +1 -1
- package/dist/turns/generate-plan.d.ts +1 -0
- package/dist/turns/generate-plan.d.ts.map +1 -1
- package/dist/turns/generate-plan.js +7 -19
- package/dist/turns/generate-plan.js.map +1 -1
- package/dist/turns/implement.d.ts +1 -0
- package/dist/turns/implement.d.ts.map +1 -1
- package/dist/turns/implement.js +7 -17
- package/dist/turns/implement.js.map +1 -1
- package/dist/turns/resolve-merge-conflict.d.ts +1 -0
- package/dist/turns/resolve-merge-conflict.d.ts.map +1 -1
- package/dist/turns/resolve-merge-conflict.js +7 -21
- package/dist/turns/resolve-merge-conflict.js.map +1 -1
- package/dist/turns/review-implementation.d.ts +1 -0
- package/dist/turns/review-implementation.d.ts.map +1 -1
- package/dist/turns/review-implementation.js +7 -25
- package/dist/turns/review-implementation.js.map +1 -1
- package/dist/turns/review-plan.d.ts +1 -0
- package/dist/turns/review-plan.d.ts.map +1 -1
- package/dist/turns/review-plan.js +7 -19
- package/dist/turns/review-plan.js.map +1 -1
- package/dist/turns/simplify-implementation.d.ts +1 -0
- package/dist/turns/simplify-implementation.d.ts.map +1 -1
- package/dist/turns/simplify-implementation.js +7 -7
- package/dist/turns/simplify-implementation.js.map +1 -1
- package/package.json +19 -8
- package/src/actions.ts +17 -1
- package/src/auto-work-branch-internal.ts +149 -0
- package/src/auto-work-branch.ts +7 -140
- package/src/finalization-git-internal.ts +855 -0
- package/src/finalization-git.ts +2 -825
- package/src/index.ts +16 -4
- package/src/repository-change-launch-internal.ts +328 -0
- package/src/repository-change-launch.ts +15 -264
- package/src/repository-change-process.ts +112 -168
- package/src/repository-change-state-internal.ts +90 -0
- package/src/repository-change-state.ts +2 -78
- package/src/turns/generate-commit-message.ts +2 -0
- package/src/turns/generate-plan.ts +1 -0
- package/src/turns/implement.ts +1 -0
- package/src/turns/resolve-merge-conflict.ts +1 -0
- package/src/turns/review-implementation.ts +1 -0
- package/src/turns/review-plan.ts +1 -0
- package/src/turns/simplify-implementation.ts +1 -0
- package/dist/actions.js +0 -45
- package/dist/actions.js.map +0 -1
- package/dist/chunk-5LVPKVI2.js.map +0 -1
- package/dist/chunk-67YKGZLM.js.map +0 -1
- package/dist/chunk-EP3ZC37F.js.map +0 -1
- package/dist/chunk-NIJCT4VK.js.map +0 -1
- package/dist/chunk-OFDNIT5X.js.map +0 -1
- package/dist/chunk-R3S5KR3J.js.map +0 -1
- package/dist/chunk-UBVLJV3V.js.map +0 -1
- package/dist/chunk-WQEPA35Z.js.map +0 -1
- package/dist/chunk-Y2S6JFVO.js +0 -185
- package/dist/chunk-Y2S6JFVO.js.map +0 -1
- package/dist/chunk-YIP4MP64.js.map +0 -1
- package/dist/repository-change-process.js +0 -689
- package/dist/repository-change-process.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeOptionalMarkdown } from "@leitwerk-dev/domain";
|
|
1
|
+
import { trimString as normalizeMessage, normalizeOptionalMarkdown } from "@leitwerk-dev/domain";
|
|
2
2
|
import {
|
|
3
3
|
acceptedReviewHandoffAction,
|
|
4
4
|
type Codec,
|
|
@@ -19,14 +19,14 @@ import {
|
|
|
19
19
|
requestReviewChangesForm,
|
|
20
20
|
requestRevisionForm,
|
|
21
21
|
} from "./actions.js";
|
|
22
|
-
import { runDeterministicFinalization } from "./finalization-git.js";
|
|
22
|
+
import { runDeterministicFinalization } from "./finalization-git-internal.js";
|
|
23
23
|
import {
|
|
24
24
|
clearReviewRefs,
|
|
25
25
|
createEmptyRepositoryChangeFinalizationState,
|
|
26
26
|
type RepositoryChangeState,
|
|
27
27
|
repositoryChangeStateCodec,
|
|
28
28
|
resetRepositoryChangeFinalizationState,
|
|
29
|
-
} from "./repository-change-state.js";
|
|
29
|
+
} from "./repository-change-state-internal.js";
|
|
30
30
|
import {
|
|
31
31
|
buildGenerateCommitMessagePrompt,
|
|
32
32
|
normalizeGeneratedCommitMessage,
|
|
@@ -38,30 +38,49 @@ import { buildReviewImplementationPrompt } from "./turns/review-implementation.j
|
|
|
38
38
|
import { buildReviewPlanPrompt } from "./turns/review-plan.js";
|
|
39
39
|
import { buildSimplifyImplementationPrompt } from "./turns/simplify-implementation.js";
|
|
40
40
|
|
|
41
|
+
/** @public */
|
|
41
42
|
export type RepositoryChangeParams = {
|
|
43
|
+
/** @internal */
|
|
42
44
|
launchKind: "requested_change" | "imported_plan";
|
|
45
|
+
/** @internal */
|
|
43
46
|
importedPlanMarkdown?: string;
|
|
44
47
|
};
|
|
45
48
|
|
|
49
|
+
/** @public */
|
|
46
50
|
export interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeParams> {
|
|
51
|
+
/** @public */
|
|
47
52
|
processId: string;
|
|
53
|
+
/** @public */
|
|
48
54
|
displayName: string;
|
|
55
|
+
/** @public */
|
|
49
56
|
paramsCodec: Codec<TParams>;
|
|
57
|
+
/** @public */
|
|
50
58
|
launcher?: ProcessLauncherDefinition<TParams>;
|
|
59
|
+
/** @public */
|
|
51
60
|
finalizeLabel: string;
|
|
61
|
+
/** @public */
|
|
52
62
|
finalizeForm: FormDefinition;
|
|
63
|
+
/** @public */
|
|
53
64
|
finalizationDescription: string;
|
|
65
|
+
/** @public */
|
|
54
66
|
repositoryCredentials?(input: {
|
|
67
|
+
/** @public */
|
|
55
68
|
params: TParams;
|
|
69
|
+
/** @internal */
|
|
56
70
|
projects: readonly RepositoryCredentialProject[];
|
|
57
71
|
}): readonly RepositoryCredentialRequirement[];
|
|
72
|
+
/** @public */
|
|
58
73
|
publication?: {
|
|
74
|
+
/** @public */
|
|
59
75
|
entryTurnId: string;
|
|
76
|
+
/** @public */
|
|
60
77
|
fragment: FlowFragmentBuilder<TParams, RepositoryChangeState>;
|
|
78
|
+
/** @public */
|
|
61
79
|
happyPath?: readonly string[];
|
|
62
80
|
};
|
|
63
81
|
}
|
|
64
82
|
|
|
83
|
+
/** @public */
|
|
65
84
|
export function createRepositoryChangeProcess<TParams extends RepositoryChangeParams>(
|
|
66
85
|
config: RepositoryChangeProcessConfig<TParams>,
|
|
67
86
|
) {
|
|
@@ -93,10 +112,6 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
93
112
|
|
|
94
113
|
const implementationTurnAvailableTools = ["read", "bash", "edit", "write"] as const;
|
|
95
114
|
|
|
96
|
-
function normalizeMessage(value: unknown): string {
|
|
97
|
-
return typeof value === "string" ? value.trim() : "";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
115
|
function resetFinalizationAfterMessage(
|
|
101
116
|
state: RepositoryChangeState,
|
|
102
117
|
overrides: Partial<RepositoryChangeState["finalization"]> = {},
|
|
@@ -115,92 +130,63 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
115
130
|
|
|
116
131
|
function requireResolvedPlanRef(
|
|
117
132
|
plan: RepositoryChangeState["semanticEntryRefs"][keyof RepositoryChangeState["semanticEntryRefs"]],
|
|
118
|
-
usage: "simplification review" | "implementation review",
|
|
133
|
+
usage: "approval" | "review" | "simplification review" | "implementation review",
|
|
119
134
|
): asserts plan is { entryId: string; turnRecordId: string } {
|
|
120
135
|
if (!hasResolvedTurnRecordRef(plan)) {
|
|
121
136
|
throw new Error(`No plan is available for ${usage}`);
|
|
122
137
|
}
|
|
123
138
|
}
|
|
124
139
|
|
|
125
|
-
function
|
|
126
|
-
state
|
|
127
|
-
}): RepositoryChangeState {
|
|
128
|
-
return patchRepositoryChangeState(ctx.state, {
|
|
140
|
+
function clearReviewState(state: RepositoryChangeState): RepositoryChangeState {
|
|
141
|
+
return patchRepositoryChangeState(state, {
|
|
129
142
|
clearReviewRefs: true,
|
|
130
143
|
clearProductRefs: [products.simplificationPlan],
|
|
131
144
|
});
|
|
132
145
|
}
|
|
133
146
|
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
adjustment
|
|
147
|
+
function buildAcceptedFollowUpMessage(input: {
|
|
148
|
+
kind: "plan_review" | "implementation_review" | "simplification";
|
|
149
|
+
markdown: unknown;
|
|
150
|
+
adjustment: unknown;
|
|
138
151
|
}): string {
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"\n\n",
|
|
147
|
-
)
|
|
148
|
-
: null,
|
|
149
|
-
]
|
|
150
|
-
.filter((section): section is string => typeof section === "string" && section !== "")
|
|
151
|
-
.join("\n\n");
|
|
152
|
+
const markdown = normalizeOptionalMarkdown(input.markdown);
|
|
153
|
+
if (!markdown) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
input.kind === "simplification"
|
|
156
|
+
? "No simplification plan markdown is available to accept"
|
|
157
|
+
: "No review output markdown is available to accept",
|
|
158
|
+
);
|
|
152
159
|
}
|
|
153
|
-
return buildAcceptedImplementationFollowUpMessage({
|
|
154
|
-
kind: "review",
|
|
155
|
-
implementationMarkdown: input.reviewMarkdown,
|
|
156
|
-
adjustment,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function buildAcceptedImplementationFollowUpMessage(input: {
|
|
161
|
-
kind: "review" | "simplification";
|
|
162
|
-
implementationMarkdown: string;
|
|
163
|
-
adjustment?: string | null;
|
|
164
|
-
}): string {
|
|
165
160
|
const adjustment = normalizeMessage(input.adjustment);
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
simplificationMarkdown: string;
|
|
190
|
-
adjustment?: string | null;
|
|
191
|
-
}): string {
|
|
192
|
-
return buildAcceptedImplementationFollowUpMessage({
|
|
193
|
-
kind: "simplification",
|
|
194
|
-
implementationMarkdown: input.simplificationMarkdown,
|
|
195
|
-
adjustment: input.adjustment,
|
|
196
|
-
});
|
|
161
|
+
const subject = input.kind === "simplification" ? "simplification plan" : "review";
|
|
162
|
+
const introduction =
|
|
163
|
+
input.kind === "plan_review"
|
|
164
|
+
? "Revise the plan according to this review:"
|
|
165
|
+
: `Implement according to this ${subject}:`;
|
|
166
|
+
const sections = [introduction, markdown];
|
|
167
|
+
if (adjustment) {
|
|
168
|
+
sections.push(
|
|
169
|
+
`Also follow this adjustment where it conflicts with the ${subject}:`,
|
|
170
|
+
adjustment,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
if (input.kind !== "plan_review") {
|
|
174
|
+
sections.push(
|
|
175
|
+
[
|
|
176
|
+
"This is now an implementation turn. Ignore earlier review-only or read-only instructions.",
|
|
177
|
+
"You may change files in the repository workspace.",
|
|
178
|
+
`Use the available tools (${implementationTurnAvailableTools.join(", ")}) to inspect, edit, build, and test the change.`,
|
|
179
|
+
"When finished, return an implementation summary.",
|
|
180
|
+
].join("\n"),
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return sections.join("\n\n");
|
|
197
184
|
}
|
|
198
185
|
|
|
199
186
|
function patchRepositoryChangeState(
|
|
200
187
|
state: RepositoryChangeState,
|
|
201
188
|
input: {
|
|
202
189
|
finalization?: RepositoryChangeState["finalization"];
|
|
203
|
-
semanticEntryRefs?: RepositoryChangeState["semanticEntryRefs"];
|
|
204
190
|
clearReviewRefs?: boolean;
|
|
205
191
|
clearProductRefs?: readonly string[];
|
|
206
192
|
},
|
|
@@ -208,7 +194,6 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
208
194
|
const nextState: RepositoryChangeState = {
|
|
209
195
|
...state,
|
|
210
196
|
...("finalization" in input ? { finalization: input.finalization } : {}),
|
|
211
|
-
...("semanticEntryRefs" in input ? { semanticEntryRefs: input.semanticEntryRefs } : {}),
|
|
212
197
|
};
|
|
213
198
|
const productRefsToClear = new Set(input.clearProductRefs ?? []);
|
|
214
199
|
if (input.clearReviewRefs) {
|
|
@@ -231,7 +216,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
231
216
|
}
|
|
232
217
|
|
|
233
218
|
const planDecisionSpec = humanTurn<TParams, RepositoryChangeState>({
|
|
234
|
-
description: "Review
|
|
219
|
+
description: "Review Plan",
|
|
235
220
|
reviewSemanticRef: "plan",
|
|
236
221
|
notesFields: [
|
|
237
222
|
{
|
|
@@ -249,15 +234,9 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
249
234
|
acceptanceState: "accepted",
|
|
250
235
|
to: turnIds.implement,
|
|
251
236
|
effect: ({ ctx }) => {
|
|
252
|
-
|
|
253
|
-
if (!hasResolvedTurnRecordRef(plan)) {
|
|
254
|
-
throw new Error("No plan is available for approval");
|
|
255
|
-
}
|
|
237
|
+
requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "approval");
|
|
256
238
|
return {
|
|
257
|
-
state:
|
|
258
|
-
clearReviewRefs: true,
|
|
259
|
-
clearProductRefs: [products.simplificationPlan],
|
|
260
|
-
}),
|
|
239
|
+
state: clearReviewState(ctx.state),
|
|
261
240
|
emit: [
|
|
262
241
|
{
|
|
263
242
|
type: "plan_approved",
|
|
@@ -281,10 +260,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
281
260
|
effect: ({ ctx, input }) => {
|
|
282
261
|
const message = normalizeMessage(input.message);
|
|
283
262
|
return {
|
|
284
|
-
state:
|
|
285
|
-
clearReviewRefs: true,
|
|
286
|
-
clearProductRefs: [products.simplificationPlan],
|
|
287
|
-
}),
|
|
263
|
+
state: clearReviewState(ctx.state),
|
|
288
264
|
emit: [{ type: "plan_revision_requested", data: { message } }],
|
|
289
265
|
};
|
|
290
266
|
},
|
|
@@ -296,15 +272,9 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
296
272
|
schedulable: true,
|
|
297
273
|
to: turnIds.reviewPlan,
|
|
298
274
|
effect: ({ ctx }) => {
|
|
299
|
-
|
|
300
|
-
if (!hasResolvedTurnRecordRef(plan)) {
|
|
301
|
-
throw new Error("No plan is available for review");
|
|
302
|
-
}
|
|
275
|
+
requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "review");
|
|
303
276
|
return {
|
|
304
|
-
state:
|
|
305
|
-
clearReviewRefs: true,
|
|
306
|
-
clearProductRefs: [products.simplificationPlan],
|
|
307
|
-
}),
|
|
277
|
+
state: clearReviewState(ctx.state),
|
|
308
278
|
};
|
|
309
279
|
},
|
|
310
280
|
},
|
|
@@ -312,7 +282,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
312
282
|
});
|
|
313
283
|
|
|
314
284
|
const planReviewFeedbackSpec = humanTurn<TParams, RepositoryChangeState>({
|
|
315
|
-
description: "Review
|
|
285
|
+
description: "Review Plan Feedback",
|
|
316
286
|
reviewSemanticRef: "review",
|
|
317
287
|
notesFields: [
|
|
318
288
|
{
|
|
@@ -331,19 +301,12 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
331
301
|
acceptanceState: "accepted",
|
|
332
302
|
form: acceptReviewForm,
|
|
333
303
|
to: turnIds.generatePlan,
|
|
334
|
-
resolveBodyMarkdown: ({ ctx, input }) =>
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
return buildAcceptedReviewFollowUpMessage({
|
|
342
|
-
reviewedProduct: products.plan,
|
|
343
|
-
reviewMarkdown,
|
|
344
|
-
adjustment: normalizeMessage(input.message),
|
|
345
|
-
});
|
|
346
|
-
},
|
|
304
|
+
resolveBodyMarkdown: ({ ctx, input }) =>
|
|
305
|
+
buildAcceptedFollowUpMessage({
|
|
306
|
+
kind: "plan_review",
|
|
307
|
+
markdown: ctx.readSemanticTurnResultMarkdown("review"),
|
|
308
|
+
adjustment: input.message,
|
|
309
|
+
}),
|
|
347
310
|
}),
|
|
348
311
|
[codingActionIds.requestReviewChanges]: revisionAction({
|
|
349
312
|
label: "Request review changes",
|
|
@@ -363,7 +326,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
363
326
|
});
|
|
364
327
|
|
|
365
328
|
const implementationDecisionSpec = humanTurn<TParams, RepositoryChangeState>({
|
|
366
|
-
description: "Review
|
|
329
|
+
description: "Review",
|
|
367
330
|
reviewSemanticRef: "currentPrimaryPathLeaf",
|
|
368
331
|
notesFields: [
|
|
369
332
|
{
|
|
@@ -398,10 +361,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
398
361
|
to: turnIds.implement,
|
|
399
362
|
queueTarget: { semanticRef: "currentPrimaryPathLeaf" },
|
|
400
363
|
effect: ({ ctx }) => ({
|
|
401
|
-
state:
|
|
402
|
-
clearReviewRefs: true,
|
|
403
|
-
clearProductRefs: [products.simplificationPlan],
|
|
404
|
-
}),
|
|
364
|
+
state: clearReviewState(ctx.state),
|
|
405
365
|
}),
|
|
406
366
|
}),
|
|
407
367
|
[codingActionIds.simplify]: {
|
|
@@ -412,7 +372,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
412
372
|
to: turnIds.simplifyImplementation,
|
|
413
373
|
effect: ({ ctx }) => {
|
|
414
374
|
requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "simplification review");
|
|
415
|
-
return { state:
|
|
375
|
+
return { state: clearReviewState(ctx.state) };
|
|
416
376
|
},
|
|
417
377
|
},
|
|
418
378
|
[codingActionIds.runReview]: {
|
|
@@ -422,7 +382,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
422
382
|
to: turnIds.reviewImplementation,
|
|
423
383
|
effect: ({ ctx }) => {
|
|
424
384
|
requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "implementation review");
|
|
425
|
-
return { state:
|
|
385
|
+
return { state: clearReviewState(ctx.state) };
|
|
426
386
|
},
|
|
427
387
|
},
|
|
428
388
|
},
|
|
@@ -449,19 +409,12 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
449
409
|
schedulable: true,
|
|
450
410
|
to: turnIds.implement,
|
|
451
411
|
queueTarget: { semanticRef: "review" },
|
|
452
|
-
resolveBodyMarkdown: ({ ctx, input }) =>
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
return buildAcceptedReviewFollowUpMessage({
|
|
460
|
-
reviewedProduct: products.implementationSummary,
|
|
461
|
-
reviewMarkdown,
|
|
462
|
-
adjustment: normalizeMessage(input.message),
|
|
463
|
-
});
|
|
464
|
-
},
|
|
412
|
+
resolveBodyMarkdown: ({ ctx, input }) =>
|
|
413
|
+
buildAcceptedFollowUpMessage({
|
|
414
|
+
kind: "implementation_review",
|
|
415
|
+
markdown: ctx.readSemanticTurnResultMarkdown("review"),
|
|
416
|
+
adjustment: input.message,
|
|
417
|
+
}),
|
|
465
418
|
effect: ({ ctx }) => ({
|
|
466
419
|
state: patchRepositoryChangeState(ctx.state, {
|
|
467
420
|
clearProductRefs: [products.simplificationPlan],
|
|
@@ -504,18 +457,12 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
504
457
|
schedulable: true,
|
|
505
458
|
to: turnIds.implement,
|
|
506
459
|
queueTarget: { productName: products.simplificationPlan },
|
|
507
|
-
resolveBodyMarkdown: ({ ctx, input }) =>
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
return buildAcceptedSimplificationFollowUpMessage({
|
|
515
|
-
simplificationMarkdown,
|
|
516
|
-
adjustment: normalizeMessage(input.message),
|
|
517
|
-
});
|
|
518
|
-
},
|
|
460
|
+
resolveBodyMarkdown: ({ ctx, input }) =>
|
|
461
|
+
buildAcceptedFollowUpMessage({
|
|
462
|
+
kind: "simplification",
|
|
463
|
+
markdown: ctx.readProductTurnResultMarkdown(products.simplificationPlan),
|
|
464
|
+
adjustment: input.message,
|
|
465
|
+
}),
|
|
519
466
|
effect: ({ ctx }) => ({
|
|
520
467
|
state: patchRepositoryChangeState(ctx.state, {
|
|
521
468
|
clearReviewRefs: true,
|
|
@@ -536,17 +483,14 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
536
483
|
acceptanceState: "neutral",
|
|
537
484
|
to: turnIds.implementationDecision,
|
|
538
485
|
effect: ({ ctx }) => ({
|
|
539
|
-
state:
|
|
540
|
-
clearReviewRefs: true,
|
|
541
|
-
clearProductRefs: [products.simplificationPlan],
|
|
542
|
-
}),
|
|
486
|
+
state: clearReviewState(ctx.state),
|
|
543
487
|
}),
|
|
544
488
|
},
|
|
545
489
|
},
|
|
546
490
|
});
|
|
547
491
|
|
|
548
492
|
const importPlanTurn = flow
|
|
549
|
-
.
|
|
493
|
+
.automatic<TParams, RepositoryChangeState>(turnIds.importPlan)
|
|
550
494
|
.description("Import handoff plan")
|
|
551
495
|
.run((ctx) => {
|
|
552
496
|
const planMarkdown =
|
|
@@ -560,10 +504,6 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
560
504
|
outcome: "imported",
|
|
561
505
|
params: { plan: planMarkdown },
|
|
562
506
|
markdown: planMarkdown,
|
|
563
|
-
state: patchRepositoryChangeState(ctx.state, {
|
|
564
|
-
clearReviewRefs: true,
|
|
565
|
-
clearProductRefs: [products.simplificationPlan],
|
|
566
|
-
}),
|
|
567
507
|
};
|
|
568
508
|
})
|
|
569
509
|
.outcome("imported", (outcome) =>
|
|
@@ -571,12 +511,15 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
571
511
|
.description("Imported a handoff plan and skipped replanning")
|
|
572
512
|
.markdown("plan", { description: "Imported handoff plan", publish: true })
|
|
573
513
|
.to(turnIds.implement)
|
|
574
|
-
.effect(({ ctx }) => ({
|
|
514
|
+
.effect(({ ctx }) => ({
|
|
515
|
+
processPatch: { planRevision: ctx.process.planRevision + 1 },
|
|
516
|
+
state: clearReviewState(ctx.state),
|
|
517
|
+
})),
|
|
575
518
|
);
|
|
576
519
|
|
|
577
520
|
const generatePlanTurn = flow
|
|
578
521
|
.llm<TParams, RepositoryChangeState>(turnIds.generatePlan)
|
|
579
|
-
.description("
|
|
522
|
+
.description("Plan")
|
|
580
523
|
.tools("read", "bash")
|
|
581
524
|
.askQuestions()
|
|
582
525
|
.freshPrimary()
|
|
@@ -602,10 +545,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
602
545
|
: [];
|
|
603
546
|
const planMarkdown = ctx.output?.content ?? "";
|
|
604
547
|
return {
|
|
605
|
-
state:
|
|
606
|
-
clearReviewRefs: true,
|
|
607
|
-
clearProductRefs: [products.simplificationPlan],
|
|
608
|
-
}),
|
|
548
|
+
state: clearReviewState(ctx.state),
|
|
609
549
|
processPatch: { planRevision },
|
|
610
550
|
broadcasts: [
|
|
611
551
|
{
|
|
@@ -636,7 +576,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
636
576
|
|
|
637
577
|
const reviewPlanTurn = flow
|
|
638
578
|
.llm<TParams, RepositoryChangeState>(turnIds.reviewPlan)
|
|
639
|
-
.description("
|
|
579
|
+
.description("Assess Plan")
|
|
640
580
|
.tools("read", "bash")
|
|
641
581
|
.rootBranchReview()
|
|
642
582
|
.startFromReviewBranch()
|
|
@@ -660,7 +600,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
660
600
|
|
|
661
601
|
const implementTurn = flow
|
|
662
602
|
.llm<TParams, RepositoryChangeState>(turnIds.implement)
|
|
663
|
-
.description("Implement
|
|
603
|
+
.description("Implement")
|
|
664
604
|
.tools(...implementationTurnAvailableTools)
|
|
665
605
|
.freshSeededPrimary()
|
|
666
606
|
.continueFromProductBranch(products.simplificationPlan, {
|
|
@@ -672,16 +612,11 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
672
612
|
.buildPrompt(buildImplementPrompt)
|
|
673
613
|
.publish(products.implementationSummary)
|
|
674
614
|
.to(turnIds.implementationDecision)
|
|
675
|
-
.state(({ ctx }) =>
|
|
676
|
-
patchRepositoryChangeState(ctx.state, {
|
|
677
|
-
clearReviewRefs: true,
|
|
678
|
-
clearProductRefs: [products.simplificationPlan],
|
|
679
|
-
}),
|
|
680
|
-
);
|
|
615
|
+
.state(({ ctx }) => clearReviewState(ctx.state));
|
|
681
616
|
|
|
682
617
|
const reviewImplementationTurn = flow
|
|
683
618
|
.llm<TParams, RepositoryChangeState>(turnIds.reviewImplementation)
|
|
684
|
-
.description("
|
|
619
|
+
.description("Assess Implementation")
|
|
685
620
|
.tools("read", "bash")
|
|
686
621
|
.rootBranchReview()
|
|
687
622
|
.startFromReviewBranch()
|
|
@@ -704,7 +639,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
704
639
|
|
|
705
640
|
const simplifyImplementationTurn = flow
|
|
706
641
|
.llm<TParams, RepositoryChangeState>(turnIds.simplifyImplementation)
|
|
707
|
-
.description("Simplify
|
|
642
|
+
.description("Simplify")
|
|
708
643
|
.tools("read", "bash")
|
|
709
644
|
.rootBranchReview()
|
|
710
645
|
.startFromProductBranch(products.simplificationPlan)
|
|
@@ -714,7 +649,7 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
714
649
|
|
|
715
650
|
const generateCommitMessageTurn = flow
|
|
716
651
|
.llm<TParams, RepositoryChangeState>(turnIds.generateCommitMessage)
|
|
717
|
-
.description("
|
|
652
|
+
.description("Write Commit Message")
|
|
718
653
|
.modelPurpose("process_title_generation")
|
|
719
654
|
.rootBranchReview()
|
|
720
655
|
.startFromRoot()
|
|
@@ -851,13 +786,22 @@ export function createRepositoryChangeProcess<TParams extends RepositoryChangePa
|
|
|
851
786
|
({
|
|
852
787
|
id,
|
|
853
788
|
...(process.turns.get(id)?.definition as HumanTurnDefinition),
|
|
854
|
-
}) as HumanTurnDefinition & {
|
|
789
|
+
}) as HumanTurnDefinition & {
|
|
790
|
+
/** @internal */
|
|
791
|
+
id: string;
|
|
792
|
+
};
|
|
855
793
|
return {
|
|
794
|
+
/** @public */
|
|
856
795
|
process,
|
|
796
|
+
/** @internal */
|
|
857
797
|
planDecision: decision(turnIds.planDecision),
|
|
798
|
+
/** @internal */
|
|
858
799
|
planReviewFeedback: decision(turnIds.planReviewFeedback),
|
|
800
|
+
/** @internal */
|
|
859
801
|
implementationDecision: decision(turnIds.implementationDecision),
|
|
802
|
+
/** @internal */
|
|
860
803
|
implementationReviewFeedback: decision(turnIds.implementationReviewFeedback),
|
|
804
|
+
/** @internal */
|
|
861
805
|
simplificationDecision: decision(turnIds.simplificationDecision),
|
|
862
806
|
};
|
|
863
807
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Codec, StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
3
|
+
|
|
4
|
+
/** @public */
|
|
5
|
+
export interface RepositoryChangeFinalizationState {
|
|
6
|
+
/** @internal */
|
|
7
|
+
expectedPostConflictHeadSha: string | null;
|
|
8
|
+
/** @internal */
|
|
9
|
+
usedConflictResolution: boolean;
|
|
10
|
+
/** @internal */
|
|
11
|
+
finalizationSummaryMarkdown: string | null;
|
|
12
|
+
/** @internal */
|
|
13
|
+
finalizedHeadSha: string | null;
|
|
14
|
+
/** @public */
|
|
15
|
+
generatedCommitMessage: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** @public */
|
|
19
|
+
export interface RepositoryChangeState extends StructuralProcessState {
|
|
20
|
+
/** @public */
|
|
21
|
+
finalization: RepositoryChangeFinalizationState;
|
|
22
|
+
/** Namespaced state owned by a caller-supplied publication workflow. @public */
|
|
23
|
+
extensionState?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @internal */
|
|
27
|
+
export function createEmptyRepositoryChangeFinalizationState(): RepositoryChangeFinalizationState {
|
|
28
|
+
return {
|
|
29
|
+
expectedPostConflictHeadSha: null,
|
|
30
|
+
usedConflictResolution: false,
|
|
31
|
+
finalizationSummaryMarkdown: null,
|
|
32
|
+
finalizedHeadSha: null,
|
|
33
|
+
generatedCommitMessage: null,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function stringOrNull(value: unknown): string | null {
|
|
38
|
+
return typeof value === "string" ? value : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function toRecord(value: unknown): Record<string, unknown> {
|
|
42
|
+
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseFinalizationState(value: unknown): RepositoryChangeFinalizationState {
|
|
46
|
+
const record = toRecord(value);
|
|
47
|
+
return {
|
|
48
|
+
expectedPostConflictHeadSha: stringOrNull(record.expectedPostConflictHeadSha),
|
|
49
|
+
usedConflictResolution: record.usedConflictResolution === true,
|
|
50
|
+
finalizationSummaryMarkdown: stringOrNull(record.finalizationSummaryMarkdown),
|
|
51
|
+
finalizedHeadSha: stringOrNull(record.finalizedHeadSha),
|
|
52
|
+
// Backward-compatible decoding for state persisted before commit-message generation.
|
|
53
|
+
generatedCommitMessage: stringOrNull(record.generatedCommitMessage),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @internal */
|
|
58
|
+
export const repositoryChangeStateCodec: Codec<RepositoryChangeState> = {
|
|
59
|
+
parse(value) {
|
|
60
|
+
const record = toRecord(value);
|
|
61
|
+
return {
|
|
62
|
+
...parseStructuralProcessState(record),
|
|
63
|
+
finalization: parseFinalizationState(record.finalization),
|
|
64
|
+
extensionState: toRecord(record.extensionState),
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
serialize(value) {
|
|
68
|
+
return value;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** @internal */
|
|
73
|
+
export function clearReviewRefs(
|
|
74
|
+
semanticEntryRefs: RepositoryChangeState["semanticEntryRefs"],
|
|
75
|
+
): RepositoryChangeState["semanticEntryRefs"] {
|
|
76
|
+
return {
|
|
77
|
+
...semanticEntryRefs,
|
|
78
|
+
review: null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @internal */
|
|
83
|
+
export function resetRepositoryChangeFinalizationState(
|
|
84
|
+
overrides: Partial<RepositoryChangeFinalizationState> = {},
|
|
85
|
+
): RepositoryChangeFinalizationState {
|
|
86
|
+
return {
|
|
87
|
+
...createEmptyRepositoryChangeFinalizationState(),
|
|
88
|
+
...overrides,
|
|
89
|
+
};
|
|
90
|
+
}
|