@leitwerk-dev/coding 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +28 -10
  2. package/dist/actions.d.ts +12 -3
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/auto-work-branch-internal.d.ts +4 -0
  5. package/dist/auto-work-branch-internal.d.ts.map +1 -0
  6. package/dist/auto-work-branch.d.ts +1 -12
  7. package/dist/auto-work-branch.d.ts.map +1 -1
  8. package/dist/auto-work-branch.js +18 -97
  9. package/dist/auto-work-branch.js.map +1 -1
  10. package/dist/{chunk-EP3ZC37F.js → chunk-34B3Q75M.js} +1 -1
  11. package/dist/chunk-34B3Q75M.js.map +1 -0
  12. package/dist/{chunk-OFDNIT5X.js → chunk-F6CEEAFE.js} +1 -1
  13. package/dist/chunk-F6CEEAFE.js.map +1 -0
  14. package/dist/chunk-GO44KCUS.js +154 -0
  15. package/dist/chunk-GO44KCUS.js.map +1 -0
  16. package/dist/{chunk-WQEPA35Z.js → chunk-R3UCUGY6.js} +1 -1
  17. package/dist/chunk-R3UCUGY6.js.map +1 -0
  18. package/dist/{chunk-67YKGZLM.js → chunk-W7VJT6AN.js} +1 -1
  19. package/dist/chunk-W7VJT6AN.js.map +1 -0
  20. package/dist/{chunk-NIJCT4VK.js → chunk-WKHVLLKE.js} +1 -1
  21. package/dist/chunk-WKHVLLKE.js.map +1 -0
  22. package/dist/{chunk-UBVLJV3V.js → chunk-YSC5GEQJ.js} +1 -1
  23. package/dist/chunk-YSC5GEQJ.js.map +1 -0
  24. package/dist/finalization-git-internal.d.ts +33 -0
  25. package/dist/finalization-git-internal.d.ts.map +1 -0
  26. package/dist/finalization-git.d.ts +2 -47
  27. package/dist/finalization-git.d.ts.map +1 -1
  28. package/dist/finalization-git.js +3 -9
  29. package/dist/index.d.ts +3 -7
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +73 -112
  32. package/dist/index.js.map +1 -1
  33. package/dist/repository-change-launch-internal.d.ts +35 -0
  34. package/dist/repository-change-launch-internal.d.ts.map +1 -0
  35. package/dist/repository-change-launch.d.ts +2 -64
  36. package/dist/repository-change-launch.d.ts.map +1 -1
  37. package/dist/repository-change-launch.js +22 -11
  38. package/dist/repository-change-launch.js.map +1 -1
  39. package/dist/repository-change-process.d.ts +31 -13
  40. package/dist/repository-change-process.d.ts.map +1 -1
  41. package/dist/repository-change-publication.d.ts +229 -0
  42. package/dist/repository-change-publication.d.ts.map +1 -0
  43. package/dist/repository-change-publication.js +368 -0
  44. package/dist/repository-change-publication.js.map +1 -0
  45. package/dist/repository-change-state-internal.d.ts +21 -0
  46. package/dist/repository-change-state-internal.d.ts.map +1 -0
  47. package/dist/repository-change-state.d.ts +1 -17
  48. package/dist/repository-change-state.d.ts.map +1 -1
  49. package/dist/repository-change-state.js +0 -13
  50. package/dist/turns/generate-commit-message.d.ts +2 -0
  51. package/dist/turns/generate-commit-message.d.ts.map +1 -1
  52. package/dist/turns/generate-commit-message.js +1 -1
  53. package/dist/turns/generate-plan.d.ts +1 -0
  54. package/dist/turns/generate-plan.d.ts.map +1 -1
  55. package/dist/turns/generate-plan.js +1 -1
  56. package/dist/turns/implement.d.ts +1 -0
  57. package/dist/turns/implement.d.ts.map +1 -1
  58. package/dist/turns/implement.js +1 -1
  59. package/dist/turns/review-implementation.d.ts +1 -0
  60. package/dist/turns/review-implementation.d.ts.map +1 -1
  61. package/dist/turns/review-implementation.js +1 -1
  62. package/dist/turns/review-plan.d.ts +1 -0
  63. package/dist/turns/review-plan.d.ts.map +1 -1
  64. package/dist/turns/review-plan.js +1 -1
  65. package/dist/turns/simplify-implementation.d.ts +1 -0
  66. package/dist/turns/simplify-implementation.d.ts.map +1 -1
  67. package/dist/turns/simplify-implementation.js +1 -1
  68. package/package.json +24 -8
  69. package/src/actions.ts +12 -9
  70. package/src/auto-work-branch-internal.ts +41 -0
  71. package/src/auto-work-branch.ts +1 -140
  72. package/src/finalization-git-internal.ts +218 -0
  73. package/src/finalization-git.ts +2 -828
  74. package/src/index.ts +15 -4
  75. package/src/repository-change-launch-internal.ts +64 -0
  76. package/src/repository-change-launch.ts +10 -264
  77. package/src/repository-change-process.ts +33 -123
  78. package/src/repository-change-publication.ts +689 -0
  79. package/src/repository-change-state-internal.ts +60 -0
  80. package/src/repository-change-state.ts +1 -78
  81. package/src/turns/generate-commit-message.ts +2 -0
  82. package/src/turns/generate-plan.ts +1 -0
  83. package/src/turns/implement.ts +1 -0
  84. package/src/turns/review-implementation.ts +1 -0
  85. package/src/turns/review-plan.ts +1 -0
  86. package/src/turns/simplify-implementation.ts +1 -0
  87. package/dist/chunk-5LVPKVI2.js +0 -27
  88. package/dist/chunk-5LVPKVI2.js.map +0 -1
  89. package/dist/chunk-67YKGZLM.js.map +0 -1
  90. package/dist/chunk-73LKROYK.js +0 -616
  91. package/dist/chunk-73LKROYK.js.map +0 -1
  92. package/dist/chunk-EP3ZC37F.js.map +0 -1
  93. package/dist/chunk-NIJCT4VK.js.map +0 -1
  94. package/dist/chunk-OFDNIT5X.js.map +0 -1
  95. package/dist/chunk-UBVLJV3V.js.map +0 -1
  96. package/dist/chunk-WQEPA35Z.js.map +0 -1
  97. package/dist/chunk-Y2S6JFVO.js +0 -185
  98. package/dist/chunk-Y2S6JFVO.js.map +0 -1
  99. package/dist/chunk-YIP4MP64.js +0 -61
  100. package/dist/chunk-YIP4MP64.js.map +0 -1
  101. package/dist/turns/resolve-merge-conflict.d.ts +0 -3
  102. package/dist/turns/resolve-merge-conflict.d.ts.map +0 -1
  103. package/dist/turns/resolve-merge-conflict.js +0 -8
  104. package/dist/turns/resolve-merge-conflict.js.map +0 -1
  105. package/src/turns/resolve-merge-conflict.ts +0 -25
@@ -0,0 +1,60 @@
1
+ import type { Codec, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
+ import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
3
+
4
+ /** @public */
5
+ export interface RepositoryChangeFinalizationState {
6
+ /** @public */
7
+ generatedCommitMessage: string | null;
8
+ }
9
+
10
+ /** @public */
11
+ export interface RepositoryChangeState extends StructuralProcessState {
12
+ /** @public */
13
+ finalization: RepositoryChangeFinalizationState;
14
+ /** Namespaced state owned by a caller-supplied publication workflow. */
15
+ /** @public */
16
+ extensionState?: Record<string, unknown>;
17
+ }
18
+
19
+ /** @internal */
20
+ export function createEmptyRepositoryChangeFinalizationState(): RepositoryChangeFinalizationState {
21
+ return { generatedCommitMessage: null };
22
+ }
23
+
24
+ function stringOrNull(value: unknown): string | null {
25
+ return typeof value === "string" ? value : null;
26
+ }
27
+
28
+ function toRecord(value: unknown): Record<string, unknown> {
29
+ return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
30
+ }
31
+
32
+ function parseFinalizationState(value: unknown): RepositoryChangeFinalizationState {
33
+ const record = toRecord(value);
34
+ return { generatedCommitMessage: stringOrNull(record.generatedCommitMessage) };
35
+ }
36
+
37
+ /** @internal */
38
+ export const repositoryChangeStateCodec: Codec<RepositoryChangeState> = {
39
+ parse(value) {
40
+ const record = toRecord(value);
41
+ return {
42
+ ...parseStructuralProcessState(record),
43
+ finalization: parseFinalizationState(record.finalization),
44
+ extensionState: toRecord(record.extensionState),
45
+ };
46
+ },
47
+ serialize(value) {
48
+ return value;
49
+ },
50
+ };
51
+
52
+ /** @internal */
53
+ export function clearReviewRefs(
54
+ semanticEntryRefs: RepositoryChangeState["semanticEntryRefs"],
55
+ ): RepositoryChangeState["semanticEntryRefs"] {
56
+ return {
57
+ ...semanticEntryRefs,
58
+ review: null,
59
+ };
60
+ }
@@ -1,78 +1 @@
1
- import type { Codec, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
- import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
3
-
4
- export interface RepositoryChangeFinalizationState {
5
- expectedPostConflictHeadSha: string | null;
6
- usedConflictResolution: boolean;
7
- finalizationSummaryMarkdown: string | null;
8
- finalizedHeadSha: string | null;
9
- generatedCommitMessage: string | null;
10
- }
11
-
12
- export interface RepositoryChangeState extends StructuralProcessState {
13
- finalization: RepositoryChangeFinalizationState;
14
- /** Namespaced state owned by a caller-supplied publication workflow. */
15
- extensionState?: Record<string, unknown>;
16
- }
17
-
18
- export function createEmptyRepositoryChangeFinalizationState(): RepositoryChangeFinalizationState {
19
- return {
20
- expectedPostConflictHeadSha: null,
21
- usedConflictResolution: false,
22
- finalizationSummaryMarkdown: null,
23
- finalizedHeadSha: null,
24
- generatedCommitMessage: null,
25
- };
26
- }
27
-
28
- function stringOrNull(value: unknown): string | null {
29
- return typeof value === "string" ? value : null;
30
- }
31
-
32
- function toRecord(value: unknown): Record<string, unknown> {
33
- return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
34
- }
35
-
36
- function parseFinalizationState(value: unknown): RepositoryChangeFinalizationState {
37
- const record = toRecord(value);
38
- return {
39
- expectedPostConflictHeadSha: stringOrNull(record.expectedPostConflictHeadSha),
40
- usedConflictResolution: record.usedConflictResolution === true,
41
- finalizationSummaryMarkdown: stringOrNull(record.finalizationSummaryMarkdown),
42
- finalizedHeadSha: stringOrNull(record.finalizedHeadSha),
43
- // Backward-compatible decoding for state persisted before commit-message generation.
44
- generatedCommitMessage: stringOrNull(record.generatedCommitMessage),
45
- };
46
- }
47
-
48
- export const repositoryChangeStateCodec: Codec<RepositoryChangeState> = {
49
- parse(value) {
50
- const record = toRecord(value);
51
- return {
52
- ...parseStructuralProcessState(record),
53
- finalization: parseFinalizationState(record.finalization),
54
- extensionState: toRecord(record.extensionState),
55
- };
56
- },
57
- serialize(value) {
58
- return value;
59
- },
60
- };
61
-
62
- export function clearReviewRefs(
63
- semanticEntryRefs: RepositoryChangeState["semanticEntryRefs"],
64
- ): RepositoryChangeState["semanticEntryRefs"] {
65
- return {
66
- ...semanticEntryRefs,
67
- review: null,
68
- };
69
- }
70
-
71
- export function resetRepositoryChangeFinalizationState(
72
- overrides: Partial<RepositoryChangeFinalizationState> = {},
73
- ): RepositoryChangeFinalizationState {
74
- return {
75
- ...createEmptyRepositoryChangeFinalizationState(),
76
- ...overrides,
77
- };
78
- }
1
+ export type { RepositoryChangeState } from "./repository-change-state-internal.js";
@@ -5,6 +5,7 @@ import {
5
5
  type FlowPromptContext,
6
6
  } from "@leitwerk-dev/process-sdk";
7
7
 
8
+ /** @internal */
8
9
  export function normalizeGeneratedCommitMessage(value: unknown): string {
9
10
  if (typeof value !== "string" || value.includes("\0")) {
10
11
  throw new Error("Generated commit message must be plain text without NUL characters");
@@ -20,6 +21,7 @@ export function normalizeGeneratedCommitMessage(value: unknown): string {
20
21
  return normalized;
21
22
  }
22
23
 
24
+ /** @internal */
23
25
  export function buildGenerateCommitMessagePrompt<TParams, TState>(
24
26
  ctx: FlowPromptContext<TParams, TState, "plan">,
25
27
  ): string {
@@ -1,5 +1,6 @@
1
1
  import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
2
 
3
+ /** @internal */
3
4
  export function buildGeneratePlanPrompt(
4
5
  ctx: FlowPromptContext<unknown, StructuralProcessState, never>,
5
6
  ): string {
@@ -1,5 +1,6 @@
1
1
  import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
2
 
3
+ /** @internal */
3
4
  export function buildImplementPrompt(
4
5
  ctx: FlowPromptContext<unknown, StructuralProcessState, "plan">,
5
6
  ): string {
@@ -1,5 +1,6 @@
1
1
  import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
2
 
3
+ /** @internal */
3
4
  export function buildReviewImplementationPrompt(
4
5
  ctx: FlowPromptContext<unknown, StructuralProcessState>,
5
6
  ): string {
@@ -1,5 +1,6 @@
1
1
  import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
2
 
3
+ /** @internal */
3
4
  export function buildReviewPlanPrompt(
4
5
  ctx: FlowPromptContext<unknown, StructuralProcessState, "plan">,
5
6
  ): string {
@@ -1,5 +1,6 @@
1
1
  import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
2
 
3
+ /** @internal */
3
4
  export function buildSimplifyImplementationPrompt(
4
5
  _ctx: FlowPromptContext<unknown, StructuralProcessState>,
5
6
  ): string {
@@ -1,27 +0,0 @@
1
- // src/turns/resolve-merge-conflict.ts
2
- function buildResolveMergeConflictPrompt(ctx) {
3
- const repo = ctx.repo.get("repo");
4
- return `Resolve the current merge conflict so this requested change can be finalized:
5
- ${ctx.prompts.initial}
6
-
7
- Repository root: . (the current working directory)
8
-
9
- Branches:
10
- - base branch: ${repo.baseBranch}
11
- - work branch: ${repo.workBranch}
12
-
13
- Rules:
14
- - resolve only the current merge conflict inside the current working directory
15
- - treat . as the repository root for file edits and git commands
16
- - complete the merge commit so the repository is no longer in a merge-in-progress state
17
- - leave the repository clean when you finish
18
- - do not push
19
- - do not read from or write to any original source repository path outside the process workspace
20
- - publish a concise Markdown summary of the merge resolution
21
- - then call clean with the final HEAD sha`;
22
- }
23
-
24
- export {
25
- buildResolveMergeConflictPrompt
26
- };
27
- //# sourceMappingURL=chunk-5LVPKVI2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/turns/resolve-merge-conflict.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\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":";AAEO,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":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/turns/generate-plan.ts"],"sourcesContent":["import type { FlowPromptContext, StructuralProcessState } from \"@leitwerk-dev/process-sdk\";\n\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":";AAEO,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":[]}