scai 0.1.72 → 0.1.74
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/README.md +1 -1
- package/dist/commands/ReviewCmd.js +22 -2
- package/dist/commands/SummaryCmd.js +3 -3
- package/dist/utils/summarizer.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,8 +17,22 @@ export async function getPullRequestsForReview(token, owner, repo, username, bra
|
|
|
17
17
|
!isMerged &&
|
|
18
18
|
(!filterForUser || pr.requested_reviewers?.some(r => r.login === username));
|
|
19
19
|
if (shouldInclude) {
|
|
20
|
-
const
|
|
20
|
+
const prNumber = pr.number;
|
|
21
21
|
try {
|
|
22
|
+
// ✅ Fetch full PR to get the body
|
|
23
|
+
const prRes = await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls/${prNumber}`, {
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `token ${token}`,
|
|
26
|
+
Accept: 'application/vnd.github.v3+json',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (!prRes.ok) {
|
|
30
|
+
throw new Error(`Failed to fetch full PR details for #${prNumber}: ${prRes.statusText}`);
|
|
31
|
+
}
|
|
32
|
+
const fullPR = await prRes.json();
|
|
33
|
+
pr.body = fullPR.body ?? ''; // Assign the body if available
|
|
34
|
+
// ✅ Fetch diff
|
|
35
|
+
const diffUrl = `https://api.github.com/repos/${owner}/${repo}/pulls/${prNumber}.diff`;
|
|
22
36
|
const diffRes = await fetch(diffUrl, {
|
|
23
37
|
headers: {
|
|
24
38
|
Authorization: `token ${token}`,
|
|
@@ -32,13 +46,14 @@ export async function getPullRequestsForReview(token, owner, repo, username, bra
|
|
|
32
46
|
filtered.push({ pr, diff });
|
|
33
47
|
}
|
|
34
48
|
catch (err) {
|
|
49
|
+
console.warn(`⚠️ Skipping PR #${pr.number} due to error: ${err.message}`);
|
|
35
50
|
failedPRs.push(pr);
|
|
36
51
|
}
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
if (failedPRs.length > 0) {
|
|
40
55
|
const failedList = failedPRs.map(pr => `#${pr.number}`).join(', ');
|
|
41
|
-
console.warn(`⚠️ Skipped ${failedPRs.length} PR(s) (${failedList}) due to
|
|
56
|
+
console.warn(`⚠️ Skipped ${failedPRs.length} PR(s) (${failedList}) due to errors.`);
|
|
42
57
|
}
|
|
43
58
|
return filtered;
|
|
44
59
|
}
|
|
@@ -209,6 +224,11 @@ export async function reviewPullRequestCmd(branch = 'main', showAll = false) {
|
|
|
209
224
|
if (selectedIndex === null)
|
|
210
225
|
return;
|
|
211
226
|
const { pr, diff } = prsWithReviewRequested[selectedIndex];
|
|
227
|
+
if (pr.body) {
|
|
228
|
+
console.log(chalk.magentaBright('\n📝 Pull Request Description:\n'));
|
|
229
|
+
console.log(chalk.gray(pr.body));
|
|
230
|
+
console.log(chalk.magentaBright('\n---\n'));
|
|
231
|
+
}
|
|
212
232
|
let prDiff = diff;
|
|
213
233
|
if (!prDiff) {
|
|
214
234
|
console.log(`🔍 Fetching diff for PR #${pr.number}...`);
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import readline from 'readline';
|
|
4
4
|
import { queryFiles, indexFile } from '../db/fileIndex.js';
|
|
5
5
|
import { summaryModule } from '../pipeline/modules/summaryModule.js';
|
|
6
|
-
import {
|
|
6
|
+
import { styleOutput } from '../utils/summarizer.js';
|
|
7
7
|
import { detectFileType } from '../fileRules/detectFileType.js';
|
|
8
8
|
import { generateEmbedding } from '../lib/generateEmbedding.js';
|
|
9
9
|
import { sanitizeQueryForFts } from '../utils/sanitizeQuery.js';
|
|
@@ -31,7 +31,7 @@ export async function summarizeFile(filepath) {
|
|
|
31
31
|
const match = matches.find(row => path.resolve(row.path) === filePathResolved);
|
|
32
32
|
if (match?.summary) {
|
|
33
33
|
console.log(`🧠 Cached summary for ${filepath}:\n`);
|
|
34
|
-
console.log(
|
|
34
|
+
console.log(styleOutput(match.summary));
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
@@ -64,7 +64,7 @@ export async function summarizeFile(filepath) {
|
|
|
64
64
|
console.warn('⚠️ No summary generated.');
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
console.log(
|
|
67
|
+
console.log(styleOutput(response.summary));
|
|
68
68
|
if (filePathResolved) {
|
|
69
69
|
const fileType = detectFileType(filePathResolved);
|
|
70
70
|
indexFile(filePathResolved, response.summary, fileType);
|
package/dist/utils/summarizer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import columnify from 'columnify';
|
|
2
|
-
export function
|
|
2
|
+
export function styleOutput(summaryText) {
|
|
3
3
|
const terminalWidth = process.stdout.columns || 80;
|
|
4
4
|
// You can control wrapping here
|
|
5
5
|
const formatted = columnify([{ Summary: summaryText }], {
|