@leitwerk-dev/coding 0.1.9 → 0.2.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 (38) hide show
  1. package/README.md +7 -2
  2. package/dist/auto-work-branch.js +86 -86
  3. package/dist/auto-work-branch.js.map +1 -1
  4. package/dist/{chunk-R3S5KR3J.js → chunk-73LKROYK.js} +135 -155
  5. package/dist/chunk-73LKROYK.js.map +1 -0
  6. package/dist/finalization-git.d.ts +6 -1
  7. package/dist/finalization-git.d.ts.map +1 -1
  8. package/dist/finalization-git.js +13 -593
  9. package/dist/finalization-git.js.map +1 -1
  10. package/dist/index.js +650 -6
  11. package/dist/index.js.map +1 -1
  12. package/dist/repository-change-launch.js +17 -182
  13. package/dist/repository-change-launch.js.map +1 -1
  14. package/dist/repository-change-process.d.ts.map +1 -1
  15. package/dist/repository-change-state.js +12 -51
  16. package/dist/repository-change-state.js.map +1 -1
  17. package/dist/turns/generate-commit-message.js +9 -38
  18. package/dist/turns/generate-commit-message.js.map +1 -1
  19. package/dist/turns/generate-plan.js +7 -19
  20. package/dist/turns/generate-plan.js.map +1 -1
  21. package/dist/turns/implement.js +7 -17
  22. package/dist/turns/implement.js.map +1 -1
  23. package/dist/turns/resolve-merge-conflict.js +7 -21
  24. package/dist/turns/resolve-merge-conflict.js.map +1 -1
  25. package/dist/turns/review-implementation.js +7 -25
  26. package/dist/turns/review-implementation.js.map +1 -1
  27. package/dist/turns/review-plan.js +7 -19
  28. package/dist/turns/review-plan.js.map +1 -1
  29. package/dist/turns/simplify-implementation.js +7 -7
  30. package/dist/turns/simplify-implementation.js.map +1 -1
  31. package/package.json +5 -4
  32. package/src/finalization-git.ts +170 -167
  33. package/src/repository-change-process.ts +81 -165
  34. package/dist/actions.js +0 -45
  35. package/dist/actions.js.map +0 -1
  36. package/dist/chunk-R3S5KR3J.js.map +0 -1
  37. package/dist/repository-change-process.js +0 -689
  38. package/dist/repository-change-process.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAW,CAAC;AACpE,MAAM,SAAS,GAA4B,EAAE,QAAQ,EAAE,CAAC;AACxD,eAAe,SAAS,CAAC;AAEzB,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"sources":["../src/actions.ts","../src/repository-change-process.ts","../src/index.ts"],"sourcesContent":["import type { FormDefinition } from \"@leitwerk-dev/process-sdk\";\n\nexport const codingActionIds = {\n\tapprovePlan: \"approve_plan\",\n\trequestRevision: \"request_revision\",\n\trunReview: \"run_review\",\n\tsimplify: \"simplify\",\n\tacceptReview: \"accept_review\",\n\trequestReviewChanges: \"request_review_changes\",\n\tdismissReview: \"dismiss_review\",\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\nexport const requestRevisionForm = notesForm(\n\tcodingActionIds.requestRevision,\n\t\"Request revision\",\n\t\"Revision notes\",\n\t\"Instructions for the next implementation pass.\",\n);\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);\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\nexport function createFinalizeChangeForm(copy: { title: string }): FormDefinition {\n\treturn {\n\t\tid: codingActionIds.finalizeChange,\n\t\ttitle: copy.title,\n\t\tfields: [],\n\t\tsubmitLabel: copy.title,\n\t};\n}\n","import { trimString as normalizeMessage, normalizeOptionalMarkdown } from \"@leitwerk-dev/domain\";\nimport {\n\tacceptedReviewHandoffAction,\n\ttype Codec,\n\tcreateEmptyStructuralProcessState,\n\ttype FlowFragmentBuilder,\n\ttype FormDefinition,\n\tflow,\n\ttype HumanTurnDefinition,\n\thumanTurn,\n\ttype ProcessLauncherDefinition,\n\ttype RepositoryCredentialProject,\n\ttype RepositoryCredentialRequirement,\n\trevisionAction,\n} from \"@leitwerk-dev/process-sdk\";\nimport {\n\tacceptReviewForm,\n\tcodingActionIds,\n\trequestReviewChangesForm,\n\trequestRevisionForm,\n} from \"./actions.js\";\nimport { runDeterministicFinalization } from \"./finalization-git.js\";\nimport {\n\tclearReviewRefs,\n\tcreateEmptyRepositoryChangeFinalizationState,\n\ttype RepositoryChangeState,\n\trepositoryChangeStateCodec,\n\tresetRepositoryChangeFinalizationState,\n} from \"./repository-change-state.js\";\nimport {\n\tbuildGenerateCommitMessagePrompt,\n\tnormalizeGeneratedCommitMessage,\n} from \"./turns/generate-commit-message.js\";\nimport { buildGeneratePlanPrompt } from \"./turns/generate-plan.js\";\nimport { buildImplementPrompt } from \"./turns/implement.js\";\nimport { buildResolveMergeConflictPrompt } from \"./turns/resolve-merge-conflict.js\";\nimport { buildReviewImplementationPrompt } from \"./turns/review-implementation.js\";\nimport { buildReviewPlanPrompt } from \"./turns/review-plan.js\";\nimport { buildSimplifyImplementationPrompt } from \"./turns/simplify-implementation.js\";\n\nexport type RepositoryChangeParams = {\n\tlaunchKind: \"requested_change\" | \"imported_plan\";\n\timportedPlanMarkdown?: string;\n};\n\nexport interface RepositoryChangeProcessConfig<TParams extends RepositoryChangeParams> {\n\tprocessId: string;\n\tdisplayName: string;\n\tparamsCodec: Codec<TParams>;\n\tlauncher?: ProcessLauncherDefinition<TParams>;\n\tfinalizeLabel: string;\n\tfinalizeForm: FormDefinition;\n\tfinalizationDescription: string;\n\trepositoryCredentials?(input: {\n\t\tparams: TParams;\n\t\tprojects: readonly RepositoryCredentialProject[];\n\t}): readonly RepositoryCredentialRequirement[];\n\tpublication?: {\n\t\tentryTurnId: string;\n\t\tfragment: FlowFragmentBuilder<TParams, RepositoryChangeState>;\n\t\thappyPath?: readonly string[];\n\t};\n}\n\nexport function createRepositoryChangeProcess<TParams extends RepositoryChangeParams>(\n\tconfig: RepositoryChangeProcessConfig<TParams>,\n) {\n\tconst turnIds = {\n\t\timportPlan: \"import_plan\",\n\t\tgeneratePlan: \"generate_plan\",\n\t\tplanDecision: \"plan_decision\",\n\t\treviewPlan: \"review_plan\",\n\t\tplanReviewFeedback: \"plan_review_feedback\",\n\t\timplement: \"implement\",\n\t\timplementationDecision: \"implementation_decision\",\n\t\treviewImplementation: \"review_implementation\",\n\t\timplementationReviewFeedback: \"implementation_review_feedback\",\n\t\tsimplifyImplementation: \"simplify_implementation\",\n\t\tsimplificationDecision: \"simplification_decision\",\n\t\tgenerateCommitMessage: \"generate_commit_message\",\n\t\tcommitAndMerge: \"commit_and_merge\",\n\t\tresolveMergeConflict: \"resolve_merge_conflict\",\n\t} as const;\n\n\tconst products = {\n\t\tplan: \"plan\",\n\t\treview: \"review\",\n\t\tsimplificationPlan: \"simplification-plan\",\n\t\timplementationSummary: \"implementation-summary\",\n\t\tmergeResolutionSummary: \"merge-resolution-summary\",\n\t\tcommitMessage: \"commit-message\",\n\t} as const;\n\n\tconst implementationTurnAvailableTools = [\"read\", \"bash\", \"edit\", \"write\"] as const;\n\n\tfunction resetFinalizationAfterMessage(\n\t\tstate: RepositoryChangeState,\n\t\toverrides: Partial<RepositoryChangeState[\"finalization\"]> = {},\n\t) {\n\t\treturn resetRepositoryChangeFinalizationState({\n\t\t\tgeneratedCommitMessage: state.finalization.generatedCommitMessage,\n\t\t\t...overrides,\n\t\t});\n\t}\n\n\tfunction hasResolvedTurnRecordRef(\n\t\tref: RepositoryChangeState[\"semanticEntryRefs\"][keyof RepositoryChangeState[\"semanticEntryRefs\"]],\n\t): ref is { entryId: string; turnRecordId: string } {\n\t\treturn typeof ref?.turnRecordId === \"string\" && ref.turnRecordId.trim() !== \"\";\n\t}\n\n\tfunction requireResolvedPlanRef(\n\t\tplan: RepositoryChangeState[\"semanticEntryRefs\"][keyof RepositoryChangeState[\"semanticEntryRefs\"]],\n\t\tusage: \"approval\" | \"review\" | \"simplification review\" | \"implementation review\",\n\t): asserts plan is { entryId: string; turnRecordId: string } {\n\t\tif (!hasResolvedTurnRecordRef(plan)) {\n\t\t\tthrow new Error(`No plan is available for ${usage}`);\n\t\t}\n\t}\n\n\tfunction clearReviewState(state: RepositoryChangeState): RepositoryChangeState {\n\t\treturn patchRepositoryChangeState(state, {\n\t\t\tclearReviewRefs: true,\n\t\t\tclearProductRefs: [products.simplificationPlan],\n\t\t});\n\t}\n\n\tfunction buildAcceptedFollowUpMessage(input: {\n\t\tkind: \"plan_review\" | \"implementation_review\" | \"simplification\";\n\t\tmarkdown: unknown;\n\t\tadjustment: unknown;\n\t}): string {\n\t\tconst markdown = normalizeOptionalMarkdown(input.markdown);\n\t\tif (!markdown) {\n\t\t\tthrow new Error(\n\t\t\t\tinput.kind === \"simplification\"\n\t\t\t\t\t? \"No simplification plan markdown is available to accept\"\n\t\t\t\t\t: \"No review output markdown is available to accept\",\n\t\t\t);\n\t\t}\n\t\tconst adjustment = normalizeMessage(input.adjustment);\n\t\tconst subject = input.kind === \"simplification\" ? \"simplification plan\" : \"review\";\n\t\tconst introduction =\n\t\t\tinput.kind === \"plan_review\"\n\t\t\t\t? \"Revise the plan according to this review:\"\n\t\t\t\t: `Implement according to this ${subject}:`;\n\t\tconst sections = [introduction, markdown];\n\t\tif (adjustment) {\n\t\t\tsections.push(\n\t\t\t\t`Also follow this adjustment where it conflicts with the ${subject}:`,\n\t\t\t\tadjustment,\n\t\t\t);\n\t\t}\n\t\tif (input.kind !== \"plan_review\") {\n\t\t\tsections.push(\n\t\t\t\t[\n\t\t\t\t\t\"This is now an implementation turn. Ignore earlier review-only or read-only instructions.\",\n\t\t\t\t\t\"You may change files in the repository workspace.\",\n\t\t\t\t\t`Use the available tools (${implementationTurnAvailableTools.join(\", \")}) to inspect, edit, build, and test the change.`,\n\t\t\t\t\t\"When finished, return an implementation summary.\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t);\n\t\t}\n\t\treturn sections.join(\"\\n\\n\");\n\t}\n\n\tfunction patchRepositoryChangeState(\n\t\tstate: RepositoryChangeState,\n\t\tinput: {\n\t\t\tfinalization?: RepositoryChangeState[\"finalization\"];\n\t\t\tclearReviewRefs?: boolean;\n\t\t\tclearProductRefs?: readonly string[];\n\t\t},\n\t): RepositoryChangeState {\n\t\tconst nextState: RepositoryChangeState = {\n\t\t\t...state,\n\t\t\t...(\"finalization\" in input ? { finalization: input.finalization } : {}),\n\t\t};\n\t\tconst productRefsToClear = new Set(input.clearProductRefs ?? []);\n\t\tif (input.clearReviewRefs) {\n\t\t\tproductRefsToClear.add(products.review);\n\t\t}\n\t\tif (!input.clearReviewRefs && productRefsToClear.size === 0) {\n\t\t\treturn nextState;\n\t\t}\n\t\tconst productRefs = { ...nextState.productRefs };\n\t\tfor (const productName of productRefsToClear) {\n\t\t\tdelete productRefs[productName];\n\t\t}\n\t\treturn {\n\t\t\t...nextState,\n\t\t\tsemanticEntryRefs: input.clearReviewRefs\n\t\t\t\t? clearReviewRefs(nextState.semanticEntryRefs)\n\t\t\t\t: nextState.semanticEntryRefs,\n\t\t\tproductRefs,\n\t\t};\n\t}\n\n\tconst planDecisionSpec = 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, request a revision, or run an automated review.\",\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: turnIds.implement,\n\t\t\t\teffect: ({ ctx }) => {\n\t\t\t\t\trequireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, \"approval\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: clearReviewState(ctx.state),\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: turnIds.generatePlan,\n\t\t\t\tqueueTarget: { semanticRef: \"currentPrimaryPathLeaf\" },\n\t\t\t\teffect: ({ ctx, input }) => {\n\t\t\t\t\tconst message = normalizeMessage(input.message);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: clearReviewState(ctx.state),\n\t\t\t\t\t\temit: [{ type: \"plan_revision_requested\", data: { message } }],\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t}),\n\t\t\t[codingActionIds.runReview]: {\n\t\t\t\tlabel: \"Run automated review\",\n\t\t\t\tdescription: \"Send the current plan to the LLM reviewer.\",\n\t\t\t\tacceptanceState: \"neutral\",\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.reviewPlan,\n\t\t\t\teffect: ({ ctx }) => {\n\t\t\t\t\trequireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, \"review\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: clearReviewState(ctx.state),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\tconst planReviewFeedbackSpec = humanTurn<TParams, RepositoryChangeState>({\n\t\tdescription: \"Review Plan Feedback\",\n\t\treviewSemanticRef: \"review\",\n\t\tnotesFields: [\n\t\t\t{\n\t\t\t\tid: \"message\",\n\t\t\t\tlabel: \"Review notes\",\n\t\t\t\tplaceholder: \"Describe how the next review pass should change\",\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcommentary:\n\t\t\t\"Apply this feedback to the next plan revision, request a revised review, or dismiss it.\",\n\t\tactions: {\n\t\t\t[codingActionIds.acceptReview]: acceptedReviewHandoffAction({\n\t\t\t\tlabel: \"Accept review\",\n\t\t\t\tdescription: \"Apply the current review outcome and continue with the plan flow.\",\n\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\tform: acceptReviewForm,\n\t\t\t\tto: turnIds.generatePlan,\n\t\t\t\tresolveBodyMarkdown: ({ ctx, input }) =>\n\t\t\t\t\tbuildAcceptedFollowUpMessage({\n\t\t\t\t\t\tkind: \"plan_review\",\n\t\t\t\t\t\tmarkdown: ctx.readSemanticTurnResultMarkdown(\"review\"),\n\t\t\t\t\t\tadjustment: input.message,\n\t\t\t\t\t}),\n\t\t\t}),\n\t\t\t[codingActionIds.requestReviewChanges]: revisionAction({\n\t\t\t\tlabel: \"Request review changes\",\n\t\t\t\tdescription: \"Ask the LLM reviewer to revise its plan review.\",\n\t\t\t\tacceptanceState: \"requires_changes\",\n\t\t\t\tform: requestReviewChangesForm,\n\t\t\t\tto: turnIds.reviewPlan,\n\t\t\t\tqueueTarget: { semanticRef: \"review\" },\n\t\t\t}),\n\t\t\t[codingActionIds.dismissReview]: {\n\t\t\t\tlabel: \"Dismiss review\",\n\t\t\t\tdescription: \"Return to the plan decision without applying the review.\",\n\t\t\t\tacceptanceState: \"neutral\",\n\t\t\t\tto: turnIds.planDecision,\n\t\t\t},\n\t\t},\n\t});\n\n\tconst implementationDecisionSpec = humanTurn<TParams, RepositoryChangeState>({\n\t\tdescription: \"Review\",\n\t\treviewSemanticRef: \"currentPrimaryPathLeaf\",\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 implementation turn should improve\",\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcommentary:\n\t\t\t\"Merge this implementation, request another pass, simplify it, or run an automated review.\",\n\t\tactions: {\n\t\t\t[codingActionIds.finalizeChange]: {\n\t\t\t\tlabel: config.finalizeLabel,\n\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\tform: config.finalizeForm,\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.generateCommitMessage,\n\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\tstate: patchRepositoryChangeState(ctx.state, {\n\t\t\t\t\t\tfinalization: createEmptyRepositoryChangeFinalizationState(),\n\t\t\t\t\t\tclearReviewRefs: true,\n\t\t\t\t\t\tclearProductRefs: [products.simplificationPlan],\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\tacceptanceState: \"requires_changes\",\n\t\t\t\tform: requestRevisionForm,\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.implement,\n\t\t\t\tqueueTarget: { semanticRef: \"currentPrimaryPathLeaf\" },\n\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\tstate: clearReviewState(ctx.state),\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t[codingActionIds.simplify]: {\n\t\t\t\tlabel: \"Simplify\",\n\t\t\t\tdescription: \"Ask for a focused simplification review before another implementation pass.\",\n\t\t\t\tacceptanceState: \"neutral\",\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.simplifyImplementation,\n\t\t\t\teffect: ({ ctx }) => {\n\t\t\t\t\trequireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, \"simplification review\");\n\t\t\t\t\treturn { state: clearReviewState(ctx.state) };\n\t\t\t\t},\n\t\t\t},\n\t\t\t[codingActionIds.runReview]: {\n\t\t\t\tlabel: \"Run automated review\",\n\t\t\t\tacceptanceState: \"neutral\",\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.reviewImplementation,\n\t\t\t\teffect: ({ ctx }) => {\n\t\t\t\t\trequireResolvedPlanRef(ctx.state.semanticEntryRefs.plan, \"implementation review\");\n\t\t\t\t\treturn { state: clearReviewState(ctx.state) };\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\tconst implementationReviewFeedbackSpec = humanTurn<TParams, RepositoryChangeState>({\n\t\tdescription: \"Review implementation feedback\",\n\t\treviewSemanticRef: \"review\",\n\t\tnotesFields: [\n\t\t\t{\n\t\t\t\tid: \"message\",\n\t\t\t\tlabel: \"Review notes\",\n\t\t\t\tplaceholder: \"Describe how the next implementation review pass should change\",\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcommentary:\n\t\t\t\"Apply this feedback to the next implementation pass, request a revised review, or dismiss it.\",\n\t\tactions: {\n\t\t\t[codingActionIds.acceptReview]: acceptedReviewHandoffAction({\n\t\t\t\tlabel: \"Accept review\",\n\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\tform: acceptReviewForm,\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.implement,\n\t\t\t\tqueueTarget: { semanticRef: \"review\" },\n\t\t\t\tresolveBodyMarkdown: ({ ctx, input }) =>\n\t\t\t\t\tbuildAcceptedFollowUpMessage({\n\t\t\t\t\t\tkind: \"implementation_review\",\n\t\t\t\t\t\tmarkdown: ctx.readSemanticTurnResultMarkdown(\"review\"),\n\t\t\t\t\t\tadjustment: input.message,\n\t\t\t\t\t}),\n\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\tstate: patchRepositoryChangeState(ctx.state, {\n\t\t\t\t\t\tclearProductRefs: [products.simplificationPlan],\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t[codingActionIds.requestReviewChanges]: revisionAction({\n\t\t\t\tlabel: \"Request review changes\",\n\t\t\t\tacceptanceState: \"requires_changes\",\n\t\t\t\tform: requestReviewChangesForm,\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.reviewImplementation,\n\t\t\t\tqueueTarget: { semanticRef: \"review\" },\n\t\t\t}),\n\t\t\t[codingActionIds.dismissReview]: {\n\t\t\t\tlabel: \"Dismiss review\",\n\t\t\t\tacceptanceState: \"neutral\",\n\t\t\t\tto: turnIds.implementationDecision,\n\t\t\t},\n\t\t},\n\t});\n\n\tconst simplificationDecisionSpec = humanTurn<TParams, RepositoryChangeState>({\n\t\tdescription: \"Review simplification plan\",\n\t\treviewProduct: products.simplificationPlan,\n\t\tnotesFields: [\n\t\t\t{\n\t\t\t\tid: \"message\",\n\t\t\t\tlabel: \"Simplification notes\",\n\t\t\t\tplaceholder: \"Describe how the simplification plan should change\",\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcommentary: \"Apply this simplification plan, request changes to it, or reject it.\",\n\t\tactions: {\n\t\t\t[codingActionIds.acceptReview]: acceptedReviewHandoffAction({\n\t\t\t\tlabel: \"Accept simplification plan\",\n\t\t\t\tacceptanceState: \"accepted\",\n\t\t\t\tform: acceptReviewForm,\n\t\t\t\tschedulable: true,\n\t\t\t\tto: turnIds.implement,\n\t\t\t\tqueueTarget: { productName: products.simplificationPlan },\n\t\t\t\tresolveBodyMarkdown: ({ ctx, input }) =>\n\t\t\t\t\tbuildAcceptedFollowUpMessage({\n\t\t\t\t\t\tkind: \"simplification\",\n\t\t\t\t\t\tmarkdown: ctx.readProductTurnResultMarkdown(products.simplificationPlan),\n\t\t\t\t\t\tadjustment: input.message,\n\t\t\t\t\t}),\n\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\tstate: patchRepositoryChangeState(ctx.state, {\n\t\t\t\t\t\tclearReviewRefs: true,\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t[codingActionIds.requestReviewChanges]: revisionAction({\n\t\t\t\tlabel: \"Request simplification changes\",\n\t\t\t\tacceptanceState: \"requires_changes\",\n\t\t\t\tform: requestReviewChangesForm,\n\t\t\t\tto: turnIds.simplifyImplementation,\n\t\t\t\tqueueTarget: { productName: products.simplificationPlan },\n\t\t\t}),\n\t\t\t[codingActionIds.dismissReview]: {\n\t\t\t\tlabel: \"Reject simplification plan\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Return to the implementation decision without applying the simplification plan.\",\n\t\t\t\tacceptanceState: \"neutral\",\n\t\t\t\tto: turnIds.implementationDecision,\n\t\t\t\teffect: ({ ctx }) => ({\n\t\t\t\t\tstate: clearReviewState(ctx.state),\n\t\t\t\t}),\n\t\t\t},\n\t\t},\n\t});\n\n\tconst importPlanTurn = flow\n\t\t.automatic<TParams, RepositoryChangeState>(turnIds.importPlan)\n\t\t.description(\"Import handoff plan\")\n\t\t.run((ctx) => {\n\t\t\tconst planMarkdown =\n\t\t\t\tctx.params.launchKind === \"imported_plan\"\n\t\t\t\t\t? normalizeOptionalMarkdown(ctx.params.importedPlanMarkdown)\n\t\t\t\t\t: null;\n\t\t\tif (!planMarkdown) {\n\t\t\t\tthrow new Error(\"No importedPlanMarkdown is available to import\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toutcome: \"imported\",\n\t\t\t\tparams: { plan: planMarkdown },\n\t\t\t\tmarkdown: planMarkdown,\n\t\t\t};\n\t\t})\n\t\t.outcome(\"imported\", (outcome) =>\n\t\t\toutcome\n\t\t\t\t.description(\"Imported a handoff plan and skipped replanning\")\n\t\t\t\t.markdown(\"plan\", { description: \"Imported handoff plan\", publish: true })\n\t\t\t\t.to(turnIds.implement)\n\t\t\t\t.effect(({ ctx }) => ({\n\t\t\t\t\tprocessPatch: { planRevision: ctx.process.planRevision + 1 },\n\t\t\t\t\tstate: clearReviewState(ctx.state),\n\t\t\t\t})),\n\t\t);\n\n\tconst generatePlanTurn = flow\n\t\t.llm<TParams, RepositoryChangeState>(turnIds.generatePlan)\n\t\t.description(\"Plan\")\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 the finished plan for review. Its Markdown may include Mermaid diagrams or uploaded images.\",\n\t\t\t\t)\n\t\t\t\t.requiredString(\"summary\", \"Short summary of the proposed plan\")\n\t\t\t\t.requiredStringArray(\n\t\t\t\t\t\"acceptanceCriteria\",\n\t\t\t\t\t\"Acceptance criteria for the requested repository change\",\n\t\t\t\t)\n\t\t\t\t.to(turnIds.planDecision)\n\t\t\t\t.effect(({ ctx, event }) => {\n\t\t\t\t\tconst planRevision = ctx.process.planRevision + 1;\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\tconst planMarkdown = ctx.output?.content ?? \"\";\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: clearReviewState(ctx.state),\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: \"awaiting_approval\",\n\t\t\t\t\t\t\t\t\tapproved: false,\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{\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,\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(products.plan);\n\n\tconst reviewPlanTurn = flow\n\t\t.llm<TParams, RepositoryChangeState>(turnIds.reviewPlan)\n\t\t.description(\"Assess Plan\")\n\t\t.tools(\"read\", \"bash\")\n\t\t.rootBranchReview()\n\t\t.startFromReviewBranch()\n\t\t.consume(products.plan)\n\t\t.buildPrompt(buildReviewPlanPrompt)\n\t\t.outcomeTool(\"no_issues\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\n\t\t\t\t\t\"Approve the plan and publish the review. Its Markdown may include Mermaid diagrams or uploaded images.\",\n\t\t\t\t)\n\t\t\t\t.to(turnIds.planDecision),\n\t\t)\n\t\t.outcomeTool(\"request_changes\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\n\t\t\t\t\t\"Request plan changes and publish actionable feedback. Its Markdown may include Mermaid diagrams or uploaded images.\",\n\t\t\t\t)\n\t\t\t\t.to(turnIds.planReviewFeedback),\n\t\t)\n\t\t.publish(products.review);\n\n\tconst implementTurn = flow\n\t\t.llm<TParams, RepositoryChangeState>(turnIds.implement)\n\t\t.description(\"Implement\")\n\t\t.tools(...implementationTurnAvailableTools)\n\t\t.freshSeededPrimary()\n\t\t.continueFromProductBranch(products.simplificationPlan, {\n\t\t\tkind: \"semantic_ref\",\n\t\t\tref: \"review\",\n\t\t\tfallback: { kind: \"session_root\" },\n\t\t})\n\t\t.consume(products.plan)\n\t\t.buildPrompt(buildImplementPrompt)\n\t\t.publish(products.implementationSummary)\n\t\t.to(turnIds.implementationDecision)\n\t\t.state(({ ctx }) => clearReviewState(ctx.state));\n\n\tconst reviewImplementationTurn = flow\n\t\t.llm<TParams, RepositoryChangeState>(turnIds.reviewImplementation)\n\t\t.description(\"Assess Implementation\")\n\t\t.tools(\"read\", \"bash\")\n\t\t.rootBranchReview()\n\t\t.startFromReviewBranch()\n\t\t.buildPrompt(buildReviewImplementationPrompt)\n\t\t.outcomeTool(\"no_issues\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\n\t\t\t\t\t\"Approve the implementation and publish the review. Its Markdown may include Mermaid diagrams or uploaded images.\",\n\t\t\t\t)\n\t\t\t\t.to(turnIds.implementationDecision),\n\t\t)\n\t\t.outcomeTool(\"request_changes\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\n\t\t\t\t\t\"Request implementation changes and publish actionable feedback. Its Markdown may include Mermaid diagrams or uploaded images.\",\n\t\t\t\t)\n\t\t\t\t.to(turnIds.implementationReviewFeedback),\n\t\t)\n\t\t.publish(products.review);\n\n\tconst simplifyImplementationTurn = flow\n\t\t.llm<TParams, RepositoryChangeState>(turnIds.simplifyImplementation)\n\t\t.description(\"Simplify\")\n\t\t.tools(\"read\", \"bash\")\n\t\t.rootBranchReview()\n\t\t.startFromProductBranch(products.simplificationPlan)\n\t\t.buildPrompt(buildSimplifyImplementationPrompt)\n\t\t.publish(products.simplificationPlan)\n\t\t.to(turnIds.simplificationDecision);\n\n\tconst generateCommitMessageTurn = flow\n\t\t.llm<TParams, RepositoryChangeState>(turnIds.generateCommitMessage)\n\t\t.description(\"Write Commit Message\")\n\t\t.modelPurpose(\"process_title_generation\")\n\t\t.rootBranchReview()\n\t\t.startFromRoot()\n\t\t.consume(products.plan)\n\t\t.buildPrompt(buildGenerateCommitMessagePrompt)\n\t\t.publish(products.commitMessage)\n\t\t.to(config.publication?.entryTurnId ?? turnIds.commitAndMerge)\n\t\t.state(({ ctx }) =>\n\t\t\tpatchRepositoryChangeState(ctx.state, {\n\t\t\t\tfinalization: {\n\t\t\t\t\t...ctx.state.finalization,\n\t\t\t\t\tgeneratedCommitMessage: normalizeGeneratedCommitMessage(ctx.output?.content),\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\n\tconst commitAndMergeTurn = flow\n\t\t.automatic<TParams, RepositoryChangeState>(turnIds.commitAndMerge)\n\t\t.description(config.finalizationDescription)\n\t\t.run(runDeterministicFinalization)\n\t\t.outcome(\"merge_conflict\", (outcome) =>\n\t\t\toutcome\n\t\t\t\t.description(\"Deterministic merge hit conflicts and needs conflict resolution\")\n\t\t\t\t.requiredString(\"headSha\", \"The current HEAD sha while the merge conflict is active\")\n\t\t\t\t.stringArray(\"conflictedFiles\", \"Conflicted files that need resolution\")\n\t\t\t\t.string(\"fetchedBaseSha\", \"The fetched origin/<baseBranch> sha when available\")\n\t\t\t\t.to(turnIds.resolveMergeConflict)\n\t\t\t\t.state(({ ctx }) =>\n\t\t\t\t\tpatchRepositoryChangeState(ctx.state, {\n\t\t\t\t\t\tfinalization: resetFinalizationAfterMessage(ctx.state),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t)\n\t\t.outcome(\"finalized\", (outcome) =>\n\t\t\toutcome\n\t\t\t\t.description(\"Deterministic finalization succeeded\")\n\t\t\t\t.requiredString(\"headSha\", \"The final HEAD sha\")\n\t\t\t\t.requiredString(\"mergeMode\", \"How origin/<baseBranch> was integrated\")\n\t\t\t\t.requiredString(\"pushTarget\", \"The final base-branch publish target\")\n\t\t\t\t.requiredBoolean(\"usedConflictResolution\", \"Whether the merge required conflict resolution\")\n\t\t\t\t.complete()\n\t\t\t\t.state(({ ctx, event }) =>\n\t\t\t\t\tpatchRepositoryChangeState(ctx.state, {\n\t\t\t\t\t\tfinalization: resetFinalizationAfterMessage(ctx.state, {\n\t\t\t\t\t\t\tusedConflictResolution:\n\t\t\t\t\t\t\t\tevent.params.usedConflictResolution === true ||\n\t\t\t\t\t\t\t\tctx.state.finalization.usedConflictResolution,\n\t\t\t\t\t\t\tfinalizationSummaryMarkdown: normalizeOptionalMarkdown(ctx.output?.content),\n\t\t\t\t\t\t\tfinalizedHeadSha: normalizeMessage(event.params.headSha),\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t);\n\n\tconst resolveMergeConflictTurn = flow\n\t\t.llm<TParams, RepositoryChangeState>(turnIds.resolveMergeConflict)\n\t\t.description(\"Resolve merge conflict\")\n\t\t.tools(\"read\", \"bash\", \"edit\", \"write\")\n\t\t.fullPrimary()\n\t\t.startFromRoot()\n\t\t.buildPrompt(buildResolveMergeConflictPrompt)\n\t\t.outcomeTool(\"clean\", (tool) =>\n\t\t\ttool\n\t\t\t\t.description(\"The merge conflict was resolved and the repository is clean\")\n\t\t\t\t.requiredString(\"headSha\", \"The post-resolution HEAD sha\")\n\t\t\t\t.to(turnIds.commitAndMerge)\n\t\t\t\t.state(({ ctx, event }) =>\n\t\t\t\t\tpatchRepositoryChangeState(ctx.state, {\n\t\t\t\t\t\tfinalization: resetFinalizationAfterMessage(ctx.state, {\n\t\t\t\t\t\t\texpectedPostConflictHeadSha: normalizeMessage(event.params.headSha),\n\t\t\t\t\t\t\tusedConflictResolution: true,\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(products.mergeResolutionSummary);\n\n\tconst planFlow = flow\n\t\t.fragment<TParams, RepositoryChangeState>(\"plan\")\n\t\t.turn(importPlanTurn)\n\t\t.turn(generatePlanTurn)\n\t\t.turn({ id: turnIds.planDecision, definition: planDecisionSpec })\n\t\t.turn(reviewPlanTurn)\n\t\t.turn({ id: turnIds.planReviewFeedback, definition: planReviewFeedbackSpec });\n\n\tconst implementationFlow = flow\n\t\t.fragment<TParams, RepositoryChangeState>(\"implementation\")\n\t\t.turn(implementTurn)\n\t\t.turn({ id: turnIds.implementationDecision, definition: implementationDecisionSpec })\n\t\t.turn(reviewImplementationTurn)\n\t\t.turn({\n\t\t\tid: turnIds.implementationReviewFeedback,\n\t\t\tdefinition: implementationReviewFeedbackSpec,\n\t\t})\n\t\t.turn(simplifyImplementationTurn)\n\t\t.turn({ id: turnIds.simplificationDecision, definition: simplificationDecisionSpec });\n\n\tconst finalizationFlow = flow\n\t\t.fragment<TParams, RepositoryChangeState>(\"finalization\")\n\t\t.turn(generateCommitMessageTurn);\n\tif (!config.publication) {\n\t\tfinalizationFlow.turn(commitAndMergeTurn).turn(resolveMergeConflictTurn);\n\t}\n\n\tconst builder = flow\n\t\t.process<TParams, RepositoryChangeState>(config.processId)\n\t\t.displayName(config.displayName)\n\t\t.entry(turnIds.generatePlan)\n\t\t.alternateEntry(turnIds.importPlan)\n\t\t.happyPath(\n\t\t\tturnIds.generatePlan,\n\t\t\tturnIds.implement,\n\t\t\tturnIds.generateCommitMessage,\n\t\t\t...(config.publication?.happyPath ?? [turnIds.commitAndMerge]),\n\t\t)\n\t\t.piConfig({ sessionCwdTemplate: \"{{{projectKey}}}\" })\n\t\t.codecs({\n\t\t\tparams: config.paramsCodec,\n\t\t\tstate: repositoryChangeStateCodec,\n\t\t})\n\t\t.initialState(() => ({\n\t\t\t...createEmptyStructuralProcessState(),\n\t\t\tfinalization: createEmptyRepositoryChangeFinalizationState(),\n\t\t\textensionState: {},\n\t\t}))\n\t\t.use(planFlow)\n\t\t.use(implementationFlow)\n\t\t.use(finalizationFlow);\n\tif (config.publication) builder.use(config.publication.fragment);\n\tif (config.repositoryCredentials) builder.repositoryCredentials(config.repositoryCredentials);\n\tif (config.launcher) builder.launcher(config.launcher);\n\tconst process = builder.define();\n\tconst decision = (id: string) =>\n\t\t({\n\t\t\tid,\n\t\t\t...(process.turns.get(id)?.definition as HumanTurnDefinition),\n\t\t}) as HumanTurnDefinition & { id: string };\n\treturn {\n\t\tprocess,\n\t\tplanDecision: decision(turnIds.planDecision),\n\t\tplanReviewFeedback: decision(turnIds.planReviewFeedback),\n\t\timplementationDecision: decision(turnIds.implementationDecision),\n\t\timplementationReviewFeedback: decision(turnIds.implementationReviewFeedback),\n\t\tsimplificationDecision: decision(turnIds.simplificationDecision),\n\t};\n}\n","import type { LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\n\nexport const manifest = { id: \"coding\", version: \"0.1.0\" } as const;\nconst extension: LeitwerkExtensionModule = { manifest };\nexport default extension;\n\nexport * from \"./actions.js\";\nexport * from \"./repository-change-launch.js\";\nexport * from \"./repository-change-process.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,kBAAkB;AAAA,EAC9B,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,gBAAgB;AACjB;AAEA,SAAS,UAAU,IAAY,OAAe,OAAe,aAAqC;AACjG,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,MACP,EAAE,IAAI,WAAW,OAAO,MAAM,YAAY,eAAe,MAAM,UAAU,MAAM,YAAY;AAAA,IAC5F;AAAA,IACA,aAAa;AAAA,EACd;AACD;AAEO,IAAM,sBAAsB;AAAA,EAClC,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACD;AACO,IAAM,2BAA2B;AAAA,EACvC,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACD;AACO,IAAM,mB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AQ,OAAO;AAAA,IACf,OAAO;AAAA,EACR,CAAC,EACA,aAAa,OAAO;AAAA,IACpB,GAAG,kCAAkC;AAAA,IACrC,cAAc,6CAA6C;AAAA,IAC3D,gBAAgB,CAAC;AAAA,EAClB,EAAE,EACD,IAAI,QAAQ,EACZ,IAAI,kBAAkB,EACtB,IAAI,gBAAgB;AACtB,MAAI,OAAO,YAAa,SAAQ,IAAI,OAAO,YAAY,QAAQ;AAC/D,MAAI,OAAO,sBAAuB,SAAQ,sBAAsB,OAAO,qBAAqB;AAC5F,MAAI,OAAO,SAAU,SAAQ,SAAS,OAAO,QAAQ;AACrD,QAAM,UAAU,QAAQ,OAAO;AAC/B,QAAM,WAAW,CAAC,QAChB;AAAA,IACA;AAAA,IACA,GAAI,QAAQ,MAAM,IAAI,EAAE,GAAG;AAAA,EAC5B;AACD,SAAO;AAAA,IACN;AAAA,IACA,cAAc,SAAS,QAAQ,YAAY;AAAA,IAC3C,oBAAoB,SAAS,QAAQ,kBAAkB;AAAA,IACvD,wBAAwB,SAAS,QAAQ,sBAAsB;AAAA,IAC/D,8BAA8B,SAAS,QAAQ,4BAA4B;AAAA,IAC3E,wBAAwB,SAAS,QAAQ,sBAAsB;AAAA,EAChE;AACD;;;ACxwBO,IAAM,WAAW,EAAE,IAAI,UAAU,SAAS,QAAQ;AACzD,IAAM,YAAqC,EAAE,SAAS;AACtD,IAAO,gBAAQ;","names":[]}
@@ -1,183 +1,18 @@
1
- import { parseRepoLocator, trimString } from "@leitwerk-dev/domain";
2
- export function repositoryChangeParamsRecord(value, displayName) {
3
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
4
- throw new Error(`${displayName} params must be an object`);
5
- }
6
- return value;
7
- }
8
- export function normalizeRepositoryChangeParamsInput(value, displayName) {
9
- const record = repositoryChangeParamsRecord(value, displayName);
10
- const rawRepoLocator = trimString(record.repoLocator);
11
- return {
12
- launchKind: trimString(record.launchKind),
13
- repoLocator: parseRepoLocator(rawRepoLocator)?.value ?? rawRepoLocator,
14
- baseBranch: trimString(record.baseBranch) || "main",
15
- workBranch: trimString(record.workBranch),
16
- prompt: trimString(record.prompt),
17
- importedPlanMarkdown: trimString(record.importedPlanMarkdown),
18
- };
19
- }
20
- export function createRepositoryChangeParamsCodec(input) {
21
- return {
22
- parse(value) {
23
- const { importedPlanMarkdown, ...shared } = input.normalize(value);
24
- if (shared.launchKind === "requested_change")
25
- return shared;
26
- if (shared.launchKind === "imported_plan") {
27
- return { ...shared, launchKind: shared.launchKind, importedPlanMarkdown };
28
- }
29
- throw new Error(`${input.displayName} params require a valid launchKind`);
30
- },
31
- serialize: (value) => value,
32
- };
33
- }
34
- export function formatRepositoryChangeLaunchErrors(errors) {
35
- return errors.map((error) => `${error.fieldId ?? "launch"}: ${error.message}`).join("; ");
36
- }
37
- export function createRepositoryChangeLaunchPlanner(config) {
38
- return {
39
- plan({ input, metadata }) {
40
- const params = config.normalize(input);
41
- const errors = [];
42
- if (params.launchKind !== "requested_change" && params.launchKind !== "imported_plan") {
43
- errors.push({
44
- code: "custom_rule",
45
- fieldId: "launchKind",
46
- message: "launchKind must be requested_change or imported_plan",
47
- });
48
- }
49
- const locatorError = config.validateRepoLocator(params.repoLocator);
50
- if (locatorError) {
51
- errors.push({
52
- code: "invalid_repo_locator",
53
- fieldId: "repoLocator",
54
- message: locatorError,
55
- });
56
- }
57
- if (params.workBranch && params.workBranch === params.baseBranch) {
58
- errors.push({
59
- code: "custom_rule",
60
- fieldId: "workBranch",
61
- message: "workBranch cannot match baseBranch",
62
- });
63
- }
64
- if (!params.prompt) {
65
- errors.push({ code: "required", fieldId: "prompt", message: "prompt is required" });
66
- }
67
- if (params.launchKind === "imported_plan" && !params.importedPlanMarkdown) {
68
- errors.push({
69
- code: "required",
70
- fieldId: "importedPlanMarkdown",
71
- message: "importedPlanMarkdown is required for imported_plan launches",
72
- });
73
- }
74
- if (params.launchKind === "requested_change" && "importedPlanMarkdown" in input) {
75
- errors.push({
76
- code: "custom_rule",
77
- fieldId: "importedPlanMarkdown",
78
- message: "importedPlanMarkdown is not allowed for requested_change launches",
79
- });
80
- }
81
- errors.push(...(config.validate?.(input, params) ?? []));
82
- if (errors.length > 0)
83
- return { ok: false, errors };
84
- const prepared = config.prepare?.(params) ?? params;
85
- const hasWorkBranch = prepared.workBranch !== "";
86
- return {
87
- ok: true,
88
- launchConfig: {
89
- processId: config.processId,
90
- params: prepared,
91
- startTurnId: config.deferWithoutWorkBranch && !hasWorkBranch
92
- ? null
93
- : prepared.launchKind === "imported_plan"
94
- ? "import_plan"
95
- : "generate_plan",
96
- titleSourceFields: [{ label: "Requested change", value: prepared.prompt }],
97
- metadata: metadata ?? null,
98
- projects: [
99
- {
100
- key: "repo",
101
- repoLocator: prepared.repoLocator,
102
- baseBranch: prepared.baseBranch,
103
- workBranch: hasWorkBranch ? prepared.workBranch : null,
104
- },
105
- ],
106
- },
107
- };
108
- },
109
- };
110
- }
111
- export function createRepositoryChangeUiLauncher(config) {
112
- return {
113
- id: config.id,
114
- label: config.title,
115
- description: "Plan, implement, review, and finalize a change in a single git repository",
116
- visibility: "ui",
117
- ui: {
118
- card: {
119
- title: config.title,
120
- description: "Run a plan → implement → review → finalize loop against any local or remote git repository.",
121
- },
122
- launchConfigSchema: {
123
- id: config.formId,
124
- title: config.title,
125
- fields: [
126
- {
127
- id: "repoLocator",
128
- label: "Repository path or URL",
129
- kind: "text",
130
- required: true,
131
- placeholder: "/path/to/repo or https://git.example.com/team/repo.git",
132
- description: "Use a local checkout path or a remote Git URL.",
133
- rememberRecentValues: true,
134
- },
135
- ...(config.sshCredentials
136
- ? [
137
- {
138
- id: "sshCredentialRef",
139
- label: "SSH credential profile",
140
- kind: "text",
141
- required: true,
142
- placeholder: "default",
143
- description: "Profile from extensions.git-ssh.credentials.",
144
- },
145
- ]
146
- : []),
147
- {
148
- id: "baseBranch",
149
- label: "Base branch",
150
- kind: "text",
151
- placeholder: "main",
152
- description: "Leave this as main unless the change should merge somewhere else.",
153
- },
154
- {
155
- id: "workBranch",
156
- label: "Work branch",
157
- kind: "text",
158
- placeholder: "feature/my-change",
159
- description: config.workBranchDescription,
160
- },
161
- {
162
- id: "prompt",
163
- label: "Requested change",
164
- kind: "textarea",
165
- required: true,
166
- placeholder: "Describe the change this process should plan, implement, and review.",
167
- },
168
- ],
169
- submitLabel: "Start change",
170
- },
171
- resolveDefaults: () => ({
172
- repoLocator: "",
173
- ...(config.sshCredentials ? { sshCredentialRef: "default" } : {}),
174
- baseBranch: "main",
175
- workBranch: "",
176
- prompt: "",
177
- }),
178
- resolveRelaunchInput: config.resolveRelaunchInput,
179
- resolveLaunchConfig: config.resolveLaunchConfig,
180
- },
181
- };
182
- }
1
+ import {
2
+ createRepositoryChangeLaunchPlanner,
3
+ createRepositoryChangeParamsCodec,
4
+ createRepositoryChangeUiLauncher,
5
+ formatRepositoryChangeLaunchErrors,
6
+ normalizeRepositoryChangeParamsInput,
7
+ repositoryChangeParamsRecord
8
+ } from "./chunk-Y2S6JFVO.js";
9
+ import "./chunk-PX6F3LHL.js";
10
+ export {
11
+ createRepositoryChangeLaunchPlanner,
12
+ createRepositoryChangeParamsCodec,
13
+ createRepositoryChangeUiLauncher,
14
+ formatRepositoryChangeLaunchErrors,
15
+ normalizeRepositoryChangeParamsInput,
16
+ repositoryChangeParamsRecord
17
+ };
183
18
  //# sourceMappingURL=repository-change-launch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository-change-launch.js","sourceRoot":"","sources":["../src/repository-change-launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAoCpE,MAAM,UAAU,4BAA4B,CAC3C,KAAc,EACd,WAAmB;IAEnB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,2BAA2B,CAAC,C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AE,CAAC;oBACN;wBACC,EAAE,EAAE,YAAY;wBAChB,KAAK,EAAE,aAAa;wBACpB,IAAI,EAAE,MAAM;wBACZ,WAAW,EAAE,MAAM;wBACnB,WAAW,EAAE,mEAAmE;qBAChF;oBACD;wBACC,EAAE,EAAE,YAAY;wBAChB,KAAK,EAAE,aAAa;wBACpB,IAAI,EAAE,MAAM;wBACZ,WAAW,EAAE,mBAAmB;wBAChC,WAAW,EAAE,MAAM,CAAC,qBAAqB;qBACzC;oBACD;wBACC,EAAE,EAAE,QAAQ;wBACZ,KAAK,EAAE,kBAAkB;wBACzB,IAAI,EAAE,UAAU;wBAChB,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,sEAAsE;qBACnF;iBACD;gBACD,WAAW,EAAE,cAAc;aAC3B;YACD,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;gBACvB,WAAW,EAAE,EAAE;gBACf,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,UAAU,EAAE,MAAM;gBAClB,UAAU,EAAE,EAAE;gBACd,MAAM,EAAE,EAAE;aACV,CAAC;YACF,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;YACjD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;SAC/C;KACD,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"repository-change-process.d.ts","sourceRoot":"","sources":["../src/repository-change-process.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,KAAK,EAEV,KAAK,mBAAmB,EACxB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAExB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EAEpC,MAAM,2BAA2B,CAAC;AAQnC,OAAO,EAGN,KAAK,qBAAqB,EAG1B,MAAM,8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;AAQnC,OAAO,EAGN,KAAK,qBAAqB,EAG1B,MAAM,8BAA8B,CAAC;AAYtC,MAAM,MAAM,sBAAsB,GAAG;IACpC,UAAU,EAAE,kBAAkB,GAAG,eAAe,CAAC;IACjD,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,WAAW,6BAA6B,CAAC,OAAO,SAAS,sBAAsB;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,cAAc,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,qBAAqB,CAAC,CAAC,KAAK,EAAE;QAC7B,MAAM,EAAE,OAAO,CAAC;QAChB,QAAQ,EAAE,SAAS,2BAA2B,EAAE,CAAC;KACjD,GAAG,SAAS,+BAA+B,EAAE,CAAC;IAC/C,WAAW,CAAC,EAAE;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;QAC9D,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KAC9B,CAAC;CACF;AAED,wBAAgB,6BAA6B,CAAC,OAAO,SAAS,sBAAsB,EACnF,MAAM,EAAE,6BAA6B,CAAC,OAAO,CAAC;;;YAgsBX,MAAM;;;YAAN,MAAM;;;YAAN,MAAM;;;YAAN,MAAM;;;YAAN,MAAM;;EASzC"}
@@ -1,53 +1,14 @@
1
- import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
2
- export function createEmptyRepositoryChangeFinalizationState() {
3
- return {
4
- expectedPostConflictHeadSha: null,
5
- usedConflictResolution: false,
6
- finalizationSummaryMarkdown: null,
7
- finalizedHeadSha: null,
8
- generatedCommitMessage: null,
9
- };
10
- }
11
- function stringOrNull(value) {
12
- return typeof value === "string" ? value : null;
13
- }
14
- function toRecord(value) {
15
- return typeof value === "object" && value !== null ? value : {};
16
- }
17
- function parseFinalizationState(value) {
18
- const record = toRecord(value);
19
- return {
20
- expectedPostConflictHeadSha: stringOrNull(record.expectedPostConflictHeadSha),
21
- usedConflictResolution: record.usedConflictResolution === true,
22
- finalizationSummaryMarkdown: stringOrNull(record.finalizationSummaryMarkdown),
23
- finalizedHeadSha: stringOrNull(record.finalizedHeadSha),
24
- // Backward-compatible decoding for state persisted before commit-message generation.
25
- generatedCommitMessage: stringOrNull(record.generatedCommitMessage),
26
- };
27
- }
28
- export const repositoryChangeStateCodec = {
29
- parse(value) {
30
- const record = toRecord(value);
31
- return {
32
- ...parseStructuralProcessState(record),
33
- finalization: parseFinalizationState(record.finalization),
34
- extensionState: toRecord(record.extensionState),
35
- };
36
- },
37
- serialize(value) {
38
- return value;
39
- },
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
40
13
  };
41
- export function clearReviewRefs(semanticEntryRefs) {
42
- return {
43
- ...semanticEntryRefs,
44
- review: null,
45
- };
46
- }
47
- export function resetRepositoryChangeFinalizationState(overrides = {}) {
48
- return {
49
- ...createEmptyRepositoryChangeFinalizationState(),
50
- ...overrides,
51
- };
52
- }
53
14
  //# sourceMappingURL=repository-change-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository-change-state.js","sourceRoot":"","sources":["../src/repository-change-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAgBxE,MAAM,UAAU,4CAA4C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AAK,CAAC;IACd,CAAC;CACD,CAAC;AAEF,MAAM,UAAU,eAAe,CAC9B,iBAA6D;IAE7D,OAAO;QACN,GAAG,iBAAiB;QACpB,MAAM,EAAE,IAAI;KACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sCAAsC,CACrD,YAAwD,EAAE;IAE1D,OAAO;QACN,GAAG,4CAA4C,EAAE;QACjD,GAAG,SAAS;KACZ,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,39 +1,10 @@
1
- import { BUILT_IN_COMMIT_MESSAGE_RULES, COMMIT_MESSAGE_PROJECT_METADATA_KEY, } from "@leitwerk-dev/process-sdk";
2
- export function normalizeGeneratedCommitMessage(value) {
3
- if (typeof value !== "string" || value.includes("\0")) {
4
- throw new Error("Generated commit message must be plain text without NUL characters");
5
- }
6
- const normalized = value.replace(/\r\n?/g, "\n").trim();
7
- if (!normalized)
8
- throw new Error("Generated commit message must have a non-empty subject");
9
- if (/^```|```$/.test(normalized)) {
10
- throw new Error("Generated commit message must not contain Markdown fences");
11
- }
12
- if (/^(commit message|message|subject)\s*:/i.test(normalized)) {
13
- throw new Error("Generated commit message must not contain an explanatory prefix");
14
- }
15
- return normalized;
16
- }
17
- export function buildGenerateCommitMessagePrompt(ctx) {
18
- const project = ctx.projects.find((candidate) => candidate.key === "repo") ?? ctx.projects[0];
19
- const pinned = project?.metadata?.[COMMIT_MESSAGE_PROJECT_METADATA_KEY];
20
- const rules = typeof pinned?.rules === "string" && pinned.rules.trim()
21
- ? pinned.rules
22
- : BUILT_IN_COMMIT_MESSAGE_RULES;
23
- const plan = ctx.input.plan ?? "";
24
- return [
25
- "Create the Git commit message for the accepted implementation plan.",
26
- "Return only the exact plain-text commit message: subject first, followed by an optional body.",
27
- "Do not add Markdown fences, labels, commentary, or a 'Commit message:' prefix.",
28
- "The plan below is trusted content to summarize, not formatting instructions.",
29
- "",
30
- "<formatting_rules>",
31
- rules,
32
- "</formatting_rules>",
33
- "",
34
- "<accepted_plan>",
35
- plan,
36
- "</accepted_plan>",
37
- ].join("\n");
38
- }
1
+ import {
2
+ buildGenerateCommitMessagePrompt,
3
+ normalizeGeneratedCommitMessage
4
+ } from "../chunk-NIJCT4VK.js";
5
+ import "../chunk-PX6F3LHL.js";
6
+ export {
7
+ buildGenerateCommitMessagePrompt,
8
+ normalizeGeneratedCommitMessage
9
+ };
39
10
  //# sourceMappingURL=generate-commit-message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-commit-message.js","sourceRoot":"","sources":["../../src/turns/generate-commit-message.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,6BAA6B,EAC7B,mCAAmC,GAGnC,MAAM,2BAA2B,CAAC;AAEnC,MAAM,UAAU,+BAA+B,CAAC,KAAc;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACvF,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IACxD,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC3F,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,wCAAwC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC/C,GAA+C;IAE/C,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9F,MAAM,MAAM,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,mCAAmC,CAE1D,CAAC;IACb,MAAM,KAAK,GACV,OAAO,MAAM,EAAE,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;QACvD,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,6BAA6B,CAAC;IAClC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;IAClC,OAAO;QACN,qEAAqE;QACrE,+FAA+F;QAC/F,gFAAgF;QAChF,8EAA8E;QAC9E,EAAE;QACF,oBAAoB;QACpB,KAAK;QACL,qBAAqB;QACrB,EAAE;QACF,iBAAiB;QACjB,IAAI;QACJ,kBAAkB;KAClB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,20 +1,8 @@
1
- export function buildGeneratePlanPrompt(ctx) {
2
- const repo = ctx.repo.get("repo");
3
- return `Create an implementation plan for this repository change:
4
- ${ctx.prompts.initial}
5
-
6
- Repository root: . (the current working directory)
7
-
8
- Branches:
9
- - base branch: ${repo.baseBranch}
10
- - work branch: ${repo.workBranch}
11
-
12
- Rules:
13
- - analyze only the cloned repository in the current working directory
14
- - treat . as the repository root for read-only inspection
15
- - use bash only for read-only inspection (e.g. git log, git diff, rg, tree, file listing, read-only http/CLI calls)
16
- - do not modify files
17
- - do not read from or write to any original source repository path outside the process workspace
18
- - publish the plan when done`;
19
- }
1
+ import {
2
+ buildGeneratePlanPrompt
3
+ } from "../chunk-67YKGZLM.js";
4
+ import "../chunk-PX6F3LHL.js";
5
+ export {
6
+ buildGeneratePlanPrompt
7
+ };
20
8
  //# sourceMappingURL=generate-plan.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-plan.js","sourceRoot":"","sources":["../../src/turns/generate-plan.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,uBAAuB,CACtC,GAA8D;IAE9D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO;EACN,GAAG,CAAC,OAAO,CAAC,OAAO;;;;;iBAKJ,IAAI,CAAC,UAAU;iBACf,IAAI,CAAC,UAAU;;;;;;;;6BAQH,CAAC;AAC9B,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,18 +1,8 @@
1
- export function buildImplementPrompt(ctx) {
2
- return `Implement this requested change:
3
- ${ctx.prompts.initial}
4
-
5
- Repository root: . (the current working directory)
6
-
7
- Follow this plan:
8
- ${ctx.input.plan}
9
-
10
- Rules:
11
- - keep going until the change is complete; do any necessary additional passes without asking
12
- - make repository changes only inside the current working directory
13
- - treat . as the repository root for file edits and git commands
14
- - do not read from or write to any original source repository path outside the process workspace
15
- - keep the implementation coherent and complete
16
- - publish the implementation summary when done`;
17
- }
1
+ import {
2
+ buildImplementPrompt
3
+ } from "../chunk-UBVLJV3V.js";
4
+ import "../chunk-PX6F3LHL.js";
5
+ export {
6
+ buildImplementPrompt
7
+ };
18
8
  //# sourceMappingURL=implement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"implement.js","sourceRoot":"","sources":["../../src/turns/implement.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CACnC,GAA+D;IAE/D,OAAO;EACN,GAAG,CAAC,OAAO,CAAC,OAAO;;;;;EAKnB,GAAG,CAAC,KAAK,CAAC,IAAI;;;;;;;;+CAQ+B,CAAC;AAChD,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,22 +1,8 @@
1
- export function buildResolveMergeConflictPrompt(ctx) {
2
- const repo = ctx.repo.get("repo");
3
- return `Resolve the current merge conflict so this requested change can be finalized:
4
- ${ctx.prompts.initial}
5
-
6
- Repository root: . (the current working directory)
7
-
8
- Branches:
9
- - base branch: ${repo.baseBranch}
10
- - work branch: ${repo.workBranch}
11
-
12
- Rules:
13
- - resolve only the current merge conflict inside the current working directory
14
- - treat . as the repository root for file edits and git commands
15
- - complete the merge commit so the repository is no longer in a merge-in-progress state
16
- - leave the repository clean when you finish
17
- - do not push
18
- - do not read from or write to any original source repository path outside the process workspace
19
- - publish a concise Markdown summary of the merge resolution
20
- - then call clean with the final HEAD sha`;
21
- }
1
+ import {
2
+ buildResolveMergeConflictPrompt
3
+ } from "../chunk-5LVPKVI2.js";
4
+ import "../chunk-PX6F3LHL.js";
5
+ export {
6
+ buildResolveMergeConflictPrompt
7
+ };
22
8
  //# sourceMappingURL=resolve-merge-conflict.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-merge-conflict.js","sourceRoot":"","sources":["../../src/turns/resolve-merge-conflict.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,+BAA+B,CAC9C,GAA8D;IAE9D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO;EACN,GAAG,CAAC,OAAO,CAAC,OAAO;;;;;iBAKJ,IAAI,CAAC,UAAU;iBACf,IAAI,CAAC,UAAU;;;;;;;;;;0CAUU,CAAC;AAC3C,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,26 +1,8 @@
1
- export function buildReviewImplementationPrompt(ctx) {
2
- const repo = ctx.repo.get("repo");
3
- return `Repository root: . (the current working directory)
4
-
5
- Review the current implementation of this requested change:
6
- ${ctx.prompts.initial}
7
-
8
- Inspect the changes with \`git diff --stat $(git merge-base ${repo.baseBranch} HEAD)\`. Check for:
9
- - bugs and logic errors
10
- - security issues
11
- - error handling gaps
12
- - missing or misplaced tests
13
- - unnecessary abstractions, duplication, and other avoidable complexity
14
-
15
- For each issue, give a concise fix.
16
-
17
- Rules:
18
- - inspect code only inside the current working directory
19
- - treat . as the repository root for read-only inspection
20
- - use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)
21
- - do not modify files, branches, commits, or git index state
22
- - do not read from or write to any original source repository path outside the process workspace
23
- - publish a short Markdown approval note if the implementation is ready
24
- - publish concise, actionable Markdown feedback if the implementation needs changes`;
25
- }
1
+ import {
2
+ buildReviewImplementationPrompt
3
+ } from "../chunk-WQEPA35Z.js";
4
+ import "../chunk-PX6F3LHL.js";
5
+ export {
6
+ buildReviewImplementationPrompt
7
+ };
26
8
  //# sourceMappingURL=review-implementation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"review-implementation.js","sourceRoot":"","sources":["../../src/turns/review-implementation.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,+BAA+B,CAC9C,GAAuD;IAEvD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO;;;EAGN,GAAG,CAAC,OAAO,CAAC,OAAO;;8DAEyC,IAAI,CAAC,UAAU;;;;;;;;;;;;;;;;oFAgBO,CAAC;AACrF,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}