@leitwerk-dev/coding 0.2.1 → 0.3.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.
Files changed (85) hide show
  1. package/README.md +51 -12
  2. package/dist/actions.d.ts +0 -5
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/auto-work-branch-internal.d.ts +2 -18
  5. package/dist/auto-work-branch-internal.d.ts.map +1 -1
  6. package/dist/auto-work-branch.d.ts +1 -2
  7. package/dist/auto-work-branch.d.ts.map +1 -1
  8. package/dist/auto-work-branch.js +4 -102
  9. package/dist/auto-work-branch.js.map +1 -1
  10. package/dist/chunk-6E5VQPC4.js +28 -0
  11. package/dist/chunk-6E5VQPC4.js.map +1 -0
  12. package/dist/chunk-GO44KCUS.js +154 -0
  13. package/dist/chunk-GO44KCUS.js.map +1 -0
  14. package/dist/chunk-KFELB7ZC.js +70 -0
  15. package/dist/chunk-KFELB7ZC.js.map +1 -0
  16. package/dist/finalization-git-internal.d.ts +6 -45
  17. package/dist/finalization-git-internal.d.ts.map +1 -1
  18. package/dist/finalization-git.js +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +48 -91
  22. package/dist/index.js.map +1 -1
  23. package/dist/profile-bindings-internal.d.ts +3 -0
  24. package/dist/profile-bindings-internal.d.ts.map +1 -0
  25. package/dist/pull-request-publication-internal.d.ts +73 -0
  26. package/dist/pull-request-publication-internal.d.ts.map +1 -0
  27. package/dist/repository-change-launch-internal-Dd-AONUs.d.ts +67 -0
  28. package/dist/repository-change-launch-internal.d.ts +31 -82
  29. package/dist/repository-change-launch-internal.d.ts.map +1 -1
  30. package/dist/repository-change-launch.d.ts +4 -2
  31. package/dist/repository-change-launch.d.ts.map +1 -1
  32. package/dist/repository-change-launch.js +205 -133
  33. package/dist/repository-change-launch.js.map +1 -1
  34. package/dist/repository-change-process.d.ts +7 -19
  35. package/dist/repository-change-process.d.ts.map +1 -1
  36. package/dist/repository-change-publication.d.ts +229 -0
  37. package/dist/repository-change-publication.d.ts.map +1 -0
  38. package/dist/repository-change-publication.js +770 -0
  39. package/dist/repository-change-publication.js.map +1 -0
  40. package/dist/repository-change-state-internal.d.ts +2 -11
  41. package/dist/repository-change-state-internal.d.ts.map +1 -1
  42. package/dist/repository-change-state.d.ts +0 -1
  43. package/dist/repository-change-state.d.ts.map +1 -1
  44. package/dist/repository-change-state.js +0 -7
  45. package/dist/repository-change-ui-launcher-internal.d.ts +53 -0
  46. package/dist/repository-change-ui-launcher-internal.d.ts.map +1 -0
  47. package/dist/repository-rebase/git.d.ts +31 -0
  48. package/dist/repository-rebase/git.d.ts.map +1 -0
  49. package/dist/repository-rebase/index.d.ts +42 -0
  50. package/dist/repository-rebase/index.d.ts.map +1 -0
  51. package/dist/repository-rebase/index.js +16 -0
  52. package/dist/repository-rebase/policy.d.ts +37 -0
  53. package/dist/repository-rebase/policy.d.ts.map +1 -0
  54. package/dist/repository-rebase/prompt.d.ts +3 -0
  55. package/dist/repository-rebase/prompt.d.ts.map +1 -0
  56. package/package.json +14 -4
  57. package/src/actions.ts +0 -13
  58. package/src/auto-work-branch-internal.ts +22 -130
  59. package/src/auto-work-branch.ts +1 -7
  60. package/src/finalization-git-internal.ts +60 -697
  61. package/src/index.ts +0 -1
  62. package/src/profile-bindings-internal.ts +39 -0
  63. package/src/pull-request-publication-internal.ts +286 -0
  64. package/src/repository-change-launch-internal.ts +79 -267
  65. package/src/repository-change-launch.ts +10 -6
  66. package/src/repository-change-process.ts +8 -126
  67. package/src/repository-change-publication.ts +673 -0
  68. package/src/repository-change-state-internal.ts +4 -34
  69. package/src/repository-change-state.ts +0 -1
  70. package/src/repository-change-ui-launcher-internal.ts +225 -0
  71. package/src/repository-rebase/git.ts +219 -0
  72. package/src/repository-rebase/index.ts +144 -0
  73. package/src/repository-rebase/policy.ts +75 -0
  74. package/src/repository-rebase/prompt.ts +2 -0
  75. package/dist/chunk-HUVXPZSF.js +0 -61
  76. package/dist/chunk-HUVXPZSF.js.map +0 -1
  77. package/dist/chunk-MY6XFGHM.js +0 -614
  78. package/dist/chunk-MY6XFGHM.js.map +0 -1
  79. package/dist/chunk-OERAYSVI.js +0 -27
  80. package/dist/chunk-OERAYSVI.js.map +0 -1
  81. package/dist/turns/resolve-merge-conflict.d.ts +0 -4
  82. package/dist/turns/resolve-merge-conflict.d.ts.map +0 -1
  83. package/dist/turns/resolve-merge-conflict.js +0 -8
  84. package/src/turns/resolve-merge-conflict.ts +0 -26
  85. /package/dist/{turns/resolve-merge-conflict.js.map → repository-rebase/index.js.map} +0 -0
@@ -0,0 +1,75 @@
1
+ import type { ConflictEvidence } from "./index.js";
2
+
3
+ /** Durable preparation evidence; optional identity fields support older records. @internal */
4
+ export interface RebaseRecord {
5
+ /** @internal */
6
+ key: string;
7
+ /** @internal */
8
+ branch: string;
9
+ /** @internal */
10
+ originalHead: string;
11
+ /** @internal */
12
+ baseSha: string;
13
+ /** @internal */
14
+ status: "prepared" | "rebasing" | "clean";
15
+ /** @internal */
16
+ originUrl?: string;
17
+ /** @internal */
18
+ originPushUrl?: string;
19
+ /** @internal */
20
+ baseBranch?: string;
21
+ }
22
+
23
+ /** Validate provider evidence against the tracked branch and retained preparation. @internal */
24
+ export function requireRebaseTarget(
25
+ workBranch: string,
26
+ conflict: ConflictEvidence,
27
+ record?: RebaseRecord | null,
28
+ ): void {
29
+ if (workBranch !== conflict.headBranch || workBranch === conflict.baseBranch)
30
+ throw new Error("Expected evidence for the tracked work branch and a distinct base");
31
+ if (record && (record.branch !== workBranch || record.originalHead !== conflict.headSha))
32
+ throw new Error("Missing matching rebase metadata");
33
+ if (record?.baseBranch && record.baseBranch !== conflict.baseBranch)
34
+ throw new Error("Rebase base branch changed since preparation");
35
+ }
36
+
37
+ /** Compare observed remote identity only where preparation retained it. @internal */
38
+ export function requireRebaseOrigin(
39
+ record: RebaseRecord | null | undefined,
40
+ origin: { originUrl?: string; originPushUrl?: string },
41
+ ): void {
42
+ if (
43
+ (record?.originUrl && origin.originUrl !== record.originUrl) ||
44
+ (record?.originPushUrl && origin.originPushUrl !== record.originPushUrl)
45
+ )
46
+ throw new Error("Rebase origin changed since preparation");
47
+ }
48
+
49
+ /** A repair may operate only on the clean tracked checkout. @internal */
50
+ export function requireRebaseWorktree(
51
+ workBranch: string,
52
+ observation: { branch: string; dirty: boolean },
53
+ ): void {
54
+ if (observation.branch !== workBranch) throw new Error("Expected tracked work branch for rebase");
55
+ if (observation.dirty)
56
+ throw new Error("Rebase requires a clean worktree with no unresolved conflicts");
57
+ }
58
+
59
+ /** Both local and remote heads must still match the provider's evidence. @internal */
60
+ export function requireRebaseHead(expected: string, local: string, remote: string): void {
61
+ if (remote !== expected || local !== expected)
62
+ throw new Error("Tracked branch changed before repair");
63
+ }
64
+
65
+ /** Recognize a completed write without accepting somebody else's remote update. @internal */
66
+ export function rebasePublicationDecision(
67
+ originalHead: string,
68
+ headSha: string,
69
+ remoteHead: string,
70
+ ): "already_published" | "push" {
71
+ if (remoteHead === headSha) return "already_published";
72
+ if (remoteHead !== originalHead)
73
+ throw new Error("Concurrent remote change rejected by rebase lease");
74
+ return "push";
75
+ }
@@ -0,0 +1,2 @@
1
+ /** @internal */
2
+ export const rebasePrompt = `Repair only the recorded pull request merge conflict or behind-base condition. Deterministic preparation has fetched and verified the tracked head and current base, retained the original head and lease in .git/leitwerk-rebase.json, and started the rebase if the conflict or missing base commits are confirmed locally. Inspect that metadata and git status first. For behind-base evidence, incorporate the fetched base even when merging would be clean. A clean preparation result means no rewrite is needed. Resolve conflicts preserving the requested behavior, original authors, and existing Signed-off-by trailers. You may use git add and GIT_EDITOR=true git rebase --continue until finished. This explicitly overrides the prohibition on creating commits only for rebase continuation. Do not create unrelated commits, reset the branch, skip commits, abort the rebase, or push. Run focused repository checks after resolution. Delivery verifies the completed rebase and publishes with the recorded pre-repair lease. If blocked, retain the workspace and explain the failure for retry or abort. Record a concise repair result.`;
@@ -1,61 +0,0 @@
1
- // src/repository-change-state-internal.ts
2
- import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
3
- function createEmptyRepositoryChangeFinalizationState() {
4
- return {
5
- expectedPostConflictHeadSha: null,
6
- usedConflictResolution: false,
7
- finalizationSummaryMarkdown: null,
8
- finalizedHeadSha: null,
9
- generatedCommitMessage: null
10
- };
11
- }
12
- function stringOrNull(value) {
13
- return typeof value === "string" ? value : null;
14
- }
15
- function toRecord(value) {
16
- return typeof value === "object" && value !== null ? value : {};
17
- }
18
- function parseFinalizationState(value) {
19
- const record = toRecord(value);
20
- return {
21
- expectedPostConflictHeadSha: stringOrNull(record.expectedPostConflictHeadSha),
22
- usedConflictResolution: record.usedConflictResolution === true,
23
- finalizationSummaryMarkdown: stringOrNull(record.finalizationSummaryMarkdown),
24
- finalizedHeadSha: stringOrNull(record.finalizedHeadSha),
25
- // Backward-compatible decoding for state persisted before commit-message generation.
26
- generatedCommitMessage: stringOrNull(record.generatedCommitMessage)
27
- };
28
- }
29
- var repositoryChangeStateCodec = {
30
- parse(value) {
31
- const record = toRecord(value);
32
- return {
33
- ...parseStructuralProcessState(record),
34
- finalization: parseFinalizationState(record.finalization),
35
- extensionState: toRecord(record.extensionState)
36
- };
37
- },
38
- serialize(value) {
39
- return value;
40
- }
41
- };
42
- function clearReviewRefs(semanticEntryRefs) {
43
- return {
44
- ...semanticEntryRefs,
45
- review: null
46
- };
47
- }
48
- function resetRepositoryChangeFinalizationState(overrides = {}) {
49
- return {
50
- ...createEmptyRepositoryChangeFinalizationState(),
51
- ...overrides
52
- };
53
- }
54
-
55
- export {
56
- createEmptyRepositoryChangeFinalizationState,
57
- repositoryChangeStateCodec,
58
- clearReviewRefs,
59
- resetRepositoryChangeFinalizationState
60
- };
61
- //# sourceMappingURL=chunk-HUVXPZSF.js.map
@@ -1 +0,0 @@
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":[]}