@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.
Files changed (130) hide show
  1. package/README.md +120 -2
  2. package/dist/auto-work-branch.js +3 -24
  3. package/dist/auto-work-branch.js.map +1 -1
  4. package/dist/chunk-6E5VQPC4.js +28 -0
  5. package/dist/chunk-6E5VQPC4.js.map +1 -0
  6. package/dist/chunk-ABQH2WZT.js +36 -0
  7. package/dist/chunk-ABQH2WZT.js.map +1 -0
  8. package/dist/{chunk-YSC5GEQJ.js → chunk-BI45R2FH.js} +7 -3
  9. package/dist/chunk-BI45R2FH.js.map +1 -0
  10. package/dist/chunk-DNG7D77K.js +65 -0
  11. package/dist/chunk-DNG7D77K.js.map +1 -0
  12. package/dist/chunk-KFELB7ZC.js +70 -0
  13. package/dist/chunk-KFELB7ZC.js.map +1 -0
  14. package/dist/chunk-L2TFD72B.js +16320 -0
  15. package/dist/chunk-L2TFD72B.js.map +1 -0
  16. package/dist/chunk-M2VTUPFO.js +265 -0
  17. package/dist/chunk-M2VTUPFO.js.map +1 -0
  18. package/dist/chunk-OM2AMDTJ.js +347 -0
  19. package/dist/chunk-OM2AMDTJ.js.map +1 -0
  20. package/dist/chunk-Q24RPXOA.js +159 -0
  21. package/dist/chunk-Q24RPXOA.js.map +1 -0
  22. package/dist/chunk-SKGB4CZS.js +14 -0
  23. package/dist/chunk-SKGB4CZS.js.map +1 -0
  24. package/dist/chunk-SZ4WOGV2.js +120 -0
  25. package/dist/chunk-SZ4WOGV2.js.map +1 -0
  26. package/dist/finalization-git-internal.d.ts +3 -0
  27. package/dist/finalization-git-internal.d.ts.map +1 -1
  28. package/dist/finalization-git.d.ts +1 -1
  29. package/dist/finalization-git.d.ts.map +1 -1
  30. package/dist/finalization-git.js +5 -3
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +17 -591
  34. package/dist/index.js.map +1 -1
  35. package/dist/profile-bindings-internal.d.ts +3 -0
  36. package/dist/profile-bindings-internal.d.ts.map +1 -0
  37. package/dist/pull-request-publication-internal.d.ts +75 -0
  38. package/dist/pull-request-publication-internal.d.ts.map +1 -0
  39. package/dist/repository-change-launch-internal-BudnAfL7.d.ts +88 -0
  40. package/dist/repository-change-launch-internal.d.ts +62 -11
  41. package/dist/repository-change-launch-internal.d.ts.map +1 -1
  42. package/dist/repository-change-launch.d.ts +5 -2
  43. package/dist/repository-change-launch.d.ts.map +1 -1
  44. package/dist/repository-change-launch.js +363 -6
  45. package/dist/repository-change-launch.js.map +1 -1
  46. package/dist/repository-change-process-DlgF04fU.d.ts +69 -0
  47. package/dist/repository-change-process.d.ts +30 -25
  48. package/dist/repository-change-process.d.ts.map +1 -1
  49. package/dist/repository-change-publication.d.ts +63 -7
  50. package/dist/repository-change-publication.d.ts.map +1 -1
  51. package/dist/repository-change-publication.js +732 -56
  52. package/dist/repository-change-publication.js.map +1 -1
  53. package/dist/repository-change-state-internal.d.ts +18 -4
  54. package/dist/repository-change-state-internal.d.ts.map +1 -1
  55. package/dist/repository-change-ui-launcher-internal.d.ts +65 -0
  56. package/dist/repository-change-ui-launcher-internal.d.ts.map +1 -0
  57. package/dist/repository-rebase/git.d.ts +31 -0
  58. package/dist/repository-rebase/git.d.ts.map +1 -0
  59. package/dist/repository-rebase/index.d.ts +42 -0
  60. package/dist/repository-rebase/index.d.ts.map +1 -0
  61. package/dist/repository-rebase/index.js +16 -0
  62. package/dist/repository-rebase/policy.d.ts +37 -0
  63. package/dist/repository-rebase/policy.d.ts.map +1 -0
  64. package/dist/repository-rebase/prompt.d.ts +3 -0
  65. package/dist/repository-rebase/prompt.d.ts.map +1 -0
  66. package/dist/settings.d.ts +15 -0
  67. package/dist/settings.d.ts.map +1 -0
  68. package/dist/turns/commit-message-evidence.d.ts +35 -0
  69. package/dist/turns/commit-message-evidence.d.ts.map +1 -0
  70. package/dist/turns/commit-message-evidence.js +9 -0
  71. package/dist/turns/generate-commit-message.d.ts +4 -1
  72. package/dist/turns/generate-commit-message.d.ts.map +1 -1
  73. package/dist/turns/generate-commit-message.js +7 -5
  74. package/dist/turns/generate-plan.d.ts.map +1 -1
  75. package/dist/turns/generate-plan.js +1 -1
  76. package/dist/turns/git-inspection-profile.d.ts +25 -0
  77. package/dist/turns/git-inspection-profile.d.ts.map +1 -0
  78. package/dist/turns/git-inspection-profile.js +8 -0
  79. package/dist/turns/git-inspection-profile.js.map +1 -0
  80. package/dist/turns/implement.d.ts.map +1 -1
  81. package/dist/turns/implement.js +1 -1
  82. package/dist/turns/simplify-implementation.d.ts +1 -1
  83. package/dist/turns/simplify-implementation.d.ts.map +1 -1
  84. package/dist/turns/simplify-implementation.js +3 -3
  85. package/package.json +10 -10
  86. package/src/finalization-git-internal.ts +117 -114
  87. package/src/finalization-git.ts +1 -1
  88. package/src/index.ts +4 -1
  89. package/src/profile-bindings-internal.ts +39 -0
  90. package/src/pull-request-publication-internal.ts +364 -0
  91. package/src/repository-change-launch-internal.ts +194 -11
  92. package/src/repository-change-launch.ts +13 -0
  93. package/src/repository-change-process.ts +234 -523
  94. package/src/repository-change-publication.ts +535 -156
  95. package/src/repository-change-state-internal.ts +34 -20
  96. package/src/repository-change-ui-launcher-internal.ts +308 -0
  97. package/src/repository-rebase/git.ts +219 -0
  98. package/src/repository-rebase/index.ts +144 -0
  99. package/src/repository-rebase/policy.ts +75 -0
  100. package/src/repository-rebase/prompt.ts +2 -0
  101. package/src/settings.ts +79 -0
  102. package/src/turns/commit-message-evidence.ts +241 -0
  103. package/src/turns/generate-commit-message.ts +53 -23
  104. package/src/turns/generate-plan.ts +26 -12
  105. package/src/turns/git-inspection-profile.ts +134 -0
  106. package/src/turns/implement.ts +9 -2
  107. package/src/turns/simplify-implementation.ts +10 -6
  108. package/dist/chunk-34B3Q75M.js +0 -25
  109. package/dist/chunk-34B3Q75M.js.map +0 -1
  110. package/dist/chunk-F6CEEAFE.js +0 -13
  111. package/dist/chunk-F6CEEAFE.js.map +0 -1
  112. package/dist/chunk-GO44KCUS.js +0 -154
  113. package/dist/chunk-GO44KCUS.js.map +0 -1
  114. package/dist/chunk-R3UCUGY6.js +0 -31
  115. package/dist/chunk-R3UCUGY6.js.map +0 -1
  116. package/dist/chunk-W7VJT6AN.js +0 -25
  117. package/dist/chunk-W7VJT6AN.js.map +0 -1
  118. package/dist/chunk-WKHVLLKE.js +0 -45
  119. package/dist/chunk-WKHVLLKE.js.map +0 -1
  120. package/dist/chunk-YSC5GEQJ.js.map +0 -1
  121. package/dist/turns/review-implementation.d.ts +0 -4
  122. package/dist/turns/review-implementation.d.ts.map +0 -1
  123. package/dist/turns/review-implementation.js +0 -8
  124. package/dist/turns/review-plan.d.ts +0 -4
  125. package/dist/turns/review-plan.d.ts.map +0 -1
  126. package/dist/turns/review-plan.js +0 -8
  127. package/src/turns/review-implementation.ts +0 -30
  128. package/src/turns/review-plan.ts +0 -24
  129. /package/dist/{turns/review-implementation.js.map → repository-rebase/index.js.map} +0 -0
  130. /package/dist/turns/{review-plan.js.map → commit-message-evidence.js.map} +0 -0
@@ -0,0 +1,134 @@
1
+ import { StringDecoder } from "node:string_decoder";
2
+
3
+ const MAX_TRACE_BYTES = 512 * 1024;
4
+ const MAX_LINE_LENGTH = 16 * 1024;
5
+ const COUNTERS = new Set([
6
+ "index/read/cache_nr",
7
+ "index/preload/sum_lstat",
8
+ "index/refresh/sum_lstat",
9
+ "index/refresh/sum_scan",
10
+ "read_directory/directories-visited",
11
+ "read_directory/paths-visited",
12
+ "status/count/changed",
13
+ "status/count/untracked",
14
+ ]);
15
+ const REGIONS = new Set([
16
+ "index/do_read_index",
17
+ "index/preload",
18
+ "index/refresh",
19
+ "index/do_write_index",
20
+ "status/worktrees",
21
+ "status/index",
22
+ "status/untracked",
23
+ "dir/read_directory",
24
+ "diff/setup",
25
+ "diff/write back to queue",
26
+ ]);
27
+
28
+ /** @internal */
29
+ export interface GitTrace2Summary {
30
+ /** @internal */
31
+ counters: Record<string, number>;
32
+ /** @internal */
33
+ regionsMs: Record<string, number>;
34
+ /** Trace was absent, malformed, or exceeded the parsing budget. @internal */
35
+ incomplete: boolean;
36
+ }
37
+
38
+ /** Reduces a bounded Trace2 stream to allowlisted numbers; never retains raw events. @internal */
39
+ export class GitTrace2Collector {
40
+ private readonly decoder = new StringDecoder("utf8");
41
+ private readonly summary: GitTrace2Summary = { counters: {}, regionsMs: {}, incomplete: false };
42
+ private bytes = 0;
43
+ private pending = "";
44
+ private droppingLine = false;
45
+ private sawEvent = false;
46
+
47
+ /** @internal */
48
+ write(chunk: Buffer): void {
49
+ const remaining = MAX_TRACE_BYTES - this.bytes;
50
+ if (chunk.length > remaining) this.summary.incomplete = true;
51
+ if (remaining <= 0) return;
52
+ const retained = chunk.subarray(0, remaining);
53
+ this.bytes += retained.length;
54
+ this.consume(this.decoder.write(retained));
55
+ }
56
+
57
+ /** @internal */
58
+ finish(): GitTrace2Summary {
59
+ this.consume(this.decoder.end());
60
+ if (this.pending || this.droppingLine || !this.sawEvent) this.summary.incomplete = true;
61
+ this.pending = "";
62
+ return this.summary;
63
+ }
64
+
65
+ private consume(text: string): void {
66
+ let start = 0;
67
+ while (start < text.length) {
68
+ const end = text.indexOf("\n", start);
69
+ const part = text.slice(start, end < 0 ? text.length : end);
70
+ if (!this.droppingLine) {
71
+ if (this.pending.length + part.length > MAX_LINE_LENGTH) {
72
+ this.summary.incomplete = true;
73
+ this.pending = "";
74
+ this.droppingLine = true;
75
+ } else this.pending += part;
76
+ }
77
+ if (end < 0) break;
78
+ if (!this.droppingLine) this.readEvent(this.pending);
79
+ this.pending = "";
80
+ this.droppingLine = false;
81
+ start = end + 1;
82
+ }
83
+ }
84
+
85
+ private readEvent(line: string): void {
86
+ let event: Record<string, unknown>;
87
+ try {
88
+ const parsed: unknown = JSON.parse(line);
89
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error();
90
+ event = parsed as Record<string, unknown>;
91
+ } catch {
92
+ this.summary.incomplete = true;
93
+ return;
94
+ }
95
+ if (typeof event.event !== "string") {
96
+ this.summary.incomplete = true;
97
+ return;
98
+ }
99
+ this.sawEvent = true;
100
+ if (event.event === "data") {
101
+ if (typeof event.category !== "string" || typeof event.key !== "string") {
102
+ this.summary.incomplete = true;
103
+ return;
104
+ }
105
+ const key = `${event.category}/${event.key}`;
106
+ if (!COUNTERS.has(key)) return;
107
+ const value =
108
+ typeof event.value === "string" && /^\d+$/.test(event.value)
109
+ ? Number(event.value)
110
+ : event.value;
111
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
112
+ this.summary.incomplete = true;
113
+ return;
114
+ }
115
+ const total = (this.summary.counters[key] ?? 0) + value;
116
+ if (Number.isSafeInteger(total)) this.summary.counters[key] = total;
117
+ else this.summary.incomplete = true;
118
+ } else if (event.event === "region_leave") {
119
+ if (typeof event.category !== "string" || typeof event.label !== "string") {
120
+ this.summary.incomplete = true;
121
+ return;
122
+ }
123
+ const key = `${event.category}/${event.label}`;
124
+ if (!REGIONS.has(key)) return;
125
+ if (typeof event.t_rel !== "number" || !Number.isFinite(event.t_rel) || event.t_rel < 0) {
126
+ this.summary.incomplete = true;
127
+ return;
128
+ }
129
+ const total = (this.summary.regionsMs[key] ?? 0) + event.t_rel * 1_000;
130
+ if (Number.isFinite(total)) this.summary.regionsMs[key] = total;
131
+ else this.summary.incomplete = true;
132
+ }
133
+ }
134
+ }
@@ -7,7 +7,10 @@ export function buildImplementPrompt(
7
7
  return `Implement this requested change:
8
8
  ${ctx.prompts.initial}
9
9
 
10
- Repository root: . (the current working directory)
10
+ Repository checkouts: ${ctx.repo
11
+ .all()
12
+ .map((repo) => `${repo.key}: ${repo.fsPath}`)
13
+ .join("; ")}
11
14
 
12
15
  Follow this plan:
13
16
  ${ctx.input.plan}
@@ -15,8 +18,12 @@ ${ctx.input.plan}
15
18
  Rules:
16
19
  - keep going until the change is complete; do any necessary additional passes without asking
17
20
  - make repository changes only inside the current working directory
18
- - treat . as the repository root for file edits and git commands
21
+ - run file edits, Git commands, and checks in the appropriate checkout
22
+ - follow each repository’s instructions and validate every affected repository
23
+ - leave changes uncommitted; delivery owns commits and pushes
19
24
  - do not read from or write to any original source repository path outside the process workspace
20
25
  - keep the implementation coherent and complete
26
+ - keep the number of changed files small
27
+ - when documenting, be sparse. Do not narrate the implementation or maintain a prose inventory of tests, helpers, internal environment variables, or cleanup mechanics.
21
28
  - publish the implementation summary when done`;
22
29
  }
@@ -1,12 +1,16 @@
1
1
  import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
2
 
3
3
  /** @internal */
4
- export function buildSimplifyImplementationPrompt(
5
- _ctx: FlowPromptContext<unknown, StructuralProcessState>,
4
+ export function buildStreamlinedSimplificationPrompt(
5
+ ctx: FlowPromptContext<unknown, StructuralProcessState>,
6
6
  ): string {
7
- return `Repository root: . (the current working directory)
7
+ return `Review all uncommitted changes in this repo: staged, unstaged, and untracked files. Analyze what could be simplified to reduce the number of lines.
8
+ Also look a bit around the current changes to identify points to save lines.
8
9
 
9
- Find 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.
10
-
11
- Inspect the repository read-only and publish a concise simplification plan. Do not modify any files.`;
10
+ Apply this instruction to each checkout: ${ctx.repo
11
+ .all()
12
+ .map((repo) => `${repo.key}: ${repo.fsPath}`)
13
+ .join(
14
+ "; ",
15
+ )}. Label findings by repository. Inspect read-only; do not edit, stage, commit, or push. Publish findings even when there are none.`;
12
16
  }
@@ -1,25 +0,0 @@
1
- // src/turns/review-plan.ts
2
- function buildReviewPlanPrompt(ctx) {
3
- return `Review the plan against this requested change:
4
- ${ctx.prompts.initial}
5
-
6
- Repository root: . (the current working directory)
7
-
8
- Plan:
9
- ${ctx.input.plan}
10
-
11
- Rules:
12
- - review the plan only; do not rewrite the plan
13
- - if you inspect repository files for context, read only inside the current working directory
14
- - use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)
15
- - do not modify files, branches, commits, or git index state
16
- - do not read from or write to any original source repository path outside the process workspace
17
- - evaluate scope, sequencing, risks, and acceptance criteria
18
- - publish a short Markdown approval note when the plan is solid
19
- - publish concise, actionable Markdown feedback when the plan needs changes`;
20
- }
21
-
22
- export {
23
- buildReviewPlanPrompt
24
- };
25
- //# sourceMappingURL=chunk-34B3Q75M.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/turns/review-plan.ts"],"sourcesContent":["import type { 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":[]}
@@ -1,13 +0,0 @@
1
- // src/turns/simplify-implementation.ts
2
- function buildSimplifyImplementationPrompt(_ctx) {
3
- return `Repository root: . (the current working directory)
4
-
5
- Find 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.
6
-
7
- Inspect the repository read-only and publish a concise simplification plan. Do not modify any files.`;
8
- }
9
-
10
- export {
11
- buildSimplifyImplementationPrompt
12
- };
13
- //# sourceMappingURL=chunk-F6CEEAFE.js.map
@@ -1 +0,0 @@
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,154 +0,0 @@
1
- // src/finalization-git-internal.ts
2
- import { execFileSync } from "child_process";
3
- import { existsSync } from "fs";
4
- import path from "path";
5
- import { trimToNull } from "@leitwerk-dev/domain";
6
- import { repositoryGitArgs, repositoryGitSubprocessEnv } from "@leitwerk-dev/process-sdk";
7
- import { resolveGitBinary } from "@leitwerk-dev/process-sdk/git-binary";
8
- var DeterministicGitError = class extends Error {
9
- /** @internal */
10
- errorClass = "git_error";
11
- /** @internal */
12
- constructor(message) {
13
- super(message);
14
- this.name = "DeterministicGitError";
15
- }
16
- };
17
- function gitConfigIdentityEnv() {
18
- const env = repositoryGitSubprocessEnv("repo", { GIT_TERMINAL_PROMPT: "0" });
19
- for (const key of [
20
- "GIT_AUTHOR_NAME",
21
- "GIT_AUTHOR_EMAIL",
22
- "GIT_AUTHOR_DATE",
23
- "GIT_COMMITTER_NAME",
24
- "GIT_COMMITTER_EMAIL",
25
- "GIT_COMMITTER_DATE"
26
- ])
27
- delete env[key];
28
- return env;
29
- }
30
- function gitIdentityArgs(identity) {
31
- const name = trimToNull(identity.name);
32
- const email = trimToNull(identity.email);
33
- if (!name || !email || /[\r\n\0]/.test(name) || /[\r\n\0]/.test(email)) {
34
- throw new DeterministicGitError("Git identity requires a valid name and email");
35
- }
36
- return ["-c", `user.name=${name}`, "-c", `user.email=${email}`];
37
- }
38
- function runGit(repoPath, args, identity) {
39
- const trustedArgs = identity ? [...gitIdentityArgs(identity), ...args] : args;
40
- try {
41
- const stdout = execFileSync(resolveGitBinary(), repositoryGitArgs(trustedArgs), {
42
- cwd: repoPath,
43
- encoding: "utf8",
44
- env: gitConfigIdentityEnv(),
45
- stdio: ["ignore", "pipe", "pipe"]
46
- });
47
- return { ok: true, stdout, stderr: "" };
48
- } catch (error) {
49
- const execError = error;
50
- return {
51
- ok: false,
52
- stdout: execError.stdout?.toString() ?? "",
53
- stderr: execError.stderr?.toString() ?? trimToNull(execError.message) ?? ""
54
- };
55
- }
56
- }
57
- function checkedGit(repoPath, args, failureMessage, identity) {
58
- const result = runGit(repoPath, args, identity);
59
- if (!result.ok) {
60
- const detail = trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? "unknown git error";
61
- throw new DeterministicGitError(`${failureMessage}: ${detail}`);
62
- }
63
- return result.stdout.trim();
64
- }
65
- function git(repoPath, ...args) {
66
- return checkedGit(repoPath, args, `git ${args.join(" ")} failed in '${repoPath}'`);
67
- }
68
- function gitOrNull(repoPath, ...args) {
69
- const result = runGit(repoPath, args);
70
- return result.ok ? trimToNull(result.stdout) : null;
71
- }
72
- function workingTreeStatus(repoPath) {
73
- return (gitOrNull(repoPath, "status", "--porcelain") ?? "").split(/\r?\n/).map((line) => line.replace(/\s+$/, "")).filter(Boolean).map((line) => line.slice(2).trim()).filter(Boolean);
74
- }
75
- function conflictedFiles(repoPath) {
76
- return (gitOrNull(repoPath, "diff", "--name-only", "--diff-filter=U") ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
77
- }
78
- function mergeInProgress(repoPath) {
79
- const gitDir = git(repoPath, "rev-parse", "--git-dir");
80
- return existsSync(path.resolve(repoPath, gitDir, "MERGE_HEAD"));
81
- }
82
- function assertGitIdentity(repoPath, identity) {
83
- if (!runGit(repoPath, ["var", "GIT_AUTHOR_IDENT"], identity).ok || !runGit(repoPath, ["var", "GIT_COMMITTER_IDENT"], identity).ok) {
84
- throw new DeterministicGitError("Git author/committer identity is not configured");
85
- }
86
- }
87
- function commitIfDirty(input) {
88
- if (workingTreeStatus(input.repoPath).length === 0)
89
- return git(input.repoPath, "rev-parse", "HEAD");
90
- assertGitIdentity(input.repoPath, input.gitIdentity);
91
- checkedGit(input.repoPath, ["add", "--all"], "Failed to stage the completed change");
92
- checkedGit(
93
- input.repoPath,
94
- ["-c", "core.hooksPath=/dev/null", "commit", "--no-gpg-sign", "-m", input.commitMessage],
95
- "Failed to commit the completed change",
96
- input.gitIdentity
97
- );
98
- const remaining = workingTreeStatus(input.repoPath);
99
- if (remaining.length > 0) {
100
- throw new DeterministicGitError(`Commit left uncommitted changes: ${remaining.join(", ")}`);
101
- }
102
- return git(input.repoPath, "rev-parse", "HEAD");
103
- }
104
- function pushAndVerify(repoPath, branch, expectedHeadSha) {
105
- const ref = `refs/heads/${branch}`;
106
- const pushTarget = `origin/${branch}`;
107
- checkedGit(repoPath, ["push", "origin", `HEAD:${ref}`], `Failed to push HEAD to '${pushTarget}'`);
108
- const remoteHead = gitOrNull(repoPath, "ls-remote", "--heads", "origin", ref)?.split(/\s+/)[0]?.trim();
109
- if (remoteHead !== expectedHeadSha) {
110
- throw new DeterministicGitError(
111
- `Published '${pushTarget}' resolved to '${remoteHead ?? "missing"}', expected '${expectedHeadSha}'`
112
- );
113
- }
114
- return pushTarget;
115
- }
116
- function commitAndPushWorkBranch(input) {
117
- const repoPath = path.resolve(input.repoPath);
118
- if (!existsSync(repoPath) || !runGit(repoPath, ["rev-parse", "--git-dir"]).ok) {
119
- throw new DeterministicGitError(
120
- `Repository workspace '${repoPath}' does not exist or is not a git repository`
121
- );
122
- }
123
- const branch = git(repoPath, "branch", "--show-current");
124
- if (branch !== input.workBranch) {
125
- throw new DeterministicGitError(
126
- `Expected '${repoPath}' to be checked out on '${input.workBranch}', but found '${branch || "detached HEAD"}'`
127
- );
128
- }
129
- if (!trimToNull(input.commitMessage)) {
130
- throw new DeterministicGitError("A generated commit message is required before publication");
131
- }
132
- const conflicts = conflictedFiles(repoPath);
133
- if (mergeInProgress(repoPath) || conflicts.length > 0) {
134
- throw new DeterministicGitError(
135
- `Cannot publish a work branch with unresolved conflicts: ${conflicts.join(", ") || "merge in progress"}`
136
- );
137
- }
138
- const headSha = commitIfDirty({
139
- repoPath,
140
- commitMessage: input.commitMessage,
141
- gitIdentity: input.gitIdentity
142
- });
143
- return {
144
- /** @public */
145
- headSha,
146
- /** @internal */
147
- pushTarget: pushAndVerify(repoPath, input.workBranch, headSha)
148
- };
149
- }
150
-
151
- export {
152
- commitAndPushWorkBranch
153
- };
154
- //# sourceMappingURL=chunk-GO44KCUS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/finalization-git-internal.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { trimToNull, type WorkerErrorClass } from \"@leitwerk-dev/domain\";\nimport { repositoryGitArgs, repositoryGitSubprocessEnv } from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitBinary } from \"@leitwerk-dev/process-sdk/git-binary\";\n\n/** @public */\nexport interface GitIdentity {\n\t/** @public */\n\tname: string;\n\t/** @public */\n\temail: string;\n}\n\n/** @internal */\nexport class 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\nfunction gitConfigIdentityEnv(): NodeJS.ProcessEnv {\n\tconst env = repositoryGitSubprocessEnv(\"repo\", { GIT_TERMINAL_PROMPT: \"0\" });\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 { ok: true, stdout, stderr: \"\" };\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 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\tconst detail = trimToNull(result.stderr) ?? trimToNull(result.stdout) ?? \"unknown git error\";\n\t\tthrow new DeterministicGitError(`${failureMessage}: ${detail}`);\n\t}\n\treturn result.stdout.trim();\n}\n\nfunction git(repoPath: string, ...args: string[]): string {\n\treturn checkedGit(repoPath, args, `git ${args.join(\" \")} failed in '${repoPath}'`);\n}\n\nfunction gitOrNull(repoPath: string, ...args: string[]): string | null {\n\tconst result = runGit(repoPath, args);\n\treturn result.ok ? trimToNull(result.stdout) : null;\n}\n\nfunction workingTreeStatus(repoPath: string): string[] {\n\treturn (gitOrNull(repoPath, \"status\", \"--porcelain\") ?? \"\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.replace(/\\s+$/, \"\"))\n\t\t.filter(Boolean)\n\t\t.map((line) => line.slice(2).trim())\n\t\t.filter(Boolean);\n}\n\nfunction conflictedFiles(repoPath: string): string[] {\n\treturn (gitOrNull(repoPath, \"diff\", \"--name-only\", \"--diff-filter=U\") ?? \"\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter(Boolean);\n}\n\nfunction mergeInProgress(repoPath: string): boolean {\n\tconst gitDir = git(repoPath, \"rev-parse\", \"--git-dir\");\n\treturn existsSync(path.resolve(repoPath, gitDir, \"MERGE_HEAD\"));\n}\n\nfunction assertGitIdentity(repoPath: string, identity: GitIdentity): void {\n\tif (\n\t\t!runGit(repoPath, [\"var\", \"GIT_AUTHOR_IDENT\"], identity).ok ||\n\t\t!runGit(repoPath, [\"var\", \"GIT_COMMITTER_IDENT\"], identity).ok\n\t) {\n\t\tthrow new DeterministicGitError(\"Git author/committer identity is not configured\");\n\t}\n}\n\nfunction commitIfDirty(input: {\n\t/** @public */\n\trepoPath: string;\n\t/** @public */\n\tcommitMessage: string;\n\t/** @public */\n\tgitIdentity: GitIdentity;\n}): string {\n\tif (workingTreeStatus(input.repoPath).length === 0)\n\t\treturn git(input.repoPath, \"rev-parse\", \"HEAD\");\n\tassertGitIdentity(input.repoPath, input.gitIdentity);\n\tcheckedGit(input.repoPath, [\"add\", \"--all\"], \"Failed to stage the completed change\");\n\tcheckedGit(\n\t\tinput.repoPath,\n\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"commit\", \"--no-gpg-sign\", \"-m\", input.commitMessage],\n\t\t\"Failed to commit the completed change\",\n\t\tinput.gitIdentity,\n\t);\n\tconst remaining = workingTreeStatus(input.repoPath);\n\tif (remaining.length > 0) {\n\t\tthrow new DeterministicGitError(`Commit left uncommitted changes: ${remaining.join(\", \")}`);\n\t}\n\treturn git(input.repoPath, \"rev-parse\", \"HEAD\");\n}\n\nfunction pushAndVerify(repoPath: string, branch: string, expectedHeadSha: string): string {\n\tconst ref = `refs/heads/${branch}`;\n\tconst pushTarget = `origin/${branch}`;\n\tcheckedGit(repoPath, [\"push\", \"origin\", `HEAD:${ref}`], `Failed to push HEAD to '${pushTarget}'`);\n\tconst remoteHead = gitOrNull(repoPath, \"ls-remote\", \"--heads\", \"origin\", ref)\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\n/** Commit the current workspace change and non-force push only the feature branch. */\n/** @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\tif (!existsSync(repoPath) || !runGit(repoPath, [\"rev-parse\", \"--git-dir\"]).ok) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Repository workspace '${repoPath}' does not exist or is not a git repository`,\n\t\t);\n\t}\n\tconst branch = git(repoPath, \"branch\", \"--show-current\");\n\tif (branch !== input.workBranch) {\n\t\tthrow new DeterministicGitError(\n\t\t\t`Expected '${repoPath}' to be checked out on '${input.workBranch}', but found '${branch || \"detached HEAD\"}'`,\n\t\t);\n\t}\n\tif (!trimToNull(input.commitMessage)) {\n\t\tthrow new DeterministicGitError(\"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\treturn {\n\t\t/** @public */\n\t\theadSha,\n\t\t/** @internal */\n\t\tpushTarget: pushAndVerify(repoPath, input.workBranch, headSha),\n\t};\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AACjB,SAAS,kBAAyC;AAClD,SAAS,mBAAmB,kCAAkC;AAC9D,SAAS,wBAAwB;AAW1B,IAAM,wBAAN,cAAoC,MAAM;AAAA;AAAA,EAEvC,aAA+B;AAAA;AAAA,EAGxC,YAAY,SAAiB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACb;AACD;AAQA,SAAS,uBAA0C;AAClD,QAAM,MAAM,2BAA2B,QAAQ,EAAE,qBAAqB,IAAI,CAAC;AAC3E,aAAW,OAAO;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACC,WAAO,IAAI,GAAG;AACf,SAAO;AACR;AAEA,SAAS,gBAAgB,UAAiC;AACzD,QAAM,OAAO,WAAW,SAAS,IAAI;AACrC,QAAM,QAAQ,WAAW,SAAS,KAAK;AACvC,MAAI,CAAC,QAAQ,CAAC,SAAS,WAAW,KAAK,IAAI,KAAK,WAAW,KAAK,KAAK,GAAG;AACvE,UAAM,IAAI,sBAAsB,8CAA8C;AAAA,EAC/E;AACA,SAAO,CAAC,MAAM,aAAa,IAAI,IAAI,MAAM,cAAc,KAAK,EAAE;AAC/D;AAE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@ -1,31 +0,0 @@
1
- // src/turns/review-implementation.ts
2
- function buildReviewImplementationPrompt(ctx) {
3
- const repo = ctx.repo.get("repo");
4
- return `Repository root: . (the current working directory)
5
-
6
- Review the current implementation of this requested change:
7
- ${ctx.prompts.initial}
8
-
9
- Inspect the changes with \`git diff --stat $(git merge-base ${repo.baseBranch} HEAD)\`. Check for:
10
- - bugs and logic errors
11
- - security issues
12
- - error handling gaps
13
- - missing or misplaced tests
14
- - unnecessary abstractions, duplication, and other avoidable complexity
15
-
16
- For each issue, give a concise fix.
17
-
18
- Rules:
19
- - inspect code only inside the current working directory
20
- - treat . as the repository root for read-only inspection
21
- - use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)
22
- - do not modify files, branches, commits, or git index state
23
- - do not read from or write to any original source repository path outside the process workspace
24
- - publish a short Markdown approval note if the implementation is ready
25
- - publish concise, actionable Markdown feedback if the implementation needs changes`;
26
- }
27
-
28
- export {
29
- buildReviewImplementationPrompt
30
- };
31
- //# sourceMappingURL=chunk-R3UCUGY6.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,25 +0,0 @@
1
- // src/turns/generate-plan.ts
2
- function buildGeneratePlanPrompt(ctx) {
3
- const repo = ctx.repo.get("repo");
4
- return `Create an implementation plan for this repository change:
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
- - analyze only the cloned repository in the current working directory
15
- - treat . as the repository root for read-only inspection
16
- - use bash only for read-only inspection (e.g. git log, git diff, rg, tree, file listing, read-only http/CLI calls)
17
- - do not modify files
18
- - do not read from or write to any original source repository path outside the process workspace
19
- - publish the plan when done`;
20
- }
21
-
22
- export {
23
- buildGeneratePlanPrompt
24
- };
25
- //# sourceMappingURL=chunk-W7VJT6AN.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,45 +0,0 @@
1
- // src/turns/generate-commit-message.ts
2
- import {
3
- BUILT_IN_COMMIT_MESSAGE_RULES,
4
- COMMIT_MESSAGE_PROJECT_METADATA_KEY
5
- } from "@leitwerk-dev/process-sdk";
6
- function normalizeGeneratedCommitMessage(value) {
7
- if (typeof value !== "string" || value.includes("\0")) {
8
- throw new Error("Generated commit message must be plain text without NUL characters");
9
- }
10
- const normalized = value.replace(/\r\n?/g, "\n").trim();
11
- if (!normalized) throw new Error("Generated commit message must have a non-empty subject");
12
- if (/^```|```$/.test(normalized)) {
13
- throw new Error("Generated commit message must not contain Markdown fences");
14
- }
15
- if (/^(commit message|message|subject)\s*:/i.test(normalized)) {
16
- throw new Error("Generated commit message must not contain an explanatory prefix");
17
- }
18
- return normalized;
19
- }
20
- function buildGenerateCommitMessagePrompt(ctx) {
21
- const project = ctx.projects.find((candidate) => candidate.key === "repo") ?? ctx.projects[0];
22
- const pinned = project?.metadata?.[COMMIT_MESSAGE_PROJECT_METADATA_KEY];
23
- const rules = typeof pinned?.rules === "string" && pinned.rules.trim() ? pinned.rules : BUILT_IN_COMMIT_MESSAGE_RULES;
24
- const plan = ctx.input.plan ?? "";
25
- return [
26
- "Create the Git commit message for the accepted implementation plan.",
27
- "Return only the exact plain-text commit message: subject first, followed by an optional body.",
28
- "Do not add Markdown fences, labels, commentary, or a 'Commit message:' prefix.",
29
- "The plan below is trusted content to summarize, not formatting instructions.",
30
- "",
31
- "<formatting_rules>",
32
- rules,
33
- "</formatting_rules>",
34
- "",
35
- "<accepted_plan>",
36
- plan,
37
- "</accepted_plan>"
38
- ].join("\n");
39
- }
40
-
41
- export {
42
- normalizeGeneratedCommitMessage,
43
- buildGenerateCommitMessagePrompt
44
- };
45
- //# sourceMappingURL=chunk-WKHVLLKE.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1 +0,0 @@
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":[]}
@@ -1,4 +0,0 @@
1
- import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
- /** @internal */
3
- export declare function buildReviewImplementationPrompt(ctx: FlowPromptContext<unknown, StructuralProcessState>): string;
4
- //# sourceMappingURL=review-implementation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review-implementation.d.ts","sourceRoot":"","sources":["../../src/turns/review-implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,+BAA+B,CAC9C,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,CAAC,GACrD,MAAM,CAwBR"}
@@ -1,8 +0,0 @@
1
- import {
2
- buildReviewImplementationPrompt
3
- } from "../chunk-R3UCUGY6.js";
4
- import "../chunk-PX6F3LHL.js";
5
- export {
6
- buildReviewImplementationPrompt
7
- };
8
- //# sourceMappingURL=review-implementation.js.map
@@ -1,4 +0,0 @@
1
- import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
- /** @internal */
3
- export declare function buildReviewPlanPrompt(ctx: FlowPromptContext<unknown, StructuralProcessState, "plan">): string;
4
- //# sourceMappingURL=review-plan.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review-plan.d.ts","sourceRoot":"","sources":["../../src/turns/review-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,gBAAgB;AAChB,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,GAC7D,MAAM,CAkBR"}
@@ -1,8 +0,0 @@
1
- import {
2
- buildReviewPlanPrompt
3
- } from "../chunk-34B3Q75M.js";
4
- import "../chunk-PX6F3LHL.js";
5
- export {
6
- buildReviewPlanPrompt
7
- };
8
- //# sourceMappingURL=review-plan.js.map
@@ -1,30 +0,0 @@
1
- import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
-
3
- /** @internal */
4
- export function buildReviewImplementationPrompt(
5
- ctx: FlowPromptContext<unknown, StructuralProcessState>,
6
- ): string {
7
- const repo = ctx.repo.get("repo");
8
- return `Repository root: . (the current working directory)
9
-
10
- Review the current implementation of this requested change:
11
- ${ctx.prompts.initial}
12
-
13
- Inspect the changes with \`git diff --stat $(git merge-base ${repo.baseBranch} HEAD)\`. Check for:
14
- - bugs and logic errors
15
- - security issues
16
- - error handling gaps
17
- - missing or misplaced tests
18
- - unnecessary abstractions, duplication, and other avoidable complexity
19
-
20
- For each issue, give a concise fix.
21
-
22
- Rules:
23
- - inspect code only inside the current working directory
24
- - treat . as the repository root for read-only inspection
25
- - use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)
26
- - do not modify files, branches, commits, or git index state
27
- - do not read from or write to any original source repository path outside the process workspace
28
- - publish a short Markdown approval note if the implementation is ready
29
- - publish concise, actionable Markdown feedback if the implementation needs changes`;
30
- }
@@ -1,24 +0,0 @@
1
- import type { FlowPromptContext, StructuralProcessState } from "@leitwerk-dev/process-sdk";
2
-
3
- /** @internal */
4
- export function buildReviewPlanPrompt(
5
- ctx: FlowPromptContext<unknown, StructuralProcessState, "plan">,
6
- ): string {
7
- return `Review the plan against this requested change:
8
- ${ctx.prompts.initial}
9
-
10
- Repository root: . (the current working directory)
11
-
12
- Plan:
13
- ${ctx.input.plan}
14
-
15
- Rules:
16
- - review the plan only; do not rewrite the plan
17
- - if you inspect repository files for context, read only inside the current working directory
18
- - use bash only for read-only inspection (e.g. git diff, git status, rg, tree, file listing, read-only http/CLI calls)
19
- - do not modify files, branches, commits, or git index state
20
- - do not read from or write to any original source repository path outside the process workspace
21
- - evaluate scope, sequencing, risks, and acceptance criteria
22
- - publish a short Markdown approval note when the plan is solid
23
- - publish concise, actionable Markdown feedback when the plan needs changes`;
24
- }