@leitwerk-dev/coding 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/actions.d.ts +14 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/auto-work-branch-internal.d.ts +20 -0
- package/dist/auto-work-branch-internal.d.ts.map +1 -0
- package/dist/auto-work-branch.d.ts +2 -12
- package/dist/auto-work-branch.d.ts.map +1 -1
- package/dist/auto-work-branch.js +2 -4
- package/dist/auto-work-branch.js.map +1 -1
- package/dist/{chunk-EP3ZC37F.js → chunk-34B3Q75M.js} +1 -1
- package/dist/chunk-34B3Q75M.js.map +1 -0
- package/dist/{chunk-OFDNIT5X.js → chunk-F6CEEAFE.js} +1 -1
- package/dist/chunk-F6CEEAFE.js.map +1 -0
- package/dist/{chunk-YIP4MP64.js → chunk-HUVXPZSF.js} +2 -2
- package/dist/chunk-HUVXPZSF.js.map +1 -0
- package/dist/{chunk-73LKROYK.js → chunk-MY6XFGHM.js} +12 -14
- package/dist/chunk-MY6XFGHM.js.map +1 -0
- package/dist/{chunk-5LVPKVI2.js → chunk-OERAYSVI.js} +1 -1
- package/dist/chunk-OERAYSVI.js.map +1 -0
- package/dist/{chunk-WQEPA35Z.js → chunk-R3UCUGY6.js} +1 -1
- package/dist/chunk-R3UCUGY6.js.map +1 -0
- package/dist/{chunk-67YKGZLM.js → chunk-W7VJT6AN.js} +1 -1
- package/dist/chunk-W7VJT6AN.js.map +1 -0
- package/dist/{chunk-NIJCT4VK.js → chunk-WKHVLLKE.js} +1 -1
- package/dist/chunk-WKHVLLKE.js.map +1 -0
- package/dist/{chunk-UBVLJV3V.js → chunk-YSC5GEQJ.js} +1 -1
- package/dist/chunk-YSC5GEQJ.js.map +1 -0
- package/dist/finalization-git-internal.d.ts +72 -0
- package/dist/finalization-git-internal.d.ts.map +1 -0
- package/dist/finalization-git.d.ts +2 -47
- package/dist/finalization-git.d.ts.map +1 -1
- package/dist/finalization-git.js +3 -9
- package/dist/index.d.ts +3 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -25
- package/dist/index.js.map +1 -1
- package/dist/repository-change-launch-internal.d.ts +116 -0
- package/dist/repository-change-launch-internal.d.ts.map +1 -0
- package/dist/repository-change-launch.d.ts +2 -64
- package/dist/repository-change-launch.d.ts.map +1 -1
- package/dist/repository-change-launch.js +176 -8
- package/dist/repository-change-launch.js.map +1 -1
- package/dist/repository-change-process.d.ts +32 -2
- package/dist/repository-change-process.d.ts.map +1 -1
- package/dist/repository-change-state-internal.d.ts +30 -0
- package/dist/repository-change-state-internal.d.ts.map +1 -0
- package/dist/repository-change-state.d.ts +2 -17
- package/dist/repository-change-state.d.ts.map +1 -1
- package/dist/repository-change-state.js +1 -7
- package/dist/turns/generate-commit-message.d.ts +2 -0
- package/dist/turns/generate-commit-message.d.ts.map +1 -1
- package/dist/turns/generate-commit-message.js +1 -1
- package/dist/turns/generate-plan.d.ts +1 -0
- package/dist/turns/generate-plan.d.ts.map +1 -1
- package/dist/turns/generate-plan.js +1 -1
- package/dist/turns/implement.d.ts +1 -0
- package/dist/turns/implement.d.ts.map +1 -1
- package/dist/turns/implement.js +1 -1
- package/dist/turns/resolve-merge-conflict.d.ts +1 -0
- package/dist/turns/resolve-merge-conflict.d.ts.map +1 -1
- package/dist/turns/resolve-merge-conflict.js +1 -1
- package/dist/turns/review-implementation.d.ts +1 -0
- package/dist/turns/review-implementation.d.ts.map +1 -1
- package/dist/turns/review-implementation.js +1 -1
- package/dist/turns/review-plan.d.ts +1 -0
- package/dist/turns/review-plan.d.ts.map +1 -1
- package/dist/turns/review-plan.js +1 -1
- package/dist/turns/simplify-implementation.d.ts +1 -0
- package/dist/turns/simplify-implementation.d.ts.map +1 -1
- package/dist/turns/simplify-implementation.js +1 -1
- package/package.json +18 -8
- package/src/actions.ts +17 -1
- package/src/auto-work-branch-internal.ts +149 -0
- package/src/auto-work-branch.ts +7 -140
- package/src/finalization-git-internal.ts +855 -0
- package/src/finalization-git.ts +2 -828
- package/src/index.ts +16 -4
- package/src/repository-change-launch-internal.ts +328 -0
- package/src/repository-change-launch.ts +15 -264
- package/src/repository-change-process.ts +31 -3
- package/src/repository-change-state-internal.ts +90 -0
- package/src/repository-change-state.ts +2 -78
- package/src/turns/generate-commit-message.ts +2 -0
- package/src/turns/generate-plan.ts +1 -0
- package/src/turns/implement.ts +1 -0
- package/src/turns/resolve-merge-conflict.ts +1 -0
- package/src/turns/review-implementation.ts +1 -0
- package/src/turns/review-plan.ts +1 -0
- package/src/turns/simplify-implementation.ts +1 -0
- package/dist/chunk-5LVPKVI2.js.map +0 -1
- package/dist/chunk-67YKGZLM.js.map +0 -1
- package/dist/chunk-73LKROYK.js.map +0 -1
- package/dist/chunk-EP3ZC37F.js.map +0 -1
- package/dist/chunk-NIJCT4VK.js.map +0 -1
- package/dist/chunk-OFDNIT5X.js.map +0 -1
- package/dist/chunk-UBVLJV3V.js.map +0 -1
- package/dist/chunk-WQEPA35Z.js.map +0 -1
- package/dist/chunk-Y2S6JFVO.js +0 -185
- package/dist/chunk-Y2S6JFVO.js.map +0 -1
- package/dist/chunk-YIP4MP64.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,3 +16,15 @@ Turn labels use short task names: Plan, Review Plan, Implement, and Review.
|
|
|
16
16
|
Automated assessments use Assess Plan and Assess Implementation so operators can
|
|
17
17
|
distinguish them from their own decisions. Local, remote, and provider-specific
|
|
18
18
|
repository-change processes share these labels; persisted turn ids are unchanged.
|
|
19
|
+
|
|
20
|
+
## API support
|
|
21
|
+
|
|
22
|
+
The following exported declarations are `@public`:
|
|
23
|
+
|
|
24
|
+
- `@leitwerk-dev/coding`: `codingActionIds`, `createRepositoryChangeProcess`, `default`.
|
|
25
|
+
- `@leitwerk-dev/coding/auto-work-branch`: `buildAutoWorkBranchFromSeed`, `generateAutoWorkBranchRandomHex`.
|
|
26
|
+
- `@leitwerk-dev/coding/finalization-git`: `GitIdentity`, `commitAndPushWorkBranch`.
|
|
27
|
+
- `@leitwerk-dev/coding/repository-change-launch`: `NormalizedRepositoryChangeParamsInput`, `RepositoryChangeLaunchParams`, `createRepositoryChangeParamsCodec`, `normalizeRepositoryChangeParamsInput`, `repositoryChangeParamsRecord`.
|
|
28
|
+
- `@leitwerk-dev/coding/repository-change-state`: `RepositoryChangeState`.
|
|
29
|
+
|
|
30
|
+
See the [SDK compatibility policy](../../docs/process-sdk.md#api-compatibility) for member classifications and support guarantees.
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import type { FormDefinition } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @public */
|
|
2
3
|
export declare const codingActionIds: {
|
|
4
|
+
/** @public */
|
|
3
5
|
readonly approvePlan: "approve_plan";
|
|
6
|
+
/** @internal */
|
|
4
7
|
readonly requestRevision: "request_revision";
|
|
8
|
+
/** @internal */
|
|
5
9
|
readonly runReview: "run_review";
|
|
10
|
+
/** @internal */
|
|
6
11
|
readonly simplify: "simplify";
|
|
12
|
+
/** @internal */
|
|
7
13
|
readonly acceptReview: "accept_review";
|
|
14
|
+
/** @internal */
|
|
8
15
|
readonly requestReviewChanges: "request_review_changes";
|
|
16
|
+
/** @internal */
|
|
9
17
|
readonly dismissReview: "dismiss_review";
|
|
18
|
+
/** @public */
|
|
10
19
|
readonly finalizeChange: "finalize_change";
|
|
11
20
|
};
|
|
21
|
+
/** @internal */
|
|
12
22
|
export declare const requestRevisionForm: FormDefinition;
|
|
23
|
+
/** @internal */
|
|
13
24
|
export declare const requestReviewChangesForm: FormDefinition;
|
|
25
|
+
/** @internal */
|
|
14
26
|
export declare const acceptReviewForm: FormDefinition;
|
|
27
|
+
/** @internal */
|
|
15
28
|
export declare function createFinalizeChangeForm(copy: {
|
|
29
|
+
/** @internal */
|
|
16
30
|
title: string;
|
|
17
31
|
}): FormDefinition;
|
|
18
32
|
//# sourceMappingURL=actions.d.ts.map
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,cAAc;AACd,eAAO,MAAM,eAAe;IAC3B,cAAc;;IAEd,gBAAgB;;IAEhB,gBAAgB;;IAEhB,gBAAgB;;IAEhB,gBAAgB;;IAEhB,gBAAgB;;IAEhB,gBAAgB;;IAEhB,cAAc;;CAEL,CAAC;AAaX,gBAAgB;AAChB,eAAO,MAAM,mBAAmB,gBAK/B,CAAC;AACF,gBAAgB;AAChB,eAAO,MAAM,wBAAwB,gBAKpC,CAAC;AACF,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,EAAE,cAc9B,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC9C,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;CACd,GAAG,cAAc,CAOjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export interface ResolveBaseBranchShaInput {
|
|
3
|
+
/** @internal */
|
|
4
|
+
repoLocator: string;
|
|
5
|
+
/** @internal */
|
|
6
|
+
baseBranch: string;
|
|
7
|
+
/** @internal */
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
}
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare function slugifyBranchSourceForBranch(sourceText: string): string;
|
|
12
|
+
/** @public */
|
|
13
|
+
export declare function generateAutoWorkBranchRandomHex(): string;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare function buildAutoWorkBranch(sourceText: string, baseBranchSha: string, randomHex?: string): string;
|
|
16
|
+
/** @public */
|
|
17
|
+
export declare function buildAutoWorkBranchFromSeed(sourceText: string, seed: string, randomHex?: string): string;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare function resolveBaseBranchSha(input: ResolveBaseBranchShaInput): Promise<string>;
|
|
20
|
+
//# sourceMappingURL=auto-work-branch-internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-work-branch-internal.d.ts","sourceRoot":"","sources":["../src/auto-work-branch-internal.ts"],"names":[],"mappings":"AAcA,gBAAgB;AAChB,MAAM,WAAW,yBAAyB;IACzC,gBAAgB;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAoBD,gBAAgB;AAChB,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAKvE;AAUD,cAAc;AACd,wBAAgB,+BAA+B,IAAI,MAAM,CAExD;AAYD,gBAAgB;AAChB,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,SAAS,SAAoC,GAC3C,MAAM,CAKR;AAOD,cAAc;AACd,wBAAgB,2BAA2B,CAC1C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,SAAS,SAAoC,GAC3C,MAAM,CAER;AAcD,gBAAgB;AAChB,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoC5F"}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
baseBranch: string;
|
|
4
|
-
timeoutMs?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function slugifyBranchSourceForBranch(sourceText: string): string;
|
|
7
|
-
export declare function generateAutoWorkBranchRandomHex(): string;
|
|
8
|
-
export declare function buildAutoWorkBranch(sourceText: string, baseBranchSha: string, randomHex?: string): string;
|
|
9
|
-
/** Builds the same safe branch shape when authenticated remote SHA lookup must wait for a worker. */
|
|
10
|
-
export declare function gitShaLikeDigestFromSeed(seed: string): string;
|
|
11
|
-
export declare function buildAutoWorkBranchFromSeed(sourceText: string, seed: string, randomHex?: string): string;
|
|
12
|
-
export declare function resolveBaseBranchSha(input: ResolveBaseBranchShaInput): Promise<string>;
|
|
1
|
+
export type { ResolveBaseBranchShaInput } from "./auto-work-branch-internal.js";
|
|
2
|
+
export { buildAutoWorkBranch, buildAutoWorkBranchFromSeed, generateAutoWorkBranchRandomHex, resolveBaseBranchSha, } from "./auto-work-branch-internal.js";
|
|
13
3
|
//# sourceMappingURL=auto-work-branch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-work-branch.d.ts","sourceRoot":"","sources":["../src/auto-work-branch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-work-branch.d.ts","sourceRoot":"","sources":["../src/auto-work-branch.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EACN,mBAAmB,EACnB,2BAA2B,EAC3B,+BAA+B,EAC/B,oBAAoB,GACpB,MAAM,gCAAgC,CAAC"}
|
package/dist/auto-work-branch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-PX6F3LHL.js";
|
|
2
2
|
|
|
3
|
-
// src/auto-work-branch.ts
|
|
3
|
+
// src/auto-work-branch-internal.ts
|
|
4
4
|
import { execFile } from "child_process";
|
|
5
5
|
import { createHash, randomBytes } from "crypto";
|
|
6
6
|
import { promisify } from "util";
|
|
@@ -101,8 +101,6 @@ export {
|
|
|
101
101
|
buildAutoWorkBranch,
|
|
102
102
|
buildAutoWorkBranchFromSeed,
|
|
103
103
|
generateAutoWorkBranchRandomHex,
|
|
104
|
-
|
|
105
|
-
resolveBaseBranchSha,
|
|
106
|
-
slugifyBranchSourceForBranch
|
|
104
|
+
resolveBaseBranchSha
|
|
107
105
|
};
|
|
108
106
|
//# sourceMappingURL=auto-work-branch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auto-work-branch.ts"],"sourcesContent":["import { execFile } from \"node:child_process\";\nimport { createHash, randomBytes } from \"node:crypto\";\nimport { promisify } from \"node:util\";\nimport { trimToNull } from \"@leitwerk-dev/domain\";\nimport { sanitizeWorkerSubprocessEnv } from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\n\nconst DEFAULT_BASE_SHA_SUFFIX_LENGTH = 12;\nconst DEFAULT_MAX_BRANCH_SLUG_LENGTH = 48;\nconst DEFAULT_PROMPT_WORD_COUNT = 5;\nconst AUTO_BRANCH_RANDOM_HEX_LENGTH = 3;\nconst DEFAULT_GIT_TIMEOUT_MS = 15_000;\nconst execFileAsync = promisify(execFile);\n\nexport interface ResolveBaseBranchShaInput {\n\trepoLocator: string;\n\tbaseBranch: string;\n\ttimeoutMs?: number;\n}\n\nfunction truncateSlugAtSeparator(value: string, maxLength: number): string {\n\tif (value.length <= maxLength) {\n\t\treturn value;\n\t}\n\treturn value.slice(0, maxLength).replace(/-+$/g, \"\");\n}\n\nfunction normalizedBranchWords(value: string): string[] {\n\treturn (\n\t\tvalue\n\t\t\t.normalize(\"NFKD\")\n\t\t\t.replace(/[\\u0300-\\u036f]/g, \"\")\n\t\t\t.toLowerCase()\n\t\t\t.replace(/[’']/g, \"\")\n\t\t\t.match(/[a-z0-9]+/g) ?? []\n\t);\n}\n\nexport function slugifyBranchSourceForBranch(sourceText: string): string {\n\tconst words = normalizedBranchWords(sourceText).slice(0, DEFAULT_PROMPT_WORD_COUNT);\n\tconst normalized = words.join(\"-\");\n\tconst slug = truncateSlugAtSeparator(normalized, DEFAULT_MAX_BRANCH_SLUG_LENGTH);\n\treturn slug || \"change\";\n}\n\nfunction normalizeSha(value: string): string {\n\tconst sha = value.trim().toLowerCase();\n\tif (!/^[0-9a-f]{7,64}$/.test(sha)) {\n\t\tthrow new Error(`Expected a git object sha, got '${value}'`);\n\t}\n\treturn sha;\n}\n\nexport function generateAutoWorkBranchRandomHex(): string {\n\treturn randomBytes(2).toString(\"hex\").slice(0, AUTO_BRANCH_RANDOM_HEX_LENGTH);\n}\n\nfunction normalizeRandomHex(value: string): string {\n\tconst normalized = value.trim().toLowerCase();\n\tif (!new RegExp(`^[0-9a-f]{${AUTO_BRANCH_RANDOM_HEX_LENGTH}}$`).test(normalized)) {\n\t\tthrow new Error(\n\t\t\t`Expected ${AUTO_BRANCH_RANDOM_HEX_LENGTH} random hex characters, got '${value}'`,\n\t\t);\n\t}\n\treturn normalized;\n}\n\nexport function buildAutoWorkBranch(\n\tsourceText: string,\n\tbaseBranchSha: string,\n\trandomHex = generateAutoWorkBranchRandomHex(),\n): string {\n\tconst slug = slugifyBranchSourceForBranch(sourceText);\n\tconst suffix = normalizeRandomHex(randomHex);\n\tconst sha = normalizeSha(baseBranchSha);\n\treturn `${slug}-${suffix}-${sha.slice(0, DEFAULT_BASE_SHA_SUFFIX_LENGTH)}`;\n}\n\n/** Builds the same safe branch shape when authenticated remote SHA lookup must wait for a worker. */\
|
|
1
|
+
{"version":3,"sources":["../src/auto-work-branch-internal.ts"],"sourcesContent":["import { execFile } from \"node:child_process\";\nimport { createHash, randomBytes } from \"node:crypto\";\nimport { promisify } from \"node:util\";\nimport { trimToNull } from \"@leitwerk-dev/domain\";\nimport { sanitizeWorkerSubprocessEnv } from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\n\nconst DEFAULT_BASE_SHA_SUFFIX_LENGTH = 12;\nconst DEFAULT_MAX_BRANCH_SLUG_LENGTH = 48;\nconst DEFAULT_PROMPT_WORD_COUNT = 5;\nconst AUTO_BRANCH_RANDOM_HEX_LENGTH = 3;\nconst DEFAULT_GIT_TIMEOUT_MS = 15_000;\nconst execFileAsync = promisify(execFile);\n\n/** @internal */\nexport interface ResolveBaseBranchShaInput {\n\t/** @internal */\n\trepoLocator: string;\n\t/** @internal */\n\tbaseBranch: string;\n\t/** @internal */\n\ttimeoutMs?: number;\n}\n\nfunction truncateSlugAtSeparator(value: string, maxLength: number): string {\n\tif (value.length <= maxLength) {\n\t\treturn value;\n\t}\n\treturn value.slice(0, maxLength).replace(/-+$/g, \"\");\n}\n\nfunction normalizedBranchWords(value: string): string[] {\n\treturn (\n\t\tvalue\n\t\t\t.normalize(\"NFKD\")\n\t\t\t.replace(/[\\u0300-\\u036f]/g, \"\")\n\t\t\t.toLowerCase()\n\t\t\t.replace(/[’']/g, \"\")\n\t\t\t.match(/[a-z0-9]+/g) ?? []\n\t);\n}\n\n/** @internal */\nexport function slugifyBranchSourceForBranch(sourceText: string): string {\n\tconst words = normalizedBranchWords(sourceText).slice(0, DEFAULT_PROMPT_WORD_COUNT);\n\tconst normalized = words.join(\"-\");\n\tconst slug = truncateSlugAtSeparator(normalized, DEFAULT_MAX_BRANCH_SLUG_LENGTH);\n\treturn slug || \"change\";\n}\n\nfunction normalizeSha(value: string): string {\n\tconst sha = value.trim().toLowerCase();\n\tif (!/^[0-9a-f]{7,64}$/.test(sha)) {\n\t\tthrow new Error(`Expected a git object sha, got '${value}'`);\n\t}\n\treturn sha;\n}\n\n/** @public */\nexport function generateAutoWorkBranchRandomHex(): string {\n\treturn randomBytes(2).toString(\"hex\").slice(0, AUTO_BRANCH_RANDOM_HEX_LENGTH);\n}\n\nfunction normalizeRandomHex(value: string): string {\n\tconst normalized = value.trim().toLowerCase();\n\tif (!new RegExp(`^[0-9a-f]{${AUTO_BRANCH_RANDOM_HEX_LENGTH}}$`).test(normalized)) {\n\t\tthrow new Error(\n\t\t\t`Expected ${AUTO_BRANCH_RANDOM_HEX_LENGTH} random hex characters, got '${value}'`,\n\t\t);\n\t}\n\treturn normalized;\n}\n\n/** @internal */\nexport function buildAutoWorkBranch(\n\tsourceText: string,\n\tbaseBranchSha: string,\n\trandomHex = generateAutoWorkBranchRandomHex(),\n): string {\n\tconst slug = slugifyBranchSourceForBranch(sourceText);\n\tconst suffix = normalizeRandomHex(randomHex);\n\tconst sha = normalizeSha(baseBranchSha);\n\treturn `${slug}-${suffix}-${sha.slice(0, DEFAULT_BASE_SHA_SUFFIX_LENGTH)}`;\n}\n\n/** Builds the same safe branch shape when authenticated remote SHA lookup must wait for a worker. @internal */\nfunction gitShaLikeDigestFromSeed(seed: string): string {\n\treturn createHash(\"sha256\").update(seed).digest(\"hex\");\n}\n\n/** @public */\nexport function buildAutoWorkBranchFromSeed(\n\tsourceText: string,\n\tseed: string,\n\trandomHex = generateAutoWorkBranchRandomHex(),\n): string {\n\treturn buildAutoWorkBranch(sourceText, gitShaLikeDigestFromSeed(seed), randomHex);\n}\n\nfunction baseBranchRef(baseBranch: string): string {\n\tconst trimmed = trimToNull(baseBranch);\n\tif (!trimmed) {\n\t\tthrow new Error(\"baseBranch is required to resolve an automatic work branch\");\n\t}\n\treturn trimmed.startsWith(\"refs/heads/\") ? trimmed : `refs/heads/${trimmed}`;\n}\n\nfunction outputToString(value: unknown): string {\n\treturn typeof value === \"string\" ? value : Buffer.isBuffer(value) ? value.toString(\"utf8\") : \"\";\n}\n\n/** @internal */\nexport async function resolveBaseBranchSha(input: ResolveBaseBranchShaInput): Promise<string> {\n\tconst repoLocator = trimToNull(input.repoLocator);\n\tif (!repoLocator) {\n\t\tthrow new Error(\"repoLocator is required to resolve an automatic work branch\");\n\t}\n\tconst ref = baseBranchRef(input.baseBranch);\n\tlet stdout = \"\";\n\ttry {\n\t\tconst result = await execFileAsync(resolveGitBinary(), [\"ls-remote\", repoLocator, ref], {\n\t\t\tencoding: \"utf8\",\n\t\t\tenv: sanitizeWorkerSubprocessEnv(process.env, { GIT_TERMINAL_PROMPT: \"0\" }),\n\t\t\ttimeout: input.timeoutMs ?? DEFAULT_GIT_TIMEOUT_MS,\n\t\t});\n\t\tstdout = outputToString(result.stdout);\n\t} catch (error) {\n\t\tconst errorOutput = error as { message?: string; stdout?: unknown; stderr?: unknown };\n\t\tconst message =\n\t\t\ttrimToNull(outputToString(errorOutput.stderr)) ??\n\t\t\ttrimToNull(outputToString(errorOutput.stdout)) ??\n\t\t\terrorOutput.message ??\n\t\t\t\"unknown git error\";\n\t\tthrow new Error(`Failed to resolve '${ref}' from '${repoLocator}': ${message}`);\n\t}\n\tconst match = stdout\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter(Boolean)\n\t\t.map((line) => line.split(/\\s+/))\n\t\t.find((parts) => parts[1] === ref);\n\tconst sha = match?.[0];\n\tif (!sha) {\n\t\tthrow new Error(\n\t\t\t`Repository '${repoLocator}' does not expose base branch '${input.baseBranch}'`,\n\t\t);\n\t}\n\treturn normalizeSha(sha);\n}\n"],"mappings":";;;AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY,mBAAmB;AACxC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,mCAAmC;AAC5C,SAAS,wBAAwB;AAEjC,IAAM,iCAAiC;AACvC,IAAM,iCAAiC;AACvC,IAAM,4BAA4B;AAClC,IAAM,gCAAgC;AACtC,IAAM,yBAAyB;AAC/B,IAAM,gBAAgB,UAAU,QAAQ;AAYxC,SAAS,wBAAwB,OAAe,WAA2B;AAC1E,MAAI,MAAM,UAAU,WAAW;AAC9B,WAAO;AAAA,EACR;AACA,SAAO,MAAM,MAAM,GAAG,SAAS,EAAE,QAAQ,QAAQ,EAAE;AACpD;AAEA,SAAS,sBAAsB,OAAyB;AACvD,SACC,MACE,UAAU,MAAM,EAChB,QAAQ,oBAAoB,EAAE,EAC9B,YAAY,EACZ,QAAQ,SAAS,EAAE,EACnB,MAAM,YAAY,KAAK,CAAC;AAE5B;AAGO,SAAS,6BAA6B,YAA4B;AACxE,QAAM,QAAQ,sBAAsB,UAAU,EAAE,MAAM,GAAG,yBAAyB;AAClF,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FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function buildReviewPlanPrompt(\n\tctx: FlowPromptContext<unknown, StructuralProcessState, \"plan\">,\n): string {\n\treturn `Review the plan against this requested change:\n${ctx.prompts.initial}\n\nRepository root: . (the current working directory)\n\nPlan:\n${ctx.input.plan}\n\nRules:\n- review the plan only; do not rewrite the plan\n- if you inspect repository files for context, read only inside the current working directory\n- use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)\n- do not modify files, branches, commits, or git index state\n- do not read from or write to any original source repository path outside the process workspace\n- evaluate scope, sequencing, risks, and acceptance criteria\n- publish a short Markdown approval note when the plan is solid\n- publish concise, actionable Markdown feedback when the plan needs changes`;\n}\n"],"mappings":";AAGO,SAAS,sBACf,KACS;AACT,SAAO;AAAA,EACN,IAAI,QAAQ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,IAAI,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWhB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/turns/simplify-implementation.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function buildSimplifyImplementationPrompt(\n\t_ctx: FlowPromptContext<unknown, StructuralProcessState>,\n): string {\n\treturn `Repository root: . (the current working directory)\n\nFind worthwhile ways to simplify the current implementation and nearby code, reducing lines without reducing clarity or behavior. If the implementation is already appropriately simple, say so.\n\nInspect the repository read-only and publish a concise simplification plan. Do not modify any files.`;\n}\n"],"mappings":";AAGO,SAAS,kCACf,MACS;AACT,SAAO;AAAA;AAAA;AAAA;AAAA;AAKR;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/repository-change-state.ts
|
|
1
|
+
// src/repository-change-state-internal.ts
|
|
2
2
|
import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
3
3
|
function createEmptyRepositoryChangeFinalizationState() {
|
|
4
4
|
return {
|
|
@@ -58,4 +58,4 @@ export {
|
|
|
58
58
|
clearReviewRefs,
|
|
59
59
|
resetRepositoryChangeFinalizationState
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-HUVXPZSF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/repository-change-state-internal.ts"],"sourcesContent":["import type { Codec, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\nimport { parseStructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @public */\nexport interface RepositoryChangeFinalizationState {\n\t/** @internal */\n\texpectedPostConflictHeadSha: string | null;\n\t/** @internal */\n\tusedConflictResolution: boolean;\n\t/** @internal */\n\tfinalizationSummaryMarkdown: string | null;\n\t/** @internal */\n\tfinalizedHeadSha: string | null;\n\t/** @public */\n\tgeneratedCommitMessage: string | null;\n}\n\n/** @public */\nexport interface RepositoryChangeState extends StructuralProcessState {\n\t/** @public */\n\tfinalization: RepositoryChangeFinalizationState;\n\t/** Namespaced state owned by a caller-supplied publication workflow. @public */\n\textensionState?: Record<string, unknown>;\n}\n\n/** @internal */\nexport function createEmptyRepositoryChangeFinalizationState(): RepositoryChangeFinalizationState {\n\treturn {\n\t\texpectedPostConflictHeadSha: null,\n\t\tusedConflictResolution: false,\n\t\tfinalizationSummaryMarkdown: null,\n\t\tfinalizedHeadSha: null,\n\t\tgeneratedCommitMessage: null,\n\t};\n}\n\nfunction stringOrNull(value: unknown): string | null {\n\treturn typeof value === \"string\" ? value : null;\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\texpectedPostConflictHeadSha: stringOrNull(record.expectedPostConflictHeadSha),\n\t\tusedConflictResolution: record.usedConflictResolution === true,\n\t\tfinalizationSummaryMarkdown: stringOrNull(record.finalizationSummaryMarkdown),\n\t\tfinalizedHeadSha: stringOrNull(record.finalizedHeadSha),\n\t\t// Backward-compatible decoding for state persisted before commit-message generation.\n\t\tgeneratedCommitMessage: stringOrNull(record.generatedCommitMessage),\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};\n\t},\n\tserialize(value) {\n\t\treturn value;\n\t},\n};\n\n/** @internal */\nexport function clearReviewRefs(\n\tsemanticEntryRefs: RepositoryChangeState[\"semanticEntryRefs\"],\n): RepositoryChangeState[\"semanticEntryRefs\"] {\n\treturn {\n\t\t...semanticEntryRefs,\n\t\treview: null,\n\t};\n}\n\n/** @internal */\nexport function resetRepositoryChangeFinalizationState(\n\toverrides: Partial<RepositoryChangeFinalizationState> = {},\n): RepositoryChangeFinalizationState {\n\treturn {\n\t\t...createEmptyRepositoryChangeFinalizationState(),\n\t\t...overrides,\n\t};\n}\n"],"mappings":";AACA,SAAS,mCAAmC;AAyBrC,SAAS,+CAAkF;AACjG,SAAO;AAAA,IACN,6BAA6B;AAAA,IAC7B,wBAAwB;AAAA,IACxB,6BAA6B;AAAA,IAC7B,kBAAkB;AAAA,IAClB,wBAAwB;AAAA,EACzB;AACD;AAEA,SAAS,aAAa,OAA+B;AACpD,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC5C;AAEA,SAAS,SAAS,OAAyC;AAC1D,SAAO,OAAO,UAAU,YAAY,UAAU,OAAQ,QAAoC,CAAC;AAC5F;AAEA,SAAS,uBAAuB,OAAmD;AAClF,QAAM,SAAS,SAAS,KAAK;AAC7B,SAAO;AAAA,IACN,6BAA6B,aAAa,OAAO,2BAA2B;AAAA,IAC5E,wBAAwB,OAAO,2BAA2B;AAAA,IAC1D,6BAA6B,aAAa,OAAO,2BAA2B;AAAA,IAC5E,kBAAkB,aAAa,OAAO,gBAAgB;AAAA;AAAA,IAEtD,wBAAwB,aAAa,OAAO,sBAAsB;AAAA,EACnE;AACD;AAGO,IAAM,6BAA2D;AAAA,EACvE,MAAM,OAAO;AACZ,UAAM,SAAS,SAAS,KAAK;AAC7B,WAAO;AAAA,MACN,GAAG,4BAA4B,MAAM;AAAA,MACrC,cAAc,uBAAuB,OAAO,YAAY;AAAA,MACxD,gBAAgB,SAAS,OAAO,cAAc;AAAA,IAC/C;AAAA,EACD;AAAA,EACA,UAAU,OAAO;AAChB,WAAO;AAAA,EACR;AACD;AAGO,SAAS,gBACf,mBAC6C;AAC7C,SAAO;AAAA,IACN,GAAG;AAAA,IACH,QAAQ;AAAA,EACT;AACD;AAGO,SAAS,uCACf,YAAwD,CAAC,GACrB;AACpC,SAAO;AAAA,IACN,GAAG,6CAA6C;AAAA,IAChD,GAAG;AAAA,EACJ;AACD;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// src/finalization-git.ts
|
|
1
|
+
// src/finalization-git-internal.ts
|
|
2
2
|
import { execFileSync } from "child_process";
|
|
3
|
-
import { existsSync
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
4
|
import { homedir } from "os";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
} from "@leitwerk-dev/process-sdk";
|
|
12
12
|
import { resolveGitBinary } from "@leitwerk-dev/process-sdk/git-binary";
|
|
13
13
|
var DeterministicGitError = class extends Error {
|
|
14
|
+
/** @internal */
|
|
14
15
|
errorClass = "git_error";
|
|
16
|
+
/** @internal */
|
|
15
17
|
constructor(message) {
|
|
16
18
|
super(message);
|
|
17
19
|
this.name = "DeterministicGitError";
|
|
@@ -456,7 +458,12 @@ function commitAndPushWorkBranch(input) {
|
|
|
456
458
|
gitIdentity: input.gitIdentity
|
|
457
459
|
});
|
|
458
460
|
const pushTarget = pushAndVerify(repoPath, input.workBranch, headSha);
|
|
459
|
-
return {
|
|
461
|
+
return {
|
|
462
|
+
/** @public */
|
|
463
|
+
headSha,
|
|
464
|
+
/** @internal */
|
|
465
|
+
pushTarget
|
|
466
|
+
};
|
|
460
467
|
}
|
|
461
468
|
function runDeterministicFinalization(ctx, gitIdentity) {
|
|
462
469
|
const progressSteps = [
|
|
@@ -599,18 +606,9 @@ function runDeterministicFinalization(ctx, gitIdentity) {
|
|
|
599
606
|
})
|
|
600
607
|
};
|
|
601
608
|
}
|
|
602
|
-
function readMergeMessage(repoPath) {
|
|
603
|
-
const messagePath = path.resolve(repoPath, git(repoPath, "rev-parse", "--git-dir"), "MERGE_MSG");
|
|
604
|
-
if (!existsSync(messagePath)) {
|
|
605
|
-
return null;
|
|
606
|
-
}
|
|
607
|
-
return trimToNull(readFileSync(messagePath, "utf8"));
|
|
608
|
-
}
|
|
609
609
|
|
|
610
610
|
export {
|
|
611
|
-
DeterministicGitError,
|
|
612
611
|
commitAndPushWorkBranch,
|
|
613
|
-
runDeterministicFinalization
|
|
614
|
-
readMergeMessage
|
|
612
|
+
runDeterministicFinalization
|
|
615
613
|
};
|
|
616
|
-
//# sourceMappingURL=chunk-
|
|
614
|
+
//# sourceMappingURL=chunk-MY6XFGHM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/finalization-git-internal.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detectRepoLocatorKind, trimToNull, type WorkerErrorClass } from \"@leitwerk-dev/domain\";\nimport {\n\ttype FlowAutomaticRunContext,\n\trepositoryGitArgs,\n\trepositoryGitSubprocessEnv,\n\ttype StructuralProcessState,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\n\n/** @internal */\ntype DeterministicFinalizationMergeMode = \"noop\" | \"fast_forward\" | \"merge_commit\";\n\n/** @public */\nexport interface GitIdentity {\n\t/** @public */\n\tname: string;\n\t/** @public */\n\temail: string;\n}\n\ninterface DeterministicFinalizationInput {\n\trepoPath: string;\n\tworkspaceClonePath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\texpectedPostConflictHeadSha?: string | null;\n\tusedConflictResolution?: boolean;\n\tcommitMessage: string;\n\tgitIdentity?: GitIdentity;\n}\n\n/** @internal */\ntype DeterministicFinalizationResult =\n\t| {\n\t\t\t/** @internal */\n\t\t\toutcome: \"merge_conflict\";\n\t\t\t/** @internal */\n\t\t\tparams: {\n\t\t\t\t/** @internal */\n\t\t\t\theadSha: string;\n\t\t\t\t/** @internal */\n\t\t\t\tconflictedFiles: string[];\n\t\t\t\t/** @internal */\n\t\t\t\tfetchedBaseSha: string | null;\n\t\t\t};\n\t }\n\t| {\n\t\t\t/** @internal */\n\t\t\toutcome: \"finalized\";\n\t\t\t/** @internal */\n\t\t\tparams: {\n\t\t\t\t/** @internal */\n\t\t\t\theadSha: string;\n\t\t\t\t/** @internal */\n\t\t\t\tmergeMode: DeterministicFinalizationMergeMode;\n\t\t\t\t/** @internal */\n\t\t\t\tpushTarget: string;\n\t\t\t\t/** @internal */\n\t\t\t\tusedConflictResolution: boolean;\n\t\t\t};\n\t\t\t/** @internal */\n\t\t\tmarkdown: string;\n\t };\n\n/** @internal */\nclass 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\ninterface LocalSourceRepo {\n\tpath: string;\n\tkind: \"bare\" | \"non_bare\";\n}\n\nfunction normalizeLines(value: string | null | undefined): string[] {\n\tif (!value) {\n\t\treturn [];\n\t}\n\treturn value\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\");\n}\n\nfunction abbreviateSha(sha: string): string {\n\treturn sha.slice(0, 12);\n}\n\nfunction describeMergeMode(mode: DeterministicFinalizationMergeMode): string {\n\tswitch (mode) {\n\t\tcase \"noop\":\n\t\t\treturn \"Already up to date\";\n\t\tcase \"fast_forward\":\n\t\t\treturn \"Fast-forwarded from origin\";\n\t\tcase \"merge_commit\":\n\t\t\treturn \"Created a merge commit\";\n\t}\n}\n\nfunction gitConfigIdentityEnv(): NodeJS.ProcessEnv {\n\tconst env = repositoryGitSubprocessEnv(\"repo\", { GIT_TERMINAL_PROMPT: \"0\" });\n\t// Identity is operator-owned repository/global Git configuration, never an\n\t// ambient worker identity or a Leitwerk override.\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 runGit(repoPath: string, args: readonly string[], identity?: GitIdentity): GitExecResult {\n\tconst trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;\n\ttry {\n\t\tconst stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {\n\t\t\tcwd: repoPath,\n\t\t\tencoding: \"utf8\",\n\t\t\tenv: gitConfigIdentityEnv(),\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\t\treturn {\n\t\t\tok: true,\n\t\t\tstdout,\n\t\t\tstderr: \"\",\n\t\t};\n\t} catch (error) {\n\t\tconst execError = error as {\n\t\t\tstdout?: string | Buffer;\n\t\t\tstderr?: string | Buffer;\n\t\t\tmessage?: string;\n\t\t};\n\t\treturn {\n\t\t\tok: false,\n\t\t\tstdout: execError.stdout?.toString() ?? \"\",\n\t\t\tstderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? \"\",\n\t\t};\n\t}\n}\n\nfunction gitFailureDetail(result: GitExecResult): string {\n\treturn trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? \"unknown git error\";\n}\n\nfunction checkedGit(\n\trepoPath: string,\n\targs: readonly string[],\n\tfailureMessage: string,\n\tidentity?: GitIdentity,\n): string {\n\tconst result = runGit(repoPath, args, identity);\n\tif (!result.ok) {\n\t\tthrow new DeterministicGitError(`${failureMessage}: ${gitFailureDetail(result)}`);\n\t}\n\treturn result.stdout;\n}\n\nfunction git(repoPath: string, ...args: string[]): string {\n\treturn checkedGit(repoPath, args, `git ${args.join(\" \")} failed in '${repoPath}'`).trim();\n}\n\nfunction gitOrNull(repoPath: string, ...args: string[]): string | null {\n\tconst result = runGit(repoPath, args);\n\tif (!result.ok) {\n\t\treturn null;\n\t}\n\treturn trimToNull(result.stdout);\n}\n\nfunction repoExists(repoPath: string): boolean {\n\treturn existsSync(repoPath) && existsSync(path.join(repoPath, \".git\"));\n}\n\nfunction gitRepositoryExists(repoPath: string): boolean {\n\treturn existsSync(repoPath) && runGit(repoPath, [\"rev-parse\", \"--git-dir\"]).ok;\n}\n\nfunction currentBranch(repoPath: string): string {\n\treturn git(repoPath, \"branch\", \"--show-current\");\n}\n\nfunction currentHeadSha(repoPath: string): string {\n\treturn git(repoPath, \"rev-parse\", \"HEAD\");\n}\n\nfunction originBaseRef(baseBranch: string): string {\n\treturn `origin/${baseBranch}`;\n}\n\nfunction remoteOriginUrl(repoPath: string): string {\n\tconst remoteUrl = gitOrNull(repoPath, \"remote\", \"get-url\", \"origin\");\n\tif (!remoteUrl) {\n\t\tthrow new DeterministicGitError(`Repository '${repoPath}' does not have an 'origin' remote`);\n\t}\n\treturn remoteUrl;\n}\n\nfunction expandHomePath(value: string): string {\n\tif (value === \"~\") {\n\t\treturn homedir();\n\t}\n\tif (value.startsWith(\"~/\")) {\n\t\treturn path.join(homedir(), value.slice(2));\n\t}\n\treturn value;\n}\n\nfunction resolveLocalRepoPath(repoPath: string, repoLocator: string): string | null {\n\tif (detectRepoLocatorKind(repoLocator) !== \"local_path\") {\n\t\treturn null;\n\t}\n\tif (repoLocator.startsWith(\"file://\")) {\n\t\ttry {\n\t\t\treturn fileURLToPath(repoLocator);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn path.resolve(repoPath, expandHomePath(repoLocator));\n}\n\nfunction isBareRepository(repoPath: string): boolean {\n\treturn git(repoPath, \"rev-parse\", \"--is-bare-repository\") === \"true\";\n}\n\nfunction resolveLocalSourceRepo(repoPath: string): LocalSourceRepo | null {\n\tconst remoteUrl = remoteOriginUrl(repoPath);\n\tconst localRepoPath = resolveLocalRepoPath(repoPath, remoteUrl);\n\tif (!localRepoPath || !gitRepositoryExists(localRepoPath)) {\n\t\treturn null;\n\t}\n\treturn {\n\t\tpath: localRepoPath,\n\t\tkind: isBareRepository(localRepoPath) ? \"bare\" : \"non_bare\",\n\t};\n}\n\nfunction workingTreeStatus(repoPath: string): string[] {\n\tconst rawStatus = gitOrNull(repoPath, \"status\", \"--porcelain\");\n\treturn (rawStatus ?? \"\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.replace(/\\s+$/, \"\"))\n\t\t.filter((line) => line !== \"\")\n\t\t.map((line) => line.slice(2).trim())\n\t\t.filter((line) => line !== \"\");\n}\n\nfunction conflictedFiles(repoPath: string): string[] {\n\treturn normalizeLines(gitOrNull(repoPath, \"diff\", \"--name-only\", \"--diff-filter=U\"));\n}\n\nfunction mergeHeadPath(repoPath: string): string {\n\tconst gitDir = git(repoPath, \"rev-parse\", \"--git-dir\");\n\treturn path.resolve(repoPath, gitDir, \"MERGE_HEAD\");\n}\n\nfunction mergeInProgress(repoPath: string): boolean {\n\treturn existsSync(mergeHeadPath(repoPath));\n}\n\nfunction assertExpectedCheckout(repoPath: string, workBranch: string): void {\n\tconst branch = currentBranch(repoPath);\n\tif (branch !== workBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected '${repoPath}' to be checked out on '${workBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n}\n\nfunction assertFinalizationCheckout(input: {\n\trepoPath: string;\n\tworkBranch: string;\n\tcommitMessage: string;\n\tmissingCommitMessage: string;\n}): void {\n\tif (!repoExists(input.repoPath)) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Repository workspace '${input.repoPath}' does not exist or is not a git repository`,\n\t\t);\n\t}\n\tassertExpectedCheckout(input.repoPath, input.workBranch);\n\tif (!trimToNull(input.commitMessage)) {\n\t\tthrow new DeterministicGitError(input.missingCommitMessage);\n\t}\n}\n\nfunction assertGitIdentity(repoPath: string, identity?: GitIdentity): void {\n\tconst author = runGit(repoPath, [\"var\", \"GIT_AUTHOR_IDENT\"], identity);\n\tconst committer = runGit(repoPath, [\"var\", \"GIT_COMMITTER_IDENT\"], identity);\n\tif (!author.ok || !committer.ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t\"Git author/committer identity is not configured. Configure user.name and user.email in this repository or the operator's global Git config, then retry finalization.\",\n\t\t);\n\t}\n}\n\nfunction commitDirtyWorktree(\n\trepoPath: string,\n\tcommitMessage: string,\n\tidentity?: GitIdentity,\n): string {\n\tassertGitIdentity(repoPath, identity);\n\tcheckedGit(repoPath, [\"add\", \"--all\"], \"Failed to stage the completed change\");\n\tcheckedGit(\n\t\trepoPath,\n\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"commit\", \"--no-gpg-sign\", \"-m\", commitMessage],\n\t\t\"Failed to commit the completed change\",\n\t\tidentity,\n\t);\n\tconst remaining = workingTreeStatus(repoPath);\n\tif (remaining.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Deterministic commit left uncommitted changes: ${remaining.join(\", \")}`,\n\t\t);\n\t}\n\treturn currentHeadSha(repoPath);\n}\n\nfunction commitIfDirty(input: {\n\trepoPath: string;\n\tcommitMessage: string;\n\tgitIdentity?: GitIdentity;\n}): string {\n\tconst status = workingTreeStatus(input.repoPath);\n\treturn status.length > 0\n\t\t? commitDirtyWorktree(input.repoPath, input.commitMessage, input.gitIdentity)\n\t\t: currentHeadSha(input.repoPath);\n}\n\nfunction assertPostConflictCheckpoint(\n\tinput: DeterministicFinalizationInput,\n\trepoPath: string,\n): void {\n\tif (!trimToNull(input.expectedPostConflictHeadSha)) {\n\t\treturn;\n\t}\n\tif (mergeInProgress(repoPath) || conflictedFiles(repoPath).length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t\"Conflict-resolution helper reported a clean merge, but the repository is still in a merge-conflict state\",\n\t\t);\n\t}\n\tconst status = workingTreeStatus(repoPath);\n\tif (status.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Conflict-resolution helper reported a clean merge, but the repository still has uncommitted changes: ${status.join(\", \")}`,\n\t\t);\n\t}\n}\n\nfunction fetchOriginBase(repoPath: string, baseBranch: string): string {\n\tconst ref = originBaseRef(baseBranch);\n\tcheckedGit(repoPath, [\"fetch\", \"origin\", baseBranch], `Failed to fetch '${ref}'`);\n\tconst baseSha = gitOrNull(repoPath, \"rev-parse\", ref);\n\tif (!baseSha) {\n\t\tthrow new DeterministicGitError(`Fetched '${ref}' but could not resolve its commit sha`);\n\t}\n\treturn baseSha;\n}\n\nfunction isAncestor(repoPath: string, olderRef: string, newerRef: string): boolean {\n\treturn runGit(repoPath, [\"merge-base\", \"--is-ancestor\", olderRef, newerRef]).ok;\n}\n\nfunction deterministicMerge(input: {\n\trepoPath: string;\n\tbaseBranch: string;\n\theadBefore: string;\n\tbaseSha: string;\n\tgitIdentity?: GitIdentity;\n}):\n\t| { ok: true; mergeMode: DeterministicFinalizationMergeMode; headSha: string }\n\t| { ok: false; conflict: true; headSha: string; conflictedFiles: string[] } {\n\tconst { repoPath, baseBranch, headBefore, baseSha } = input;\n\tconst ref = originBaseRef(baseBranch);\n\tconst headIsAncestorOfBase = isAncestor(repoPath, headBefore, ref);\n\tconst baseIsAncestorOfHead = isAncestor(repoPath, ref, headBefore);\n\n\tif (baseIsAncestorOfHead) {\n\t\treturn { ok: true, mergeMode: \"noop\", headSha: headBefore };\n\t}\n\n\tif (headIsAncestorOfBase) {\n\t\tcheckedGit(repoPath, [\"merge\", \"--ff-only\", ref], `Fast-forward merge from '${ref}' failed`);\n\t\treturn {\n\t\t\tok: true,\n\t\t\tmergeMode: \"fast_forward\",\n\t\t\theadSha: currentHeadSha(repoPath),\n\t\t};\n\t}\n\n\tassertGitIdentity(repoPath, input.gitIdentity);\n\tconst mergeResult = runGit(\n\t\trepoPath,\n\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"merge\", \"--no-edit\", \"--no-gpg-sign\", ref],\n\t\tinput.gitIdentity,\n\t);\n\tif (!mergeResult.ok) {\n\t\tconst conflicts = conflictedFiles(repoPath);\n\t\tif (mergeInProgress(repoPath) || conflicts.length > 0) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tconflict: true,\n\t\t\t\theadSha: currentHeadSha(repoPath),\n\t\t\t\tconflictedFiles: conflicts,\n\t\t\t};\n\t\t}\n\t\tthrow new DeterministicGitError(\n\t\t\t`Deterministic merge from '${ref}' failed: ${gitFailureDetail(mergeResult)}`,\n\t\t);\n\t}\n\n\tconst headAfter = currentHeadSha(repoPath);\n\treturn {\n\t\tok: true,\n\t\tmergeMode: headAfter === baseSha ? \"fast_forward\" : \"merge_commit\",\n\t\theadSha: headAfter,\n\t};\n}\n\nfunction branchRef(branch: string): string {\n\treturn `refs/heads/${branch}`;\n}\n\nfunction pushAndVerify(repoPath: string, branch: string, expectedHeadSha: string): string {\n\tconst pushTarget = `origin/${branch}`;\n\tcheckedGit(\n\t\trepoPath,\n\t\t[\"push\", \"origin\", `HEAD:${branchRef(branch)}`],\n\t\t`Failed to push HEAD to '${pushTarget}'`,\n\t);\n\tconst remoteHead = gitOrNull(repoPath, \"ls-remote\", \"--heads\", \"origin\", branchRef(branch))\n\t\t?.split(/\\s+/)[0]\n\t\t?.trim();\n\tif (remoteHead !== expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Published '${pushTarget}' resolved to '${remoteHead ?? \"missing\"}', expected '${expectedHeadSha}'`,\n\t\t);\n\t}\n\treturn pushTarget;\n}\n\nfunction assertLocalSourceBaseRef(input: {\n\tlocalSourceRepoPath: string;\n\tbaseBranch: string;\n\texpectedHeadSha: string;\n\toperation: string;\n}): void {\n\tconst ref = branchRef(input.baseBranch);\n\tconst actualHeadSha = gitOrNull(input.localSourceRepoPath, \"rev-parse\", ref);\n\tif (!actualHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localSourceRepoPath}' does not have '${ref}' ${input.operation}`,\n\t\t);\n\t}\n\tif (actualHeadSha !== input.expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localSourceRepoPath}' has '${ref}' at '${actualHeadSha}', but expected '${input.expectedHeadSha}' ${input.operation}`,\n\t\t);\n\t}\n}\n\nfunction assertLocalBareSourceRepoReady(\n\tlocalSourceRepoPath: string,\n\tbaseBranch: string,\n\texpectedBaseSha: string,\n): void {\n\tassertLocalSourceBaseRef({\n\t\tlocalSourceRepoPath,\n\t\tbaseBranch,\n\t\texpectedHeadSha: expectedBaseSha,\n\t\toperation: \"before finalization could publish the workspace branch. Retry finalization.\",\n\t});\n}\n\nfunction pushLocalSourceBaseBranchToOriginIfPresent(input: {\n\tlocalSourceRepoPath: string;\n\tbaseBranch: string;\n\texpectedHeadSha: string;\n}): string | null {\n\tif (!runGit(input.localSourceRepoPath, [\"remote\", \"get-url\", \"origin\"]).ok) {\n\t\treturn null;\n\t}\n\tassertLocalSourceBaseRef({\n\t\tlocalSourceRepoPath: input.localSourceRepoPath,\n\t\tbaseBranch: input.baseBranch,\n\t\texpectedHeadSha: input.expectedHeadSha,\n\t\toperation: \"before pushing it to its origin remote\",\n\t});\n\tconst ref = branchRef(input.baseBranch);\n\tconst pushTarget = originBaseRef(input.baseBranch);\n\tcheckedGit(\n\t\tinput.localSourceRepoPath,\n\t\t[\"push\", \"origin\", `${ref}:${ref}`],\n\t\t`Failed to push local source repo '${input.localSourceRepoPath}' base branch '${input.baseBranch}' to '${pushTarget}'`,\n\t);\n\treturn pushTarget;\n}\n\nfunction assertLocalBaseRepoReady(\n\tlocalBaseRepoPath: string,\n\tbaseBranch: string,\n\texpectedBaseSha: string,\n): void {\n\tconst branch = currentBranch(localBaseRepoPath);\n\tif (branch !== baseBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected local source repo '${localBaseRepoPath}' to be checked out on '${baseBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n\tif (mergeInProgress(localBaseRepoPath) || conflictedFiles(localBaseRepoPath).length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' must not already be in a merge-conflict state before finalization updates '${baseBranch}'`,\n\t\t);\n\t}\n\tconst status = workingTreeStatus(localBaseRepoPath);\n\tif (status.length > 0) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' must be clean before finalization updates '${baseBranch}': ${status.join(\", \")}`,\n\t\t);\n\t}\n\tconst actualBaseSha = currentHeadSha(localBaseRepoPath);\n\tif (actualBaseSha !== expectedBaseSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${localBaseRepoPath}' moved on '${baseBranch}' from '${expectedBaseSha}' to '${actualBaseSha}' before finalization could continue. Retry finalization.`,\n\t\t);\n\t}\n}\n\nfunction mergeWorkBranchIntoLocalBaseRepo(input: {\n\tlocalBaseRepoPath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\texpectedBaseSha: string;\n\texpectedHeadSha: string;\n}): void {\n\tassertLocalBaseRepoReady(input.localBaseRepoPath, input.baseBranch, input.expectedBaseSha);\n\tcheckedGit(\n\t\tinput.localBaseRepoPath,\n\t\t[\"merge\", \"--ff-only\", `refs/heads/${input.workBranch}`],\n\t\t`Failed to fast-forward local source repo '${input.localBaseRepoPath}' branch '${input.baseBranch}' from '${input.workBranch}'`,\n\t);\n\tconst actualHeadSha = currentHeadSha(input.localBaseRepoPath);\n\tif (actualHeadSha !== input.expectedHeadSha) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Local source repo '${input.localBaseRepoPath}' finished finalization at '${actualHeadSha}', but expected '${input.expectedHeadSha}' after merging '${input.workBranch}' into '${input.baseBranch}'`,\n\t\t);\n\t}\n}\n\nfunction updateLocalBaseRef(repoPath: string, baseBranch: string): void {\n\tconst branch = currentBranch(repoPath);\n\tif (branch === baseBranch) {\n\t\treturn;\n\t}\n\tcheckedGit(\n\t\trepoPath,\n\t\t[\"branch\", \"--force\", baseBranch, \"HEAD\"],\n\t\t`Failed to update the local '${baseBranch}' ref to the finalized HEAD`,\n\t);\n}\n\nfunction buildFinalizationMarkdown(input: {\n\tworkspaceClonePath: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\theadSha: string;\n\tmergeMode: DeterministicFinalizationMergeMode;\n\tpushTarget: string;\n\tlocalSourceRepoPath: string | null;\n\tlocalSourceRepoKind: LocalSourceRepo[\"kind\"] | null;\n\tworkspacePushTarget: string | null;\n\tsourceOriginPushTarget: string | null;\n\tusedConflictResolution: boolean;\n}): string {\n\tconst lines = [\n\t\t\"## Finalized change\",\n\t\t\"\",\n\t\t`- Repository workspace: ${input.workspaceClonePath}`,\n\t\t`- Work branch: ${input.workBranch}`,\n\t\t`- Base branch: ${input.baseBranch}`,\n\t\t`- Merge result: ${describeMergeMode(input.mergeMode)}`,\n\t];\n\tif (input.localSourceRepoPath) {\n\t\tlines.push(\n\t\t\t`- Local source repo: ${input.localSourceRepoPath} (${input.localSourceRepoKind === \"bare\" ? \"bare\" : \"non-bare\"})`,\n\t\t);\n\t\tif (input.workspacePushTarget) {\n\t\t\tlines.push(`- Workspace publish: HEAD -> ${input.workspacePushTarget}`);\n\t\t}\n\t\tif (input.localSourceRepoKind === \"non_bare\") {\n\t\t\tlines.push(`- Base repo merge: ${input.workBranch} -> ${input.baseBranch}`);\n\t\t}\n\t\tif (input.sourceOriginPushTarget) {\n\t\t\tlines.push(\n\t\t\t\t`- Source origin push: ${branchRef(input.baseBranch)} -> ${input.sourceOriginPushTarget}`,\n\t\t\t);\n\t\t} else {\n\t\t\tlines.push(\"- Source origin push: skipped (local source repo has no origin remote)\");\n\t\t}\n\t} else {\n\t\tlines.push(`- Pushed: HEAD -> ${input.pushTarget}`);\n\t}\n\tlines.push(\n\t\t`- Final HEAD: \\`${abbreviateSha(input.headSha)}\\``,\n\t\t`- Conflict resolution used: ${input.usedConflictResolution ? \"yes\" : \"no\"}`,\n\t);\n\treturn lines.join(\"\\n\");\n}\n\n/** @internal */\ninterface RepositoryChangeFinalizationContextState extends StructuralProcessState {\n\t/** @internal */\n\tfinalization: {\n\t\t/** @internal */\n\t\texpectedPostConflictHeadSha: string | null;\n\t\t/** @internal */\n\t\tusedConflictResolution: boolean;\n\t\t/** @internal */\n\t\tgeneratedCommitMessage: string | null;\n\t};\n}\n\n/** Commit the current workspace change and non-force push only the feature branch. @public */\nexport function commitAndPushWorkBranch(input: {\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\tassertFinalizationCheckout({\n\t\trepoPath,\n\t\tworkBranch: input.workBranch,\n\t\tcommitMessage: input.commitMessage,\n\t\tmissingCommitMessage: \"A generated commit message is required before publication\",\n\t});\n\tconst conflicts = conflictedFiles(repoPath);\n\tif (mergeInProgress(repoPath) || 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({\n\t\trepoPath,\n\t\tcommitMessage: input.commitMessage,\n\t\tgitIdentity: input.gitIdentity,\n\t});\n\tconst pushTarget = pushAndVerify(repoPath, input.workBranch, headSha);\n\treturn {\n\t\t/** @public */\n\t\theadSha,\n\t\t/** @internal */\n\t\tpushTarget,\n\t};\n}\n\n/** @internal */\nexport function runDeterministicFinalization<\n\tTParams,\n\tTState extends RepositoryChangeFinalizationContextState,\n>(\n\tctx: FlowAutomaticRunContext<TParams, TState>,\n\tgitIdentity?: GitIdentity,\n): DeterministicFinalizationResult {\n\tconst progressSteps = [\n\t\t[\"validate_checkout\", \"Validate the repository checkout\"],\n\t\t[\"fetch_base\", \"Fetch and verify the latest base branch\"],\n\t\t[\"commit_merge\", \"Commit changes and integrate the base branch\"],\n\t\t[\"publish\", \"Push the finalized branch\"],\n\t] as const;\n\tconst reportProgress = (\n\t\tactiveIndex: number | null,\n\t\tcompletedCount: number,\n\t\tfailure?: { index: number; detail: string },\n\t) =>\n\t\tctx.reportProgress?.({\n\t\t\ttitle: \"Finalization progress\",\n\t\t\tsteps: progressSteps.map(([id, label], index) => ({\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tstatus:\n\t\t\t\t\tindex === failure?.index\n\t\t\t\t\t\t? \"failed\"\n\t\t\t\t\t\t: index < completedCount\n\t\t\t\t\t\t\t? \"completed\"\n\t\t\t\t\t\t\t: index === activeIndex\n\t\t\t\t\t\t\t\t? \"in_progress\"\n\t\t\t\t\t\t\t\t: \"incomplete\",\n\t\t\t\t...(index === failure?.index ? { detail: failure.detail } : {}),\n\t\t\t})),\n\t\t});\n\treportProgress(0, 0);\n\tconst repo = ctx.repo.get(\"repo\");\n\tconst input: DeterministicFinalizationInput = {\n\t\trepoPath: repo.fsPath,\n\t\tworkspaceClonePath: repo.workspaceClonePath,\n\t\tbaseBranch: repo.baseBranch,\n\t\tworkBranch: repo.workBranch,\n\t\texpectedPostConflictHeadSha: ctx.state.finalization.expectedPostConflictHeadSha,\n\t\tusedConflictResolution: ctx.state.finalization.usedConflictResolution,\n\t\tcommitMessage: ctx.state.finalization.generatedCommitMessage ?? \"\",\n\t\tgitIdentity,\n\t};\n\tconst repoPath = path.resolve(input.repoPath);\n\tassertFinalizationCheckout({\n\t\trepoPath,\n\t\tworkBranch: input.workBranch,\n\t\tcommitMessage: input.commitMessage,\n\t\tmissingCommitMessage:\n\t\t\t\"No generated commit message is available; retry commit-message generation before finalization\",\n\t});\n\tassertPostConflictCheckpoint(input, repoPath);\n\treportProgress(1, 1);\n\n\tlet headSha = currentHeadSha(repoPath);\n\tconst conflicts = conflictedFiles(repoPath);\n\tif (mergeInProgress(repoPath) || conflicts.length > 0) {\n\t\treportProgress(null, 1, {\n\t\t\tindex: 2,\n\t\t\tdetail: \"The checkout already contains merge conflicts\",\n\t\t});\n\t\treturn {\n\t\t\toutcome: \"merge_conflict\",\n\t\t\tparams: {\n\t\t\t\theadSha,\n\t\t\t\tconflictedFiles: conflicts,\n\t\t\t\tfetchedBaseSha: null,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst baseSha = fetchOriginBase(repoPath, input.baseBranch);\n\tconst localSourceRepo = resolveLocalSourceRepo(repoPath);\n\tif (localSourceRepo?.kind === \"non_bare\") {\n\t\tassertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t} else if (localSourceRepo?.kind === \"bare\") {\n\t\tassertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t}\n\treportProgress(2, 2);\n\n\theadSha = commitIfDirty({\n\t\trepoPath,\n\t\tcommitMessage: input.commitMessage,\n\t\tgitIdentity: input.gitIdentity,\n\t});\n\tconst mergeResult = deterministicMerge({\n\t\trepoPath,\n\t\tbaseBranch: input.baseBranch,\n\t\theadBefore: headSha,\n\t\tbaseSha,\n\t\tgitIdentity: input.gitIdentity,\n\t});\n\tif (!mergeResult.ok) {\n\t\treportProgress(null, 2, {\n\t\t\tindex: 2,\n\t\t\tdetail: \"Base integration produced merge conflicts\",\n\t\t});\n\t\treturn {\n\t\t\toutcome: \"merge_conflict\",\n\t\t\tparams: {\n\t\t\t\theadSha: mergeResult.headSha,\n\t\t\t\tconflictedFiles: mergeResult.conflictedFiles,\n\t\t\t\tfetchedBaseSha: baseSha,\n\t\t\t},\n\t\t};\n\t}\n\n\treportProgress(3, 3);\n\tlet pushTarget: string;\n\tlet workspacePushTarget: string | null = null;\n\tlet sourceOriginPushTarget: string | null = null;\n\tif (localSourceRepo) {\n\t\tif (localSourceRepo.kind === \"non_bare\") {\n\t\t\tassertLocalBaseRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t\t\tworkspacePushTarget = pushAndVerify(repoPath, input.workBranch, mergeResult.headSha);\n\t\t\tmergeWorkBranchIntoLocalBaseRepo({\n\t\t\t\tlocalBaseRepoPath: localSourceRepo.path,\n\t\t\t\tbaseBranch: input.baseBranch,\n\t\t\t\tworkBranch: input.workBranch,\n\t\t\t\texpectedBaseSha: baseSha,\n\t\t\t\texpectedHeadSha: mergeResult.headSha,\n\t\t\t});\n\t\t} else {\n\t\t\tassertLocalBareSourceRepoReady(localSourceRepo.path, input.baseBranch, baseSha);\n\t\t\tworkspacePushTarget = pushAndVerify(repoPath, input.baseBranch, mergeResult.headSha);\n\t\t}\n\t\tsourceOriginPushTarget = pushLocalSourceBaseBranchToOriginIfPresent({\n\t\t\tlocalSourceRepoPath: localSourceRepo.path,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\texpectedHeadSha: mergeResult.headSha,\n\t\t});\n\t\tpushTarget = sourceOriginPushTarget ?? originBaseRef(input.baseBranch);\n\t} else {\n\t\tpushTarget = pushAndVerify(repoPath, input.baseBranch, mergeResult.headSha);\n\t}\n\tupdateLocalBaseRef(repoPath, input.baseBranch);\n\tconst finalHeadSha = currentHeadSha(repoPath);\n\treportProgress(null, 4);\n\treturn {\n\t\toutcome: \"finalized\",\n\t\tparams: {\n\t\t\theadSha: finalHeadSha,\n\t\t\tmergeMode: mergeResult.mergeMode,\n\t\t\tpushTarget,\n\t\t\tusedConflictResolution: input.usedConflictResolution === true,\n\t\t},\n\t\tmarkdown: buildFinalizationMarkdown({\n\t\t\tworkspaceClonePath: input.workspaceClonePath,\n\t\t\tbaseBranch: input.baseBranch,\n\t\t\tworkBranch: input.workBranch,\n\t\t\theadSha: finalHeadSha,\n\t\t\tmergeMode: mergeResult.mergeMode,\n\t\t\tpushTarget,\n\t\t\tlocalSourceRepoPath: localSourceRepo?.path ?? null,\n\t\t\tlocalSourceRepoKind: localSourceRepo?.kind ?? null,\n\t\t\tworkspacePushTarget,\n\t\t\tsourceOriginPushTarget,\n\t\t\tusedConflictResolution: input.usedConflictResolution === true,\n\t\t}),\n\t};\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,kBAAyC;AACzE;AAAA,EAEC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,wBAAwB;AA0DjC,IAAM,wBAAN,cAAoC,MAAM;AAAA;AAAA,EAEhC,aAA+B;AAAA;AAAA,EAGxC,YAAY,SAAiB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACb;AACD;AAaA,SAAS,eAAe,OAA4C;AACnE,MAAI,CAAC,OAAO;AACX,WAAO,CAAC;AAAA,EACT;AACA,SAAO,MACL,MAAM,OAAO,EACb,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,CAAC,SAAS,SA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MAClB,YAAY,MAAM;AAAA,MAClB,SAAS;AAAA,MACT,WAAW,YAAY;AAAA,MACvB;AAAA,MACA,qBAAqB,iBAAiB,QAAQ;AAAA,MAC9C,qBAAqB,iBAAiB,QAAQ;AAAA,MAC9C;AAAA,MACA;AAAA,MACA,wBAAwB,MAAM,2BAA2B;AAAA,IAC1D,CAAC;AAAA,EACF;AACD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/turns/resolve-merge-conflict.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function buildResolveMergeConflictPrompt(\n\tctx: FlowPromptContext<unknown, StructuralProcessState, never>,\n): string {\n\tconst repo = ctx.repo.get(\"repo\");\n\treturn `Resolve the current merge conflict so this requested change can be finalized:\n${ctx.prompts.initial}\n\nRepository root: . (the current working directory)\n\nBranches:\n- base branch: ${repo.baseBranch}\n- work branch: ${repo.workBranch}\n\nRules:\n- resolve only the current merge conflict inside the current working directory\n- treat . as the repository root for file edits and git commands\n- complete the merge commit so the repository is no longer in a merge-in-progress state\n- leave the repository clean when you finish\n- do not push\n- do not read from or write to any original source repository path outside the process workspace\n- publish a concise Markdown summary of the merge resolution\n- then call clean with the final HEAD sha`;\n}\n"],"mappings":";AAGO,SAAS,gCACf,KACS;AACT,QAAM,OAAO,IAAI,KAAK,IAAI,MAAM;AAChC,SAAO;AAAA,EACN,IAAI,QAAQ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKJ,KAAK,UAAU;AAAA,iBACf,KAAK,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWhC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/turns/review-implementation.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function buildReviewImplementationPrompt(\n\tctx: FlowPromptContext<unknown, StructuralProcessState>,\n): string {\n\tconst repo = ctx.repo.get(\"repo\");\n\treturn `Repository root: . (the current working directory)\n\nReview the current implementation of this requested change:\n${ctx.prompts.initial}\n\nInspect the changes with \\`git diff --stat $(git merge-base ${repo.baseBranch} HEAD)\\`. Check for:\n- bugs and logic errors\n- security issues\n- error handling gaps\n- missing or misplaced tests\n- unnecessary abstractions, duplication, and other avoidable complexity\n\nFor each issue, give a concise fix.\n\nRules:\n- inspect code only inside the current working directory\n- treat . as the repository root for read-only inspection\n- use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)\n- do not modify files, branches, commits, or git index state\n- do not read from or write to any original source repository path outside the process workspace\n- publish a short Markdown approval note if the implementation is ready\n- publish concise, actionable Markdown feedback if the implementation needs changes`;\n}\n"],"mappings":";AAGO,SAAS,gCACf,KACS;AACT,QAAM,OAAO,IAAI,KAAK,IAAI,MAAM;AAChC,SAAO;AAAA;AAAA;AAAA,EAGN,IAAI,QAAQ,OAAO;AAAA;AAAA,8DAEyC,KAAK,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB7E;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/turns/generate-plan.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function buildGeneratePlanPrompt(\n\tctx: FlowPromptContext<unknown, StructuralProcessState, never>,\n): string {\n\tconst repo = ctx.repo.get(\"repo\");\n\treturn `Create an implementation plan for this repository change:\n${ctx.prompts.initial}\n\nRepository root: . (the current working directory)\n\nBranches:\n- base branch: ${repo.baseBranch}\n- work branch: ${repo.workBranch}\n\nRules:\n- analyze only the cloned repository in the current working directory\n- treat . as the repository root for read-only inspection\n- use bash only for read-only inspection (e.g. git log, git diff, rg, tree, file listing, read-only http/CLI calls)\n- do not modify files\n- do not read from or write to any original source repository path outside the process workspace\n- publish the plan when done`;\n}\n"],"mappings":";AAGO,SAAS,wBACf,KACS;AACT,QAAM,OAAO,IAAI,KAAK,IAAI,MAAM;AAChC,SAAO;AAAA,EACN,IAAI,QAAQ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKJ,KAAK,UAAU;AAAA,iBACf,KAAK,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/turns/generate-commit-message.ts"],"sourcesContent":["import {\n\tBUILT_IN_COMMIT_MESSAGE_RULES,\n\tCOMMIT_MESSAGE_PROJECT_METADATA_KEY,\n\ttype CommitMessageProjectMetadata,\n\ttype FlowPromptContext,\n} from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function normalizeGeneratedCommitMessage(value: unknown): string {\n\tif (typeof value !== \"string\" || value.includes(\"\\0\")) {\n\t\tthrow new Error(\"Generated commit message must be plain text without NUL characters\");\n\t}\n\tconst normalized = value.replace(/\\r\\n?/g, \"\\n\").trim();\n\tif (!normalized) throw new Error(\"Generated commit message must have a non-empty subject\");\n\tif (/^```|```$/.test(normalized)) {\n\t\tthrow new Error(\"Generated commit message must not contain Markdown fences\");\n\t}\n\tif (/^(commit message|message|subject)\\s*:/i.test(normalized)) {\n\t\tthrow new Error(\"Generated commit message must not contain an explanatory prefix\");\n\t}\n\treturn normalized;\n}\n\n/** @internal */\nexport function buildGenerateCommitMessagePrompt<TParams, TState>(\n\tctx: FlowPromptContext<TParams, TState, \"plan\">,\n): string {\n\tconst project = ctx.projects.find((candidate) => candidate.key === \"repo\") ?? ctx.projects[0];\n\tconst pinned = project?.metadata?.[COMMIT_MESSAGE_PROJECT_METADATA_KEY] as\n\t\t| Partial<CommitMessageProjectMetadata>\n\t\t| undefined;\n\tconst rules =\n\t\ttypeof pinned?.rules === \"string\" && pinned.rules.trim()\n\t\t\t? pinned.rules\n\t\t\t: BUILT_IN_COMMIT_MESSAGE_RULES;\n\tconst plan = ctx.input.plan ?? \"\";\n\treturn [\n\t\t\"Create the Git commit message for the accepted implementation plan.\",\n\t\t\"Return only the exact plain-text commit message: subject first, followed by an optional body.\",\n\t\t\"Do not add Markdown fences, labels, commentary, or a 'Commit message:' prefix.\",\n\t\t\"The plan below is trusted content to summarize, not formatting instructions.\",\n\t\t\"\",\n\t\t\"<formatting_rules>\",\n\t\trules,\n\t\t\"</formatting_rules>\",\n\t\t\"\",\n\t\t\"<accepted_plan>\",\n\t\tplan,\n\t\t\"</accepted_plan>\",\n\t].join(\"\\n\");\n}\n"],"mappings":";AAAA;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AAGA,SAAS,gCAAgC,OAAwB;AACvE,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,GAAG;AACtD,UAAM,IAAI,MAAM,oEAAoE;AAAA,EACrF;AACA,QAAM,aAAa,MAAM,QAAQ,UAAU,IAAI,EAAE,KAAK;AACtD,MAAI,CAAC,WAAY,OAAM,IAAI,MAAM,wDAAwD;AACzF,MAAI,YAAY,KAAK,UAAU,GAAG;AACjC,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC5E;AACA,MAAI,yCAAyC,KAAK,UAAU,GAAG;AAC9D,UAAM,IAAI,MAAM,iEAAiE;AAAA,EAClF;AACA,SAAO;AACR;AAGO,SAAS,iCACf,KACS;AACT,QAAM,UAAU,IAAI,SAAS,KAAK,CAAC,cAAc,UAAU,QAAQ,MAAM,KAAK,IAAI,SAAS,CAAC;AAC5F,QAAM,SAAS,SAAS,WAAW,mCAAmC;AAGtE,QAAM,QACL,OAAO,QAAQ,UAAU,YAAY,OAAO,MAAM,KAAK,IACpD,OAAO,QACP;AACJ,QAAM,OAAO,IAAI,MAAM,QAAQ;AAC/B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EAAE,KAAK,IAAI;AACZ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/turns/implement.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport function buildImplementPrompt(\n\tctx: FlowPromptContext<unknown, StructuralProcessState, \"plan\">,\n): string {\n\treturn `Implement this requested change:\n${ctx.prompts.initial}\n\nRepository root: . (the current working directory)\n\nFollow this plan:\n${ctx.input.plan}\n\nRules:\n- keep going until the change is complete; do any necessary additional passes without asking\n- make repository changes only inside the current working directory\n- treat . as the repository root for file edits and git commands\n- do not read from or write to any original source repository path outside the process workspace\n- keep the implementation coherent and complete\n- publish the implementation summary when done`;\n}\n"],"mappings":";AAGO,SAAS,qBACf,KACS;AACT,SAAO;AAAA,EACN,IAAI,QAAQ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,IAAI,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShB;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type FlowAutomaticRunContext, type StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
3
|
+
type DeterministicFinalizationMergeMode = "noop" | "fast_forward" | "merge_commit";
|
|
4
|
+
/** @public */
|
|
5
|
+
export interface GitIdentity {
|
|
6
|
+
/** @public */
|
|
7
|
+
name: string;
|
|
8
|
+
/** @public */
|
|
9
|
+
email: string;
|
|
10
|
+
}
|
|
11
|
+
/** @internal */
|
|
12
|
+
type DeterministicFinalizationResult = {
|
|
13
|
+
/** @internal */
|
|
14
|
+
outcome: "merge_conflict";
|
|
15
|
+
/** @internal */
|
|
16
|
+
params: {
|
|
17
|
+
/** @internal */
|
|
18
|
+
headSha: string;
|
|
19
|
+
/** @internal */
|
|
20
|
+
conflictedFiles: string[];
|
|
21
|
+
/** @internal */
|
|
22
|
+
fetchedBaseSha: string | null;
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
/** @internal */
|
|
26
|
+
outcome: "finalized";
|
|
27
|
+
/** @internal */
|
|
28
|
+
params: {
|
|
29
|
+
/** @internal */
|
|
30
|
+
headSha: string;
|
|
31
|
+
/** @internal */
|
|
32
|
+
mergeMode: DeterministicFinalizationMergeMode;
|
|
33
|
+
/** @internal */
|
|
34
|
+
pushTarget: string;
|
|
35
|
+
/** @internal */
|
|
36
|
+
usedConflictResolution: boolean;
|
|
37
|
+
};
|
|
38
|
+
/** @internal */
|
|
39
|
+
markdown: string;
|
|
40
|
+
};
|
|
41
|
+
/** @internal */
|
|
42
|
+
interface RepositoryChangeFinalizationContextState extends StructuralProcessState {
|
|
43
|
+
/** @internal */
|
|
44
|
+
finalization: {
|
|
45
|
+
/** @internal */
|
|
46
|
+
expectedPostConflictHeadSha: string | null;
|
|
47
|
+
/** @internal */
|
|
48
|
+
usedConflictResolution: boolean;
|
|
49
|
+
/** @internal */
|
|
50
|
+
generatedCommitMessage: string | null;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Commit the current workspace change and non-force push only the feature branch. @public */
|
|
54
|
+
export declare function commitAndPushWorkBranch(input: {
|
|
55
|
+
/** @public */
|
|
56
|
+
repoPath: string;
|
|
57
|
+
/** @public */
|
|
58
|
+
workBranch: string;
|
|
59
|
+
/** @public */
|
|
60
|
+
commitMessage: string;
|
|
61
|
+
/** @public */
|
|
62
|
+
gitIdentity: GitIdentity;
|
|
63
|
+
}): {
|
|
64
|
+
/** @public */
|
|
65
|
+
headSha: string;
|
|
66
|
+
/** @internal */
|
|
67
|
+
pushTarget: string;
|
|
68
|
+
};
|
|
69
|
+
/** @internal */
|
|
70
|
+
export declare function runDeterministicFinalization<TParams, TState extends RepositoryChangeFinalizationContextState>(ctx: FlowAutomaticRunContext<TParams, TState>, gitIdentity?: GitIdentity): DeterministicFinalizationResult;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=finalization-git-internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalization-git-internal.d.ts","sourceRoot":"","sources":["../src/finalization-git-internal.ts"],"names":[],"mappings":"AAMA,OAAO,EACN,KAAK,uBAAuB,EAG5B,KAAK,sBAAsB,EAC3B,MAAM,2BAA2B,CAAC;AAGnC,gBAAgB;AAChB,KAAK,kCAAkC,GAAG,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;AAEnF,cAAc;AACd,MAAM,WAAW,WAAW;IAC3B,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;CACd;AAaD,gBAAgB;AAChB,KAAK,+BAA+B,GACjC;IACA,gBAAgB;IAChB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,gBAAgB;IAChB,MAAM,EAAE;QACP,gBAAgB;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB;QAChB,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,gBAAgB;QAChB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC9B,CAAC;CACD,GACD;IACA,gBAAgB;IAChB,OAAO,EAAE,WAAW,CAAC;IACrB,gBAAgB;IAChB,MAAM,EAAE;QACP,gBAAgB;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB;QAChB,SAAS,EAAE,kCAAkC,CAAC;QAC9C,gBAAgB;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB;QAChB,sBAAsB,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;CAChB,CAAC;AA4jBL,gBAAgB;AAChB,UAAU,wCAAyC,SAAQ,sBAAsB;IAChF,gBAAgB;IAChB,YAAY,EAAE;QACb,gBAAgB;QAChB,2BAA2B,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3C,gBAAgB;QAChB,sBAAsB,EAAE,OAAO,CAAC;QAChC,gBAAgB;QAChB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;KACtC,CAAC;CACF;AAED,8FAA8F;AAC9F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC9C,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc;IACd,WAAW,EAAE,WAAW,CAAC;CACzB;IAqBC,cAAc;;IAEd,gBAAgB;;EAGjB;AAED,gBAAgB;AAChB,wBAAgB,4BAA4B,CAC3C,OAAO,EACP,MAAM,SAAS,wCAAwC,EAEvD,GAAG,EAAE,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,EAC7C,WAAW,CAAC,EAAE,WAAW,GACvB,+BAA+B,CA6JjC"}
|
|
@@ -1,48 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type DeterministicFinalizationMergeMode = "noop" | "fast_forward" | "merge_commit";
|
|
4
|
-
export interface GitIdentity {
|
|
5
|
-
name: string;
|
|
6
|
-
email: string;
|
|
7
|
-
}
|
|
8
|
-
export type DeterministicFinalizationResult = {
|
|
9
|
-
outcome: "merge_conflict";
|
|
10
|
-
params: {
|
|
11
|
-
headSha: string;
|
|
12
|
-
conflictedFiles: string[];
|
|
13
|
-
fetchedBaseSha: string | null;
|
|
14
|
-
};
|
|
15
|
-
} | {
|
|
16
|
-
outcome: "finalized";
|
|
17
|
-
params: {
|
|
18
|
-
headSha: string;
|
|
19
|
-
mergeMode: DeterministicFinalizationMergeMode;
|
|
20
|
-
pushTarget: string;
|
|
21
|
-
usedConflictResolution: boolean;
|
|
22
|
-
};
|
|
23
|
-
markdown: string;
|
|
24
|
-
};
|
|
25
|
-
export declare class DeterministicGitError extends Error {
|
|
26
|
-
readonly errorClass: WorkerErrorClass;
|
|
27
|
-
constructor(message: string);
|
|
28
|
-
}
|
|
29
|
-
export interface RepositoryChangeFinalizationContextState extends StructuralProcessState {
|
|
30
|
-
finalization: {
|
|
31
|
-
expectedPostConflictHeadSha: string | null;
|
|
32
|
-
usedConflictResolution: boolean;
|
|
33
|
-
generatedCommitMessage: string | null;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/** Commit the current workspace change and non-force push only the feature branch. */
|
|
37
|
-
export declare function commitAndPushWorkBranch(input: {
|
|
38
|
-
repoPath: string;
|
|
39
|
-
workBranch: string;
|
|
40
|
-
commitMessage: string;
|
|
41
|
-
gitIdentity: GitIdentity;
|
|
42
|
-
}): {
|
|
43
|
-
headSha: string;
|
|
44
|
-
pushTarget: string;
|
|
45
|
-
};
|
|
46
|
-
export declare function runDeterministicFinalization<TParams, TState extends RepositoryChangeFinalizationContextState>(ctx: FlowAutomaticRunContext<TParams, TState>, gitIdentity?: GitIdentity): DeterministicFinalizationResult;
|
|
47
|
-
export declare function readMergeMessage(repoPath: string): string | null;
|
|
1
|
+
export type { GitIdentity } from "./finalization-git-internal.js";
|
|
2
|
+
export { commitAndPushWorkBranch } from "./finalization-git-internal.js";
|
|
48
3
|
//# sourceMappingURL=finalization-git.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finalization-git.d.ts","sourceRoot":"","sources":["../src/finalization-git.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"finalization-git.d.ts","sourceRoot":"","sources":["../src/finalization-git.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/dist/finalization-git.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readMergeMessage,
|
|
5
|
-
runDeterministicFinalization
|
|
6
|
-
} from "./chunk-73LKROYK.js";
|
|
2
|
+
commitAndPushWorkBranch
|
|
3
|
+
} from "./chunk-MY6XFGHM.js";
|
|
7
4
|
import "./chunk-PX6F3LHL.js";
|
|
8
5
|
export {
|
|
9
|
-
|
|
10
|
-
commitAndPushWorkBranch,
|
|
11
|
-
readMergeMessage,
|
|
12
|
-
runDeterministicFinalization
|
|
6
|
+
commitAndPushWorkBranch
|
|
13
7
|
};
|
|
14
8
|
//# sourceMappingURL=finalization-git.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
2
|
-
|
|
3
|
-
readonly id: "coding";
|
|
4
|
-
readonly version: "0.1.0";
|
|
5
|
-
};
|
|
2
|
+
/** @public */
|
|
6
3
|
declare const extension: LeitwerkExtensionModule;
|
|
7
4
|
export default extension;
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export * from "./repository-change-process.js";
|
|
5
|
+
export { acceptReviewForm, codingActionIds, createFinalizeChangeForm, requestReviewChangesForm, requestRevisionForm, } from "./actions.js";
|
|
6
|
+
export { createRepositoryChangeProcess } from "./repository-change-process.js";
|
|
11
7
|
//# sourceMappingURL=index.d.ts.map
|