@leitwerk-dev/coding 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +120 -2
  2. package/dist/auto-work-branch.js +3 -24
  3. package/dist/auto-work-branch.js.map +1 -1
  4. package/dist/chunk-6E5VQPC4.js +28 -0
  5. package/dist/chunk-6E5VQPC4.js.map +1 -0
  6. package/dist/chunk-ABQH2WZT.js +36 -0
  7. package/dist/chunk-ABQH2WZT.js.map +1 -0
  8. package/dist/{chunk-YSC5GEQJ.js → chunk-BI45R2FH.js} +7 -3
  9. package/dist/chunk-BI45R2FH.js.map +1 -0
  10. package/dist/chunk-DNG7D77K.js +65 -0
  11. package/dist/chunk-DNG7D77K.js.map +1 -0
  12. package/dist/chunk-KFELB7ZC.js +70 -0
  13. package/dist/chunk-KFELB7ZC.js.map +1 -0
  14. package/dist/chunk-L2TFD72B.js +16320 -0
  15. package/dist/chunk-L2TFD72B.js.map +1 -0
  16. package/dist/chunk-M2VTUPFO.js +265 -0
  17. package/dist/chunk-M2VTUPFO.js.map +1 -0
  18. package/dist/chunk-OM2AMDTJ.js +347 -0
  19. package/dist/chunk-OM2AMDTJ.js.map +1 -0
  20. package/dist/chunk-Q24RPXOA.js +159 -0
  21. package/dist/chunk-Q24RPXOA.js.map +1 -0
  22. package/dist/chunk-SKGB4CZS.js +14 -0
  23. package/dist/chunk-SKGB4CZS.js.map +1 -0
  24. package/dist/chunk-SZ4WOGV2.js +120 -0
  25. package/dist/chunk-SZ4WOGV2.js.map +1 -0
  26. package/dist/finalization-git-internal.d.ts +3 -0
  27. package/dist/finalization-git-internal.d.ts.map +1 -1
  28. package/dist/finalization-git.d.ts +1 -1
  29. package/dist/finalization-git.d.ts.map +1 -1
  30. package/dist/finalization-git.js +5 -3
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +17 -591
  34. package/dist/index.js.map +1 -1
  35. package/dist/profile-bindings-internal.d.ts +3 -0
  36. package/dist/profile-bindings-internal.d.ts.map +1 -0
  37. package/dist/pull-request-publication-internal.d.ts +75 -0
  38. package/dist/pull-request-publication-internal.d.ts.map +1 -0
  39. package/dist/repository-change-launch-internal-BudnAfL7.d.ts +88 -0
  40. package/dist/repository-change-launch-internal.d.ts +62 -11
  41. package/dist/repository-change-launch-internal.d.ts.map +1 -1
  42. package/dist/repository-change-launch.d.ts +5 -2
  43. package/dist/repository-change-launch.d.ts.map +1 -1
  44. package/dist/repository-change-launch.js +363 -6
  45. package/dist/repository-change-launch.js.map +1 -1
  46. package/dist/repository-change-process-DlgF04fU.d.ts +69 -0
  47. package/dist/repository-change-process.d.ts +30 -25
  48. package/dist/repository-change-process.d.ts.map +1 -1
  49. package/dist/repository-change-publication.d.ts +63 -7
  50. package/dist/repository-change-publication.d.ts.map +1 -1
  51. package/dist/repository-change-publication.js +732 -56
  52. package/dist/repository-change-publication.js.map +1 -1
  53. package/dist/repository-change-state-internal.d.ts +18 -4
  54. package/dist/repository-change-state-internal.d.ts.map +1 -1
  55. package/dist/repository-change-ui-launcher-internal.d.ts +65 -0
  56. package/dist/repository-change-ui-launcher-internal.d.ts.map +1 -0
  57. package/dist/repository-rebase/git.d.ts +31 -0
  58. package/dist/repository-rebase/git.d.ts.map +1 -0
  59. package/dist/repository-rebase/index.d.ts +42 -0
  60. package/dist/repository-rebase/index.d.ts.map +1 -0
  61. package/dist/repository-rebase/index.js +16 -0
  62. package/dist/repository-rebase/policy.d.ts +37 -0
  63. package/dist/repository-rebase/policy.d.ts.map +1 -0
  64. package/dist/repository-rebase/prompt.d.ts +3 -0
  65. package/dist/repository-rebase/prompt.d.ts.map +1 -0
  66. package/dist/settings.d.ts +15 -0
  67. package/dist/settings.d.ts.map +1 -0
  68. package/dist/turns/commit-message-evidence.d.ts +35 -0
  69. package/dist/turns/commit-message-evidence.d.ts.map +1 -0
  70. package/dist/turns/commit-message-evidence.js +9 -0
  71. package/dist/turns/generate-commit-message.d.ts +4 -1
  72. package/dist/turns/generate-commit-message.d.ts.map +1 -1
  73. package/dist/turns/generate-commit-message.js +7 -5
  74. package/dist/turns/generate-plan.d.ts.map +1 -1
  75. package/dist/turns/generate-plan.js +1 -1
  76. package/dist/turns/git-inspection-profile.d.ts +25 -0
  77. package/dist/turns/git-inspection-profile.d.ts.map +1 -0
  78. package/dist/turns/git-inspection-profile.js +8 -0
  79. package/dist/turns/git-inspection-profile.js.map +1 -0
  80. package/dist/turns/implement.d.ts.map +1 -1
  81. package/dist/turns/implement.js +1 -1
  82. package/dist/turns/simplify-implementation.d.ts +1 -1
  83. package/dist/turns/simplify-implementation.d.ts.map +1 -1
  84. package/dist/turns/simplify-implementation.js +3 -3
  85. package/package.json +10 -10
  86. package/src/finalization-git-internal.ts +117 -114
  87. package/src/finalization-git.ts +1 -1
  88. package/src/index.ts +4 -1
  89. package/src/profile-bindings-internal.ts +39 -0
  90. package/src/pull-request-publication-internal.ts +364 -0
  91. package/src/repository-change-launch-internal.ts +194 -11
  92. package/src/repository-change-launch.ts +13 -0
  93. package/src/repository-change-process.ts +234 -523
  94. package/src/repository-change-publication.ts +535 -156
  95. package/src/repository-change-state-internal.ts +34 -20
  96. package/src/repository-change-ui-launcher-internal.ts +308 -0
  97. package/src/repository-rebase/git.ts +219 -0
  98. package/src/repository-rebase/index.ts +144 -0
  99. package/src/repository-rebase/policy.ts +75 -0
  100. package/src/repository-rebase/prompt.ts +2 -0
  101. package/src/settings.ts +79 -0
  102. package/src/turns/commit-message-evidence.ts +241 -0
  103. package/src/turns/generate-commit-message.ts +53 -23
  104. package/src/turns/generate-plan.ts +26 -12
  105. package/src/turns/git-inspection-profile.ts +134 -0
  106. package/src/turns/implement.ts +9 -2
  107. package/src/turns/simplify-implementation.ts +10 -6
  108. package/dist/chunk-34B3Q75M.js +0 -25
  109. package/dist/chunk-34B3Q75M.js.map +0 -1
  110. package/dist/chunk-F6CEEAFE.js +0 -13
  111. package/dist/chunk-F6CEEAFE.js.map +0 -1
  112. package/dist/chunk-GO44KCUS.js +0 -154
  113. package/dist/chunk-GO44KCUS.js.map +0 -1
  114. package/dist/chunk-R3UCUGY6.js +0 -31
  115. package/dist/chunk-R3UCUGY6.js.map +0 -1
  116. package/dist/chunk-W7VJT6AN.js +0 -25
  117. package/dist/chunk-W7VJT6AN.js.map +0 -1
  118. package/dist/chunk-WKHVLLKE.js +0 -45
  119. package/dist/chunk-WKHVLLKE.js.map +0 -1
  120. package/dist/chunk-YSC5GEQJ.js.map +0 -1
  121. package/dist/turns/review-implementation.d.ts +0 -4
  122. package/dist/turns/review-implementation.d.ts.map +0 -1
  123. package/dist/turns/review-implementation.js +0 -8
  124. package/dist/turns/review-plan.d.ts +0 -4
  125. package/dist/turns/review-plan.d.ts.map +0 -1
  126. package/dist/turns/review-plan.js +0 -8
  127. package/src/turns/review-implementation.ts +0 -30
  128. package/src/turns/review-plan.ts +0 -24
  129. /package/dist/{turns/review-implementation.js.map → repository-rebase/index.js.map} +0 -0
  130. /package/dist/turns/{review-plan.js.map → commit-message-evidence.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,597 +1,21 @@
1
1
  import {
2
- buildGeneratePlanPrompt
3
- } from "./chunk-W7VJT6AN.js";
4
- import {
5
- buildImplementPrompt
6
- } from "./chunk-YSC5GEQJ.js";
7
- import {
8
- buildReviewImplementationPrompt
9
- } from "./chunk-R3UCUGY6.js";
10
- import {
11
- buildReviewPlanPrompt
12
- } from "./chunk-34B3Q75M.js";
13
- import {
14
- buildSimplifyImplementationPrompt
15
- } from "./chunk-F6CEEAFE.js";
2
+ acceptReviewForm,
3
+ codingActionIds,
4
+ createRepositoryChangeProcess,
5
+ requestReviewChangesForm,
6
+ requestRevisionForm
7
+ } from "./chunk-OM2AMDTJ.js";
8
+ import "./chunk-DNG7D77K.js";
9
+ import "./chunk-ABQH2WZT.js";
10
+ import "./chunk-BI45R2FH.js";
11
+ import "./chunk-SKGB4CZS.js";
16
12
  import {
17
- buildGenerateCommitMessagePrompt,
18
- normalizeGeneratedCommitMessage
19
- } from "./chunk-WKHVLLKE.js";
13
+ codingPurposes,
14
+ codingSettings
15
+ } from "./chunk-M2VTUPFO.js";
16
+ import "./chunk-SZ4WOGV2.js";
20
17
  import "./chunk-PX6F3LHL.js";
21
18
 
22
- // src/actions.ts
23
- var codingActionIds = {
24
- /** @public */
25
- approvePlan: "approve_plan",
26
- /** @internal */
27
- requestRevision: "request_revision",
28
- /** @internal */
29
- runReview: "run_review",
30
- /** @internal */
31
- simplify: "simplify",
32
- /** @internal */
33
- acceptReview: "accept_review",
34
- /** @internal */
35
- requestReviewChanges: "request_review_changes",
36
- /** @internal */
37
- dismissReview: "dismiss_review",
38
- /** @public */
39
- finalizeChange: "finalize_change"
40
- };
41
- function notesForm(id, title, label, description) {
42
- return {
43
- id,
44
- title,
45
- fields: [
46
- { id: "message", label, kind: "textarea", primaryPrompt: true, required: true, description }
47
- ],
48
- submitLabel: title
49
- };
50
- }
51
- var requestRevisionForm = notesForm(
52
- codingActionIds.requestRevision,
53
- "Request revision",
54
- "Revision notes",
55
- "Instructions for the next implementation pass."
56
- );
57
- var requestReviewChangesForm = notesForm(
58
- codingActionIds.requestReviewChanges,
59
- "Request review changes",
60
- "Review notes",
61
- "Instructions for the next review pass."
62
- );
63
- var acceptReviewForm = {
64
- id: codingActionIds.acceptReview,
65
- title: "Accept review",
66
- fields: [
67
- {
68
- id: "message",
69
- label: "Review adjustment",
70
- kind: "textarea",
71
- primaryPrompt: true,
72
- description: "Optional instructions to apply with the accepted review, such as dropping one finding."
73
- }
74
- ],
75
- submitLabel: "Accept review"
76
- };
77
-
78
- // src/repository-change-process.ts
79
- import { trimString as normalizeMessage, normalizeOptionalMarkdown } from "@leitwerk-dev/domain";
80
- import {
81
- acceptedReviewHandoffAction,
82
- createEmptyStructuralProcessState,
83
- flow,
84
- humanTurn,
85
- revisionAction
86
- } from "@leitwerk-dev/process-sdk";
87
-
88
- // src/repository-change-state-internal.ts
89
- import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
90
- function createEmptyRepositoryChangeFinalizationState() {
91
- return { generatedCommitMessage: null };
92
- }
93
- function stringOrNull(value) {
94
- return typeof value === "string" ? value : null;
95
- }
96
- function toRecord(value) {
97
- return typeof value === "object" && value !== null ? value : {};
98
- }
99
- function parseFinalizationState(value) {
100
- const record = toRecord(value);
101
- return { generatedCommitMessage: stringOrNull(record.generatedCommitMessage) };
102
- }
103
- var repositoryChangeStateCodec = {
104
- parse(value) {
105
- const record = toRecord(value);
106
- return {
107
- ...parseStructuralProcessState(record),
108
- finalization: parseFinalizationState(record.finalization),
109
- extensionState: toRecord(record.extensionState)
110
- };
111
- },
112
- serialize(value) {
113
- return value;
114
- }
115
- };
116
- function clearReviewRefs(semanticEntryRefs) {
117
- return {
118
- ...semanticEntryRefs,
119
- review: null
120
- };
121
- }
122
-
123
- // src/repository-change-process.ts
124
- function createRepositoryChangeProcess(config) {
125
- const turnIds = {
126
- generatePlan: "generate_plan",
127
- planDecision: "plan_decision",
128
- reviewPlan: "review_plan",
129
- planReviewFeedback: "plan_review_feedback",
130
- implement: "implement",
131
- implementationDecision: "implementation_decision",
132
- reviewImplementation: "review_implementation",
133
- implementationReviewFeedback: "implementation_review_feedback",
134
- simplifyImplementation: "simplify_implementation",
135
- simplificationDecision: "simplification_decision",
136
- generateCommitMessage: "generate_commit_message"
137
- };
138
- const products = {
139
- plan: "plan",
140
- review: "review",
141
- simplificationPlan: "simplification-plan",
142
- implementationSummary: "implementation-summary",
143
- commitMessage: "commit-message"
144
- };
145
- const implementationTurnAvailableTools = ["read", "bash", "edit", "write"];
146
- function hasResolvedTurnRecordRef(ref) {
147
- return typeof ref?.turnRecordId === "string" && ref.turnRecordId.trim() !== "";
148
- }
149
- function requireResolvedPlanRef(plan, usage) {
150
- if (!hasResolvedTurnRecordRef(plan)) {
151
- throw new Error(`No plan is available for ${usage}`);
152
- }
153
- }
154
- function clearReviewState(state) {
155
- return patchRepositoryChangeState(state, {
156
- clearReviewRefs: true,
157
- clearProductRefs: [products.simplificationPlan]
158
- });
159
- }
160
- function buildAcceptedFollowUpMessage(input) {
161
- const markdown = normalizeOptionalMarkdown(input.markdown);
162
- if (!markdown) {
163
- throw new Error(
164
- input.kind === "simplification" ? "No simplification plan markdown is available to accept" : "No review output markdown is available to accept"
165
- );
166
- }
167
- const adjustment = normalizeMessage(input.adjustment);
168
- const subject = input.kind === "simplification" ? "simplification plan" : "review";
169
- const introduction = input.kind === "plan_review" ? "Revise the plan according to this review:" : `Implement according to this ${subject}:`;
170
- const sections = [introduction, markdown];
171
- if (adjustment) {
172
- sections.push(
173
- `Also follow this adjustment where it conflicts with the ${subject}:`,
174
- adjustment
175
- );
176
- }
177
- if (input.kind !== "plan_review") {
178
- sections.push(
179
- [
180
- "This is now an implementation turn. Ignore earlier review-only or read-only instructions.",
181
- "You may change files in the repository workspace.",
182
- `Use the available tools (${implementationTurnAvailableTools.join(", ")}) to inspect, edit, build, and test the change.`,
183
- "When finished, return an implementation summary."
184
- ].join("\n")
185
- );
186
- }
187
- return sections.join("\n\n");
188
- }
189
- function patchRepositoryChangeState(state, input) {
190
- const nextState = {
191
- ...state,
192
- ..."finalization" in input ? { finalization: input.finalization } : {}
193
- };
194
- const productRefsToClear = new Set(input.clearProductRefs ?? []);
195
- if (input.clearReviewRefs) {
196
- productRefsToClear.add(products.review);
197
- }
198
- if (!input.clearReviewRefs && productRefsToClear.size === 0) {
199
- return nextState;
200
- }
201
- const productRefs = { ...nextState.productRefs };
202
- for (const productName of productRefsToClear) {
203
- delete productRefs[productName];
204
- }
205
- return {
206
- ...nextState,
207
- semanticEntryRefs: input.clearReviewRefs ? clearReviewRefs(nextState.semanticEntryRefs) : nextState.semanticEntryRefs,
208
- productRefs
209
- };
210
- }
211
- const planDecisionSpec = humanTurn({
212
- description: "Review Plan",
213
- reviewSemanticRef: "plan",
214
- notesFields: [
215
- {
216
- id: "message",
217
- label: "Revision notes",
218
- placeholder: "Describe what the next plan revision should improve",
219
- required: true
220
- }
221
- ],
222
- commentary: "Approve this plan, request a revision, or run an automated review.",
223
- actions: {
224
- [codingActionIds.approvePlan]: {
225
- label: "Approve plan",
226
- description: "Accept the current plan and continue into implementation.",
227
- acceptanceState: "accepted",
228
- to: turnIds.implement,
229
- effect: ({ ctx }) => {
230
- requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "approval");
231
- return {
232
- state: clearReviewState(ctx.state),
233
- emit: [
234
- {
235
- type: "plan_approved",
236
- data: {
237
- externalId: ctx.process.externalId,
238
- planRevision: ctx.process.planRevision
239
- }
240
- }
241
- ]
242
- };
243
- }
244
- },
245
- [codingActionIds.requestRevision]: revisionAction({
246
- label: "Request revision",
247
- description: "Send the plan back for another draft revision.",
248
- acceptanceState: "requires_changes",
249
- form: requestRevisionForm,
250
- schedulable: true,
251
- to: turnIds.generatePlan,
252
- queueTarget: { semanticRef: "currentPrimaryPathLeaf" },
253
- effect: ({ ctx, input }) => {
254
- const message = normalizeMessage(input.message);
255
- return {
256
- state: clearReviewState(ctx.state),
257
- emit: [{ type: "plan_revision_requested", data: { message } }]
258
- };
259
- }
260
- }),
261
- [codingActionIds.runReview]: {
262
- label: "Run automated review",
263
- description: "Send the current plan to the LLM reviewer.",
264
- acceptanceState: "neutral",
265
- schedulable: true,
266
- to: turnIds.reviewPlan,
267
- effect: ({ ctx }) => {
268
- requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "review");
269
- return {
270
- state: clearReviewState(ctx.state)
271
- };
272
- }
273
- }
274
- }
275
- });
276
- const planReviewFeedbackSpec = humanTurn({
277
- description: "Review Plan Feedback",
278
- reviewSemanticRef: "review",
279
- notesFields: [
280
- {
281
- id: "message",
282
- label: "Review notes",
283
- placeholder: "Describe how the next review pass should change",
284
- required: true
285
- }
286
- ],
287
- commentary: "Apply this feedback to the next plan revision, request a revised review, or dismiss it.",
288
- actions: {
289
- [codingActionIds.acceptReview]: acceptedReviewHandoffAction({
290
- label: "Accept review",
291
- description: "Apply the current review outcome and continue with the plan flow.",
292
- acceptanceState: "accepted",
293
- form: acceptReviewForm,
294
- to: turnIds.generatePlan,
295
- resolveBodyMarkdown: ({ ctx, input }) => buildAcceptedFollowUpMessage({
296
- kind: "plan_review",
297
- markdown: ctx.readSemanticTurnResultMarkdown("review"),
298
- adjustment: input.message
299
- })
300
- }),
301
- [codingActionIds.requestReviewChanges]: revisionAction({
302
- label: "Request review changes",
303
- description: "Ask the LLM reviewer to revise its plan review.",
304
- acceptanceState: "requires_changes",
305
- form: requestReviewChangesForm,
306
- to: turnIds.reviewPlan,
307
- queueTarget: { semanticRef: "review" }
308
- }),
309
- [codingActionIds.dismissReview]: {
310
- label: "Dismiss review",
311
- description: "Return to the plan decision without applying the review.",
312
- acceptanceState: "neutral",
313
- to: turnIds.planDecision
314
- }
315
- }
316
- });
317
- const implementationDecisionSpec = humanTurn({
318
- description: "Review",
319
- reviewSemanticRef: "currentPrimaryPathLeaf",
320
- notesFields: [
321
- {
322
- id: "message",
323
- label: "Revision notes",
324
- placeholder: "Describe what the next implementation turn should improve",
325
- required: true
326
- }
327
- ],
328
- commentary: "Publish this implementation, request another pass, simplify it, or run an automated review.",
329
- actions: {
330
- [codingActionIds.finalizeChange]: {
331
- label: config.finalizeLabel,
332
- acceptanceState: "accepted",
333
- form: config.finalizeForm,
334
- schedulable: true,
335
- to: turnIds.generateCommitMessage,
336
- effect: ({ ctx }) => ({
337
- state: patchRepositoryChangeState(ctx.state, {
338
- finalization: createEmptyRepositoryChangeFinalizationState(),
339
- clearReviewRefs: true,
340
- clearProductRefs: [products.simplificationPlan]
341
- })
342
- })
343
- },
344
- [codingActionIds.requestRevision]: revisionAction({
345
- label: "Request revision",
346
- acceptanceState: "requires_changes",
347
- form: requestRevisionForm,
348
- schedulable: true,
349
- to: turnIds.implement,
350
- queueTarget: { semanticRef: "currentPrimaryPathLeaf" },
351
- effect: ({ ctx }) => ({
352
- state: clearReviewState(ctx.state)
353
- })
354
- }),
355
- [codingActionIds.simplify]: {
356
- label: "Simplify",
357
- description: "Ask for a focused simplification review before another implementation pass.",
358
- acceptanceState: "neutral",
359
- schedulable: true,
360
- to: turnIds.simplifyImplementation,
361
- effect: ({ ctx }) => {
362
- requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "simplification review");
363
- return { state: clearReviewState(ctx.state) };
364
- }
365
- },
366
- [codingActionIds.runReview]: {
367
- label: "Run automated review",
368
- acceptanceState: "neutral",
369
- schedulable: true,
370
- to: turnIds.reviewImplementation,
371
- effect: ({ ctx }) => {
372
- requireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, "implementation review");
373
- return { state: clearReviewState(ctx.state) };
374
- }
375
- }
376
- }
377
- });
378
- const implementationReviewFeedbackSpec = humanTurn({
379
- description: "Review implementation feedback",
380
- reviewSemanticRef: "review",
381
- notesFields: [
382
- {
383
- id: "message",
384
- label: "Review notes",
385
- placeholder: "Describe how the next implementation review pass should change",
386
- required: true
387
- }
388
- ],
389
- commentary: "Apply this feedback to the next implementation pass, request a revised review, or dismiss it.",
390
- actions: {
391
- [codingActionIds.acceptReview]: acceptedReviewHandoffAction({
392
- label: "Accept review",
393
- acceptanceState: "accepted",
394
- form: acceptReviewForm,
395
- schedulable: true,
396
- to: turnIds.implement,
397
- queueTarget: { semanticRef: "review" },
398
- resolveBodyMarkdown: ({ ctx, input }) => buildAcceptedFollowUpMessage({
399
- kind: "implementation_review",
400
- markdown: ctx.readSemanticTurnResultMarkdown("review"),
401
- adjustment: input.message
402
- }),
403
- effect: ({ ctx }) => ({
404
- state: patchRepositoryChangeState(ctx.state, {
405
- clearProductRefs: [products.simplificationPlan]
406
- })
407
- })
408
- }),
409
- [codingActionIds.requestReviewChanges]: revisionAction({
410
- label: "Request review changes",
411
- acceptanceState: "requires_changes",
412
- form: requestReviewChangesForm,
413
- schedulable: true,
414
- to: turnIds.reviewImplementation,
415
- queueTarget: { semanticRef: "review" }
416
- }),
417
- [codingActionIds.dismissReview]: {
418
- label: "Dismiss review",
419
- acceptanceState: "neutral",
420
- to: turnIds.implementationDecision
421
- }
422
- }
423
- });
424
- const simplificationDecisionSpec = humanTurn({
425
- description: "Review simplification plan",
426
- reviewProduct: products.simplificationPlan,
427
- notesFields: [
428
- {
429
- id: "message",
430
- label: "Simplification notes",
431
- placeholder: "Describe how the simplification plan should change",
432
- required: true
433
- }
434
- ],
435
- commentary: "Apply this simplification plan, request changes to it, or reject it.",
436
- actions: {
437
- [codingActionIds.acceptReview]: acceptedReviewHandoffAction({
438
- label: "Accept simplification plan",
439
- acceptanceState: "accepted",
440
- form: acceptReviewForm,
441
- schedulable: true,
442
- to: turnIds.implement,
443
- queueTarget: { productName: products.simplificationPlan },
444
- resolveBodyMarkdown: ({ ctx, input }) => buildAcceptedFollowUpMessage({
445
- kind: "simplification",
446
- markdown: ctx.readProductTurnResultMarkdown(products.simplificationPlan),
447
- adjustment: input.message
448
- }),
449
- effect: ({ ctx }) => ({
450
- state: patchRepositoryChangeState(ctx.state, {
451
- clearReviewRefs: true
452
- })
453
- })
454
- }),
455
- [codingActionIds.requestReviewChanges]: revisionAction({
456
- label: "Request simplification changes",
457
- acceptanceState: "requires_changes",
458
- form: requestReviewChangesForm,
459
- to: turnIds.simplifyImplementation,
460
- queueTarget: { productName: products.simplificationPlan }
461
- }),
462
- [codingActionIds.dismissReview]: {
463
- label: "Reject simplification plan",
464
- description: "Return to the implementation decision without applying the simplification plan.",
465
- acceptanceState: "neutral",
466
- to: turnIds.implementationDecision,
467
- effect: ({ ctx }) => ({
468
- state: clearReviewState(ctx.state)
469
- })
470
- }
471
- }
472
- });
473
- const generatePlanTurn = flow.llm(turnIds.generatePlan).description("Plan").tools("read", "bash").askQuestions().freshPrimary().buildPrompt(buildGeneratePlanPrompt).outcomeTool(
474
- "plan_saved",
475
- (tool) => tool.description(
476
- "Save the finished plan for review. Its Markdown may include Mermaid diagrams or uploaded images."
477
- ).requiredString("summary", "Short summary of the proposed plan").requiredStringArray(
478
- "acceptanceCriteria",
479
- "Acceptance criteria for the requested repository change"
480
- ).to(turnIds.planDecision).effect(({ ctx, event }) => {
481
- const planRevision = ctx.process.planRevision + 1;
482
- const summary = normalizeMessage(event.params.summary);
483
- const acceptanceCriteria = Array.isArray(event.params.acceptanceCriteria) ? event.params.acceptanceCriteria.filter(
484
- (entry) => typeof entry === "string" && entry.trim() !== ""
485
- ) : [];
486
- const planMarkdown = ctx.output?.content ?? "";
487
- return {
488
- state: clearReviewState(ctx.state),
489
- processPatch: { planRevision },
490
- broadcasts: [
491
- {
492
- type: "plan.updated",
493
- payload: {
494
- planRevision,
495
- reviewState: "awaiting_approval",
496
- approved: false,
497
- summary
498
- }
499
- }
500
- ],
501
- emit: [
502
- {
503
- type: "plan_saved",
504
- data: {
505
- planRevision,
506
- summary,
507
- planMarkdown,
508
- acceptanceCriteria
509
- }
510
- }
511
- ]
512
- };
513
- })
514
- ).publish(products.plan);
515
- const reviewPlanTurn = flow.llm(turnIds.reviewPlan).description("Assess Plan").tools("read", "bash").rootBranchReview().startFromReviewBranch().consume(products.plan).buildPrompt(buildReviewPlanPrompt).outcomeTool(
516
- "no_issues",
517
- (tool) => tool.description(
518
- "Approve the plan and publish the review. Its Markdown may include Mermaid diagrams or uploaded images."
519
- ).to(turnIds.planDecision)
520
- ).outcomeTool(
521
- "request_changes",
522
- (tool) => tool.description(
523
- "Request plan changes and publish actionable feedback. Its Markdown may include Mermaid diagrams or uploaded images."
524
- ).to(turnIds.planReviewFeedback)
525
- ).publish(products.review);
526
- const implementTurn = flow.llm(turnIds.implement).description("Implement").tools(...implementationTurnAvailableTools).freshSeededPrimary().continueFromProductBranch(products.simplificationPlan, {
527
- kind: "semantic_ref",
528
- ref: "review",
529
- fallback: { kind: "session_root" }
530
- }).consume(products.plan).buildPrompt(buildImplementPrompt).publish(products.implementationSummary).to(turnIds.implementationDecision).state(({ ctx }) => clearReviewState(ctx.state));
531
- const reviewImplementationTurn = flow.llm(turnIds.reviewImplementation).description("Assess Implementation").tools("read", "bash").rootBranchReview().startFromReviewBranch().buildPrompt(buildReviewImplementationPrompt).outcomeTool(
532
- "no_issues",
533
- (tool) => tool.description(
534
- "Approve the implementation and publish the review. Its Markdown may include Mermaid diagrams or uploaded images."
535
- ).to(turnIds.implementationDecision)
536
- ).outcomeTool(
537
- "request_changes",
538
- (tool) => tool.description(
539
- "Request implementation changes and publish actionable feedback. Its Markdown may include Mermaid diagrams or uploaded images."
540
- ).to(turnIds.implementationReviewFeedback)
541
- ).publish(products.review);
542
- const simplifyImplementationTurn = flow.llm(turnIds.simplifyImplementation).description("Simplify").tools("read", "bash").rootBranchReview().startFromProductBranch(products.simplificationPlan).buildPrompt(buildSimplifyImplementationPrompt).publish(products.simplificationPlan).to(turnIds.simplificationDecision);
543
- const generateCommitMessageTurn = flow.llm(turnIds.generateCommitMessage).description("Write Commit Message").modelPurpose("process_title_generation").rootBranchReview().startFromRoot().consume(products.plan).buildPrompt(buildGenerateCommitMessagePrompt).publish(products.commitMessage).to(config.publication.entryTurnId).state(
544
- ({ ctx }) => patchRepositoryChangeState(ctx.state, {
545
- finalization: {
546
- ...ctx.state.finalization,
547
- generatedCommitMessage: normalizeGeneratedCommitMessage(ctx.output?.content)
548
- }
549
- })
550
- );
551
- const planFlow = flow.fragment("plan").turn(generatePlanTurn).turn({ id: turnIds.planDecision, definition: planDecisionSpec }).turn(reviewPlanTurn).turn({ id: turnIds.planReviewFeedback, definition: planReviewFeedbackSpec });
552
- const implementationFlow = flow.fragment("implementation").turn(implementTurn).turn({ id: turnIds.implementationDecision, definition: implementationDecisionSpec }).turn(reviewImplementationTurn).turn({
553
- id: turnIds.implementationReviewFeedback,
554
- definition: implementationReviewFeedbackSpec
555
- }).turn(simplifyImplementationTurn).turn({ id: turnIds.simplificationDecision, definition: simplificationDecisionSpec });
556
- const finalizationFlow = flow.fragment("finalization").turn(generateCommitMessageTurn);
557
- const builder = flow.process(config.processId).displayName(config.displayName).entry(turnIds.generatePlan).happyPath(
558
- turnIds.generatePlan,
559
- turnIds.implement,
560
- turnIds.generateCommitMessage,
561
- ...config.publication.happyPath ?? [config.publication.entryTurnId]
562
- ).piConfig({ sessionCwdTemplate: "{{{projectKey}}}" }).codecs({
563
- params: config.paramsCodec,
564
- state: repositoryChangeStateCodec
565
- }).initialState(() => ({
566
- ...createEmptyStructuralProcessState(),
567
- finalization: createEmptyRepositoryChangeFinalizationState(),
568
- extensionState: {}
569
- })).use(planFlow).use(implementationFlow).use(finalizationFlow);
570
- builder.use(config.publication.fragment);
571
- if (config.repositoryCredentials) builder.repositoryCredentials(config.repositoryCredentials);
572
- if (config.launcher) builder.launcher(config.launcher);
573
- const process = builder.define();
574
- const decision = (id) => ({
575
- /** @public */
576
- id,
577
- ...process.turns.get(id)?.definition
578
- });
579
- return {
580
- /** @public */
581
- process,
582
- /** @internal */
583
- planDecision: decision(turnIds.planDecision),
584
- /** @internal */
585
- planReviewFeedback: decision(turnIds.planReviewFeedback),
586
- /** @internal */
587
- implementationDecision: decision(turnIds.implementationDecision),
588
- /** @internal */
589
- implementationReviewFeedback: decision(turnIds.implementationReviewFeedback),
590
- /** @internal */
591
- simplificationDecision: decision(turnIds.simplificationDecision)
592
- };
593
- }
594
-
595
19
  // src/index.ts
596
20
  var manifest = {
597
21
  /** @internal */
@@ -599,11 +23,13 @@ var manifest = {
599
23
  /** @internal */
600
24
  version: "0.1.0"
601
25
  };
602
- var extension = { manifest };
26
+ var extension = { manifest, scopedSettings: codingSettings };
603
27
  var index_default = extension;
604
28
  export {
605
29
  acceptReviewForm,
606
30
  codingActionIds,
31
+ codingPurposes,
32
+ codingSettings,
607
33
  createRepositoryChangeProcess,
608
34
  index_default as default,
609
35
  requestReviewChangesForm,