codekin 0.5.4 → 0.6.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 (88) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/index-BvKzbtKg.css +1 -0
  3. package/dist/assets/index-D59Xr9pK.js +182 -0
  4. package/dist/index.html +2 -2
  5. package/package.json +1 -1
  6. package/server/dist/approval-manager.js +2 -3
  7. package/server/dist/approval-manager.js.map +1 -1
  8. package/server/dist/claude-process.d.ts +17 -5
  9. package/server/dist/claude-process.js +56 -66
  10. package/server/dist/claude-process.js.map +1 -1
  11. package/server/dist/coding-process.d.ts +83 -0
  12. package/server/dist/coding-process.js +32 -0
  13. package/server/dist/coding-process.js.map +1 -0
  14. package/server/dist/commit-event-handler.js +1 -0
  15. package/server/dist/commit-event-handler.js.map +1 -1
  16. package/server/dist/config.js +2 -1
  17. package/server/dist/config.js.map +1 -1
  18. package/server/dist/docs-routes.js +22 -1
  19. package/server/dist/docs-routes.js.map +1 -1
  20. package/server/dist/native-permissions.js +3 -2
  21. package/server/dist/native-permissions.js.map +1 -1
  22. package/server/dist/opencode-process.d.ts +104 -0
  23. package/server/dist/opencode-process.js +657 -0
  24. package/server/dist/opencode-process.js.map +1 -0
  25. package/server/dist/orchestrator-children.d.ts +9 -0
  26. package/server/dist/orchestrator-children.js +50 -7
  27. package/server/dist/orchestrator-children.js.map +1 -1
  28. package/server/dist/orchestrator-manager.js +17 -0
  29. package/server/dist/orchestrator-manager.js.map +1 -1
  30. package/server/dist/orchestrator-reports.d.ts +0 -4
  31. package/server/dist/orchestrator-reports.js +6 -12
  32. package/server/dist/orchestrator-reports.js.map +1 -1
  33. package/server/dist/orchestrator-routes.js +8 -1
  34. package/server/dist/orchestrator-routes.js.map +1 -1
  35. package/server/dist/prompt-router.d.ts +95 -0
  36. package/server/dist/prompt-router.js +589 -0
  37. package/server/dist/prompt-router.js.map +1 -0
  38. package/server/dist/session-lifecycle.d.ts +73 -0
  39. package/server/dist/session-lifecycle.js +408 -0
  40. package/server/dist/session-lifecycle.js.map +1 -0
  41. package/server/dist/session-manager.d.ts +42 -60
  42. package/server/dist/session-manager.js +310 -835
  43. package/server/dist/session-manager.js.map +1 -1
  44. package/server/dist/session-persistence.d.ts +1 -0
  45. package/server/dist/session-persistence.js +24 -4
  46. package/server/dist/session-persistence.js.map +1 -1
  47. package/server/dist/session-routes.js +15 -1
  48. package/server/dist/session-routes.js.map +1 -1
  49. package/server/dist/stepflow-handler.d.ts +2 -2
  50. package/server/dist/stepflow-handler.js +4 -4
  51. package/server/dist/stepflow-handler.js.map +1 -1
  52. package/server/dist/tool-labels.d.ts +8 -0
  53. package/server/dist/tool-labels.js +51 -0
  54. package/server/dist/tool-labels.js.map +1 -0
  55. package/server/dist/tsconfig.tsbuildinfo +1 -1
  56. package/server/dist/types.d.ts +27 -8
  57. package/server/dist/types.js +4 -1
  58. package/server/dist/types.js.map +1 -1
  59. package/server/dist/webhook-dedup.d.ts +11 -0
  60. package/server/dist/webhook-dedup.js +23 -0
  61. package/server/dist/webhook-dedup.js.map +1 -1
  62. package/server/dist/webhook-handler.d.ts +20 -4
  63. package/server/dist/webhook-handler.js +256 -20
  64. package/server/dist/webhook-handler.js.map +1 -1
  65. package/server/dist/webhook-pr-cache.d.ts +57 -0
  66. package/server/dist/webhook-pr-cache.js +95 -0
  67. package/server/dist/webhook-pr-cache.js.map +1 -0
  68. package/server/dist/webhook-pr-github.d.ts +68 -0
  69. package/server/dist/webhook-pr-github.js +202 -0
  70. package/server/dist/webhook-pr-github.js.map +1 -0
  71. package/server/dist/webhook-pr-prompt.d.ts +27 -0
  72. package/server/dist/webhook-pr-prompt.js +251 -0
  73. package/server/dist/webhook-pr-prompt.js.map +1 -0
  74. package/server/dist/webhook-types.d.ts +70 -1
  75. package/server/dist/webhook-workspace.js +20 -1
  76. package/server/dist/webhook-workspace.js.map +1 -1
  77. package/server/dist/workflow-config.d.ts +2 -0
  78. package/server/dist/workflow-config.js.map +1 -1
  79. package/server/dist/workflow-loader.js +3 -0
  80. package/server/dist/workflow-loader.js.map +1 -1
  81. package/server/dist/workflow-routes.js +6 -2
  82. package/server/dist/workflow-routes.js.map +1 -1
  83. package/server/dist/ws-message-handler.js +24 -4
  84. package/server/dist/ws-message-handler.js.map +1 -1
  85. package/server/dist/ws-server.js +10 -2
  86. package/server/dist/ws-server.js.map +1 -1
  87. package/dist/assets/index-COGLICp9.js +0 -178
  88. package/dist/assets/index-CjEQkT2b.css +0 -1
@@ -0,0 +1,68 @@
1
+ /**
2
+ * GitHub API helpers for pull request webhook processing.
3
+ *
4
+ * All functions delegate to the `gh` CLI and degrade gracefully — errors are
5
+ * logged as warnings and an empty result is returned so callers can proceed
6
+ * with partial data.
7
+ */
8
+ type GhRunner = (args: string[]) => Promise<string>;
9
+ /** @internal Test-only: override the gh CLI runner */
10
+ export declare function _setGhRunner(runner: GhRunner): void;
11
+ /** @internal Test-only: reset to default gh CLI runner */
12
+ export declare function _resetGhRunner(): void;
13
+ /**
14
+ * Fetch the unified diff for a pull request.
15
+ * Truncates to ~100KB with a note if larger.
16
+ *
17
+ * @param repo - GitHub repo in `owner/name` format.
18
+ * @param prNumber - Pull request number.
19
+ * @returns The diff text, or empty string on error.
20
+ */
21
+ export declare function fetchPrDiff(repo: string, prNumber: number): Promise<{
22
+ diff: string;
23
+ truncated: boolean;
24
+ }>;
25
+ /**
26
+ * Fetch the list of changed files for a pull request with stats.
27
+ *
28
+ * @param repo - GitHub repo in `owner/name` format.
29
+ * @param prNumber - Pull request number.
30
+ * @returns Formatted file list, or empty string on error.
31
+ */
32
+ export declare function fetchPrFiles(repo: string, prNumber: number): Promise<string>;
33
+ /**
34
+ * Fetch commit messages for a pull request.
35
+ *
36
+ * @param repo - GitHub repo in `owner/name` format.
37
+ * @param prNumber - Pull request number.
38
+ * @returns Formatted commit list, or empty string on error.
39
+ */
40
+ /**
41
+ * Fetch existing review comments (inline code comments) for a pull request.
42
+ *
43
+ * @param repo - GitHub repo in `owner/name` format.
44
+ * @param prNumber - Pull request number.
45
+ * @returns Formatted comment list, or empty string on error.
46
+ */
47
+ export declare function fetchPrReviewComments(repo: string, prNumber: number): Promise<string>;
48
+ /**
49
+ * Fetch review summaries (approve/request changes/comment) for a pull request.
50
+ *
51
+ * @param repo - GitHub repo in `owner/name` format.
52
+ * @param prNumber - Pull request number.
53
+ * @returns Formatted review list, or empty string on error.
54
+ */
55
+ export declare function fetchPrReviews(repo: string, prNumber: number): Promise<string>;
56
+ /** HTML marker embedded in Codekin review comments for identification. */
57
+ export declare const REVIEW_COMMENT_MARKER = "<!-- codekin-review -->";
58
+ /**
59
+ * Find an existing Codekin review summary comment on a PR.
60
+ * Searches issue comments (top-level conversation comments) for the marker.
61
+ *
62
+ * @param repo - GitHub repo in `owner/name` format.
63
+ * @param prNumber - Pull request number.
64
+ * @returns The comment ID if found, or undefined.
65
+ */
66
+ export declare function fetchExistingReviewComment(repo: string, prNumber: number): Promise<number | undefined>;
67
+ export declare function fetchPrCommits(repo: string, prNumber: number): Promise<string>;
68
+ export {};
@@ -0,0 +1,202 @@
1
+ /**
2
+ * GitHub API helpers for pull request webhook processing.
3
+ *
4
+ * All functions delegate to the `gh` CLI and degrade gracefully — errors are
5
+ * logged as warnings and an empty result is returned so callers can proceed
6
+ * with partial data.
7
+ */
8
+ import { execFile } from 'child_process';
9
+ import { promisify } from 'util';
10
+ const execFileAsync = promisify(execFile);
11
+ const GH_TIMEOUT_MS = 30_000;
12
+ /** Maximum diff size in bytes before truncation (~100KB). */
13
+ const MAX_DIFF_BYTES = 100_000;
14
+ let ghRunner = async (args) => {
15
+ const { stdout } = await execFileAsync('gh', args, { timeout: GH_TIMEOUT_MS });
16
+ return stdout;
17
+ };
18
+ /** @internal Test-only: override the gh CLI runner */
19
+ export function _setGhRunner(runner) {
20
+ ghRunner = runner;
21
+ }
22
+ /** @internal Test-only: reset to default gh CLI runner */
23
+ export function _resetGhRunner() {
24
+ ghRunner = async (args) => {
25
+ const { stdout } = await execFileAsync('gh', args, { timeout: GH_TIMEOUT_MS });
26
+ return stdout;
27
+ };
28
+ }
29
+ /**
30
+ * Fetch the unified diff for a pull request.
31
+ * Truncates to ~100KB with a note if larger.
32
+ *
33
+ * @param repo - GitHub repo in `owner/name` format.
34
+ * @param prNumber - Pull request number.
35
+ * @returns The diff text, or empty string on error.
36
+ */
37
+ export async function fetchPrDiff(repo, prNumber) {
38
+ try {
39
+ const output = await ghRunner([
40
+ 'api',
41
+ `/repos/${repo}/pulls/${prNumber}`,
42
+ '-H', 'Accept: application/vnd.github.diff',
43
+ ]);
44
+ if (output.length > MAX_DIFF_BYTES) {
45
+ const truncated = output.slice(0, MAX_DIFF_BYTES);
46
+ // Cut at last newline to avoid splitting a line
47
+ const lastNewline = truncated.lastIndexOf('\n');
48
+ return {
49
+ diff: (lastNewline > 0 ? truncated.slice(0, lastNewline) : truncated) +
50
+ `\n\n... (diff truncated — full diff is ${Math.round(output.length / 1024)}KB, showing first ~${Math.round(MAX_DIFF_BYTES / 1024)}KB)`,
51
+ truncated: true,
52
+ };
53
+ }
54
+ return { diff: output, truncated: false };
55
+ }
56
+ catch (err) {
57
+ console.warn(`fetchPrDiff: failed for ${repo} PR #${prNumber}:`, err);
58
+ return { diff: '', truncated: false };
59
+ }
60
+ }
61
+ /**
62
+ * Fetch the list of changed files for a pull request with stats.
63
+ *
64
+ * @param repo - GitHub repo in `owner/name` format.
65
+ * @param prNumber - Pull request number.
66
+ * @returns Formatted file list, or empty string on error.
67
+ */
68
+ export async function fetchPrFiles(repo, prNumber) {
69
+ try {
70
+ const raw = await ghRunner([
71
+ 'api',
72
+ `/repos/${repo}/pulls/${prNumber}/files`,
73
+ '--paginate',
74
+ ]);
75
+ const files = JSON.parse(raw);
76
+ if (!Array.isArray(files) || files.length === 0)
77
+ return '';
78
+ return files
79
+ .map(f => `${f.filename} (${f.status}, +${f.additions}/-${f.deletions})`)
80
+ .join('\n');
81
+ }
82
+ catch (err) {
83
+ console.warn(`fetchPrFiles: failed for ${repo} PR #${prNumber}:`, err);
84
+ return '';
85
+ }
86
+ }
87
+ /**
88
+ * Fetch commit messages for a pull request.
89
+ *
90
+ * @param repo - GitHub repo in `owner/name` format.
91
+ * @param prNumber - Pull request number.
92
+ * @returns Formatted commit list, or empty string on error.
93
+ */
94
+ /**
95
+ * Fetch existing review comments (inline code comments) for a pull request.
96
+ *
97
+ * @param repo - GitHub repo in `owner/name` format.
98
+ * @param prNumber - Pull request number.
99
+ * @returns Formatted comment list, or empty string on error.
100
+ */
101
+ export async function fetchPrReviewComments(repo, prNumber) {
102
+ try {
103
+ const raw = await ghRunner([
104
+ 'api',
105
+ `/repos/${repo}/pulls/${prNumber}/comments`,
106
+ '--paginate',
107
+ ]);
108
+ const comments = JSON.parse(raw);
109
+ if (!Array.isArray(comments) || comments.length === 0)
110
+ return '';
111
+ return comments
112
+ .map(c => {
113
+ const location = c.line ? `${c.path}:${c.line}` : c.path;
114
+ return `- ${c.user.login} on ${location}: ${c.body}`;
115
+ })
116
+ .join('\n');
117
+ }
118
+ catch (err) {
119
+ console.warn(`fetchPrReviewComments: failed for ${repo} PR #${prNumber}:`, err);
120
+ return '';
121
+ }
122
+ }
123
+ /**
124
+ * Fetch review summaries (approve/request changes/comment) for a pull request.
125
+ *
126
+ * @param repo - GitHub repo in `owner/name` format.
127
+ * @param prNumber - Pull request number.
128
+ * @returns Formatted review list, or empty string on error.
129
+ */
130
+ export async function fetchPrReviews(repo, prNumber) {
131
+ try {
132
+ const raw = await ghRunner([
133
+ 'api',
134
+ `/repos/${repo}/pulls/${prNumber}/reviews`,
135
+ '--paginate',
136
+ ]);
137
+ const reviews = JSON.parse(raw);
138
+ if (!Array.isArray(reviews) || reviews.length === 0)
139
+ return '';
140
+ return reviews
141
+ .filter(r => r.state !== 'PENDING')
142
+ .map(r => `- ${r.user.login} (${r.state}): ${r.body || '(no summary)'}`)
143
+ .join('\n');
144
+ }
145
+ catch (err) {
146
+ console.warn(`fetchPrReviews: failed for ${repo} PR #${prNumber}:`, err);
147
+ return '';
148
+ }
149
+ }
150
+ /** HTML marker embedded in Codekin review comments for identification. */
151
+ export const REVIEW_COMMENT_MARKER = '<!-- codekin-review -->';
152
+ /**
153
+ * Find an existing Codekin review summary comment on a PR.
154
+ * Searches issue comments (top-level conversation comments) for the marker.
155
+ *
156
+ * @param repo - GitHub repo in `owner/name` format.
157
+ * @param prNumber - Pull request number.
158
+ * @returns The comment ID if found, or undefined.
159
+ */
160
+ export async function fetchExistingReviewComment(repo, prNumber) {
161
+ try {
162
+ const raw = await ghRunner([
163
+ 'api',
164
+ `/repos/${repo}/issues/${prNumber}/comments`,
165
+ '--paginate',
166
+ ]);
167
+ const comments = JSON.parse(raw);
168
+ if (!Array.isArray(comments) || comments.length === 0)
169
+ return undefined;
170
+ // Search in reverse to find the most recent matching comment
171
+ for (let i = comments.length - 1; i >= 0; i--) {
172
+ if (comments[i].body.includes(REVIEW_COMMENT_MARKER)) {
173
+ return comments[i].id;
174
+ }
175
+ }
176
+ return undefined;
177
+ }
178
+ catch (err) {
179
+ console.warn(`fetchExistingReviewComment: failed for ${repo} PR #${prNumber}:`, err);
180
+ return undefined;
181
+ }
182
+ }
183
+ export async function fetchPrCommits(repo, prNumber) {
184
+ try {
185
+ const raw = await ghRunner([
186
+ 'api',
187
+ `/repos/${repo}/pulls/${prNumber}/commits`,
188
+ '--paginate',
189
+ ]);
190
+ const commits = JSON.parse(raw);
191
+ if (!Array.isArray(commits) || commits.length === 0)
192
+ return '';
193
+ return commits
194
+ .map(c => `- ${c.sha.slice(0, 7)}: ${c.commit.message.split('\n')[0]}`)
195
+ .join('\n');
196
+ }
197
+ catch (err) {
198
+ console.warn(`fetchPrCommits: failed for ${repo} PR #${prNumber}:`, err);
199
+ return '';
200
+ }
201
+ }
202
+ //# sourceMappingURL=webhook-pr-github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-pr-github.js","sourceRoot":"","sources":["../webhook-pr-github.ts"],"names":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GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,8BAA8B,IAAI,QAAQ,QAAQ,GAAG,EAAE,GAAG,CAAC,CAAA;QACxE,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Builds the structured prompt sent to Claude for pull request code review.
3
+ *
4
+ * Supports a 3-tier custom prompt resolution for the review instructions:
5
+ * 1. Repo-level: {workspacePath}/.codekin/pr-review-prompt.md
6
+ * 2. Global: ~/.codekin/pr-review-prompt.md
7
+ * 3. Built-in default (hardcoded below)
8
+ *
9
+ * The PR metadata and diff context are always prepended — custom prompts
10
+ * only replace the review instructions section.
11
+ */
12
+ import type { PullRequestContext } from './webhook-types.js';
13
+ import type { PrCacheData } from './webhook-pr-cache.js';
14
+ /** Options for prompt assembly — cache context and comment management. */
15
+ export interface PrPromptOptions {
16
+ priorCache?: PrCacheData;
17
+ cachePath?: string;
18
+ existingCommentId?: number;
19
+ }
20
+ /**
21
+ * Builds the full prompt for PR review, combining PR context with review instructions.
22
+ *
23
+ * @param ctx - Pull request context with metadata and diff.
24
+ * @param workspacePath - Path to the cloned workspace (for repo-level prompt lookup).
25
+ * @param options - Optional cache context and comment management settings.
26
+ */
27
+ export declare function buildPrReviewPrompt(ctx: PullRequestContext, workspacePath: string, options?: PrPromptOptions): string;
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Builds the structured prompt sent to Claude for pull request code review.
3
+ *
4
+ * Supports a 3-tier custom prompt resolution for the review instructions:
5
+ * 1. Repo-level: {workspacePath}/.codekin/pr-review-prompt.md
6
+ * 2. Global: ~/.codekin/pr-review-prompt.md
7
+ * 3. Built-in default (hardcoded below)
8
+ *
9
+ * The PR metadata and diff context are always prepended — custom prompts
10
+ * only replace the review instructions section.
11
+ */
12
+ import { existsSync, readFileSync } from 'fs';
13
+ import { homedir } from 'os';
14
+ import { join } from 'path';
15
+ import { REVIEW_COMMENT_MARKER } from './webhook-pr-github.js';
16
+ const CUSTOM_PROMPT_FILENAME = 'pr-review-prompt.md';
17
+ /**
18
+ * Attempt to load a custom review prompt from disk.
19
+ * Returns the file contents if found, or undefined.
20
+ */
21
+ function loadCustomPrompt(workspacePath) {
22
+ // 1. Repo-level
23
+ const repoPromptPath = join(workspacePath, '.codekin', CUSTOM_PROMPT_FILENAME);
24
+ if (existsSync(repoPromptPath)) {
25
+ try {
26
+ const content = readFileSync(repoPromptPath, 'utf-8').trim();
27
+ if (content) {
28
+ console.log(`[pr-prompt] Using repo-level custom prompt: ${repoPromptPath}`);
29
+ return content;
30
+ }
31
+ }
32
+ catch (err) {
33
+ console.warn(`[pr-prompt] Failed to read repo-level prompt:`, err);
34
+ }
35
+ }
36
+ // 2. Global
37
+ const globalPromptPath = join(homedir(), '.codekin', CUSTOM_PROMPT_FILENAME);
38
+ if (existsSync(globalPromptPath)) {
39
+ try {
40
+ const content = readFileSync(globalPromptPath, 'utf-8').trim();
41
+ if (content) {
42
+ console.log(`[pr-prompt] Using global custom prompt: ${globalPromptPath}`);
43
+ return content;
44
+ }
45
+ }
46
+ catch (err) {
47
+ console.warn(`[pr-prompt] Failed to read global prompt:`, err);
48
+ }
49
+ }
50
+ return undefined;
51
+ }
52
+ /**
53
+ * Build the default review instructions (used when no custom prompt is found).
54
+ */
55
+ function buildDefaultInstructions(ctx) {
56
+ const lines = [];
57
+ if (ctx.action === 'synchronize' && ctx.beforeSha) {
58
+ lines.push(`This PR has been updated with new commits. The previous head was \`${ctx.beforeSha.slice(0, 7)}\`, the new head is \`${ctx.headSha.slice(0, 7)}\`. Review the full PR diff but pay particular attention to changes since the previous head.`);
59
+ }
60
+ else if (ctx.action === 'reopened') {
61
+ lines.push('This PR has been reopened. Provide a fresh comprehensive code review.');
62
+ }
63
+ else {
64
+ lines.push('Provide a comprehensive code review of this pull request.');
65
+ }
66
+ lines.push('');
67
+ lines.push('Focus on:');
68
+ lines.push('1. Code correctness and logic errors');
69
+ lines.push('2. Security vulnerabilities (injection, auth issues, data exposure)');
70
+ lines.push('3. Performance implications');
71
+ lines.push('4. Code style, readability, and maintainability');
72
+ lines.push('5. Test coverage for new or changed code');
73
+ lines.push('');
74
+ lines.push('Produce a structured review report with:');
75
+ lines.push('- **Summary**: 1-2 sentence overview of the PR');
76
+ lines.push('- **Findings**: Grouped by severity (Critical / Warning / Suggestion / Nitpick)');
77
+ lines.push(' - For each finding: file path, line number(s), description, and suggested fix');
78
+ lines.push('- **Overall Assessment**: Approve / Request Changes / Comment');
79
+ return lines.join('\n');
80
+ }
81
+ /**
82
+ * Builds the full prompt for PR review, combining PR context with review instructions.
83
+ *
84
+ * @param ctx - Pull request context with metadata and diff.
85
+ * @param workspacePath - Path to the cloned workspace (for repo-level prompt lookup).
86
+ * @param options - Optional cache context and comment management settings.
87
+ */
88
+ export function buildPrReviewPrompt(ctx, workspacePath, options) {
89
+ const lines = [];
90
+ const reviewBodyPath = `${workspacePath}/pr-${ctx.prNumber}-review-body.md`;
91
+ // --- PR metadata (always included) ---
92
+ lines.push('A pull request needs code review.');
93
+ lines.push('');
94
+ lines.push('## PR Details');
95
+ lines.push(`- **Repository**: ${ctx.repo}`);
96
+ lines.push(`- **PR**: #${ctx.prNumber} — ${ctx.prTitle}`);
97
+ lines.push(`- **Author**: ${ctx.author}`);
98
+ lines.push(`- **Branch**: ${ctx.headBranch} → ${ctx.baseBranch}`);
99
+ lines.push(`- **Stats**: ${ctx.changedFiles} files changed, +${ctx.additions}/-${ctx.deletions}`);
100
+ const shortHead = ctx.headSha.slice(0, 7);
101
+ lines.push(`- **Head**: ${shortHead}`);
102
+ if (ctx.prUrl) {
103
+ lines.push(`- **URL**: ${ctx.prUrl}`);
104
+ }
105
+ // PR description
106
+ if (ctx.prBody) {
107
+ lines.push('');
108
+ lines.push('## PR Description');
109
+ lines.push(ctx.prBody);
110
+ }
111
+ // Changed files
112
+ if (ctx.fileList) {
113
+ lines.push('');
114
+ lines.push('## Changed Files');
115
+ lines.push(ctx.fileList);
116
+ }
117
+ // Commit messages
118
+ if (ctx.commitMessages) {
119
+ lines.push('');
120
+ lines.push('## Commits');
121
+ lines.push(ctx.commitMessages);
122
+ }
123
+ // Existing review comments
124
+ if (ctx.reviews || ctx.reviewComments) {
125
+ lines.push('');
126
+ lines.push('## Existing Reviews');
127
+ if (ctx.reviews) {
128
+ lines.push('### Review Summaries');
129
+ lines.push(ctx.reviews);
130
+ }
131
+ if (ctx.reviewComments) {
132
+ lines.push('### Inline Comments');
133
+ lines.push(ctx.reviewComments);
134
+ }
135
+ }
136
+ // Prior review context (from cache)
137
+ if (options?.priorCache) {
138
+ const cache = options.priorCache;
139
+ lines.push('');
140
+ lines.push('## Prior Review Context');
141
+ lines.push(`(from review at commit ${cache.lastReviewedSha} on ${cache.timestamp})`);
142
+ lines.push('');
143
+ lines.push('### Codebase Familiarity');
144
+ lines.push(cache.codebaseContext);
145
+ lines.push('');
146
+ lines.push('### Previous Review Findings');
147
+ lines.push(cache.reviewFindings);
148
+ lines.push('');
149
+ lines.push('### Previous Review Summary');
150
+ lines.push(cache.priorReviewSummary);
151
+ lines.push('');
152
+ lines.push('Note: The above is from a previous review. The diff and comments below are fresh. Review the full current diff but leverage your prior context for faster, more informed review.');
153
+ }
154
+ // Diff
155
+ lines.push('');
156
+ lines.push('## Diff');
157
+ if (ctx.diff) {
158
+ lines.push('```diff');
159
+ lines.push(ctx.diff);
160
+ lines.push('```');
161
+ }
162
+ else {
163
+ lines.push('No diff available.');
164
+ }
165
+ // --- Review instructions (custom or default) ---
166
+ lines.push('');
167
+ lines.push('## Instructions');
168
+ const customPrompt = loadCustomPrompt(workspacePath);
169
+ if (customPrompt) {
170
+ lines.push(customPrompt);
171
+ }
172
+ else {
173
+ lines.push(buildDefaultInstructions(ctx));
174
+ }
175
+ // Override any hardcoded intermediate review file paths from custom prompts
176
+ // so concurrent reviews don't collide or write into tracked repo files.
177
+ lines.push('');
178
+ lines.push('## File Paths for This Review');
179
+ lines.push('When writing intermediate files during the review process, use these paths:');
180
+ lines.push(`- Draft review: \`${workspacePath}/pr-${ctx.prNumber}-draft-review.md\``);
181
+ lines.push(`- Codex cross-review output: \`${workspacePath}/pr-${ctx.prNumber}-codex-review.md\``);
182
+ lines.push(`- Codex command: \`codex exec - --skip-git-repo-check -o ${workspacePath}/pr-${ctx.prNumber}-codex-review.md < ${workspacePath}/pr-${ctx.prNumber}-draft-review.md\``);
183
+ lines.push('These paths override any file paths mentioned in the review instructions above.');
184
+ lines.push('Do NOT write review files to the `docs/` directory or any other git-tracked location.');
185
+ // --- Comment posting instructions ---
186
+ lines.push('');
187
+ if (options?.existingCommentId) {
188
+ lines.push('## Posting Your Review Summary');
189
+ lines.push(`An existing Codekin review comment was found on this PR (comment ID: ${options.existingCommentId}).`);
190
+ lines.push('Update it instead of creating a new comment. Use a temporary file for the body to avoid shell escaping issues:');
191
+ lines.push('');
192
+ lines.push(`1. Write your review summary to \`${reviewBodyPath}\``);
193
+ lines.push(`2. Ensure the file starts with \`${REVIEW_COMMENT_MARKER}\` on its own line`);
194
+ lines.push(`3. Run: \`gh api repos/${ctx.repo}/issues/comments/${options.existingCommentId} -X PATCH -F body=@${reviewBodyPath}\``);
195
+ lines.push('');
196
+ lines.push(`IMPORTANT: Always include \`${REVIEW_COMMENT_MARKER}\` at the very beginning of the comment body.`);
197
+ }
198
+ else {
199
+ lines.push('## Posting Your Review Summary');
200
+ lines.push('Post your review summary as a new comment on the PR. Use a temporary file for the body to avoid shell escaping issues:');
201
+ lines.push('');
202
+ lines.push(`1. Write your review summary to \`${reviewBodyPath}\``);
203
+ lines.push(`2. Ensure the file starts with \`${REVIEW_COMMENT_MARKER}\` on its own line`);
204
+ lines.push(`3. Run: \`gh api repos/${ctx.repo}/issues/${ctx.prNumber}/comments -F body=@${reviewBodyPath}\``);
205
+ lines.push('');
206
+ lines.push(`IMPORTANT: Always include \`${REVIEW_COMMENT_MARKER}\` at the very beginning of the comment body. This marker allows future reviews to update this comment instead of creating a new one.`);
207
+ }
208
+ // --- Cache-writing instructions ---
209
+ if (options?.cachePath) {
210
+ lines.push('');
211
+ lines.push('## Post-Review: Save Context');
212
+ lines.push('After completing your review, write a JSON file to preserve your context for future reviews of this PR.');
213
+ lines.push('');
214
+ lines.push(`Path: ${options.cachePath}`);
215
+ lines.push('');
216
+ lines.push('The file must be valid JSON with this exact structure:');
217
+ lines.push('```json');
218
+ lines.push('{');
219
+ lines.push(` "prNumber": ${ctx.prNumber},`);
220
+ lines.push(` "repo": "${ctx.repo}",`);
221
+ lines.push(` "lastReviewedSha": "${ctx.headSha}",`);
222
+ lines.push(' "timestamp": "<current ISO timestamp>",');
223
+ lines.push(' "priorReviewSummary": "<1-3 sentence summary of your review findings>",');
224
+ lines.push(' "codebaseContext": "<key architectural observations, module structure, patterns you noticed>",');
225
+ lines.push(' "reviewFindings": "<specific issues found, their locations, and whether they were fixed>",');
226
+ lines.push(' "verdict": "<approve | request_changes | comment>",');
227
+ lines.push(' "structuredFindings": [');
228
+ lines.push(' {');
229
+ lines.push(' "severity": "<critical | must-fix | suggestion | minor | nitpick>",');
230
+ lines.push(' "file": "<path/to/file.ts>",');
231
+ lines.push(' "line": <line number or null>,');
232
+ lines.push(' "description": "<short description of the finding>",');
233
+ lines.push(' "status": "<new | open | fixed>"');
234
+ lines.push(' }');
235
+ lines.push(' ],');
236
+ lines.push(` "author": ${JSON.stringify(ctx.author)},`);
237
+ lines.push(` "prTitle": ${JSON.stringify(ctx.prTitle)},`);
238
+ lines.push(` "changedFiles": ${ctx.changedFiles},`);
239
+ lines.push(` "additions": ${ctx.additions},`);
240
+ lines.push(` "deletions": ${ctx.deletions}`);
241
+ lines.push('}');
242
+ lines.push('```');
243
+ lines.push('');
244
+ lines.push('IMPORTANT: The `structuredFindings` array must include every finding from your review.');
245
+ lines.push('Use an empty array `[]` if there are no findings. The `verdict` must be exactly one of: approve, request_changes, comment.');
246
+ lines.push('');
247
+ lines.push('Use the Write tool to save this file. This helps future reviews of this PR be more efficient.');
248
+ }
249
+ return lines.join('\n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xE,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAA;QACpD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAClB,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACxD,KAAK,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC1D,KAAK,CAAC,IAAI,CAAC,qBAAqB,GAAG,CAAC,YAAY,GAAG,CAAC,CAAA;QACpD,KAAK,CAAC,IAAI,CAAC,kBAAkB,GAAG,CAAC,SAAS,GAAG,CAAC,CAAA;QAC9C,KAAK,CAAC,IAAI,CAAC,kBAAkB,GAAG,CAAC,SAAS,EAAE,CAAC,CAAA;QAC7C,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACjB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACd,KAAK,CAAC,IAAI,CAAC,wFAAwF,CAAC,CAAA;QACpG,KAAK,CAAC,IAAI,CAAC,4HAA4H,CAAC,CAAA;QACxI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACd,KAAK,CAAC,IAAI,CAAC,+FAA+F,CAAC,CAAA;IAC7G,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -1,4 +1,4 @@
1
- export type WebhookEventStatus = 'received' | 'filtered' | 'duplicate' | 'processing' | 'session_created' | 'completed' | 'error';
1
+ export type WebhookEventStatus = 'received' | 'filtered' | 'duplicate' | 'processing' | 'session_created' | 'completed' | 'error' | 'superseded';
2
2
  export interface WebhookEvent {
3
3
  id: string;
4
4
  idempotencyKey: string;
@@ -15,6 +15,10 @@ export interface WebhookEvent {
15
15
  sessionId?: string;
16
16
  error?: string;
17
17
  filterReason?: string;
18
+ prNumber?: number;
19
+ prTitle?: string;
20
+ headSha?: string;
21
+ baseBranch?: string;
18
22
  }
19
23
  export interface WorkflowRunPayload {
20
24
  action: string;
@@ -97,3 +101,68 @@ export interface WebhookConfig {
97
101
  logLinesToInclude: number;
98
102
  actorAllowlist: string[];
99
103
  }
104
+ export interface PullRequestPayload {
105
+ action: string;
106
+ number: number;
107
+ before?: string;
108
+ after?: string;
109
+ pull_request: {
110
+ number: number;
111
+ title: string;
112
+ body: string | null;
113
+ state: string;
114
+ draft: boolean;
115
+ merged: boolean;
116
+ user: {
117
+ login: string;
118
+ };
119
+ head: {
120
+ ref: string;
121
+ sha: string;
122
+ repo: {
123
+ clone_url: string;
124
+ } | null;
125
+ };
126
+ base: {
127
+ ref: string;
128
+ sha: string;
129
+ };
130
+ html_url: string;
131
+ changed_files: number;
132
+ additions: number;
133
+ deletions: number;
134
+ };
135
+ repository: {
136
+ full_name: string;
137
+ name: string;
138
+ clone_url: string;
139
+ };
140
+ sender: {
141
+ login: string;
142
+ };
143
+ }
144
+ export interface PullRequestContext {
145
+ repo: string;
146
+ repoName: string;
147
+ prNumber: number;
148
+ prTitle: string;
149
+ prBody: string;
150
+ prUrl: string;
151
+ author: string;
152
+ headBranch: string;
153
+ baseBranch: string;
154
+ headSha: string;
155
+ baseSha: string;
156
+ beforeSha?: string;
157
+ action: 'opened' | 'synchronize' | 'reopened' | 'ready_for_review';
158
+ changedFiles: number;
159
+ additions: number;
160
+ deletions: number;
161
+ diff: string;
162
+ fileList: string;
163
+ commitMessages: string;
164
+ reviewComments: string;
165
+ reviews: string;
166
+ existingComment: string | null;
167
+ priorCache: import('./webhook-pr-cache.js').PrCacheData | null;
168
+ }