@in-the-loop-labs/pair-review 3.1.4 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/public/css/pr.css +913 -1
- package/public/js/components/CouncilProgressModal.js +8 -0
- package/public/js/components/NotificationDropdown.js +257 -0
- package/public/js/components/StackAnalysisDialog.js +313 -0
- package/public/js/components/StackProgressModal.js +475 -0
- package/public/js/components/StatusIndicator.js +1 -0
- package/public/js/pr.js +420 -2
- package/public/js/utils/notification-sounds.js +62 -0
- package/public/local.html +10 -0
- package/public/pr.html +12 -0
- package/public/setup.html +4 -0
- package/src/ai/pi-provider.js +13 -5
- package/src/ai/provider.js +4 -0
- package/src/chat/chat-providers.js +4 -0
- package/src/chat/pi-bridge.js +8 -0
- package/src/chat/session-manager.js +5 -1
- package/src/git/base-branch.js +1 -51
- package/src/git/worktree-lock.js +88 -0
- package/src/git/worktree.js +64 -0
- package/src/github/stack-walker.js +196 -0
- package/src/routes/local.js +12 -8
- package/src/routes/pr.js +139 -26
- package/src/routes/sound.js +49 -0
- package/src/routes/stack-analysis.js +886 -0
- package/src/server.js +4 -0
- package/src/setup/stack-setup.js +77 -0
package/src/server.js
CHANGED
|
@@ -312,6 +312,8 @@ async function startServer(sharedDb = null) {
|
|
|
312
312
|
const chatRoutes = require('./routes/chat');
|
|
313
313
|
const contextFilesRoutes = require('./routes/context-files');
|
|
314
314
|
const githubCollectionsRoutes = require('./routes/github-collections');
|
|
315
|
+
const stackAnalysisRoutes = require('./routes/stack-analysis');
|
|
316
|
+
const { createSoundRouter } = require('./routes/sound');
|
|
315
317
|
|
|
316
318
|
// Initialize chat session manager
|
|
317
319
|
const ChatSessionManager = require('./chat/session-manager');
|
|
@@ -330,6 +332,8 @@ async function startServer(sharedDb = null) {
|
|
|
330
332
|
app.use('/', setupRoutes);
|
|
331
333
|
app.use('/', mcpRoutes);
|
|
332
334
|
app.use('/', githubCollectionsRoutes);
|
|
335
|
+
app.use('/', stackAnalysisRoutes);
|
|
336
|
+
app.use('/', createSoundRouter());
|
|
333
337
|
app.use('/', prRoutes);
|
|
334
338
|
|
|
335
339
|
// Error handling middleware
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Stack PR Setup Utility
|
|
4
|
+
*
|
|
5
|
+
* Lightweight setup for individual PRs during stack analysis.
|
|
6
|
+
* Fetches PR data (or accepts pre-fetched data), generates diffs,
|
|
7
|
+
* and stores metadata via storePRData().
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { storePRData } = require('./pr-setup');
|
|
11
|
+
const { GitHubClient } = require('../github/client');
|
|
12
|
+
const logger = require('../utils/logger');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Set up a single PR within a stack analysis context.
|
|
16
|
+
*
|
|
17
|
+
* Fetches PR data from GitHub (or uses pre-fetched data when provided),
|
|
18
|
+
* generates a diff in the worktree, and stores everything in the database
|
|
19
|
+
* via storePRData().
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} params
|
|
22
|
+
* @param {Object} params.db - Database instance
|
|
23
|
+
* @param {string} params.owner - Repository owner
|
|
24
|
+
* @param {string} params.repo - Repository name
|
|
25
|
+
* @param {number} params.prNumber - Pull request number
|
|
26
|
+
* @param {string} params.githubToken - GitHub personal access token
|
|
27
|
+
* @param {string} params.worktreePath - Path to the per-PR worktree
|
|
28
|
+
* @param {import('../git/worktree').GitWorktreeManager} params.worktreeManager - Worktree manager instance
|
|
29
|
+
* @param {Object} [params.prData] - Pre-fetched PR data from GitHub (skips API call when provided)
|
|
30
|
+
* @returns {Promise<{ reviewId: number, prMetadata: Object, prData: Object, isNew: boolean }>}
|
|
31
|
+
*/
|
|
32
|
+
async function setupStackPR({ db, owner, repo, prNumber, githubToken, worktreePath, worktreeManager, prData: prefetchedPRData }) {
|
|
33
|
+
logger.info(`Setting up stack PR #${prNumber} for ${owner}/${repo}`);
|
|
34
|
+
|
|
35
|
+
// 1. Fetch PR data from GitHub (or use pre-fetched data)
|
|
36
|
+
const githubClient = new GitHubClient(githubToken);
|
|
37
|
+
let prData;
|
|
38
|
+
if (prefetchedPRData) {
|
|
39
|
+
prData = prefetchedPRData;
|
|
40
|
+
} else {
|
|
41
|
+
prData = await githubClient.fetchPullRequest(owner, repo, prNumber);
|
|
42
|
+
}
|
|
43
|
+
logger.info(`Fetched PR #${prNumber}: "${prData.title}"`);
|
|
44
|
+
|
|
45
|
+
// 2. Fetch changed files list from GitHub API
|
|
46
|
+
const prFiles = await githubClient.fetchPullRequestFiles(owner, repo, prNumber);
|
|
47
|
+
logger.info(`PR #${prNumber} has ${prFiles.length} changed files`);
|
|
48
|
+
|
|
49
|
+
// 3. Generate diff in the worktree (SHA-based, works after checkout)
|
|
50
|
+
const diff = await worktreeManager.generateUnifiedDiff(worktreePath, prData);
|
|
51
|
+
|
|
52
|
+
// 4. Get changed files with stats
|
|
53
|
+
const changedFiles = await worktreeManager.getChangedFiles(worktreePath, prData);
|
|
54
|
+
|
|
55
|
+
// 5. Store via storePRData (creates/updates pr_metadata, reviews, worktrees records)
|
|
56
|
+
const prInfo = { owner, repo, number: prNumber };
|
|
57
|
+
const { isNewReview, reviewId } = await storePRData(db, prInfo, prData, diff, changedFiles, worktreePath);
|
|
58
|
+
|
|
59
|
+
logger.info(`Stack PR #${prNumber} setup complete (reviewId: ${reviewId}, new: ${isNewReview})`);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
reviewId,
|
|
63
|
+
prMetadata: {
|
|
64
|
+
owner,
|
|
65
|
+
repo,
|
|
66
|
+
number: prNumber,
|
|
67
|
+
title: prData.title,
|
|
68
|
+
author: prData.author,
|
|
69
|
+
base_branch: prData.base_branch,
|
|
70
|
+
head_branch: prData.head_branch,
|
|
71
|
+
},
|
|
72
|
+
prData,
|
|
73
|
+
isNew: isNewReview,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { setupStackPR };
|