@leitwerk-dev/coding 0.4.0 → 0.4.2

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 (46) hide show
  1. package/README.md +67 -11
  2. package/dist/{chunk-Q24RPXOA.js → chunk-3WJRJ3Q7.js} +68 -7
  3. package/dist/chunk-3WJRJ3Q7.js.map +1 -0
  4. package/dist/chunk-B3PE6DPF.js +820 -0
  5. package/dist/chunk-B3PE6DPF.js.map +1 -0
  6. package/dist/chunk-E3DB4TIZ.js +49 -0
  7. package/dist/chunk-E3DB4TIZ.js.map +1 -0
  8. package/dist/{chunk-BI45R2FH.js → chunk-QD6FI4HR.js} +1 -1
  9. package/dist/chunk-QD6FI4HR.js.map +1 -0
  10. package/dist/finalization-git-internal.d.ts +6 -0
  11. package/dist/finalization-git-internal.d.ts.map +1 -1
  12. package/dist/finalization-git.js +2 -1
  13. package/dist/index.js +3 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/pull-request-publication-internal.d.ts +8 -0
  16. package/dist/pull-request-publication-internal.d.ts.map +1 -1
  17. package/dist/repository-change-process.d.ts.map +1 -1
  18. package/dist/repository-change-publication.d.ts +16 -3
  19. package/dist/repository-change-publication.d.ts.map +1 -1
  20. package/dist/repository-change-publication.js +283 -69
  21. package/dist/repository-change-publication.js.map +1 -1
  22. package/dist/repository-publication-receipt.d.ts +23 -0
  23. package/dist/repository-publication-receipt.d.ts.map +1 -0
  24. package/dist/repository-rebase/git.d.ts +8 -0
  25. package/dist/repository-rebase/git.d.ts.map +1 -1
  26. package/dist/repository-reconciliation.d.ts +47 -0
  27. package/dist/repository-reconciliation.d.ts.map +1 -0
  28. package/dist/repository-record.d.ts +6 -0
  29. package/dist/repository-record.d.ts.map +1 -0
  30. package/dist/turns/implement.d.ts +1 -1
  31. package/dist/turns/implement.d.ts.map +1 -1
  32. package/dist/turns/implement.js +1 -1
  33. package/package.json +5 -5
  34. package/src/finalization-git-internal.ts +75 -6
  35. package/src/pull-request-publication-internal.ts +3 -2
  36. package/src/repository-change-process.ts +19 -2
  37. package/src/repository-change-publication.ts +243 -57
  38. package/src/repository-publication-receipt.ts +71 -0
  39. package/src/repository-rebase/git.ts +108 -29
  40. package/src/repository-reconciliation.ts +600 -0
  41. package/src/repository-record.ts +14 -0
  42. package/src/turns/implement.ts +4 -1
  43. package/dist/chunk-BI45R2FH.js.map +0 -1
  44. package/dist/chunk-OM2AMDTJ.js +0 -347
  45. package/dist/chunk-OM2AMDTJ.js.map +0 -1
  46. package/dist/chunk-Q24RPXOA.js.map +0 -1
@@ -1,347 +0,0 @@
1
- import {
2
- buildRepositoryCommitMessagesPrompt,
3
- parseRepositoryCommitMessages
4
- } from "./chunk-DNG7D77K.js";
5
- import {
6
- buildGeneratePlanPrompt
7
- } from "./chunk-ABQH2WZT.js";
8
- import {
9
- buildImplementPrompt
10
- } from "./chunk-BI45R2FH.js";
11
- import {
12
- buildStreamlinedSimplificationPrompt
13
- } from "./chunk-SKGB4CZS.js";
14
- import {
15
- codingPurposes,
16
- prepareRepositoryCommitMessageEvidence
17
- } from "./chunk-M2VTUPFO.js";
18
-
19
- // src/actions.ts
20
- var codingActionIds = {
21
- /** @public */
22
- approvePlan: "approve_plan",
23
- /** @internal */
24
- requestRevision: "request_revision",
25
- /** @internal */
26
- runReview: "run_review",
27
- /** @internal */
28
- simplify: "simplify",
29
- /** @internal */
30
- acceptReview: "accept_review",
31
- /** @internal */
32
- requestReviewChanges: "request_review_changes",
33
- /** @internal */
34
- dismissReview: "dismiss_review",
35
- /** @public */
36
- finalizeChange: "finalize_change"
37
- };
38
- function notesForm(id, title, label, description) {
39
- return {
40
- id,
41
- title,
42
- fields: [
43
- { id: "message", label, kind: "textarea", primaryPrompt: true, required: true, description }
44
- ],
45
- submitLabel: title
46
- };
47
- }
48
- var requestRevisionForm = notesForm(
49
- codingActionIds.requestRevision,
50
- "Request revision",
51
- "Revision notes",
52
- "Instructions for the next implementation pass."
53
- );
54
- var requestReviewChangesForm = notesForm(
55
- codingActionIds.requestReviewChanges,
56
- "Request review changes",
57
- "Review notes",
58
- "Instructions for the next review pass."
59
- );
60
- var acceptReviewForm = {
61
- id: codingActionIds.acceptReview,
62
- title: "Accept review",
63
- fields: [
64
- {
65
- id: "message",
66
- label: "Review adjustment",
67
- kind: "textarea",
68
- primaryPrompt: true,
69
- description: "Optional instructions to apply with the accepted review, such as dropping one finding."
70
- }
71
- ],
72
- submitLabel: "Accept review"
73
- };
74
-
75
- // src/repository-change-process.ts
76
- import { trimString as normalizeMessage } from "@leitwerk-dev/domain";
77
- import {
78
- flow,
79
- humanTurn,
80
- revisionAction
81
- } from "@leitwerk-dev/process-sdk";
82
-
83
- // src/repository-change-state-internal.ts
84
- import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
85
- function toRecord(value) {
86
- return typeof value === "object" && value !== null ? value : {};
87
- }
88
- function parseFinalizationState(value) {
89
- const record = toRecord(value);
90
- return {
91
- generatedCommitMessage: typeof record.generatedCommitMessage === "string" ? record.generatedCommitMessage : null,
92
- ...record.commitMessages ? {
93
- commitMessages: Object.fromEntries(
94
- Object.entries(toRecord(record.commitMessages)).filter(
95
- (entry) => typeof entry[1] === "string"
96
- )
97
- )
98
- } : {}
99
- };
100
- }
101
- var repositoryChangeStateCodec = {
102
- parse(value) {
103
- const record = toRecord(value);
104
- return {
105
- ...parseStructuralProcessState(record),
106
- finalization: parseFinalizationState(record.finalization),
107
- extensionState: toRecord(record.extensionState),
108
- routing: toRecord(record.routing)
109
- };
110
- },
111
- serialize(value) {
112
- return value;
113
- }
114
- };
115
-
116
- // src/repository-change-process.ts
117
- function createRepositoryChangeProcess(config) {
118
- const tools = ["read", "bash", "edit", "write"];
119
- const planDecision = humanTurn({
120
- description: "Review Plan",
121
- reviewSemanticRef: "plan",
122
- notesFields: [
123
- {
124
- id: "message",
125
- label: "Revision notes",
126
- placeholder: "Describe what the next plan revision should improve",
127
- required: true
128
- }
129
- ],
130
- commentary: "Approve this plan or request a revision with comments.",
131
- actions: {
132
- [codingActionIds.approvePlan]: {
133
- label: "Approve plan",
134
- description: "Accept the current plan and continue into implementation.",
135
- acceptanceState: "accepted",
136
- to: "implement",
137
- effect: ({ ctx }) => {
138
- if (!ctx.state.semanticEntryRefs.plan?.turnRecordId?.trim())
139
- throw new Error("No plan is available for approval");
140
- return {
141
- emit: [
142
- {
143
- type: "plan_approved",
144
- data: {
145
- externalId: ctx.process.externalId,
146
- planRevision: ctx.process.planRevision
147
- }
148
- }
149
- ]
150
- };
151
- }
152
- },
153
- [codingActionIds.requestRevision]: revisionAction({
154
- label: "Request revision",
155
- description: "Send the plan back for another draft revision.",
156
- acceptanceState: "requires_changes",
157
- form: requestRevisionForm,
158
- schedulable: true,
159
- to: "generate_plan",
160
- queueTarget: { semanticRef: "currentPrimaryPathLeaf" },
161
- effect: ({ input }) => ({
162
- emit: [
163
- { type: "plan_revision_requested", data: { message: normalizeMessage(input.message) } }
164
- ]
165
- })
166
- })
167
- }
168
- });
169
- if (config.workflow?.planBypassSource)
170
- planDecision.externalActions = {
171
- bypass_plan: {
172
- id: "bypass_plan",
173
- label: "Skip plan approval",
174
- source: config.workflow.planBypassSource,
175
- to: "implement",
176
- effect: ({ state, process, event }) => {
177
- if (event.planRevision !== process.planRevision)
178
- throw new Error("Stale plan bypass event");
179
- return {
180
- state: {
181
- ...state,
182
- routing: {
183
- ...state.routing,
184
- plan: { planRevision: process.planRevision, skip: true, reason: "Jira label" }
185
- }
186
- },
187
- emit: [
188
- {
189
- type: "plan_approved",
190
- data: {
191
- planRevision: process.planRevision,
192
- actor: "system",
193
- bypassed: true,
194
- reason: "Jira label"
195
- }
196
- }
197
- ]
198
- };
199
- }
200
- }
201
- };
202
- const generatePlan = flow.llm("generate_plan").description("Plan").executionPurpose(codingPurposes.planning).tools("read", "bash").askQuestions().freshPrimary().buildPrompt(buildGeneratePlanPrompt).outcomeTool(
203
- "plan_saved",
204
- (tool) => tool.description(
205
- "Save a finished, implementable plan after resolving design-critical questions. Required investigation and access must be complete. If blocked, use abort_turn. Use ask_questions for operator decisions when available; otherwise decide within the requested scope and document assumptions."
206
- ).requiredString("summary", "One concise sentence summarizing the proposed plan").requiredStringArray(
207
- "acceptanceCriteria",
208
- "Requested outcomes for the repository change, without expanding scope"
209
- ).routeByState(
210
- {
211
- approval: {
212
- to: "plan_decision",
213
- label: "Approval required",
214
- description: "When the process policy requires an operator to approve the saved plan."
215
- },
216
- bypass: {
217
- to: "implement",
218
- label: "Skip plan approval",
219
- description: "When the process policy skips plan approval, for example through the Skip plan approval launcher option."
220
- }
221
- },
222
- ({ ctx }) => ctx.state.routing?.plan?.skip ? "bypass" : "approval"
223
- ).effect(async ({ ctx, event }) => {
224
- const planRevision = ctx.process.planRevision + 1;
225
- const policy = await config.workflow?.planDecision?.(ctx.params).catch(() => ({ skip: false, reason: "Source unavailable; approval required" })) ?? {
226
- skip: false,
227
- reason: "Human approval required"
228
- };
229
- const summary = normalizeMessage(event.params.summary);
230
- const acceptanceCriteria = Array.isArray(event.params.acceptanceCriteria) ? event.params.acceptanceCriteria.filter(
231
- (entry) => typeof entry === "string" && entry.trim() !== ""
232
- ) : [];
233
- return {
234
- state: {
235
- ...ctx.state,
236
- routing: { ...ctx.state.routing, plan: { ...policy, planRevision } }
237
- },
238
- processPatch: { planRevision },
239
- broadcasts: [
240
- {
241
- type: "plan.updated",
242
- payload: {
243
- planRevision,
244
- reviewState: policy.skip ? "accepted" : "awaiting_approval",
245
- approved: policy.skip,
246
- summary
247
- }
248
- }
249
- ],
250
- emit: [
251
- ...policy.skip ? [
252
- {
253
- type: "plan_approved",
254
- data: {
255
- planRevision,
256
- actor: "system",
257
- bypassed: true,
258
- reason: policy.reason
259
- }
260
- }
261
- ] : [],
262
- {
263
- type: "plan_saved",
264
- data: {
265
- planRevision,
266
- summary,
267
- planMarkdown: ctx.output?.content ?? "",
268
- acceptanceCriteria
269
- }
270
- }
271
- ]
272
- };
273
- })
274
- ).publish("plan");
275
- const implement = flow.llm("implement").description("Implement").waitFor(({ state }) => !!state.productRefs.plan).executionPurpose(codingPurposes.implementation).tools(...tools).freshSeededPrimary().startFromRoot().consume("plan").buildPrompt(buildImplementPrompt).outcomeTool(
276
- "implementation_ready",
277
- (tool) => tool.description("Implementation and checks are complete; continue to delivery").routeByState(
278
- {
279
- simplify: {
280
- to: "simplify_implementation",
281
- label: "Simplification enabled",
282
- description: "When the process policy enables simplification. This is the default unless a launcher option or source policy skips it."
283
- },
284
- skip: {
285
- to: "generate_commit_message",
286
- label: "Skip simplification",
287
- description: "When simplification is skipped, for example through the Skip simplification launcher option or the leitwerk-skip-simplification source label."
288
- }
289
- },
290
- ({ ctx }) => ctx.state.routing?.simplification?.skip ? "skip" : "simplify"
291
- ).effect(async ({ ctx }) => ({
292
- state: {
293
- ...ctx.state,
294
- routing: {
295
- ...ctx.state.routing,
296
- simplification: ctx.state.routing?.simplification ?? await config.workflow?.simplification?.(ctx.params) ?? {
297
- skip: false,
298
- reason: "Simplification enabled by default"
299
- }
300
- }
301
- }
302
- }))
303
- ).publish("implementation-summary");
304
- const simplify = flow.llm("simplify_implementation").description("Simplify").executionPurpose(codingPurposes.review).tools("read", "bash").rootBranchReview().startFromProductBranch("simplification-plan").buildPrompt(buildStreamlinedSimplificationPrompt).publish("simplification-plan").to("apply_simplification");
305
- const applySimplification = flow.llm("apply_simplification").description("Apply simplification").executionPurpose(codingPurposes.implementation).tools(...tools).freshSeededPrimary().consume("plan").consume("simplification-plan").buildPrompt(
306
- (ctx) => `Apply justified simplifications to each repository, preserving the accepted plan and behavior. Rerun the required checks. Empty findings require no edits. Leave changes uncommitted for delivery.
307
-
308
- Accepted plan:
309
- ${ctx.input.plan}
310
-
311
- Findings by repository:
312
- ${ctx.input["simplification-plan"]}`
313
- ).publish("implementation-summary").to("generate_commit_message");
314
- const generateCommitMessage = flow.llm("generate_commit_message").description("Write Commit Message").executionPurpose(codingPurposes.implementation).tools("read", "grep", "find", "ls").rootBranchReview().startFromRoot().consume("plan").consume("implementation-summary").prepare(prepareRepositoryCommitMessageEvidence).buildPrompt(buildRepositoryCommitMessagesPrompt).publish("commit-message").to(config.publication.entryTurnId).state(({ ctx }) => ({
315
- ...ctx.state,
316
- finalization: {
317
- ...ctx.state.finalization,
318
- commitMessages: parseRepositoryCommitMessages(
319
- ctx.output?.content,
320
- ctx.projects.map((p) => p.key)
321
- )
322
- }
323
- }));
324
- const builder = flow.process(config.processId).displayName(config.displayName).entry("generate_plan").happyPath(
325
- "generate_plan",
326
- "implement",
327
- "simplify_implementation",
328
- "apply_simplification",
329
- "generate_commit_message",
330
- ...config.publication.happyPath ?? [config.publication.entryTurnId]
331
- ).piConfig(config.workflow?.multiRepository ? {} : { sessionCwdTemplate: "{{{projectKey}}}" }).codecs({ params: config.paramsCodec, state: repositoryChangeStateCodec }).initialState(() => repositoryChangeStateCodec.parse({})).turn(generatePlan).turn({ id: "plan_decision", definition: planDecision }).turn(implement).turn(simplify).turn(applySimplification).turn(generateCommitMessage).use(config.publication.fragment);
332
- if (config.repositoryCredentials) builder.repositoryCredentials(config.repositoryCredentials);
333
- if (config.launcher) builder.launcher(config.launcher);
334
- return {
335
- /** @public */
336
- process: builder.define()
337
- };
338
- }
339
-
340
- export {
341
- codingActionIds,
342
- requestRevisionForm,
343
- requestReviewChangesForm,
344
- acceptReviewForm,
345
- createRepositoryChangeProcess
346
- };
347
- //# sourceMappingURL=chunk-OM2AMDTJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/actions.ts","../src/repository-change-process.ts","../src/repository-change-state-internal.ts"],"sourcesContent":["import type { FormDefinition } from \"@leitwerk-dev/process-sdk\";\n\n/** @public */\nexport const codingActionIds = {\n\t/** @public */\n\tapprovePlan: \"approve_plan\",\n\t/** @internal */\n\trequestRevision: \"request_revision\",\n\t/** @internal */\n\trunReview: \"run_review\",\n\t/** @internal */\n\tsimplify: \"simplify\",\n\t/** @internal */\n\tacceptReview: \"accept_review\",\n\t/** @internal */\n\trequestReviewChanges: \"request_review_changes\",\n\t/** @internal */\n\tdismissReview: \"dismiss_review\",\n\t/** @public */\n\tfinalizeChange: \"finalize_change\",\n} as const;\n\nfunction notesForm(id: string, title: string, label: string, description: string): FormDefinition {\n\treturn {\n\t\tid,\n\t\ttitle,\n\t\tfields: [\n\t\t\t{ id: \"message\", label, kind: \"textarea\", primaryPrompt: true, required: true, description },\n\t\t],\n\t\tsubmitLabel: title,\n\t};\n}\n\n/** @internal */\nexport const requestRevisionForm = notesForm(\n\tcodingActionIds.requestRevision,\n\t\"Request revision\",\n\t\"Revision notes\",\n\t\"Instructions for the next implementation pass.\",\n);\n/** @internal */\nexport const requestReviewChangesForm = notesForm(\n\tcodingActionIds.requestReviewChanges,\n\t\"Request review changes\",\n\t\"Review notes\",\n\t\"Instructions for the next review pass.\",\n);\n/** @internal */\nexport const acceptReviewForm: FormDefinition = {\n\tid: codingActionIds.acceptReview,\n\ttitle: \"Accept review\",\n\tfields: [\n\t\t{\n\t\t\tid: \"message\",\n\t\t\tlabel: \"Review adjustment\",\n\t\t\tkind: \"textarea\",\n\t\t\tprimaryPrompt: true,\n\t\t\tdescription:\n\t\t\t\t\"Optional instructions to apply with the accepted review, such as dropping one finding.\",\n\t\t},\n\t],\n\tsubmitLabel: \"Accept review\",\n};\n","import { trimString as normalizeMessage } from \"@leitwerk-dev/domain\";\nimport {\n\ttype Codec,\n\ttype ExternalActionSource,\n\ttype FlowFragmentBuilder,\n\ttype FormDefinition,\n\tflow,\n\thumanTurn,\n\ttype ProcessLauncherDefinition,\n\ttype RepositoryCredentialProject,\n\ttype RepositoryCredentialRequirement,\n\trevisionAction,\n} from \"@leitwerk-dev/process-sdk\";\nimport { codingActionIds, requestRevisionForm } from \"./actions.js\";\nimport {\n\ttype RepositoryChangeState,\n\trepositoryChangeStateCodec,\n} from \"./repository-change-state-internal.js\";\nimport { codingPurposes } from \"./settings.js\";\nimport { prepareRepositoryCommitMessageEvidence } from \"./turns/commit-message-evidence.js\";\nimport {\n\tbuildRepositoryCommitMessagesPrompt,\n\tparseRepositoryCommitMessages,\n} from \"./turns/generate-commit-message.js\";\nimport { buildGeneratePlanPrompt } from \"./turns/generate-plan.js\";\nimport { buildImplementPrompt } from \"./turns/implement.js\";\nimport { buildStreamlinedSimplificationPrompt } from \"./turns/simplify-implementation.js\";\n\n/** @public */\nexport type RepositoryChangeParams = object;\n\n/** Server-side policies evaluated at the route boundary. @public */\nexport interface RepositoryChangeWorkflow<TParams> {\n\t/** @deprecated All repository changes use the streamlined graph. @public */\n\tvariant?: \"streamlined\";\n\t/** @public */\n\tmultiRepository?: boolean;\n\t/** @public */\n\tplanDecision?(params: TParams): Promise<{\n\t\t/** @internal */\n\t\tskip: boolean;\n\t\t/** @internal */\n\t\treason: string;\n\t}>;\n\t/** @public */\n\tsimplification?(params: TParams): Promise<{\n\t\t/** @internal */\n\t\tskip: boolean;\n\t\t/** @internal */\n\t\treason: string;\n\t}>;\n\t/** Must recheck the current revision and source before firing. @public */\n\tplanBypassSource?: ExternalActionSource<TParams, RepositoryChangeState, unknown>;\n}\n\n/** @public */\nexport interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeParams> {\n\t/** @public */\n\tprocessId: string;\n\t/** @public */\n\tdisplayName: string;\n\t/** @public */\n\tworkflow?: RepositoryChangeWorkflow<TParams>;\n\t/** @public */\n\tparamsCodec: Codec<TParams>;\n\t/** @public */\n\tlauncher?: ProcessLauncherDefinition<TParams>;\n\t/** @deprecated Publication follows implementation automatically. @public */\n\tfinalizeLabel?: string;\n\t/** @deprecated Publication follows implementation automatically. @public */\n\tfinalizeForm?: FormDefinition;\n\t/** @public */\n\trepositoryCredentials?(input: {\n\t\t/** @public */\n\t\tparams: TParams;\n\t\t/** @internal */\n\t\tprojects: readonly RepositoryCredentialProject[];\n\t}): readonly RepositoryCredentialRequirement[];\n\t/** @public */\n\tpublication: {\n\t\t/** @public */\n\t\tentryTurnId: string;\n\t\t/** @public */\n\t\tfragment: FlowFragmentBuilder<TParams, RepositoryChangeState>;\n\t\t/** @public */\n\t\thappyPath?: readonly string[];\n\t};\n}\n\n/** @public */\nexport function createRepositoryChangeProcess<TParams extends RepositoryChangeParams>(\n\tconfig: RepositoryChangeProcessConfig<TParams>,\n) {\n\tconst tools = [\"read\", \"bash\", \"edit\", \"write\"] as const;\n\tconst planDecision = humanTurn<TParams, RepositoryChangeState>({\n\t\tdescription: \"Review Plan\",\n\t\treviewSemanticRef: \"plan\",\n\t\tnotesFields: [\n\t\t\t{\n\t\t\t\tid: \"message\",\n\t\t\t\tlabel: \"Revision notes\",\n\t\t\t\tplaceholder: \"Describe what the next plan revision should improve\",\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcommentary: \"Approve this plan or request a revision with comments.\",\n\t\tactions: {\n\t\t\t[codingActionIds.approvePlan]: {\n\t\t\t\tlabel: \"Approve plan\",\n\t\t\t\tdescription: \"Accept the current plan and continue into implementation.\",\n\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\tto: \"implement\",\n\t\t\t\teffect: ({ ctx }) => {\n\t\t\t\t\tif (!ctx.state.semanticEntryRefs.plan?.turnRecordId?.trim())\n\t\t\t\t\t\tthrow new Error(\"No plan is available for approval\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\temit: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan_approved\",\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\texternalId: ctx.process.externalId,\n\t\t\t\t\t\t\t\t\tplanRevision: ctx.process.planRevision,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t\t[codingActionIds.requestRevision]: revisionAction({\n\t\t\t\tlabel: \"Request revision\",\n\t\t\t\tdescription: \"Send the plan back for another draft revision.\",\n\t\t\t\tacceptanceState: \"requires_changes\",\n\t\t\t\tform: requestRevisionForm,\n\t\t\t\tschedulable: true,\n\t\t\t\tto: \"generate_plan\",\n\t\t\t\tqueueTarget: { semanticRef: \"currentPrimaryPathLeaf\" },\n\t\t\t\teffect: ({ input }) => ({\n\t\t\t\t\temit: [\n\t\t\t\t\t\t{ type: \"plan_revision_requested\", data: { message: normalizeMessage(input.message) } },\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t}),\n\t\t},\n\t});\n\tif (config.workflow?.planBypassSource)\n\t\tplanDecision.externalActions = {\n\t\t\tbypass_plan: {\n\t\t\t\tid: \"bypass_plan\",\n\t\t\t\tlabel: \"Skip plan approval\",\n\t\t\t\tsource: config.workflow.planBypassSource,\n\t\t\t\tto: \"implement\",\n\t\t\t\teffect: ({ state, process, event }) => {\n\t\t\t\t\tif ((event as { planRevision?: number }).planRevision !== process.planRevision)\n\t\t\t\t\t\tthrow new Error(\"Stale plan bypass event\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\t\t...state.routing,\n\t\t\t\t\t\t\t\tplan: { planRevision: process.planRevision, skip: true, reason: \"Jira label\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\temit: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan_approved\" as const,\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\tplanRevision: process.planRevision,\n\t\t\t\t\t\t\t\t\tactor: \"system\",\n\t\t\t\t\t\t\t\t\tbypassed: true,\n\t\t\t\t\t\t\t\t\treason: \"Jira label\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\tconst generatePlan = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"generate_plan\")\n\t\t.description(\"Plan\")\n\t\t.executionPurpose(codingPurposes.planning)\n\t\t.tools(\"read\", \"bash\")\n\t\t.askQuestions()\n\t\t.freshPrimary()\n\t\t.buildPrompt(buildGeneratePlanPrompt)\n\t\t.outcomeTool(\"plan_saved\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\n\t\t\t\t\t\"Save a finished, implementable plan after resolving design-critical questions. Required investigation and access must be complete. If blocked, use abort_turn. Use ask_questions for operator decisions when available; otherwise decide within the requested scope and document assumptions.\",\n\t\t\t\t)\n\t\t\t\t.requiredString(\"summary\", \"One concise sentence summarizing the proposed plan\")\n\t\t\t\t.requiredStringArray(\n\t\t\t\t\t\"acceptanceCriteria\",\n\t\t\t\t\t\"Requested outcomes for the repository change, without expanding scope\",\n\t\t\t\t)\n\t\t\t\t.routeByState(\n\t\t\t\t\t{\n\t\t\t\t\t\tapproval: {\n\t\t\t\t\t\t\tto: \"plan_decision\",\n\t\t\t\t\t\t\tlabel: \"Approval required\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When the process policy requires an operator to approve the saved plan.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbypass: {\n\t\t\t\t\t\t\tto: \"implement\",\n\t\t\t\t\t\t\tlabel: \"Skip plan approval\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When the process policy skips plan approval, for example through the Skip plan approval launcher option.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t({ ctx }) => (ctx.state.routing?.plan?.skip ? \"bypass\" : \"approval\"),\n\t\t\t\t)\n\t\t\t\t.effect(async ({ ctx, event }) => {\n\t\t\t\t\tconst planRevision = ctx.process.planRevision + 1;\n\t\t\t\t\tconst policy = (await config.workflow\n\t\t\t\t\t\t?.planDecision?.(ctx.params)\n\t\t\t\t\t\t.catch(() => ({ skip: false, reason: \"Source unavailable; approval required\" }))) ?? {\n\t\t\t\t\t\tskip: false,\n\t\t\t\t\t\treason: \"Human approval required\",\n\t\t\t\t\t};\n\t\t\t\t\tconst summary = normalizeMessage(event.params.summary);\n\t\t\t\t\tconst acceptanceCriteria = Array.isArray(event.params.acceptanceCriteria)\n\t\t\t\t\t\t? event.params.acceptanceCriteria.filter(\n\t\t\t\t\t\t\t\t(entry): entry is string => typeof entry === \"string\" && entry.trim() !== \"\",\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: [];\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t...ctx.state,\n\t\t\t\t\t\t\trouting: { ...ctx.state.routing, plan: { ...policy, planRevision } },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tprocessPatch: { planRevision },\n\t\t\t\t\t\tbroadcasts: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan.updated\",\n\t\t\t\t\t\t\t\tpayload: {\n\t\t\t\t\t\t\t\t\tplanRevision,\n\t\t\t\t\t\t\t\t\treviewState: policy.skip ? \"accepted\" : \"awaiting_approval\",\n\t\t\t\t\t\t\t\t\tapproved: policy.skip,\n\t\t\t\t\t\t\t\t\tsummary,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\temit: [\n\t\t\t\t\t\t\t...(policy.skip\n\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ttype: \"plan_approved\" as const,\n\t\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\t\tplanRevision,\n\t\t\t\t\t\t\t\t\t\t\t\tactor: \"system\",\n\t\t\t\t\t\t\t\t\t\t\t\tbypassed: true,\n\t\t\t\t\t\t\t\t\t\t\t\treason: policy.reason,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"plan_saved\",\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\tplanRevision,\n\t\t\t\t\t\t\t\t\tsummary,\n\t\t\t\t\t\t\t\t\tplanMarkdown: ctx.output?.content ?? \"\",\n\t\t\t\t\t\t\t\t\tacceptanceCriteria,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t)\n\t\t.publish(\"plan\");\n\tconst implement = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"implement\")\n\t\t.description(\"Implement\")\n\t\t.waitFor(({ state }) => !!state.productRefs.plan)\n\t\t.executionPurpose(codingPurposes.implementation)\n\t\t.tools(...tools)\n\t\t.freshSeededPrimary()\n\t\t.startFromRoot()\n\t\t.consume(\"plan\")\n\t\t.buildPrompt(buildImplementPrompt)\n\t\t.outcomeTool(\"implementation_ready\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\"Implementation and checks are complete; continue to delivery\")\n\t\t\t\t.routeByState(\n\t\t\t\t\t{\n\t\t\t\t\t\tsimplify: {\n\t\t\t\t\t\t\tto: \"simplify_implementation\",\n\t\t\t\t\t\t\tlabel: \"Simplification enabled\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When the process policy enables simplification. This is the default unless a launcher option or source policy skips it.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tskip: {\n\t\t\t\t\t\t\tto: \"generate_commit_message\",\n\t\t\t\t\t\t\tlabel: \"Skip simplification\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"When simplification is skipped, for example through the Skip simplification launcher option or the leitwerk-skip-simplification source label.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t({ ctx }) => (ctx.state.routing?.simplification?.skip ? \"skip\" : \"simplify\"),\n\t\t\t\t)\n\t\t\t\t.effect(async ({ ctx }) => ({\n\t\t\t\t\tstate: {\n\t\t\t\t\t\t...ctx.state,\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\t...ctx.state.routing,\n\t\t\t\t\t\t\tsimplification: ctx.state.routing?.simplification ??\n\t\t\t\t\t\t\t\t(await config.workflow?.simplification?.(ctx.params)) ?? {\n\t\t\t\t\t\t\t\t\tskip: false,\n\t\t\t\t\t\t\t\t\treason: \"Simplification enabled by default\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t)\n\t\t.publish(\"implementation-summary\");\n\tconst simplify = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"simplify_implementation\")\n\t\t.description(\"Simplify\")\n\t\t.executionPurpose(codingPurposes.review)\n\t\t.tools(\"read\", \"bash\")\n\t\t.rootBranchReview()\n\t\t.startFromProductBranch(\"simplification-plan\")\n\t\t.buildPrompt(buildStreamlinedSimplificationPrompt)\n\t\t.publish(\"simplification-plan\")\n\t\t.to(\"apply_simplification\");\n\tconst applySimplification = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"apply_simplification\")\n\t\t.description(\"Apply simplification\")\n\t\t.executionPurpose(codingPurposes.implementation)\n\t\t.tools(...tools)\n\t\t.freshSeededPrimary()\n\t\t.consume(\"plan\")\n\t\t.consume(\"simplification-plan\")\n\t\t.buildPrompt(\n\t\t\t(\n\t\t\t\tctx,\n\t\t\t) => `Apply justified simplifications to each repository, preserving the accepted plan and behavior. Rerun the required checks. Empty findings require no edits. Leave changes uncommitted for delivery.\n\nAccepted plan:\n${ctx.input.plan}\n\nFindings by repository:\n${ctx.input[\"simplification-plan\"]}`,\n\t\t)\n\t\t.publish(\"implementation-summary\")\n\t\t.to(\"generate_commit_message\");\n\tconst generateCommitMessage = flow\n\t\t.llm<TParams, RepositoryChangeState>(\"generate_commit_message\")\n\t\t.description(\"Write Commit Message\")\n\t\t.executionPurpose(codingPurposes.implementation)\n\t\t.tools(\"read\", \"grep\", \"find\", \"ls\")\n\t\t.rootBranchReview()\n\t\t.startFromRoot()\n\t\t.consume(\"plan\")\n\t\t.consume(\"implementation-summary\")\n\t\t.prepare(prepareRepositoryCommitMessageEvidence)\n\t\t.buildPrompt(buildRepositoryCommitMessagesPrompt)\n\t\t.publish(\"commit-message\")\n\t\t.to(config.publication.entryTurnId)\n\t\t.state(({ ctx }) => ({\n\t\t\t...ctx.state,\n\t\t\tfinalization: {\n\t\t\t\t...ctx.state.finalization,\n\t\t\t\tcommitMessages: parseRepositoryCommitMessages(\n\t\t\t\t\tctx.output?.content,\n\t\t\t\t\tctx.projects.map((p) => p.key),\n\t\t\t\t),\n\t\t\t},\n\t\t}));\n\tconst builder = flow\n\t\t.process<TParams, RepositoryChangeState>(config.processId)\n\t\t.displayName(config.displayName)\n\t\t.entry(\"generate_plan\")\n\t\t.happyPath(\n\t\t\t\"generate_plan\",\n\t\t\t\"implement\",\n\t\t\t\"simplify_implementation\",\n\t\t\t\"apply_simplification\",\n\t\t\t\"generate_commit_message\",\n\t\t\t...(config.publication.happyPath ?? [config.publication.entryTurnId]),\n\t\t)\n\t\t.piConfig(config.workflow?.multiRepository ? {} : { sessionCwdTemplate: \"{{{projectKey}}}\" })\n\t\t.codecs({ params: config.paramsCodec, state: repositoryChangeStateCodec })\n\t\t.initialState(() => repositoryChangeStateCodec.parse({}))\n\t\t.turn(generatePlan)\n\t\t.turn({ id: \"plan_decision\", definition: planDecision })\n\t\t.turn(implement)\n\t\t.turn(simplify)\n\t\t.turn(applySimplification)\n\t\t.turn(generateCommitMessage)\n\t\t.use(config.publication.fragment);\n\tif (config.repositoryCredentials) builder.repositoryCredentials(config.repositoryCredentials);\n\tif (config.launcher) builder.launcher(config.launcher);\n\treturn {\n\t\t/** @public */\n\t\tprocess: builder.define(),\n\t};\n}\n","import type { Codec, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\nimport { parseStructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @public */\nexport interface RepositoryChangeFinalizationState {\n\t/** @public */\n\tgeneratedCommitMessage: string | null;\n\t/** Messages keyed by process project key. @public */\n\tcommitMessages?: Record<string, string>;\n}\n\n/** @public */\nexport interface RepositoryChangeState extends StructuralProcessState {\n\t/** @public */\n\tfinalization: RepositoryChangeFinalizationState;\n\t/** Completed routing decisions survive recovery. @public */\n\trouting?: {\n\t\t/** @public */\n\t\tplan?: {\n\t\t\t/** @internal */\n\t\t\tplanRevision: number;\n\t\t\t/** @internal */ skip: boolean;\n\t\t\t/** @internal */ reason: string;\n\t\t};\n\n\t\t/** @public */\n\t\tsimplification?: {\n\t\t\t/** @internal */\n\t\t\tskip: boolean;\n\t\t\t/** @internal */ reason: string;\n\t\t};\n\t};\n\t/** Namespaced state owned by a caller-supplied publication workflow. */\n\n\t/** @public */\n\textensionState?: Record<string, unknown>;\n}\n\nfunction toRecord(value: unknown): Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null ? (value as Record<string, unknown>) : {};\n}\n\nfunction parseFinalizationState(value: unknown): RepositoryChangeFinalizationState {\n\tconst record = toRecord(value);\n\treturn {\n\t\tgeneratedCommitMessage:\n\t\t\ttypeof record.generatedCommitMessage === \"string\" ? record.generatedCommitMessage : null,\n\t\t...(record.commitMessages\n\t\t\t? {\n\t\t\t\t\tcommitMessages: Object.fromEntries(\n\t\t\t\t\t\tObject.entries(toRecord(record.commitMessages)).filter(\n\t\t\t\t\t\t\t(entry): entry is [string, string] => typeof entry[1] === \"string\",\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/** @internal */\nexport const repositoryChangeStateCodec: Codec<RepositoryChangeState> = {\n\tparse(value) {\n\t\tconst record = toRecord(value);\n\t\treturn {\n\t\t\t...parseStructuralProcessState(record),\n\t\t\tfinalization: parseFinalizationState(record.finalization),\n\t\t\textensionState: toRecord(record.extensionState),\n\t\t\trouting: toRecord(record.routing) as RepositoryChangeState[\"routing\"],\n\t\t};\n\t},\n\tserialize(value) {\n\t\treturn value;\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAGO,IAAM,kBAAkB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IACA;AAAA,IACA;AAAA,IACA,GAAI,OAAO,YAAY,aAAa,CAAC,OAAO,YAAY,WAAW;AAAA,EACpE,EACC,SAAS,OAAO,UAAU,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,mBAAmB,CAAC,EAC3F,OAAO,EAAE,QAAQ,OAAO,aAAa,OAAO,2BAA2B,CAAC,EACxE,aAAa,MAAM,2BAA2B,MAAM,CAAC,CAAC,CAAC,EACvD,KAAK,YAAY,EACjB,KAAK,EAAE,IAAI,iBAAiB,YAAY,aAAa,CAAC,EACtD,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,IAAI,OAAO,YAAY,QAAQ;AACjC,MAAI,OAAO,sBAAuB,SAAQ,sBAAsB,OAAO,qBAAqB;AAC5F,MAAI,OAAO,SAAU,SAAQ,SAAS,OAAO,QAAQ;AACrD,SAAO;AAAA;AAAA,IAEN,SAAS,QAAQ,OAAO;AAAA,EACzB;AACD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/finalization-git-internal.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { trimToNull, type WorkerErrorClass } from \"@leitwerk-dev/domain\";\nimport { repositoryGitArgs, repositoryGitSubprocessEnv } from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\n\n/** @public */\nexport interface GitIdentity {\n\t/** @public */\n\tname: string;\n\t/** @public */\n\temail: string;\n}\n\n/** @internal */\nexport class DeterministicGitError extends Error {\n\t/** @internal */\n\treadonly errorClass: WorkerErrorClass = \"git_error\";\n\n\t/** @internal */\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"DeterministicGitError\";\n\t}\n}\n\ninterface GitExecResult {\n\tok: boolean;\n\tstdout: string;\n\tstderr: string;\n}\n\nfunction gitConfigIdentityEnv(projectKey: string): NodeJS.ProcessEnv {\n\tconst env = repositoryGitSubprocessEnv(projectKey, { GIT_TERMINAL_PROMPT: \"0\" });\n\tfor (const key of [\n\t\t\"GIT_AUTHOR_NAME\",\n\t\t\"GIT_AUTHOR_EMAIL\",\n\t\t\"GIT_AUTHOR_DATE\",\n\t\t\"GIT_COMMITTER_NAME\",\n\t\t\"GIT_COMMITTER_EMAIL\",\n\t\t\"GIT_COMMITTER_DATE\",\n\t])\n\t\tdelete env[key];\n\treturn env;\n}\n\nfunction gitIdentityArgs(identity: GitIdentity): string[] {\n\tconst name = trimToNull(identity.name);\n\tconst email = trimToNull(identity.email);\n\tif (!name || !email || /[\\r\\n\\0]/.test(name) || /[\\r\\n\\0]/.test(email)) {\n\t\tthrow new DeterministicGitError(\"Git identity requires a valid name and email\");\n\t}\n\treturn [\"-c\", `user.name=${name}`, \"-c\", `user.email=${email}`];\n}\n\nfunction repositoryGit(projectKey: string, repoPath: string) {\n\tfunction runGit(args: readonly string[], identity?: GitIdentity): GitExecResult {\n\t\tconst trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;\n\t\ttry {\n\t\t\tconst stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {\n\t\t\t\tcwd: repoPath,\n\t\t\t\tencoding: \"utf8\",\n\t\t\t\tenv: gitConfigIdentityEnv(projectKey),\n\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t});\n\t\t\treturn { ok: true, stdout, stderr: \"\" };\n\t\t} catch (error) {\n\t\t\tconst execError = error as {\n\t\t\t\tstdout?: string | Buffer;\n\t\t\t\tstderr?: string | Buffer;\n\t\t\t\tmessage?: string;\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tstdout: execError.stdout?.toString() ?? \"\",\n\t\t\t\tstderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? \"\",\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction checkedGit(\n\t\targs: readonly string[],\n\t\tfailureMessage: string,\n\t\tidentity?: GitIdentity,\n\t): string {\n\t\tconst result = runGit(args, identity);\n\t\tif (!result.ok) {\n\t\t\tconst detail = trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? \"unknown git error\";\n\t\t\tthrow new DeterministicGitError(`${failureMessage}: ${detail}`);\n\t\t}\n\t\treturn result.stdout.trim();\n\t}\n\n\tfunction git(...args: string[]): string {\n\t\treturn checkedGit(args, `git ${args.join(\" \")} failed in '${repoPath}'`);\n\t}\n\n\tfunction gitOrNull(...args: string[]): string | null {\n\t\tconst result = runGit(args);\n\t\treturn result.ok ? trimToNull(result.stdout) : null;\n\t}\n\n\tfunction workingTreeStatus(): string[] {\n\t\treturn (gitOrNull(\"status\", \"--porcelain\") ?? \"\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((line) => line.replace(/\\s+$/, \"\"))\n\t\t\t.filter(Boolean)\n\t\t\t.map((line) => line.slice(2).trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tfunction conflictedFiles(): string[] {\n\t\treturn (gitOrNull(\"diff\", \"--name-only\", \"--diff-filter=U\") ?? \"\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((line) => line.trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tfunction mergeInProgress(): boolean {\n\t\tconst gitDir = git(\"rev-parse\", \"--git-dir\");\n\t\treturn existsSync(path.resolve(repoPath, gitDir, \"MERGE_HEAD\"));\n\t}\n\n\tfunction assertGitIdentity(identity: GitIdentity): void {\n\t\tif (\n\t\t\t!runGit([\"var\", \"GIT_AUTHOR_IDENT\"], identity).ok ||\n\t\t\t!runGit([\"var\", \"GIT_COMMITTER_IDENT\"], identity).ok\n\t\t) {\n\t\t\tthrow new DeterministicGitError(\"Git author/committer identity is not configured\");\n\t\t}\n\t}\n\n\tfunction commitIfDirty(commitMessage: string, identity: GitIdentity): string {\n\t\tif (workingTreeStatus().length === 0) return git(\"rev-parse\", \"HEAD\");\n\t\tassertGitIdentity(identity);\n\t\tcheckedGit([\"add\", \"--all\"], \"Failed to stage the completed change\");\n\t\tcheckedGit(\n\t\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"commit\", \"--no-gpg-sign\", \"-m\", commitMessage],\n\t\t\t\"Failed to commit the completed change\",\n\t\t\tidentity,\n\t\t);\n\t\tconst remaining = workingTreeStatus();\n\t\tif (remaining.length > 0) {\n\t\t\tthrow new DeterministicGitError(`Commit left uncommitted changes: ${remaining.join(\", \")}`);\n\t\t}\n\t\treturn git(\"rev-parse\", \"HEAD\");\n\t}\n\n\tfunction pushAndVerify(branch: string, expectedHeadSha: string): string {\n\t\tconst ref = `refs/heads/${branch}`;\n\t\tconst pushTarget = `origin/${branch}`;\n\t\tcheckedGit([\"push\", \"origin\", `HEAD:${ref}`], `Failed to push HEAD to '${pushTarget}'`);\n\t\tconst remoteHead = gitOrNull(\"ls-remote\", \"--heads\", \"origin\", ref)?.split(/\\s+/)[0]?.trim();\n\t\tif (remoteHead !== expectedHeadSha) {\n\t\t\tthrow new DeterministicGitError(\n\t\t\t\t`Published '${pushTarget}' resolved to '${remoteHead ?? \"missing\"}', expected '${expectedHeadSha}'`,\n\t\t\t);\n\t\t}\n\t\treturn pushTarget;\n\t}\n\n\treturn { runGit, git, conflictedFiles, mergeInProgress, commitIfDirty, pushAndVerify };\n}\n\n/** Inspect staged, unstaged, untracked, and already committed unpublished changes. @public */\nexport function repositoryHasChanges(\n\trepoPath: string,\n\tbaseBranch: string,\n\tprojectKey = \"repo\",\n): boolean {\n\tconst { git } = repositoryGit(projectKey, repoPath);\n\treturn Boolean(\n\t\tgit(\"status\", \"--porcelain\") || git(\"diff\", \"--name-only\", `origin/${baseBranch}...HEAD`),\n\t);\n}\n\n/** Commit the current workspace change and non-force push only the feature branch. */\n/** @public */\nexport function commitAndPushWorkBranch(input: {\n\t/** @public */ projectKey?: string;\n\t/** @public */\n\trepoPath: string;\n\t/** @public */\n\tworkBranch: string;\n\t/** @public */\n\tcommitMessage: string;\n\t/** @public */\n\tgitIdentity: GitIdentity;\n}) {\n\tconst repoPath = path.resolve(input.repoPath);\n\tconst { runGit, git, conflictedFiles, mergeInProgress, commitIfDirty, pushAndVerify } =\n\t\trepositoryGit(input.projectKey ?? \"repo\", repoPath);\n\tif (!existsSync(repoPath) || !runGit([\"rev-parse\", \"--git-dir\"]).ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Repository workspace '${repoPath}' does not exist or is not a git repository`,\n\t\t);\n\t}\n\tconst branch = git(\"branch\", \"--show-current\");\n\tif (branch !== input.workBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected '${repoPath}' to be checked out on '${input.workBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n\tif (!trimToNull(input.commitMessage)) {\n\t\tthrow new DeterministicGitError(\"A generated commit message is required before publication\");\n\t}\n\tconst conflicts = conflictedFiles();\n\tif (mergeInProgress() || conflicts.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Cannot publish a work branch with unresolved conflicts: ${conflicts.join(\", \") || \"merge in progress\"}`,\n\t\t);\n\t}\n\tconst headSha = commitIfDirty(input.commitMessage, input.gitIdentity);\n\treturn {\n\t\t/** @public */\n\t\theadSha,\n\t\t/** @internal */\n\t\tpushTarget: pushAndVerify(input.workBranch, headSha),\n\t};\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AACjB,SAAS,kBAAyC;AAClD,SAAS,mBAAmB,kCAAkC;AAC9D,SAAS,wBAAwB;AAW1B,IAAM,wBAAN,cAAoC,MAAM;AAAA;AAAA,EAEvC,aAA+B;AAAA;AAAA,EAGxC,YAAY,SAAiB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACb;AACD;AAQA,SAAS,qBAAqB,YAAuC;AACpE,QAAM,MAAM,2BAA2B,YAAY,EAAE,qBAAqB,IAAI,CAAC;AAC/E,aAAW,OAAO;AAAA,IACjB;AAAA,IACA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