@leitwerk-dev/coding 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -2
- package/dist/auto-work-branch.js +3 -24
- package/dist/auto-work-branch.js.map +1 -1
- package/dist/chunk-6E5VQPC4.js +28 -0
- package/dist/chunk-6E5VQPC4.js.map +1 -0
- package/dist/chunk-ABQH2WZT.js +36 -0
- package/dist/chunk-ABQH2WZT.js.map +1 -0
- package/dist/{chunk-YSC5GEQJ.js → chunk-BI45R2FH.js} +7 -3
- package/dist/chunk-BI45R2FH.js.map +1 -0
- package/dist/chunk-DNG7D77K.js +65 -0
- package/dist/chunk-DNG7D77K.js.map +1 -0
- package/dist/chunk-KFELB7ZC.js +70 -0
- package/dist/chunk-KFELB7ZC.js.map +1 -0
- package/dist/chunk-L2TFD72B.js +16320 -0
- package/dist/chunk-L2TFD72B.js.map +1 -0
- package/dist/chunk-M2VTUPFO.js +265 -0
- package/dist/chunk-M2VTUPFO.js.map +1 -0
- package/dist/chunk-OM2AMDTJ.js +347 -0
- package/dist/chunk-OM2AMDTJ.js.map +1 -0
- package/dist/chunk-Q24RPXOA.js +159 -0
- package/dist/chunk-Q24RPXOA.js.map +1 -0
- package/dist/chunk-SKGB4CZS.js +14 -0
- package/dist/chunk-SKGB4CZS.js.map +1 -0
- package/dist/chunk-SZ4WOGV2.js +120 -0
- package/dist/chunk-SZ4WOGV2.js.map +1 -0
- package/dist/finalization-git-internal.d.ts +3 -0
- package/dist/finalization-git-internal.d.ts.map +1 -1
- package/dist/finalization-git.d.ts +1 -1
- package/dist/finalization-git.d.ts.map +1 -1
- package/dist/finalization-git.js +5 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -591
- package/dist/index.js.map +1 -1
- package/dist/profile-bindings-internal.d.ts +3 -0
- package/dist/profile-bindings-internal.d.ts.map +1 -0
- package/dist/pull-request-publication-internal.d.ts +75 -0
- package/dist/pull-request-publication-internal.d.ts.map +1 -0
- package/dist/repository-change-launch-internal-BudnAfL7.d.ts +88 -0
- package/dist/repository-change-launch-internal.d.ts +62 -11
- package/dist/repository-change-launch-internal.d.ts.map +1 -1
- package/dist/repository-change-launch.d.ts +5 -2
- package/dist/repository-change-launch.d.ts.map +1 -1
- package/dist/repository-change-launch.js +363 -6
- package/dist/repository-change-launch.js.map +1 -1
- package/dist/repository-change-process-DlgF04fU.d.ts +69 -0
- package/dist/repository-change-process.d.ts +30 -25
- package/dist/repository-change-process.d.ts.map +1 -1
- package/dist/repository-change-publication.d.ts +63 -7
- package/dist/repository-change-publication.d.ts.map +1 -1
- package/dist/repository-change-publication.js +732 -56
- package/dist/repository-change-publication.js.map +1 -1
- package/dist/repository-change-state-internal.d.ts +18 -4
- package/dist/repository-change-state-internal.d.ts.map +1 -1
- package/dist/repository-change-ui-launcher-internal.d.ts +65 -0
- package/dist/repository-change-ui-launcher-internal.d.ts.map +1 -0
- package/dist/repository-rebase/git.d.ts +31 -0
- package/dist/repository-rebase/git.d.ts.map +1 -0
- package/dist/repository-rebase/index.d.ts +42 -0
- package/dist/repository-rebase/index.d.ts.map +1 -0
- package/dist/repository-rebase/index.js +16 -0
- package/dist/repository-rebase/policy.d.ts +37 -0
- package/dist/repository-rebase/policy.d.ts.map +1 -0
- package/dist/repository-rebase/prompt.d.ts +3 -0
- package/dist/repository-rebase/prompt.d.ts.map +1 -0
- package/dist/settings.d.ts +15 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/turns/commit-message-evidence.d.ts +35 -0
- package/dist/turns/commit-message-evidence.d.ts.map +1 -0
- package/dist/turns/commit-message-evidence.js +9 -0
- package/dist/turns/generate-commit-message.d.ts +4 -1
- package/dist/turns/generate-commit-message.d.ts.map +1 -1
- package/dist/turns/generate-commit-message.js +7 -5
- package/dist/turns/generate-plan.d.ts.map +1 -1
- package/dist/turns/generate-plan.js +1 -1
- package/dist/turns/git-inspection-profile.d.ts +25 -0
- package/dist/turns/git-inspection-profile.d.ts.map +1 -0
- package/dist/turns/git-inspection-profile.js +8 -0
- package/dist/turns/git-inspection-profile.js.map +1 -0
- package/dist/turns/implement.d.ts.map +1 -1
- package/dist/turns/implement.js +1 -1
- package/dist/turns/simplify-implementation.d.ts +1 -1
- package/dist/turns/simplify-implementation.d.ts.map +1 -1
- package/dist/turns/simplify-implementation.js +3 -3
- package/package.json +10 -10
- package/src/finalization-git-internal.ts +117 -114
- package/src/finalization-git.ts +1 -1
- package/src/index.ts +4 -1
- package/src/profile-bindings-internal.ts +39 -0
- package/src/pull-request-publication-internal.ts +364 -0
- package/src/repository-change-launch-internal.ts +194 -11
- package/src/repository-change-launch.ts +13 -0
- package/src/repository-change-process.ts +234 -523
- package/src/repository-change-publication.ts +535 -156
- package/src/repository-change-state-internal.ts +34 -20
- package/src/repository-change-ui-launcher-internal.ts +308 -0
- package/src/repository-rebase/git.ts +219 -0
- package/src/repository-rebase/index.ts +144 -0
- package/src/repository-rebase/policy.ts +75 -0
- package/src/repository-rebase/prompt.ts +2 -0
- package/src/settings.ts +79 -0
- package/src/turns/commit-message-evidence.ts +241 -0
- package/src/turns/generate-commit-message.ts +53 -23
- package/src/turns/generate-plan.ts +26 -12
- package/src/turns/git-inspection-profile.ts +134 -0
- package/src/turns/implement.ts +9 -2
- package/src/turns/simplify-implementation.ts +10 -6
- package/dist/chunk-34B3Q75M.js +0 -25
- package/dist/chunk-34B3Q75M.js.map +0 -1
- package/dist/chunk-F6CEEAFE.js +0 -13
- package/dist/chunk-F6CEEAFE.js.map +0 -1
- package/dist/chunk-GO44KCUS.js +0 -154
- package/dist/chunk-GO44KCUS.js.map +0 -1
- package/dist/chunk-R3UCUGY6.js +0 -31
- package/dist/chunk-R3UCUGY6.js.map +0 -1
- package/dist/chunk-W7VJT6AN.js +0 -25
- package/dist/chunk-W7VJT6AN.js.map +0 -1
- package/dist/chunk-WKHVLLKE.js +0 -45
- package/dist/chunk-WKHVLLKE.js.map +0 -1
- package/dist/chunk-YSC5GEQJ.js.map +0 -1
- package/dist/turns/review-implementation.d.ts +0 -4
- package/dist/turns/review-implementation.d.ts.map +0 -1
- package/dist/turns/review-implementation.js +0 -8
- package/dist/turns/review-plan.d.ts +0 -4
- package/dist/turns/review-plan.d.ts.map +0 -1
- package/dist/turns/review-plan.js +0 -8
- package/src/turns/review-implementation.ts +0 -30
- package/src/turns/review-plan.ts +0 -24
- /package/dist/{turns/review-implementation.js.map → repository-rebase/index.js.map} +0 -0
- /package/dist/turns/{review-plan.js.map → commit-message-evidence.js.map} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ScopedSettingsSnapshot } from "@leitwerk-dev/domain";
|
|
2
|
+
import { type TurnDiagnosticReport } from "@leitwerk-dev/process-sdk";
|
|
3
|
+
interface GitOutput {
|
|
4
|
+
text: string;
|
|
5
|
+
truncated: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface RepositoryChanges {
|
|
8
|
+
key: string;
|
|
9
|
+
path: string;
|
|
10
|
+
head: string;
|
|
11
|
+
status: GitOutput;
|
|
12
|
+
stagedDiff: GitOutput;
|
|
13
|
+
unstagedDiff: GitOutput;
|
|
14
|
+
untrackedFiles: GitOutput;
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
export interface RepositoryCommitMessagePreparation {
|
|
18
|
+
/** @internal */
|
|
19
|
+
repositories: RepositoryChanges[];
|
|
20
|
+
}
|
|
21
|
+
/** @internal */
|
|
22
|
+
export declare function prepareRepositoryCommitMessageEvidence(ctx: {
|
|
23
|
+
projects: readonly {
|
|
24
|
+
key: string;
|
|
25
|
+
}[];
|
|
26
|
+
repo: {
|
|
27
|
+
get(key: string): {
|
|
28
|
+
fsPath: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
scopedSettings?: ScopedSettingsSnapshot;
|
|
32
|
+
reportDiagnostic?: (report: TurnDiagnosticReport) => void;
|
|
33
|
+
}): Promise<RepositoryCommitMessagePreparation>;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=commit-message-evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-message-evidence.d.ts","sourceRoot":"","sources":["../../src/turns/commit-message-evidence.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAGN,KAAK,oBAAoB,EACzB,MAAM,2BAA2B,CAAC;AAKnC,UAAU,SAAS;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,iBAAiB;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,SAAS,CAAC;IACtB,YAAY,EAAE,SAAS,CAAC;IACxB,cAAc,EAAE,SAAS,CAAC;CAC1B;AAED,gBAAgB;AAChB,MAAM,WAAW,kCAAkC;IAClD,gBAAgB;IAChB,YAAY,EAAE,iBAAiB,EAAE,CAAC;CAClC;AA0HD,gBAAgB;AAChB,wBAAsB,sCAAsC,CAAC,GAAG,EAAE;IACjE,QAAQ,EAAE,SAAS;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrC,IAAI,EAAE;QAAE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC/C,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC1D,GAAG,OAAO,CAAC,kCAAkC,CAAC,CA+E9C"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type FlowPromptContext } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import type { RepositoryCommitMessagePreparation } from "./commit-message-evidence.js";
|
|
2
3
|
/** @internal */
|
|
3
4
|
export declare function normalizeGeneratedCommitMessage(value: unknown): string;
|
|
4
5
|
/** @internal */
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function buildRepositoryCommitMessagesPrompt<TParams, TState>(ctx: FlowPromptContext<TParams, TState, "plan" | "implementation-summary", RepositoryCommitMessagePreparation>): string;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function parseRepositoryCommitMessages(raw: unknown, keys: string[]): Record<string, string>;
|
|
6
9
|
//# sourceMappingURL=generate-commit-message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-commit-message.d.ts","sourceRoot":"","sources":["../../src/turns/generate-commit-message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-commit-message.d.ts","sourceRoot":"","sources":["../../src/turns/generate-commit-message.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAEvF,gBAAgB;AAChB,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAatE;AAYD,gBAAgB;AAChB,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,MAAM,EAClE,GAAG,EAAE,iBAAiB,CACrB,OAAO,EACP,MAAM,EACN,MAAM,GAAG,wBAAwB,EACjC,kCAAkC,CAClC,GACC,MAAM,CAuBR;AACD,gBAAgB;AAChB,wBAAgB,6BAA6B,CAC5C,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,EAAE,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxB"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
normalizeGeneratedCommitMessage
|
|
4
|
-
|
|
2
|
+
buildRepositoryCommitMessagesPrompt,
|
|
3
|
+
normalizeGeneratedCommitMessage,
|
|
4
|
+
parseRepositoryCommitMessages
|
|
5
|
+
} from "../chunk-DNG7D77K.js";
|
|
5
6
|
import "../chunk-PX6F3LHL.js";
|
|
6
7
|
export {
|
|
7
|
-
|
|
8
|
-
normalizeGeneratedCommitMessage
|
|
8
|
+
buildRepositoryCommitMessagesPrompt,
|
|
9
|
+
normalizeGeneratedCommitMessage,
|
|
10
|
+
parseRepositoryCommitMessages
|
|
9
11
|
};
|
|
10
12
|
//# sourceMappingURL=generate-commit-message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-plan.d.ts","sourceRoot":"","sources":["../../src/turns/generate-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,CAAC,GAC5D,MAAM,
|
|
1
|
+
{"version":3,"file":"generate-plan.d.ts","sourceRoot":"","sources":["../../src/turns/generate-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,CAAC,GAC5D,MAAM,CAgCR"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export interface GitTrace2Summary {
|
|
3
|
+
/** @internal */
|
|
4
|
+
counters: Record<string, number>;
|
|
5
|
+
/** @internal */
|
|
6
|
+
regionsMs: Record<string, number>;
|
|
7
|
+
/** Trace was absent, malformed, or exceeded the parsing budget. @internal */
|
|
8
|
+
incomplete: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Reduces a bounded Trace2 stream to allowlisted numbers; never retains raw events. @internal */
|
|
11
|
+
export declare class GitTrace2Collector {
|
|
12
|
+
private readonly decoder;
|
|
13
|
+
private readonly summary;
|
|
14
|
+
private bytes;
|
|
15
|
+
private pending;
|
|
16
|
+
private droppingLine;
|
|
17
|
+
private sawEvent;
|
|
18
|
+
/** @internal */
|
|
19
|
+
write(chunk: Buffer): void;
|
|
20
|
+
/** @internal */
|
|
21
|
+
finish(): GitTrace2Summary;
|
|
22
|
+
private consume;
|
|
23
|
+
private readEvent;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=git-inspection-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-inspection-profile.d.ts","sourceRoot":"","sources":["../../src/turns/git-inspection-profile.ts"],"names":[],"mappings":"AA2BA,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAChC,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,6EAA6E;IAC7E,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,kGAAkG;AAClG,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwE;IAChG,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAS;IAEzB,gBAAgB;IAChB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS1B,gBAAgB;IAChB,MAAM,IAAI,gBAAgB;IAO1B,OAAO,CAAC,OAAO;IAoBf,OAAO,CAAC,SAAS;CAiDjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/turns/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,GAC7D,MAAM,
|
|
1
|
+
{"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/turns/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,GAC7D,MAAM,CAuBR"}
|
package/dist/turns/implement.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
2
2
|
/** @internal */
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function buildStreamlinedSimplificationPrompt(ctx: FlowPromptContext<unknown, StructuralProcessState>): string;
|
|
4
4
|
//# sourceMappingURL=simplify-implementation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify-implementation.d.ts","sourceRoot":"","sources":["../../src/turns/simplify-implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,
|
|
1
|
+
{"version":3,"file":"simplify-implementation.d.ts","sourceRoot":"","sources":["../../src/turns/simplify-implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,oCAAoC,CACnD,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,CAAC,GACrD,MAAM,CAUR"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
2
|
+
buildStreamlinedSimplificationPrompt
|
|
3
|
+
} from "../chunk-SKGB4CZS.js";
|
|
4
4
|
import "../chunk-PX6F3LHL.js";
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
buildStreamlinedSimplificationPrompt
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=simplify-implementation.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/coding",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/leitwerk-dev/leitwerk.git",
|
|
@@ -45,11 +45,6 @@
|
|
|
45
45
|
"import": "./dist/turns/implement.js",
|
|
46
46
|
"types": "./dist/turns/implement.d.ts"
|
|
47
47
|
},
|
|
48
|
-
"./turns/review-implementation": {
|
|
49
|
-
"source": "./src/turns/review-implementation.ts",
|
|
50
|
-
"import": "./dist/turns/review-implementation.js",
|
|
51
|
-
"types": "./dist/turns/review-implementation.d.ts"
|
|
52
|
-
},
|
|
53
48
|
"./turns/simplify-implementation": {
|
|
54
49
|
"source": "./src/turns/simplify-implementation.ts",
|
|
55
50
|
"import": "./dist/turns/simplify-implementation.js",
|
|
@@ -59,18 +54,23 @@
|
|
|
59
54
|
"source": "./src/repository-change-publication.ts",
|
|
60
55
|
"import": "./dist/repository-change-publication.js",
|
|
61
56
|
"types": "./dist/repository-change-publication.d.ts"
|
|
57
|
+
},
|
|
58
|
+
"./repository-rebase": {
|
|
59
|
+
"source": "./src/repository-rebase/index.ts",
|
|
60
|
+
"import": "./dist/repository-rebase/index.js",
|
|
61
|
+
"types": "./dist/repository-rebase/index.d.ts"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsup --silent"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@leitwerk-dev/domain": "0.
|
|
69
|
-
"@leitwerk-dev/process-sdk": "0.
|
|
70
|
-
"@leitwerk-dev/repository-rebase": "0.3.0"
|
|
68
|
+
"@leitwerk-dev/domain": "0.4.0",
|
|
69
|
+
"@leitwerk-dev/process-sdk": "0.4.0"
|
|
71
70
|
},
|
|
72
71
|
"devDependencies": {
|
|
73
|
-
"@leitwerk-dev/
|
|
72
|
+
"@leitwerk-dev/extension-runtime": "0.4.0",
|
|
73
|
+
"@leitwerk-dev/test-support": "0.4.0",
|
|
74
74
|
"tsup": "^8.5.1"
|
|
75
75
|
},
|
|
76
76
|
"license": "Apache-2.0",
|
|
@@ -31,8 +31,8 @@ interface GitExecResult {
|
|
|
31
31
|
stderr: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function gitConfigIdentityEnv(): NodeJS.ProcessEnv {
|
|
35
|
-
const env = repositoryGitSubprocessEnv(
|
|
34
|
+
function gitConfigIdentityEnv(projectKey: string): NodeJS.ProcessEnv {
|
|
35
|
+
const env = repositoryGitSubprocessEnv(projectKey, { GIT_TERMINAL_PROMPT: "0" });
|
|
36
36
|
for (const key of [
|
|
37
37
|
"GIT_AUTHOR_NAME",
|
|
38
38
|
"GIT_AUTHOR_EMAIL",
|
|
@@ -54,126 +54,131 @@ function gitIdentityArgs(identity: GitIdentity): string[] {
|
|
|
54
54
|
return ["-c", `user.name=${name}`, "-c", `user.email=${email}`];
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
function repositoryGit(projectKey: string, repoPath: string) {
|
|
58
|
+
function runGit(args: readonly string[], identity?: GitIdentity): GitExecResult {
|
|
59
|
+
const trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;
|
|
60
|
+
try {
|
|
61
|
+
const stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {
|
|
62
|
+
cwd: repoPath,
|
|
63
|
+
encoding: "utf8",
|
|
64
|
+
env: gitConfigIdentityEnv(projectKey),
|
|
65
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
66
|
+
});
|
|
67
|
+
return { ok: true, stdout, stderr: "" };
|
|
68
|
+
} catch (error) {
|
|
69
|
+
const execError = error as {
|
|
70
|
+
stdout?: string | Buffer;
|
|
71
|
+
stderr?: string | Buffer;
|
|
72
|
+
message?: string;
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
stdout: execError.stdout?.toString() ?? "",
|
|
77
|
+
stderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? "",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
78
80
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function checkedGit(
|
|
82
|
-
repoPath: string,
|
|
83
|
-
args: readonly string[],
|
|
84
|
-
failureMessage: string,
|
|
85
|
-
identity?: GitIdentity,
|
|
86
|
-
): string {
|
|
87
|
-
const result = runGit(repoPath, args, identity);
|
|
88
|
-
if (!result.ok) {
|
|
89
|
-
const detail = trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error";
|
|
90
|
-
throw new DeterministicGitError(`${failureMessage}: ${detail}`);
|
|
91
|
-
}
|
|
92
|
-
return result.stdout.trim();
|
|
93
|
-
}
|
|
94
81
|
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
function checkedGit(
|
|
83
|
+
args: readonly string[],
|
|
84
|
+
failureMessage: string,
|
|
85
|
+
identity?: GitIdentity,
|
|
86
|
+
): string {
|
|
87
|
+
const result = runGit(args, identity);
|
|
88
|
+
if (!result.ok) {
|
|
89
|
+
const detail = trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error";
|
|
90
|
+
throw new DeterministicGitError(`${failureMessage}: ${detail}`);
|
|
91
|
+
}
|
|
92
|
+
return result.stdout.trim();
|
|
93
|
+
}
|
|
98
94
|
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
95
|
+
function git(...args: string[]): string {
|
|
96
|
+
return checkedGit(args, `git ${args.join(" ")} failed in '${repoPath}'`);
|
|
97
|
+
}
|
|
103
98
|
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
.
|
|
107
|
-
|
|
108
|
-
.filter(Boolean)
|
|
109
|
-
.map((line) => line.slice(2).trim())
|
|
110
|
-
.filter(Boolean);
|
|
111
|
-
}
|
|
99
|
+
function gitOrNull(...args: string[]): string | null {
|
|
100
|
+
const result = runGit(args);
|
|
101
|
+
return result.ok ? trimToNull(result.stdout) : null;
|
|
102
|
+
}
|
|
112
103
|
|
|
113
|
-
function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
function workingTreeStatus(): string[] {
|
|
105
|
+
return (gitOrNull("status", "--porcelain") ?? "")
|
|
106
|
+
.split(/\r?\n/)
|
|
107
|
+
.map((line) => line.replace(/\s+$/, ""))
|
|
108
|
+
.filter(Boolean)
|
|
109
|
+
.map((line) => line.slice(2).trim())
|
|
110
|
+
.filter(Boolean);
|
|
111
|
+
}
|
|
119
112
|
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
113
|
+
function conflictedFiles(): string[] {
|
|
114
|
+
return (gitOrNull("diff", "--name-only", "--diff-filter=U") ?? "")
|
|
115
|
+
.split(/\r?\n/)
|
|
116
|
+
.map((line) => line.trim())
|
|
117
|
+
.filter(Boolean);
|
|
118
|
+
}
|
|
124
119
|
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
!runGit(repoPath, ["var", "GIT_COMMITTER_IDENT"], identity).ok
|
|
129
|
-
) {
|
|
130
|
-
throw new DeterministicGitError("Git author/committer identity is not configured");
|
|
120
|
+
function mergeInProgress(): boolean {
|
|
121
|
+
const gitDir = git("rev-parse", "--git-dir");
|
|
122
|
+
return existsSync(path.resolve(repoPath, gitDir, "MERGE_HEAD"));
|
|
131
123
|
}
|
|
132
|
-
}
|
|
133
124
|
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}): string {
|
|
142
|
-
if (workingTreeStatus(input.repoPath).length === 0)
|
|
143
|
-
return git(input.repoPath, "rev-parse", "HEAD");
|
|
144
|
-
assertGitIdentity(input.repoPath, input.gitIdentity);
|
|
145
|
-
checkedGit(input.repoPath, ["add", "--all"], "Failed to stage the completed change");
|
|
146
|
-
checkedGit(
|
|
147
|
-
input.repoPath,
|
|
148
|
-
["-c", "core.hooksPath=/dev/null", "commit", "--no-gpg-sign", "-m", input.commitMessage],
|
|
149
|
-
"Failed to commit the completed change",
|
|
150
|
-
input.gitIdentity,
|
|
151
|
-
);
|
|
152
|
-
const remaining = workingTreeStatus(input.repoPath);
|
|
153
|
-
if (remaining.length > 0) {
|
|
154
|
-
throw new DeterministicGitError(`Commit left uncommitted changes: ${remaining.join(", ")}`);
|
|
125
|
+
function assertGitIdentity(identity: GitIdentity): void {
|
|
126
|
+
if (
|
|
127
|
+
!runGit(["var", "GIT_AUTHOR_IDENT"], identity).ok ||
|
|
128
|
+
!runGit(["var", "GIT_COMMITTER_IDENT"], identity).ok
|
|
129
|
+
) {
|
|
130
|
+
throw new DeterministicGitError("Git author/committer identity is not configured");
|
|
131
|
+
}
|
|
155
132
|
}
|
|
156
|
-
return git(input.repoPath, "rev-parse", "HEAD");
|
|
157
|
-
}
|
|
158
133
|
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
throw new DeterministicGitError(
|
|
168
|
-
`Published '${pushTarget}' resolved to '${remoteHead ?? "missing"}', expected '${expectedHeadSha}'`,
|
|
134
|
+
function commitIfDirty(commitMessage: string, identity: GitIdentity): string {
|
|
135
|
+
if (workingTreeStatus().length === 0) return git("rev-parse", "HEAD");
|
|
136
|
+
assertGitIdentity(identity);
|
|
137
|
+
checkedGit(["add", "--all"], "Failed to stage the completed change");
|
|
138
|
+
checkedGit(
|
|
139
|
+
["-c", "core.hooksPath=/dev/null", "commit", "--no-gpg-sign", "-m", commitMessage],
|
|
140
|
+
"Failed to commit the completed change",
|
|
141
|
+
identity,
|
|
169
142
|
);
|
|
143
|
+
const remaining = workingTreeStatus();
|
|
144
|
+
if (remaining.length > 0) {
|
|
145
|
+
throw new DeterministicGitError(`Commit left uncommitted changes: ${remaining.join(", ")}`);
|
|
146
|
+
}
|
|
147
|
+
return git("rev-parse", "HEAD");
|
|
170
148
|
}
|
|
171
|
-
|
|
149
|
+
|
|
150
|
+
function pushAndVerify(branch: string, expectedHeadSha: string): string {
|
|
151
|
+
const ref = `refs/heads/${branch}`;
|
|
152
|
+
const pushTarget = `origin/${branch}`;
|
|
153
|
+
checkedGit(["push", "origin", `HEAD:${ref}`], `Failed to push HEAD to '${pushTarget}'`);
|
|
154
|
+
const remoteHead = gitOrNull("ls-remote", "--heads", "origin", ref)?.split(/\s+/)[0]?.trim();
|
|
155
|
+
if (remoteHead !== expectedHeadSha) {
|
|
156
|
+
throw new DeterministicGitError(
|
|
157
|
+
`Published '${pushTarget}' resolved to '${remoteHead ?? "missing"}', expected '${expectedHeadSha}'`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
return pushTarget;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return { runGit, git, conflictedFiles, mergeInProgress, commitIfDirty, pushAndVerify };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Inspect staged, unstaged, untracked, and already committed unpublished changes. @public */
|
|
167
|
+
export function repositoryHasChanges(
|
|
168
|
+
repoPath: string,
|
|
169
|
+
baseBranch: string,
|
|
170
|
+
projectKey = "repo",
|
|
171
|
+
): boolean {
|
|
172
|
+
const { git } = repositoryGit(projectKey, repoPath);
|
|
173
|
+
return Boolean(
|
|
174
|
+
git("status", "--porcelain") || git("diff", "--name-only", `origin/${baseBranch}...HEAD`),
|
|
175
|
+
);
|
|
172
176
|
}
|
|
173
177
|
|
|
174
178
|
/** Commit the current workspace change and non-force push only the feature branch. */
|
|
175
179
|
/** @public */
|
|
176
180
|
export function commitAndPushWorkBranch(input: {
|
|
181
|
+
/** @public */ projectKey?: string;
|
|
177
182
|
/** @public */
|
|
178
183
|
repoPath: string;
|
|
179
184
|
/** @public */
|
|
@@ -184,12 +189,14 @@ export function commitAndPushWorkBranch(input: {
|
|
|
184
189
|
gitIdentity: GitIdentity;
|
|
185
190
|
}) {
|
|
186
191
|
const repoPath = path.resolve(input.repoPath);
|
|
187
|
-
|
|
192
|
+
const { runGit, git, conflictedFiles, mergeInProgress, commitIfDirty, pushAndVerify } =
|
|
193
|
+
repositoryGit(input.projectKey ?? "repo", repoPath);
|
|
194
|
+
if (!existsSync(repoPath) || !runGit(["rev-parse", "--git-dir"]).ok) {
|
|
188
195
|
throw new DeterministicGitError(
|
|
189
196
|
`Repository workspace '${repoPath}' does not exist or is not a git repository`,
|
|
190
197
|
);
|
|
191
198
|
}
|
|
192
|
-
const branch = git(
|
|
199
|
+
const branch = git("branch", "--show-current");
|
|
193
200
|
if (branch !== input.workBranch) {
|
|
194
201
|
throw new DeterministicGitError(
|
|
195
202
|
`Expected '${repoPath}' to be checked out on '${input.workBranch}', but found '${branch || "detached HEAD"}'`,
|
|
@@ -198,21 +205,17 @@ export function commitAndPushWorkBranch(input: {
|
|
|
198
205
|
if (!trimToNull(input.commitMessage)) {
|
|
199
206
|
throw new DeterministicGitError("A generated commit message is required before publication");
|
|
200
207
|
}
|
|
201
|
-
const conflicts = conflictedFiles(
|
|
202
|
-
if (mergeInProgress(
|
|
208
|
+
const conflicts = conflictedFiles();
|
|
209
|
+
if (mergeInProgress() || conflicts.length > 0) {
|
|
203
210
|
throw new DeterministicGitError(
|
|
204
211
|
`Cannot publish a work branch with unresolved conflicts: ${conflicts.join(", ") || "merge in progress"}`,
|
|
205
212
|
);
|
|
206
213
|
}
|
|
207
|
-
const headSha = commitIfDirty(
|
|
208
|
-
repoPath,
|
|
209
|
-
commitMessage: input.commitMessage,
|
|
210
|
-
gitIdentity: input.gitIdentity,
|
|
211
|
-
});
|
|
214
|
+
const headSha = commitIfDirty(input.commitMessage, input.gitIdentity);
|
|
212
215
|
return {
|
|
213
216
|
/** @public */
|
|
214
217
|
headSha,
|
|
215
218
|
/** @internal */
|
|
216
|
-
pushTarget: pushAndVerify(
|
|
219
|
+
pushTarget: pushAndVerify(input.workBranch, headSha),
|
|
217
220
|
};
|
|
218
221
|
}
|
package/src/finalization-git.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { GitIdentity } from "./finalization-git-internal.js";
|
|
2
|
-
export { commitAndPushWorkBranch } from "./finalization-git-internal.js";
|
|
2
|
+
export { commitAndPushWorkBranch, repositoryHasChanges } from "./finalization-git-internal.js";
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import { codingSettings } from "./settings.js";
|
|
2
3
|
|
|
3
4
|
/** @internal */
|
|
4
5
|
const manifest = {
|
|
@@ -8,7 +9,7 @@ const manifest = {
|
|
|
8
9
|
version: "0.1.0",
|
|
9
10
|
} as const;
|
|
10
11
|
/** @public */
|
|
11
|
-
const extension: LeitwerkExtensionModule = { manifest };
|
|
12
|
+
const extension: LeitwerkExtensionModule = { manifest, scopedSettings: codingSettings };
|
|
12
13
|
export default extension;
|
|
13
14
|
|
|
14
15
|
export {
|
|
@@ -18,3 +19,5 @@ export {
|
|
|
18
19
|
requestRevisionForm,
|
|
19
20
|
} from "./actions.js";
|
|
20
21
|
export { createRepositoryChangeProcess } from "./repository-change-process.js";
|
|
22
|
+
|
|
23
|
+
export { codingPurposes, codingSettings } from "./settings.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function record(value: unknown, label: string): Record<string, unknown> {
|
|
2
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3
|
+
throw new Error(`${label} must be an object`);
|
|
4
|
+
return value as Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** Strict profile wiring shared by repository-change extensions. @internal */
|
|
8
|
+
export function parseRepositoryProfileBindings<K extends string>(
|
|
9
|
+
raw: unknown,
|
|
10
|
+
extensionId: string,
|
|
11
|
+
fields: Record<K, string>,
|
|
12
|
+
): Readonly<Record<string, Readonly<Record<K, string>>>> {
|
|
13
|
+
const config = raw === undefined ? {} : record(raw, `${extensionId} configuration`);
|
|
14
|
+
if (config.profile_bindings === undefined) return Object.freeze({});
|
|
15
|
+
const mappings = record(config.profile_bindings, "profile_bindings");
|
|
16
|
+
return Object.freeze(
|
|
17
|
+
Object.fromEntries(
|
|
18
|
+
Object.entries(mappings).map(([profile, value]) => {
|
|
19
|
+
if (!profile.trim() || profile.trim() !== profile)
|
|
20
|
+
throw new Error(
|
|
21
|
+
"profile_bindings keys must be non-empty profile names without surrounding whitespace",
|
|
22
|
+
);
|
|
23
|
+
const mapping = record(value, `profile_bindings.${profile}`);
|
|
24
|
+
for (const key of Object.keys(mapping))
|
|
25
|
+
if (!Object.values(fields).includes(key))
|
|
26
|
+
throw new Error(`Unknown profile_bindings.${profile}.${key}`);
|
|
27
|
+
const binding = Object.fromEntries(
|
|
28
|
+
Object.entries<string>(fields).map(([field, key]) => {
|
|
29
|
+
const value = mapping[key];
|
|
30
|
+
if (value !== undefined && (typeof value !== "string" || !value.trim()))
|
|
31
|
+
throw new Error(`profile_bindings.${profile}.${key} must be a non-empty string`);
|
|
32
|
+
return [field, value === undefined ? profile : (value as string).trim()];
|
|
33
|
+
}),
|
|
34
|
+
) as Record<K, string>;
|
|
35
|
+
return [profile, Object.freeze(binding)];
|
|
36
|
+
}),
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
}
|