@leitwerk-dev/coding 0.2.0 → 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 +28 -10
- package/dist/actions.d.ts +12 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/auto-work-branch-internal.d.ts +4 -0
- package/dist/auto-work-branch-internal.d.ts.map +1 -0
- package/dist/auto-work-branch.d.ts +1 -12
- package/dist/auto-work-branch.d.ts.map +1 -1
- package/dist/auto-work-branch.js +18 -97
- 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-GO44KCUS.js +154 -0
- package/dist/chunk-GO44KCUS.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 +33 -0
- package/dist/finalization-git-internal.d.ts.map +1 -0
- package/dist/finalization-git.d.ts +2 -47
- package/dist/finalization-git.d.ts.map +1 -1
- package/dist/finalization-git.js +3 -9
- package/dist/index.d.ts +3 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -112
- package/dist/index.js.map +1 -1
- package/dist/repository-change-launch-internal.d.ts +35 -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 +22 -11
- package/dist/repository-change-launch.js.map +1 -1
- package/dist/repository-change-process.d.ts +31 -13
- 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 +21 -0
- package/dist/repository-change-state-internal.d.ts.map +1 -0
- package/dist/repository-change-state.d.ts +1 -17
- package/dist/repository-change-state.d.ts.map +1 -1
- package/dist/repository-change-state.js +0 -13
- 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 +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 +1 -1
- package/dist/turns/implement.d.ts +1 -0
- package/dist/turns/implement.d.ts.map +1 -1
- package/dist/turns/implement.js +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 +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 +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 +1 -1
- package/package.json +24 -8
- package/src/actions.ts +12 -9
- package/src/auto-work-branch-internal.ts +41 -0
- package/src/auto-work-branch.ts +1 -140
- package/src/finalization-git-internal.ts +218 -0
- package/src/finalization-git.ts +2 -828
- package/src/index.ts +15 -4
- package/src/repository-change-launch-internal.ts +64 -0
- package/src/repository-change-launch.ts +10 -264
- package/src/repository-change-process.ts +33 -123
- package/src/repository-change-publication.ts +689 -0
- package/src/repository-change-state-internal.ts +60 -0
- package/src/repository-change-state.ts +1 -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/review-implementation.ts +1 -0
- package/src/turns/review-plan.ts +1 -0
- package/src/turns/simplify-implementation.ts +1 -0
- package/dist/chunk-5LVPKVI2.js +0 -27
- package/dist/chunk-5LVPKVI2.js.map +0 -1
- package/dist/chunk-67YKGZLM.js.map +0 -1
- package/dist/chunk-73LKROYK.js +0 -616
- package/dist/chunk-73LKROYK.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-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 +0 -61
- package/dist/chunk-YIP4MP64.js.map +0 -1
- package/dist/turns/resolve-merge-conflict.d.ts +0 -3
- 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 -25
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import {
|
|
2
|
+
commitAndPushWorkBranch
|
|
3
|
+
} from "./chunk-GO44KCUS.js";
|
|
4
|
+
import "./chunk-PX6F3LHL.js";
|
|
5
|
+
|
|
6
|
+
// src/repository-change-publication.ts
|
|
7
|
+
import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
8
|
+
import {
|
|
9
|
+
flow
|
|
10
|
+
} from "@leitwerk-dev/process-sdk";
|
|
11
|
+
import {
|
|
12
|
+
conflictKey,
|
|
13
|
+
validateConflict
|
|
14
|
+
} from "@leitwerk-dev/repository-rebase";
|
|
15
|
+
import { publishRebase, startRebase } from "@leitwerk-dev/repository-rebase/git";
|
|
16
|
+
import { rebasePrompt } from "@leitwerk-dev/repository-rebase/prompt";
|
|
17
|
+
var initialDeliveryState = {
|
|
18
|
+
stage: "not_started",
|
|
19
|
+
issueLinked: false,
|
|
20
|
+
adjustment: null,
|
|
21
|
+
terminalPullRequest: null
|
|
22
|
+
};
|
|
23
|
+
var initialPublicationState = {
|
|
24
|
+
headSha: null,
|
|
25
|
+
prNumber: null,
|
|
26
|
+
prUrl: null,
|
|
27
|
+
conversationCursor: 0,
|
|
28
|
+
reviewCursor: 0,
|
|
29
|
+
inlineCursor: 0,
|
|
30
|
+
feedbackIds: [],
|
|
31
|
+
pipeline: null,
|
|
32
|
+
ciRecoveryCycles: 0,
|
|
33
|
+
delivery: initialDeliveryState
|
|
34
|
+
};
|
|
35
|
+
var publicationObject = (value) => asUnknownRecord(value) ?? {};
|
|
36
|
+
function readPublicationState(state, namespace) {
|
|
37
|
+
const stored = publicationObject(publicationObject(state.extensionState)[namespace]);
|
|
38
|
+
return {
|
|
39
|
+
...initialPublicationState,
|
|
40
|
+
...stored,
|
|
41
|
+
delivery: {
|
|
42
|
+
...initialDeliveryState,
|
|
43
|
+
...publicationObject(stored.delivery)
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function patchPublicationState(state, namespace, patch) {
|
|
48
|
+
const current = readPublicationState(state, namespace);
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
extensionState: {
|
|
52
|
+
...state.extensionState,
|
|
53
|
+
[namespace]: {
|
|
54
|
+
...current,
|
|
55
|
+
...patch,
|
|
56
|
+
delivery: { ...current.delivery, ...patch.delivery }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function applyPublicationEvidence(params, current, evidence, countFailure = true) {
|
|
62
|
+
if (evidence.observationKey !== void 0)
|
|
63
|
+
current = { ...current, observationKey: evidence.observationKey };
|
|
64
|
+
switch (evidence.kind) {
|
|
65
|
+
case "feedback": {
|
|
66
|
+
const { kind: _, ...batch } = evidence;
|
|
67
|
+
return { ...current, ...batch, repairReason: "feedback" };
|
|
68
|
+
}
|
|
69
|
+
case "failure":
|
|
70
|
+
return {
|
|
71
|
+
...current,
|
|
72
|
+
repairReason: "ci",
|
|
73
|
+
pipeline: evidence.pipeline,
|
|
74
|
+
ciRecoveryCycles: current.ciRecoveryCycles + (countFailure ? 1 : 0)
|
|
75
|
+
};
|
|
76
|
+
case "conflict": {
|
|
77
|
+
const conflict = validateConflict(
|
|
78
|
+
evidence.conflict,
|
|
79
|
+
{
|
|
80
|
+
owner: params.owner,
|
|
81
|
+
repo: params.repo,
|
|
82
|
+
prNumber: current.prNumber ?? 0,
|
|
83
|
+
headSha: current.headSha ?? "",
|
|
84
|
+
headBranch: params.workBranch,
|
|
85
|
+
baseBranch: params.baseBranch
|
|
86
|
+
},
|
|
87
|
+
current.lastConflictKey
|
|
88
|
+
);
|
|
89
|
+
return {
|
|
90
|
+
...current,
|
|
91
|
+
conflict,
|
|
92
|
+
lastConflictKey: conflictKey(conflict),
|
|
93
|
+
repairReason: "rebase"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
case "terminal":
|
|
97
|
+
return {
|
|
98
|
+
...current,
|
|
99
|
+
delivery: { ...current.delivery, terminalPullRequest: evidence.request }
|
|
100
|
+
};
|
|
101
|
+
default:
|
|
102
|
+
return current;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function deliveryProgress(value, label, activeStepId) {
|
|
106
|
+
const delivery = value.delivery;
|
|
107
|
+
const step = (id, label2, done) => ({
|
|
108
|
+
id,
|
|
109
|
+
label: label2,
|
|
110
|
+
status: activeStepId === id ? "in_progress" : done ? "completed" : "incomplete"
|
|
111
|
+
});
|
|
112
|
+
const adjustmentHandled = delivery.adjustment === null && delivery.stage === "awaiting" && value.headSha !== null;
|
|
113
|
+
return {
|
|
114
|
+
title: "Delivery progress",
|
|
115
|
+
steps: [
|
|
116
|
+
step("publish_branch", "Publish work branch", value.headSha !== null),
|
|
117
|
+
step("open_pr", "Create or find pull request", value.prNumber !== null),
|
|
118
|
+
step("link_issue", "Link source issue when applicable", delivery.issueLinked),
|
|
119
|
+
step("publish_adjustment", "Publish an adjustment when applicable", adjustmentHandled),
|
|
120
|
+
step(
|
|
121
|
+
"reply_feedback",
|
|
122
|
+
"Acknowledge or reply to feedback when applicable",
|
|
123
|
+
value.feedbackIds.length === 0
|
|
124
|
+
),
|
|
125
|
+
step("await_evidence", "Await external evidence", delivery.stage === "awaiting"),
|
|
126
|
+
step(
|
|
127
|
+
"reconcile_terminal",
|
|
128
|
+
"Reconcile terminal pull request",
|
|
129
|
+
delivery.terminalPullRequest !== null
|
|
130
|
+
)
|
|
131
|
+
],
|
|
132
|
+
...value.prNumber && value.prUrl ? {
|
|
133
|
+
links: [
|
|
134
|
+
{
|
|
135
|
+
id: `${label}-pr-${value.prNumber}`,
|
|
136
|
+
label: `${label} #${value.prNumber}`,
|
|
137
|
+
url: value.prUrl,
|
|
138
|
+
kind: "pull_request"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
} : {}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function createRepositoryChangePublication(adapter) {
|
|
145
|
+
const applyEvidence = applyPublicationEvidence;
|
|
146
|
+
const ids = adapter.ids;
|
|
147
|
+
const publication = flow.fragment(`${adapter.namespace}-publication`);
|
|
148
|
+
const remote = (state) => readPublicationState(state, adapter.namespace);
|
|
149
|
+
const patchRemote = (state, patch) => patchPublicationState(state, adapter.namespace, patch);
|
|
150
|
+
async function commitWorkBranch(ctx, commitMessage) {
|
|
151
|
+
const repo = ctx.repo.get("repo");
|
|
152
|
+
return commitAndPushWorkBranch({
|
|
153
|
+
repoPath: repo.fsPath,
|
|
154
|
+
workBranch: repo.workBranch,
|
|
155
|
+
commitMessage,
|
|
156
|
+
gitIdentity: await adapter.identity(ctx)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const delivery = flow.automatic(ids.deliver).description("Deliver").integrationTools(...adapter.tools.delivery).run(async (ctx) => {
|
|
160
|
+
let current = remote(ctx.state);
|
|
161
|
+
const update = (patch) => {
|
|
162
|
+
current = { ...current, ...patch, delivery: { ...current.delivery, ...patch.delivery } };
|
|
163
|
+
};
|
|
164
|
+
const result = (outcome) => ({
|
|
165
|
+
outcome,
|
|
166
|
+
params: { nextState: patchRemote(ctx.state, current) }
|
|
167
|
+
});
|
|
168
|
+
if (current.pendingEvidence) {
|
|
169
|
+
const evidence = current.pendingEvidence;
|
|
170
|
+
const needsOperator = evidence.kind === "failure" && current.ciRecoveryCycles >= 3;
|
|
171
|
+
current = applyEvidence(ctx.params, current, evidence, !needsOperator);
|
|
172
|
+
current.pendingEvidence = null;
|
|
173
|
+
if (evidence.kind === "cancelled") return result("aborted");
|
|
174
|
+
if (evidence.kind === "failure")
|
|
175
|
+
return result(needsOperator ? "operator_action" : "ci_ready");
|
|
176
|
+
if (evidence.kind === "conflict") return result("conflict_ready");
|
|
177
|
+
}
|
|
178
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label));
|
|
179
|
+
if (current.delivery.terminalPullRequest) {
|
|
180
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "reconcile_terminal"));
|
|
181
|
+
const pr = current.delivery.terminalPullRequest;
|
|
182
|
+
await adapter.reconcileTerminal(ctx, current, pr);
|
|
183
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label));
|
|
184
|
+
return result(pr.merged ? "completed" : "aborted");
|
|
185
|
+
}
|
|
186
|
+
if (!current.headSha) {
|
|
187
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "publish_branch"));
|
|
188
|
+
const published = await commitWorkBranch(
|
|
189
|
+
ctx,
|
|
190
|
+
ctx.state.finalization.generatedCommitMessage ?? ""
|
|
191
|
+
);
|
|
192
|
+
update({ headSha: published.headSha, pipeline: null });
|
|
193
|
+
}
|
|
194
|
+
if (!current.prNumber || !current.prUrl) {
|
|
195
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "open_pr"));
|
|
196
|
+
const pr = await adapter.ensureRequest(ctx);
|
|
197
|
+
update({ prNumber: pr.number, prUrl: pr.html_url });
|
|
198
|
+
}
|
|
199
|
+
if (!current.delivery.issueLinked) {
|
|
200
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "link_issue"));
|
|
201
|
+
await adapter.linkIssue(ctx, current);
|
|
202
|
+
update({ delivery: { issueLinked: true } });
|
|
203
|
+
}
|
|
204
|
+
if (current.delivery.adjustment) {
|
|
205
|
+
const adjustment = current.delivery.adjustment;
|
|
206
|
+
if (adjustment.publishRequired || adjustment.origin === "rebase") {
|
|
207
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "publish_adjustment"));
|
|
208
|
+
const published = adjustment.origin === "rebase" ? publishRebase(rebaseInput(ctx)) : await commitWorkBranch(ctx, adapter.commitMessage(adjustment.origin));
|
|
209
|
+
if (adjustment.origin === "rebase") {
|
|
210
|
+
const head = await adapter.head(ctx, current);
|
|
211
|
+
if (head !== published.headSha)
|
|
212
|
+
throw new Error("Pull request head has not caught up with rebase publication");
|
|
213
|
+
}
|
|
214
|
+
update({ headSha: published.headSha, pipeline: null });
|
|
215
|
+
}
|
|
216
|
+
if (adjustment.origin === "rebase") await adapter.afterRebase(ctx, current);
|
|
217
|
+
if (adjustment.origin === "feedback") {
|
|
218
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "reply_feedback"));
|
|
219
|
+
await adapter.reply(ctx, current);
|
|
220
|
+
}
|
|
221
|
+
update({
|
|
222
|
+
...adjustment.origin === "feedback" ? { feedbackIds: [] } : {},
|
|
223
|
+
delivery: { adjustment: null }
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (current.feedbackIds.length > 0) {
|
|
227
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "reply_feedback"));
|
|
228
|
+
await adapter.acknowledge(ctx, current);
|
|
229
|
+
return result("feedback_ready");
|
|
230
|
+
}
|
|
231
|
+
update({ delivery: { stage: "awaiting" } });
|
|
232
|
+
ctx.reportProgress(deliveryProgress(current, adapter.label, "await_evidence"));
|
|
233
|
+
return result("awaiting");
|
|
234
|
+
}).outcome(
|
|
235
|
+
"awaiting",
|
|
236
|
+
(outcome) => outcome.description("Delivery is waiting for external evidence").object("nextState").wait().state(({ event }) => event.params.nextState)
|
|
237
|
+
).outcome(
|
|
238
|
+
"feedback_ready",
|
|
239
|
+
(outcome) => outcome.description("Pull request feedback is acknowledged and ready for revision").object("nextState").to(ids.feedback).state(({ event }) => event.params.nextState)
|
|
240
|
+
).outcome(
|
|
241
|
+
"completed",
|
|
242
|
+
(outcome) => outcome.description("Merged pull request was reconciled").object("nextState").complete().state(({ event }) => event.params.nextState)
|
|
243
|
+
).outcome(
|
|
244
|
+
"aborted",
|
|
245
|
+
(outcome) => outcome.description("Closed pull request was reconciled").object("nextState").lifecycleStatus("aborted").state(({ event }) => event.params.nextState)
|
|
246
|
+
);
|
|
247
|
+
for (const [outcome, target] of [
|
|
248
|
+
["ci_ready", ids.ciRepair],
|
|
249
|
+
["conflict_ready", ids.feedback],
|
|
250
|
+
["operator_action", ids.operator]
|
|
251
|
+
]) {
|
|
252
|
+
delivery.outcome(
|
|
253
|
+
outcome,
|
|
254
|
+
(o) => o.description("Route observed delivery evidence").object("nextState").to(target).state(({ event }) => event.params.nextState)
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
for (const source of adapter.sources) {
|
|
258
|
+
const attach = (id, operator) => delivery.externalAction(id, source.source, (external) => {
|
|
259
|
+
external.label(source.label).when(
|
|
260
|
+
({ params, state }) => (!source.enabled || source.enabled(params)) && (source.kind !== "failure" || remote(state).ciRecoveryCycles >= 3 === operator)
|
|
261
|
+
);
|
|
262
|
+
if (source.kind === "cancelled") return external.lifecycleStatus("aborted");
|
|
263
|
+
external.to(
|
|
264
|
+
source.kind === "conflict" ? ids.feedback : source.kind === "failure" ? operator ? ids.operator : ids.ciRepair : ids.deliver
|
|
265
|
+
);
|
|
266
|
+
return external.effect((input) => {
|
|
267
|
+
const evidence = source.read(input);
|
|
268
|
+
const current = remote(input.state);
|
|
269
|
+
return {
|
|
270
|
+
state: patchRemote(
|
|
271
|
+
input.state,
|
|
272
|
+
source.kind === "observation" ? { pendingEvidence: evidence } : applyEvidence(input.params, current, evidence, !operator)
|
|
273
|
+
)
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
attach(source.id, false);
|
|
278
|
+
if (source.kind === "failure") attach(source.operatorId ?? `${source.id}_operator`, true);
|
|
279
|
+
}
|
|
280
|
+
publication.turn(delivery);
|
|
281
|
+
function rebaseInput(ctx) {
|
|
282
|
+
const project = ctx.repo.get("repo");
|
|
283
|
+
const conflict = remote(ctx.state).conflict;
|
|
284
|
+
if (!conflict) throw new Error("Missing conflict evidence");
|
|
285
|
+
return { projectKey: "repo", path: project.fsPath, workBranch: project.workBranch, conflict };
|
|
286
|
+
}
|
|
287
|
+
function repairReason(state, kind) {
|
|
288
|
+
return kind === "feedback" && remote(state).repairReason === "rebase" ? "rebase" : kind;
|
|
289
|
+
}
|
|
290
|
+
function revisionPrompt(kind) {
|
|
291
|
+
return (ctx) => {
|
|
292
|
+
const current = remote(ctx.state);
|
|
293
|
+
if (repairReason(ctx.state, kind) === "rebase")
|
|
294
|
+
return `${rebasePrompt} Evidence: ${JSON.stringify(current.conflict)}. Call changes_ready or no_changes when verified complete, cannot_repair when blocked.`;
|
|
295
|
+
return adapter.prompt(kind, current);
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function revisionTurn(id, kind) {
|
|
299
|
+
const turn = flow.llm(id).description(kind === "feedback" ? "Address Feedback" : "Fix CI").tools("read", "bash", "edit", "write").resolveIntegrationTools(
|
|
300
|
+
(_params, state) => repairReason(state, kind) === "rebase" ? [] : adapter.tools[kind]
|
|
301
|
+
).prepare(
|
|
302
|
+
(ctx) => repairReason(ctx.state, kind) === "rebase" ? startRebase(rebaseInput(ctx)) : {}
|
|
303
|
+
).freshPrimary().prompt(revisionPrompt(kind));
|
|
304
|
+
for (const [name, description, publishRequired] of [
|
|
305
|
+
["changes_ready", "Repository changes are ready to publish", true],
|
|
306
|
+
["no_changes", "No repository change is required", false]
|
|
307
|
+
]) {
|
|
308
|
+
turn.outcomeTool(
|
|
309
|
+
name,
|
|
310
|
+
(tool) => tool.resultSummary().description(description).to(ids.deliver).state(
|
|
311
|
+
({ ctx }) => patchRemote(ctx.state, {
|
|
312
|
+
delivery: { adjustment: { origin: repairReason(ctx.state, kind), publishRequired } }
|
|
313
|
+
})
|
|
314
|
+
)
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
return turn.outcomeTool(
|
|
318
|
+
"cannot_repair",
|
|
319
|
+
(tool) => tool.description("The adjustment requires operator action").to(ids.operator)
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
publication.turn(revisionTurn(ids.feedback, "feedback"));
|
|
323
|
+
publication.turn(revisionTurn(ids.ciRepair, "ci"));
|
|
324
|
+
publication.turn({
|
|
325
|
+
id: ids.operator,
|
|
326
|
+
definition: {
|
|
327
|
+
kind: "human",
|
|
328
|
+
description: "Repository repair needs operator action",
|
|
329
|
+
operatorAttention: "required",
|
|
330
|
+
actions: {
|
|
331
|
+
retry_repair: {
|
|
332
|
+
label: "Retry repair",
|
|
333
|
+
acceptanceState: "accepted",
|
|
334
|
+
branches: { feedback: { to: ids.feedback }, ci: { to: ids.ciRepair } },
|
|
335
|
+
choose: ({ ctx }) => remote(ctx.state).repairReason === "rebase" || remote(ctx.state).repairReason === "feedback" ? "feedback" : "ci"
|
|
336
|
+
},
|
|
337
|
+
resume_waiting: {
|
|
338
|
+
label: "Resume waiting",
|
|
339
|
+
acceptanceState: "accepted",
|
|
340
|
+
to: ids.deliver,
|
|
341
|
+
effect: ({ ctx }) => ({
|
|
342
|
+
state: patchRemote(ctx.state, {
|
|
343
|
+
feedbackIds: [],
|
|
344
|
+
delivery: { adjustment: null }
|
|
345
|
+
})
|
|
346
|
+
})
|
|
347
|
+
},
|
|
348
|
+
abort: { label: "Abort process", acceptanceState: "neutral", lifecycleStatus: "aborted" }
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
/** @public */
|
|
354
|
+
entryTurnId: ids.deliver,
|
|
355
|
+
/** @public */
|
|
356
|
+
fragment: publication,
|
|
357
|
+
/** @public */
|
|
358
|
+
happyPath: [ids.deliver]
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
export {
|
|
362
|
+
applyPublicationEvidence,
|
|
363
|
+
createRepositoryChangePublication,
|
|
364
|
+
patchPublicationState,
|
|
365
|
+
publicationObject,
|
|
366
|
+
readPublicationState
|
|
367
|
+
};
|
|
368
|
+
//# sourceMappingURL=repository-change-publication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/repository-change-publication.ts"],"sourcesContent":["import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype ExternalActionSource,\n\ttype FlowAutomaticRunContext,\n\tflow,\n} from \"@leitwerk-dev/process-sdk\";\nimport {\n\ttype ConflictEvidence,\n\tconflictKey,\n\tvalidateConflict,\n} from \"@leitwerk-dev/repository-rebase\";\nimport { publishRebase, startRebase } from \"@leitwerk-dev/repository-rebase/git\";\nimport { rebasePrompt } from \"@leitwerk-dev/repository-rebase/prompt\";\nimport { commitAndPushWorkBranch, type GitIdentity } from \"./finalization-git.js\";\nimport type { RepositoryChangeState } from \"./repository-change-state.js\";\n\n/** @public */\nexport interface PublicationRequest {\n\t/** @public */\n\tnumber: number;\n\t/** @public */\n\thtml_url: string;\n\t/** @public */\n\tmerged: boolean;\n\t/** @public */\n\tmerge_commit_sha?: string | null;\n}\n/** @public */\nexport interface PublicationPipeline {\n\t/** @public */\n\tnumber: number;\n\t/** @public */\n\tstatus: string;\n\t/** @public */\n\t[key: string]: unknown;\n}\n/** @public */\nexport interface PublicationParams {\n\t/** @public */\n\towner: string;\n\t/** @public */\n\trepo: string;\n\t/** @public */\n\tworkBranch: string;\n\t/** @public */\n\tbaseBranch: string;\n}\n/** @public */\nexport type PublicationContext<P> = FlowAutomaticRunContext<P, RepositoryChangeState>;\n/** @public */\nexport type PublicationEvidence = (\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"feedback\";\n\t\t\t/** @public */\n\t\t\tfeedbackIds: PublicationFeedbackId[];\n\t\t\t/** @public */\n\t\t\tconversationCursor: number;\n\t\t\t/** @public */\n\t\t\treviewCursor: number;\n\t\t\t/** @public */\n\t\t\tinlineCursor: number;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"failure\";\n\t\t\t/** @public */\n\t\t\tpipeline: PublicationPipeline;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"conflict\";\n\t\t\t/** @public */\n\t\t\tconflict: ConflictEvidence;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"terminal\";\n\t\t\t/** @public */\n\t\t\trequest: PublicationRequest;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"cancelled\";\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tkind: \"observed\";\n\t }\n) & {\n\t/** @public */\n\tobservationKey?: string;\n};\n/** @public */\nexport interface PublicationSource<P> {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tkind: \"feedback\" | \"failure\" | \"conflict\" | \"terminal\" | \"cancelled\" | \"observation\";\n\t/** @public */\n\toperatorId?: string;\n\t/** @public */\n\tlabel: string;\n\t/** @public */\n\tsource: ExternalActionSource<P, RepositoryChangeState, unknown>;\n\t/** @public */\n\tenabled?(params: P): boolean;\n\t/** @public */\n\tread(input: {\n\t\t/** @public */\n\t\tparams: P;\n\t\t/** @public */\n\t\tstate: RepositoryChangeState;\n\t\t/** @public */\n\t\tevent: unknown;\n\t}): PublicationEvidence;\n}\n/** @public */\nexport interface RepositoryChangePublicationAdapter<P extends PublicationParams> {\n\t/** @public */\n\tnamespace: string;\n\t/** @public */\n\tlabel: string;\n\t/** @public */\n\tids: {\n\t\t/** @public */\n\t\tdeliver: string;\n\t\t/** @public */\n\t\tfeedback: string;\n\t\t/** @public */\n\t\tciRepair: string;\n\t\t/** @public */\n\t\toperator: string;\n\t};\n\t/** @public */\n\ttools: {\n\t\t/** @public */\n\t\tdelivery: readonly string[];\n\t\t/** @public */\n\t\tfeedback: readonly string[];\n\t\t/** @public */\n\t\tci: readonly string[];\n\t};\n\t/** @public */\n\tsources: readonly PublicationSource<P>[];\n\t/** @public */\n\tidentity(ctx: PublicationContext<P>): Promise<GitIdentity>;\n\t/** @public */\n\tensureRequest(ctx: PublicationContext<P>): Promise<PublicationRequest>;\n\t/** @public */\n\treconcileTerminal(\n\t\tctx: PublicationContext<P>,\n\t\tcurrent: PublicationState,\n\t\trequest: PublicationRequest,\n\t): Promise<void>;\n\t/** @public */\n\tlinkIssue(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\t/** @public */\n\tacknowledge(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\t/** @public */\n\treply(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\t/** @public */\n\tafterRebase(ctx: PublicationContext<P>, current: PublicationState): Promise<void>;\n\t/** @public */\n\thead(ctx: PublicationContext<P>, current: PublicationState): Promise<string>;\n\t/** @public */\n\tprompt(kind: \"feedback\" | \"ci\", current: PublicationState): string;\n\t/** @public */\n\tcommitMessage(kind: \"feedback\" | \"ci\"): string;\n}\n/** @public */\nexport type PublicationFeedbackId = {\n\t/** @public */\n\tkind: \"conversation\" | \"review\" | \"inline\";\n\t/** @public */\n\tid: number;\n\t/** @public */\n\tdiscussionId?: string;\n};\n/** @public */\ntype AdjustmentInvocation = {\n\t/** @public */\n\torigin: \"feedback\" | \"ci\" | \"rebase\";\n\t/** @public */\n\tpublishRequired: boolean;\n};\n\n/** @public */\nexport interface DeliveryState {\n\t/** @public */\n\tstage: \"not_started\" | \"branch_published\" | \"pull_request_ready\" | \"awaiting\";\n\t/** @public */\n\tissueLinked: boolean;\n\t/** @public */\n\tadjustment: AdjustmentInvocation | null;\n\t/** @public */\n\tterminalPullRequest: PublicationRequest | null;\n}\n\n/** @public */\nexport interface PublicationState {\n\t/** @public */\n\tlastConflictKey?: string | null;\n\t/** @public */\n\tconflict?: ConflictEvidence | null;\n\t/** @public */\n\trepairReason?: \"feedback\" | \"ci\" | \"rebase\";\n\t/** @public */\n\theadSha: string | null;\n\t/** @public */\n\tprNumber: number | null;\n\t/** @public */\n\tprUrl: string | null;\n\t/** @public */\n\tconversationCursor: number;\n\t/** @public */\n\treviewCursor: number;\n\t/** @public */\n\tinlineCursor: number;\n\t/** @public */\n\tfeedbackIds: PublicationFeedbackId[];\n\t/** @public */\n\tpipeline: PublicationPipeline | null;\n\t/** @public */\n\tciRecoveryCycles: number;\n\t/** @public */\n\tdelivery: DeliveryState;\n\t/** @public */\n\tobservationKey?: string;\n\t/** @public */\n\tpendingEvidence?: PublicationEvidence | null;\n}\n\nconst initialDeliveryState: DeliveryState = {\n\tstage: \"not_started\",\n\tissueLinked: false,\n\tadjustment: null,\n\tterminalPullRequest: null,\n};\n\nconst initialPublicationState: PublicationState = {\n\theadSha: null,\n\tprNumber: null,\n\tprUrl: null,\n\tconversationCursor: 0,\n\treviewCursor: 0,\n\tinlineCursor: 0,\n\tfeedbackIds: [],\n\tpipeline: null,\n\tciRecoveryCycles: 0,\n\tdelivery: initialDeliveryState,\n};\n\n/** @public */\nexport const publicationObject = (value: unknown) => asUnknownRecord(value) ?? {};\n\n/** @public */\nexport function readPublicationState(\n\tstate: RepositoryChangeState,\n\tnamespace: string,\n): PublicationState {\n\tconst stored = publicationObject(publicationObject(state.extensionState)[namespace]);\n\treturn {\n\t\t...initialPublicationState,\n\t\t...stored,\n\t\tdelivery: {\n\t\t\t...initialDeliveryState,\n\t\t\t...publicationObject(stored.delivery),\n\t\t},\n\t} as PublicationState;\n}\n\n/** @public */\nexport function patchPublicationState(\n\tstate: RepositoryChangeState,\n\tnamespace: string,\n\tpatch: Partial<Omit<PublicationState, \"delivery\">> & {\n\t\t/** @public */\n\t\tdelivery?: Partial<DeliveryState>;\n\t},\n): RepositoryChangeState {\n\tconst current = readPublicationState(state, namespace);\n\treturn {\n\t\t...state,\n\t\textensionState: {\n\t\t\t...state.extensionState,\n\t\t\t[namespace]: {\n\t\t\t\t...current,\n\t\t\t\t...patch,\n\t\t\t\tdelivery: { ...current.delivery, ...patch.delivery },\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** @public */\nexport function applyPublicationEvidence(\n\tparams: PublicationParams,\n\tcurrent: PublicationState,\n\tevidence: PublicationEvidence,\n\tcountFailure = true,\n): PublicationState {\n\tif (evidence.observationKey !== undefined)\n\t\tcurrent = { ...current, observationKey: evidence.observationKey };\n\tswitch (evidence.kind) {\n\t\tcase \"feedback\": {\n\t\t\tconst { kind: _, ...batch } = evidence;\n\t\t\treturn { ...current, ...batch, repairReason: \"feedback\" };\n\t\t}\n\t\tcase \"failure\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\trepairReason: \"ci\",\n\t\t\t\tpipeline: evidence.pipeline,\n\t\t\t\tciRecoveryCycles: current.ciRecoveryCycles + (countFailure ? 1 : 0),\n\t\t\t};\n\t\tcase \"conflict\": {\n\t\t\tconst conflict = validateConflict(\n\t\t\t\tevidence.conflict,\n\t\t\t\t{\n\t\t\t\t\towner: params.owner,\n\t\t\t\t\trepo: params.repo,\n\t\t\t\t\tprNumber: current.prNumber ?? 0,\n\t\t\t\t\theadSha: current.headSha ?? \"\",\n\t\t\t\t\theadBranch: params.workBranch,\n\t\t\t\t\tbaseBranch: params.baseBranch,\n\t\t\t\t},\n\t\t\t\tcurrent.lastConflictKey,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tconflict,\n\t\t\t\tlastConflictKey: conflictKey(conflict),\n\t\t\t\trepairReason: \"rebase\",\n\t\t\t};\n\t\t}\n\t\tcase \"terminal\":\n\t\t\treturn {\n\t\t\t\t...current,\n\t\t\t\tdelivery: { ...current.delivery, terminalPullRequest: evidence.request },\n\t\t\t};\n\t\tdefault:\n\t\t\treturn current;\n\t}\n}\nfunction deliveryProgress(value: PublicationState, label: string, activeStepId?: string) {\n\tconst delivery = value.delivery;\n\tconst step = (id: string, label: string, done: boolean) => ({\n\t\tid,\n\t\tlabel,\n\t\tstatus: (activeStepId === id ? \"in_progress\" : done ? \"completed\" : \"incomplete\") as\n\t\t\t| \"in_progress\"\n\t\t\t| \"completed\"\n\t\t\t| \"incomplete\",\n\t});\n\tconst adjustmentHandled =\n\t\tdelivery.adjustment === null && delivery.stage === \"awaiting\" && value.headSha !== null;\n\treturn {\n\t\ttitle: \"Delivery progress\",\n\t\tsteps: [\n\t\t\tstep(\"publish_branch\", \"Publish work branch\", value.headSha !== null),\n\t\t\tstep(\"open_pr\", \"Create or find pull request\", value.prNumber !== null),\n\t\t\tstep(\"link_issue\", \"Link source issue when applicable\", delivery.issueLinked),\n\t\t\tstep(\"publish_adjustment\", \"Publish an adjustment when applicable\", adjustmentHandled),\n\t\t\tstep(\n\t\t\t\t\"reply_feedback\",\n\t\t\t\t\"Acknowledge or reply to feedback when applicable\",\n\t\t\t\tvalue.feedbackIds.length === 0,\n\t\t\t),\n\t\t\tstep(\"await_evidence\", \"Await external evidence\", delivery.stage === \"awaiting\"),\n\t\t\tstep(\n\t\t\t\t\"reconcile_terminal\",\n\t\t\t\t\"Reconcile terminal pull request\",\n\t\t\t\tdelivery.terminalPullRequest !== null,\n\t\t\t),\n\t\t],\n\t\t...(value.prNumber && value.prUrl\n\t\t\t? {\n\t\t\t\t\tlinks: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: `${label}-pr-${value.prNumber}`,\n\t\t\t\t\t\t\tlabel: `${label} #${value.prNumber}`,\n\t\t\t\t\t\t\turl: value.prUrl,\n\t\t\t\t\t\t\tkind: \"pull_request\" as const,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n}\n\n/** @public */\nexport function createRepositoryChangePublication<P extends PublicationParams>(\n\tadapter: RepositoryChangePublicationAdapter<P>,\n) {\n\tconst applyEvidence = applyPublicationEvidence;\n\tconst ids = adapter.ids;\n\tconst publication = flow.fragment<P, RepositoryChangeState>(`${adapter.namespace}-publication`);\n\tconst remote = (state: RepositoryChangeState) => readPublicationState(state, adapter.namespace);\n\tconst patchRemote = (\n\t\tstate: RepositoryChangeState,\n\t\tpatch: Partial<Omit<PublicationState, \"delivery\">> & { delivery?: Partial<DeliveryState> },\n\t) => patchPublicationState(state, adapter.namespace, patch);\n\tasync function commitWorkBranch(ctx: PublicationContext<P>, commitMessage: string) {\n\t\tconst repo = ctx.repo.get(\"repo\");\n\t\treturn commitAndPushWorkBranch({\n\t\t\trepoPath: repo.fsPath,\n\t\t\tworkBranch: repo.workBranch,\n\t\t\tcommitMessage,\n\t\t\tgitIdentity: await adapter.identity(ctx),\n\t\t});\n\t}\n\tconst delivery = flow\n\t\t.automatic<P, RepositoryChangeState>(ids.deliver)\n\t\t.description(\"Deliver\")\n\t\t.integrationTools(...adapter.tools.delivery)\n\t\t.run(async (ctx) => {\n\t\t\tlet current = remote(ctx.state);\n\t\t\tconst update = (patch: Parameters<typeof patchRemote>[1]) => {\n\t\t\t\tcurrent = { ...current, ...patch, delivery: { ...current.delivery, ...patch.delivery } };\n\t\t\t};\n\t\t\tconst result = (\n\t\t\t\toutcome:\n\t\t\t\t\t| \"awaiting\"\n\t\t\t\t\t| \"feedback_ready\"\n\t\t\t\t\t| \"completed\"\n\t\t\t\t\t| \"aborted\"\n\t\t\t\t\t| \"ci_ready\"\n\t\t\t\t\t| \"conflict_ready\"\n\t\t\t\t\t| \"operator_action\",\n\t\t\t) => ({\n\t\t\t\toutcome,\n\t\t\t\tparams: { nextState: patchRemote(ctx.state, current) },\n\t\t\t});\n\t\t\tif (current.pendingEvidence) {\n\t\t\t\tconst evidence = current.pendingEvidence;\n\t\t\t\tconst needsOperator = evidence.kind === \"failure\" && current.ciRecoveryCycles >= 3;\n\t\t\t\tcurrent = applyEvidence(ctx.params, current, evidence, !needsOperator);\n\t\t\t\tcurrent.pendingEvidence = null;\n\t\t\t\tif (evidence.kind === \"cancelled\") return result(\"aborted\");\n\t\t\t\tif (evidence.kind === \"failure\")\n\t\t\t\t\treturn result(needsOperator ? \"operator_action\" : \"ci_ready\");\n\t\t\t\tif (evidence.kind === \"conflict\") return result(\"conflict_ready\");\n\t\t\t}\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label));\n\n\t\t\tif (current.delivery.terminalPullRequest) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reconcile_terminal\"));\n\t\t\t\tconst pr = current.delivery.terminalPullRequest;\n\t\t\t\tawait adapter.reconcileTerminal(ctx, current, pr);\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label));\n\t\t\t\treturn result(pr.merged ? \"completed\" : \"aborted\");\n\t\t\t}\n\n\t\t\tif (!current.headSha) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"publish_branch\"));\n\t\t\t\tconst published = await commitWorkBranch(\n\t\t\t\t\tctx,\n\t\t\t\t\tctx.state.finalization.generatedCommitMessage ?? \"\",\n\t\t\t\t);\n\t\t\t\tupdate({ headSha: published.headSha, pipeline: null });\n\t\t\t}\n\n\t\t\tif (!current.prNumber || !current.prUrl) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"open_pr\"));\n\t\t\t\tconst pr = await adapter.ensureRequest(ctx);\n\t\t\t\tupdate({ prNumber: pr.number, prUrl: pr.html_url });\n\t\t\t}\n\n\t\t\tif (!current.delivery.issueLinked) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"link_issue\"));\n\t\t\t\tawait adapter.linkIssue(ctx, current);\n\t\t\t\tupdate({ delivery: { issueLinked: true } });\n\t\t\t}\n\n\t\t\tif (current.delivery.adjustment) {\n\t\t\t\tconst adjustment = current.delivery.adjustment;\n\t\t\t\tif (adjustment.publishRequired || adjustment.origin === \"rebase\") {\n\t\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"publish_adjustment\"));\n\t\t\t\t\tconst published =\n\t\t\t\t\t\tadjustment.origin === \"rebase\"\n\t\t\t\t\t\t\t? publishRebase(rebaseInput(ctx))\n\t\t\t\t\t\t\t: await commitWorkBranch(ctx, adapter.commitMessage(adjustment.origin));\n\t\t\t\t\tif (adjustment.origin === \"rebase\") {\n\t\t\t\t\t\tconst head = await adapter.head(ctx, current);\n\t\t\t\t\t\tif (head !== published.headSha)\n\t\t\t\t\t\t\tthrow new Error(\"Pull request head has not caught up with rebase publication\");\n\t\t\t\t\t}\n\t\t\t\t\tupdate({ headSha: published.headSha, pipeline: null });\n\t\t\t\t}\n\t\t\t\tif (adjustment.origin === \"rebase\") await adapter.afterRebase(ctx, current);\n\t\t\t\tif (adjustment.origin === \"feedback\") {\n\t\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reply_feedback\"));\n\t\t\t\t\tawait adapter.reply(ctx, current);\n\t\t\t\t}\n\t\t\t\tupdate({\n\t\t\t\t\t...(adjustment.origin === \"feedback\" ? { feedbackIds: [] } : {}),\n\t\t\t\t\tdelivery: { adjustment: null },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (current.feedbackIds.length > 0) {\n\t\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"reply_feedback\"));\n\t\t\t\tawait adapter.acknowledge(ctx, current);\n\t\t\t\treturn result(\"feedback_ready\");\n\t\t\t}\n\n\t\t\tupdate({ delivery: { stage: \"awaiting\" } });\n\t\t\tctx.reportProgress(deliveryProgress(current, adapter.label, \"await_evidence\"));\n\t\t\treturn result(\"awaiting\");\n\t\t})\n\t\t.outcome(\"awaiting\", (outcome) =>\n\t\t\toutcome\n\t\t\t\t.description(\"Delivery is waiting for external evidence\")\n\t\t\t\t.object(\"nextState\")\n\t\t\t\t.wait()\n\t\t\t\t.state(({ event }) => event.params.nextState as RepositoryChangeState),\n\t\t)\n\t\t.outcome(\"feedback_ready\", (outcome) =>\n\t\t\toutcome\n\t\t\t\t.description(\"Pull request feedback is acknowledged and ready for revision\")\n\t\t\t\t.object(\"nextState\")\n\t\t\t\t.to(ids.feedback)\n\t\t\t\t.state(({ event }) => event.params.nextState as RepositoryChangeState),\n\t\t)\n\t\t.outcome(\"completed\", (outcome) =>\n\t\t\toutcome\n\t\t\t\t.description(\"Merged pull request was reconciled\")\n\t\t\t\t.object(\"nextState\")\n\t\t\t\t.complete()\n\t\t\t\t.state(({ event }) => event.params.nextState as RepositoryChangeState),\n\t\t)\n\t\t.outcome(\"aborted\", (outcome) =>\n\t\t\toutcome\n\t\t\t\t.description(\"Closed pull request was reconciled\")\n\t\t\t\t.object(\"nextState\")\n\t\t\t\t.lifecycleStatus(\"aborted\")\n\t\t\t\t.state(({ event }) => event.params.nextState as RepositoryChangeState),\n\t\t);\n\tfor (const [outcome, target] of [\n\t\t[\"ci_ready\", ids.ciRepair],\n\t\t[\"conflict_ready\", ids.feedback],\n\t\t[\"operator_action\", ids.operator],\n\t] as const) {\n\t\tdelivery.outcome(outcome, (o) =>\n\t\t\to\n\t\t\t\t.description(\"Route observed delivery evidence\")\n\t\t\t\t.object(\"nextState\")\n\t\t\t\t.to(target)\n\t\t\t\t.state(({ event }) => event.params.nextState as RepositoryChangeState),\n\t\t);\n\t}\n\tfor (const source of adapter.sources) {\n\t\tconst attach = (id: string, operator: boolean) =>\n\t\t\tdelivery.externalAction(id, source.source, (external) => {\n\t\t\t\texternal\n\t\t\t\t\t.label(source.label)\n\t\t\t\t\t.when(\n\t\t\t\t\t\t({ params, state }) =>\n\t\t\t\t\t\t\t(!source.enabled || source.enabled(params)) &&\n\t\t\t\t\t\t\t(source.kind !== \"failure\" || remote(state).ciRecoveryCycles >= 3 === operator),\n\t\t\t\t\t);\n\t\t\t\tif (source.kind === \"cancelled\") return external.lifecycleStatus(\"aborted\");\n\t\t\t\texternal.to(\n\t\t\t\t\tsource.kind === \"conflict\"\n\t\t\t\t\t\t? ids.feedback\n\t\t\t\t\t\t: source.kind === \"failure\"\n\t\t\t\t\t\t\t? operator\n\t\t\t\t\t\t\t\t? ids.operator\n\t\t\t\t\t\t\t\t: ids.ciRepair\n\t\t\t\t\t\t\t: ids.deliver,\n\t\t\t\t);\n\t\t\t\treturn external.effect((input) => {\n\t\t\t\t\tconst evidence = source.read(input);\n\t\t\t\t\tconst current = remote(input.state);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: patchRemote(\n\t\t\t\t\t\t\tinput.state,\n\t\t\t\t\t\t\tsource.kind === \"observation\"\n\t\t\t\t\t\t\t\t? { pendingEvidence: evidence }\n\t\t\t\t\t\t\t\t: applyEvidence(input.params, current, evidence, !operator),\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t});\n\t\tattach(source.id, false);\n\t\tif (source.kind === \"failure\") attach(source.operatorId ?? `${source.id}_operator`, true);\n\t}\n\tpublication.turn(delivery);\n\tfunction rebaseInput(ctx: {\n\t\tstate: RepositoryChangeState;\n\t\trepo: { get(key: string): { fsPath: string; workBranch: string } };\n\t}) {\n\t\tconst project = ctx.repo.get(\"repo\");\n\t\tconst conflict = remote(ctx.state).conflict;\n\t\tif (!conflict) throw new Error(\"Missing conflict evidence\");\n\t\treturn { projectKey: \"repo\", path: project.fsPath, workBranch: project.workBranch, conflict };\n\t}\n\tfunction repairReason(state: RepositoryChangeState, kind: \"feedback\" | \"ci\") {\n\t\treturn kind === \"feedback\" && remote(state).repairReason === \"rebase\" ? \"rebase\" : kind;\n\t}\n\n\tfunction revisionPrompt(kind: \"feedback\" | \"ci\") {\n\t\treturn (ctx: { state: RepositoryChangeState }) => {\n\t\t\tconst current = remote(ctx.state);\n\t\t\tif (repairReason(ctx.state, kind) === \"rebase\")\n\t\t\t\treturn `${rebasePrompt} Evidence: ${JSON.stringify(current.conflict)}. Call changes_ready or no_changes when verified complete, cannot_repair when blocked.`;\n\t\t\treturn adapter.prompt(kind, current);\n\t\t};\n\t}\n\n\tfunction revisionTurn(id: string, kind: \"feedback\" | \"ci\") {\n\t\tconst turn = flow\n\t\t\t.llm<P, RepositoryChangeState>(id)\n\t\t\t.description(kind === \"feedback\" ? \"Address Feedback\" : \"Fix CI\")\n\t\t\t.tools(\"read\", \"bash\", \"edit\", \"write\")\n\t\t\t.resolveIntegrationTools((_params, state) =>\n\t\t\t\trepairReason(state, kind) === \"rebase\" ? [] : adapter.tools[kind],\n\t\t\t)\n\t\t\t.prepare((ctx) =>\n\t\t\t\trepairReason(ctx.state, kind) === \"rebase\" ? startRebase(rebaseInput(ctx)) : {},\n\t\t\t)\n\t\t\t.freshPrimary()\n\t\t\t.prompt(revisionPrompt(kind));\n\t\tfor (const [name, description, publishRequired] of [\n\t\t\t[\"changes_ready\", \"Repository changes are ready to publish\", true],\n\t\t\t[\"no_changes\", \"No repository change is required\", false],\n\t\t] as const) {\n\t\t\tturn.outcomeTool(name, (tool) =>\n\t\t\t\ttool\n\t\t\t\t\t.resultSummary()\n\t\t\t\t\t.description(description)\n\t\t\t\t\t.to(ids.deliver)\n\t\t\t\t\t.state(({ ctx }) =>\n\t\t\t\t\t\tpatchRemote(ctx.state, {\n\t\t\t\t\t\t\tdelivery: { adjustment: { origin: repairReason(ctx.state, kind), publishRequired } },\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn turn.outcomeTool(\"cannot_repair\", (tool) =>\n\t\t\ttool.description(\"The adjustment requires operator action\").to(ids.operator),\n\t\t);\n\t}\n\n\tpublication.turn(revisionTurn(ids.feedback, \"feedback\"));\n\tpublication.turn(revisionTurn(ids.ciRepair, \"ci\"));\n\tpublication.turn({\n\t\tid: ids.operator,\n\t\tdefinition: {\n\t\t\tkind: \"human\",\n\t\t\tdescription: \"Repository repair needs operator action\",\n\t\t\toperatorAttention: \"required\",\n\t\t\tactions: {\n\t\t\t\tretry_repair: {\n\t\t\t\t\tlabel: \"Retry repair\",\n\t\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\t\tbranches: { feedback: { to: ids.feedback }, ci: { to: ids.ciRepair } },\n\t\t\t\t\tchoose: ({ ctx }) =>\n\t\t\t\t\t\tremote(ctx.state).repairReason === \"rebase\" ||\n\t\t\t\t\t\tremote(ctx.state).repairReason === \"feedback\"\n\t\t\t\t\t\t\t? \"feedback\"\n\t\t\t\t\t\t\t: \"ci\",\n\t\t\t\t},\n\t\t\t\tresume_waiting: {\n\t\t\t\t\tlabel: \"Resume waiting\",\n\t\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\t\tto: ids.deliver,\n\t\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\t\tstate: patchRemote(ctx.state, {\n\t\t\t\t\t\t\tfeedbackIds: [],\n\t\t\t\t\t\t\tdelivery: { adjustment: null },\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tabort: { label: \"Abort process\", acceptanceState: \"neutral\", lifecycleStatus: \"aborted\" },\n\t\t\t},\n\t\t},\n\t});\n\n\treturn {\n\t\t/** @public */\n\t\tentryTurnId: ids.deliver,\n\t\t/** @public */\n\t\tfragment: publication,\n\t\t/** @public */\n\t\thappyPath: [ids.deliver],\n\t};\n}\n"],"mappings":";;;;;;AAAA,SAAS,uBAAuB;AAChC;AAAA,EAGC;AAAA,OACM;AACP;AAAA,EAEC;AAAA,EACA;AAAA,OACM;AACP,SAAS,eAAe,mBAAmB;AAC3C,SAAS,oBAAoB;AA6N7B,IAAM,uBAAsC;AAAA,EAC3C,OAAO;AAAA,EACP,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,qBAAqB;AACtB;AAEA,IAAM,0BAA4C;AAAA,EACjD,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,cAAc;AA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QACR,cAAc;AAAA,UACb,OAAO;AAAA,UACP,iBAAiB;AAAA,UACjB,UAAU,EAAE,UAAU,EAAE,IAAI,IAAI,SAAS,GAAG,IAAI,EAAE,IAAI,IAAI,SAAS,EAAE;AAAA,UACrE,QAAQ,CAAC,EAAE,IAAI,MACd,OAAO,IAAI,KAAK,EAAE,iBAAiB,YACnC,OAAO,IAAI,KAAK,EAAE,iBAAiB,aAChC,aACA;AAAA,QACL;AAAA,QACA,gBAAgB;AAAA,UACf,OAAO;AAAA,UACP,iBAAiB;AAAA,UACjB,IAAI,IAAI;AAAA,UACR,QAAQ,CAAC,EAAE,IAAI,OAAO;AAAA,YACrB,OAAO,YAAY,IAAI,OAAO;AAAA,cAC7B,aAAa,CAAC;AAAA,cACd,UAAU,EAAE,YAAY,KAAK;AAAA,YAC9B,CAAC;AAAA,UACF;AAAA,QACD;AAAA,QACA,OAAO,EAAE,OAAO,iBAAiB,iBAAiB,WAAW,iBAAiB,UAAU;AAAA,MACzF;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO;AAAA;AAAA,IAEN,aAAa,IAAI;AAAA;AAAA,IAEjB,UAAU;AAAA;AAAA,IAEV,WAAW,CAAC,IAAI,OAAO;AAAA,EACxB;AACD;","names":["label"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Codec, StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @public */
|
|
3
|
+
export interface RepositoryChangeFinalizationState {
|
|
4
|
+
/** @public */
|
|
5
|
+
generatedCommitMessage: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** @public */
|
|
8
|
+
export interface RepositoryChangeState extends StructuralProcessState {
|
|
9
|
+
/** @public */
|
|
10
|
+
finalization: RepositoryChangeFinalizationState;
|
|
11
|
+
/** Namespaced state owned by a caller-supplied publication workflow. */
|
|
12
|
+
/** @public */
|
|
13
|
+
extensionState?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/** @internal */
|
|
16
|
+
export declare function createEmptyRepositoryChangeFinalizationState(): RepositoryChangeFinalizationState;
|
|
17
|
+
/** @internal */
|
|
18
|
+
export declare const repositoryChangeStateCodec: Codec<RepositoryChangeState>;
|
|
19
|
+
/** @internal */
|
|
20
|
+
export declare function clearReviewRefs(semanticEntryRefs: RepositoryChangeState["semanticEntryRefs"]): RepositoryChangeState["semanticEntryRefs"];
|
|
21
|
+
//# sourceMappingURL=repository-change-state-internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-change-state-internal.d.ts","sourceRoot":"","sources":["../src/repository-change-state-internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAG/E,cAAc;AACd,MAAM,WAAW,iCAAiC;IACjD,cAAc;IACd,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,cAAc;AACd,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;IACpE,cAAc;IACd,YAAY,EAAE,iCAAiC,CAAC;IAChD,wEAAwE;IACxE,cAAc;IACd,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,gBAAgB;AAChB,wBAAgB,4CAA4C,IAAI,iCAAiC,CAEhG;AAeD,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,qBAAqB,CAYnE,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,eAAe,CAC9B,iBAAiB,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,GAC3D,qBAAqB,CAAC,mBAAmB,CAAC,CAK5C"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export interface RepositoryChangeFinalizationState {
|
|
3
|
-
expectedPostConflictHeadSha: string | null;
|
|
4
|
-
usedConflictResolution: boolean;
|
|
5
|
-
finalizationSummaryMarkdown: string | null;
|
|
6
|
-
finalizedHeadSha: string | null;
|
|
7
|
-
generatedCommitMessage: string | null;
|
|
8
|
-
}
|
|
9
|
-
export interface RepositoryChangeState extends StructuralProcessState {
|
|
10
|
-
finalization: RepositoryChangeFinalizationState;
|
|
11
|
-
/** Namespaced state owned by a caller-supplied publication workflow. */
|
|
12
|
-
extensionState?: Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
export declare function createEmptyRepositoryChangeFinalizationState(): RepositoryChangeFinalizationState;
|
|
15
|
-
export declare const repositoryChangeStateCodec: Codec<RepositoryChangeState>;
|
|
16
|
-
export declare function clearReviewRefs(semanticEntryRefs: RepositoryChangeState["semanticEntryRefs"]): RepositoryChangeState["semanticEntryRefs"];
|
|
17
|
-
export declare function resetRepositoryChangeFinalizationState(overrides?: Partial<RepositoryChangeFinalizationState>): RepositoryChangeFinalizationState;
|
|
1
|
+
export type { RepositoryChangeState } from "./repository-change-state-internal.js";
|
|
18
2
|
//# sourceMappingURL=repository-change-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-change-state.d.ts","sourceRoot":"","sources":["../src/repository-change-state.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"repository-change-state.d.ts","sourceRoot":"","sources":["../src/repository-change-state.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
clearReviewRefs,
|
|
3
|
-
createEmptyRepositoryChangeFinalizationState,
|
|
4
|
-
repositoryChangeStateCodec,
|
|
5
|
-
resetRepositoryChangeFinalizationState
|
|
6
|
-
} from "./chunk-YIP4MP64.js";
|
|
7
|
-
import "./chunk-PX6F3LHL.js";
|
|
8
|
-
export {
|
|
9
|
-
clearReviewRefs,
|
|
10
|
-
createEmptyRepositoryChangeFinalizationState,
|
|
11
|
-
repositoryChangeStateCodec,
|
|
12
|
-
resetRepositoryChangeFinalizationState
|
|
13
|
-
};
|
|
14
1
|
//# sourceMappingURL=repository-change-state.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type FlowPromptContext } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare function normalizeGeneratedCommitMessage(value: unknown): string;
|
|
4
|
+
/** @internal */
|
|
3
5
|
export declare function buildGenerateCommitMessagePrompt<TParams, TState>(ctx: FlowPromptContext<TParams, TState, "plan">): string;
|
|
4
6
|
//# sourceMappingURL=generate-commit-message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-commit-message.d.ts","sourceRoot":"","sources":["../../src/turns/generate-commit-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAatE;AAED,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAC/D,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,GAC7C,MAAM,CAwBR"}
|
|
1
|
+
{"version":3,"file":"generate-commit-message.d.ts","sourceRoot":"","sources":["../../src/turns/generate-commit-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,gBAAgB;AAChB,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAatE;AAED,gBAAgB;AAChB,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAC/D,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,GAC7C,MAAM,CAwBR"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare function buildGeneratePlanPrompt(ctx: FlowPromptContext<unknown, StructuralProcessState, never>): string;
|
|
3
4
|
//# sourceMappingURL=generate-plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-plan.d.ts","sourceRoot":"","sources":["../../src/turns/generate-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,CAAC,GAC5D,MAAM,CAkBR"}
|
|
1
|
+
{"version":3,"file":"generate-plan.d.ts","sourceRoot":"","sources":["../../src/turns/generate-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,CAAC,GAC5D,MAAM,CAkBR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/turns/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,GAC7D,MAAM,CAgBR"}
|
|
1
|
+
{"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/turns/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,GAC7D,MAAM,CAgBR"}
|
package/dist/turns/implement.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare function buildReviewImplementationPrompt(ctx: FlowPromptContext<unknown, StructuralProcessState>): string;
|
|
3
4
|
//# sourceMappingURL=review-implementation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-implementation.d.ts","sourceRoot":"","sources":["../../src/turns/review-implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,wBAAgB,+BAA+B,CAC9C,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,CAAC,GACrD,MAAM,CAwBR"}
|
|
1
|
+
{"version":3,"file":"review-implementation.d.ts","sourceRoot":"","sources":["../../src/turns/review-implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,+BAA+B,CAC9C,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,CAAC,GACrD,MAAM,CAwBR"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare function buildReviewPlanPrompt(ctx: FlowPromptContext<unknown, StructuralProcessState, "plan">): string;
|
|
3
4
|
//# sourceMappingURL=review-plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-plan.d.ts","sourceRoot":"","sources":["../../src/turns/review-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,GAC7D,MAAM,CAkBR"}
|
|
1
|
+
{"version":3,"file":"review-plan.d.ts","sourceRoot":"","sources":["../../src/turns/review-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,GAC7D,MAAM,CAkBR"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare function buildSimplifyImplementationPrompt(_ctx: FlowPromptContext<unknown, StructuralProcessState>): string;
|
|
3
4
|
//# sourceMappingURL=simplify-implementation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify-implementation.d.ts","sourceRoot":"","sources":["../../src/turns/simplify-implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,wBAAgB,iCAAiC,CAChD,IAAI,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,CAAC,GACtD,MAAM,CAMR"}
|
|
1
|
+
{"version":3,"file":"simplify-implementation.d.ts","sourceRoot":"","sources":["../../src/turns/simplify-implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,iCAAiC,CAChD,IAAI,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,CAAC,GACtD,MAAM,CAMR"}
|