@leitwerk-dev/coding 0.3.1 → 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 (108) hide show
  1. package/README.md +86 -1
  2. package/dist/chunk-ABQH2WZT.js +36 -0
  3. package/dist/chunk-ABQH2WZT.js.map +1 -0
  4. package/dist/{chunk-YSC5GEQJ.js → chunk-BI45R2FH.js} +7 -3
  5. package/dist/chunk-BI45R2FH.js.map +1 -0
  6. package/dist/chunk-DNG7D77K.js +65 -0
  7. package/dist/chunk-DNG7D77K.js.map +1 -0
  8. package/dist/chunk-L2TFD72B.js +16320 -0
  9. package/dist/chunk-L2TFD72B.js.map +1 -0
  10. package/dist/chunk-M2VTUPFO.js +265 -0
  11. package/dist/chunk-M2VTUPFO.js.map +1 -0
  12. package/dist/chunk-OM2AMDTJ.js +347 -0
  13. package/dist/chunk-OM2AMDTJ.js.map +1 -0
  14. package/dist/chunk-Q24RPXOA.js +159 -0
  15. package/dist/chunk-Q24RPXOA.js.map +1 -0
  16. package/dist/chunk-SKGB4CZS.js +14 -0
  17. package/dist/chunk-SKGB4CZS.js.map +1 -0
  18. package/dist/chunk-SZ4WOGV2.js +120 -0
  19. package/dist/chunk-SZ4WOGV2.js.map +1 -0
  20. package/dist/finalization-git-internal.d.ts +3 -0
  21. package/dist/finalization-git-internal.d.ts.map +1 -1
  22. package/dist/finalization-git.d.ts +1 -1
  23. package/dist/finalization-git.d.ts.map +1 -1
  24. package/dist/finalization-git.js +5 -3
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +17 -591
  28. package/dist/index.js.map +1 -1
  29. package/dist/pull-request-publication-internal.d.ts +26 -24
  30. package/dist/pull-request-publication-internal.d.ts.map +1 -1
  31. package/dist/repository-change-launch-internal-BudnAfL7.d.ts +88 -0
  32. package/dist/repository-change-launch-internal.d.ts +32 -11
  33. package/dist/repository-change-launch-internal.d.ts.map +1 -1
  34. package/dist/repository-change-launch.d.ts +4 -3
  35. package/dist/repository-change-launch.d.ts.map +1 -1
  36. package/dist/repository-change-launch.js +162 -34
  37. package/dist/repository-change-launch.js.map +1 -1
  38. package/dist/repository-change-process-DlgF04fU.d.ts +69 -0
  39. package/dist/repository-change-process.d.ts +30 -25
  40. package/dist/repository-change-process.d.ts.map +1 -1
  41. package/dist/repository-change-publication.d.ts +62 -6
  42. package/dist/repository-change-publication.d.ts.map +1 -1
  43. package/dist/repository-change-publication.js +364 -90
  44. package/dist/repository-change-publication.js.map +1 -1
  45. package/dist/repository-change-state-internal.d.ts +18 -4
  46. package/dist/repository-change-state-internal.d.ts.map +1 -1
  47. package/dist/repository-change-ui-launcher-internal.d.ts +34 -22
  48. package/dist/repository-change-ui-launcher-internal.d.ts.map +1 -1
  49. package/dist/settings.d.ts +15 -0
  50. package/dist/settings.d.ts.map +1 -0
  51. package/dist/turns/commit-message-evidence.d.ts +35 -0
  52. package/dist/turns/commit-message-evidence.d.ts.map +1 -0
  53. package/dist/turns/commit-message-evidence.js +9 -0
  54. package/dist/turns/generate-commit-message.d.ts +4 -1
  55. package/dist/turns/generate-commit-message.d.ts.map +1 -1
  56. package/dist/turns/generate-commit-message.js +7 -5
  57. package/dist/turns/generate-plan.d.ts.map +1 -1
  58. package/dist/turns/generate-plan.js +1 -1
  59. package/dist/turns/git-inspection-profile.d.ts +25 -0
  60. package/dist/turns/git-inspection-profile.d.ts.map +1 -0
  61. package/dist/turns/git-inspection-profile.js +8 -0
  62. package/dist/turns/implement.d.ts.map +1 -1
  63. package/dist/turns/implement.js +1 -1
  64. package/dist/turns/simplify-implementation.d.ts +1 -1
  65. package/dist/turns/simplify-implementation.d.ts.map +1 -1
  66. package/dist/turns/simplify-implementation.js +3 -3
  67. package/package.json +5 -9
  68. package/src/finalization-git-internal.ts +117 -114
  69. package/src/finalization-git.ts +1 -1
  70. package/src/index.ts +4 -1
  71. package/src/pull-request-publication-internal.ts +156 -78
  72. package/src/repository-change-launch-internal.ts +119 -12
  73. package/src/repository-change-launch.ts +8 -4
  74. package/src/repository-change-process.ts +234 -523
  75. package/src/repository-change-publication.ts +516 -121
  76. package/src/repository-change-state-internal.ts +34 -20
  77. package/src/repository-change-ui-launcher-internal.ts +139 -56
  78. package/src/settings.ts +79 -0
  79. package/src/turns/commit-message-evidence.ts +241 -0
  80. package/src/turns/generate-commit-message.ts +53 -23
  81. package/src/turns/generate-plan.ts +26 -12
  82. package/src/turns/git-inspection-profile.ts +134 -0
  83. package/src/turns/implement.ts +9 -2
  84. package/src/turns/simplify-implementation.ts +10 -6
  85. package/dist/chunk-34B3Q75M.js +0 -25
  86. package/dist/chunk-34B3Q75M.js.map +0 -1
  87. package/dist/chunk-F6CEEAFE.js +0 -13
  88. package/dist/chunk-F6CEEAFE.js.map +0 -1
  89. package/dist/chunk-GO44KCUS.js +0 -154
  90. package/dist/chunk-GO44KCUS.js.map +0 -1
  91. package/dist/chunk-R3UCUGY6.js +0 -31
  92. package/dist/chunk-R3UCUGY6.js.map +0 -1
  93. package/dist/chunk-W7VJT6AN.js +0 -25
  94. package/dist/chunk-W7VJT6AN.js.map +0 -1
  95. package/dist/chunk-WKHVLLKE.js +0 -45
  96. package/dist/chunk-WKHVLLKE.js.map +0 -1
  97. package/dist/chunk-YSC5GEQJ.js.map +0 -1
  98. package/dist/repository-change-launch-internal-Dd-AONUs.d.ts +0 -67
  99. package/dist/turns/review-implementation.d.ts +0 -4
  100. package/dist/turns/review-implementation.d.ts.map +0 -1
  101. package/dist/turns/review-implementation.js +0 -8
  102. package/dist/turns/review-plan.d.ts +0 -4
  103. package/dist/turns/review-plan.d.ts.map +0 -1
  104. package/dist/turns/review-plan.js +0 -8
  105. package/src/turns/review-implementation.ts +0 -30
  106. package/src/turns/review-plan.ts +0 -24
  107. /package/dist/turns/{review-implementation.js.map → commit-message-evidence.js.map} +0 -0
  108. /package/dist/turns/{review-plan.js.map → git-inspection-profile.js.map} +0 -0
@@ -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,67 +0,0 @@
1
- import { Codec } from '@leitwerk-dev/process-sdk';
2
-
3
- /** @public */
4
- interface RepositoryChangeParamsBase {
5
- /** @public */
6
- repoLocator: string;
7
- /** @public */
8
- baseBranch: string;
9
- /** @public */
10
- workBranch: string;
11
- /** @public */
12
- prompt: string;
13
- }
14
- /** @public */
15
- type RepositoryChangeLaunchParams<TExtra extends object = Record<never, never>> = TExtra & RepositoryChangeParamsBase;
16
- /** Shared source metadata; provider-specific interfaces retain their exported names. @public */
17
- interface RepositoryIssueOriginParams {
18
- /** @public */
19
- origin: "issue";
20
- /** @public */
21
- issueNumber: number;
22
- /** @public */
23
- issueUrl: string;
24
- /** @public */
25
- triggerLabel: string;
26
- /** @public */
27
- doneLabel: string;
28
- }
29
- /** @public */
30
- interface RepositoryUiOriginParams {
31
- /** @public */
32
- origin: "ui";
33
- /** @public */
34
- issueNumber: null;
35
- /** @public */
36
- issueUrl: null;
37
- /** @public */
38
- triggerLabel: null;
39
- /** @public */
40
- doneLabel: null;
41
- }
42
- /** GitHub/Forgejo legacy origins default to issue; other providers may be stricter. @internal */
43
- declare function normalizeRepositoryIssueOrigin(record: Record<string, unknown>, displayName: string, text: (name: string) => string): RepositoryIssueOriginParams | RepositoryUiOriginParams;
44
- /** @public */
45
- interface NormalizedRepositoryChangeParamsInput {
46
- /** @internal */
47
- repoLocator: string;
48
- /** @internal */
49
- baseBranch: string;
50
- /** @internal */
51
- workBranch: string;
52
- /** @internal */
53
- prompt: string;
54
- }
55
- /** @public */
56
- declare function repositoryChangeParamsRecord(value: unknown, displayName: string): Record<string, unknown>;
57
- /** @public */
58
- declare function normalizeRepositoryChangeParamsInput(value: unknown, displayName: string): NormalizedRepositoryChangeParamsInput;
59
- /** Normalize issue-capable repository params with provider-owned required text fields. @internal */
60
- declare function normalizeRepositoryIssueChangeParams<K extends string>(value: unknown, displayName: string, fields: readonly K[]): NormalizedRepositoryChangeParamsInput & Record<K, string> & (RepositoryIssueOriginParams | RepositoryUiOriginParams);
61
- /** @public */
62
- declare function createRepositoryChangeParamsCodec<T extends RepositoryChangeParamsBase>(input: {
63
- /** @public */
64
- normalize(value: unknown): T;
65
- }): Codec<T>;
66
-
67
- export { type NormalizedRepositoryChangeParamsInput as N, type RepositoryChangeLaunchParams as R, type RepositoryChangeParamsBase as a, type RepositoryIssueOriginParams as b, type RepositoryUiOriginParams as c, createRepositoryChangeParamsCodec as d, normalizeRepositoryIssueChangeParams as e, normalizeRepositoryIssueOrigin as f, normalizeRepositoryChangeParamsInput as n, repositoryChangeParamsRecord as r };
@@ -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
- }