difit 0.0.4 → 0.0.5
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/dist/cli/index.js +0 -0
- package/dist/client/assets/index-W2UC55JC.css +1 -0
- package/dist/client/assets/index-hiGBtmpa.js +142 -0
- package/dist/client/index.html +2 -2
- package/dist/server/comment-store.js +85 -8
- package/dist/server/git-diff.js +3 -1
- package/dist/server/server.js +10 -0
- package/package.json +3 -2
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.test.d.ts +0 -1
- package/dist/cli/index.test.js +0 -676
- package/dist/cli/utils.d.ts +0 -1
- package/dist/cli/utils.test.d.ts +0 -1
- package/dist/cli/utils.test.js +0 -214
- package/dist/client/assets/index-B79lDGO8.js +0 -53
- package/dist/client/assets/index-CSJzfcU-.css +0 -1
- package/dist/client/assets/prism-css-Bpx-unsJ.js +0 -1
- package/dist/client/assets/prism-json-xwnKirkR.js +0 -1
- package/dist/client/assets/prism-typescript-B2PMeEx1.js +0 -1
- package/dist/server/comment-store.d.ts +0 -13
- package/dist/server/git-diff-tui.d.ts +0 -2
- package/dist/server/git-diff-tui.js +0 -95
- package/dist/server/git-diff.d.ts +0 -10
- package/dist/server/git-diff.test.d.ts +0 -1
- package/dist/server/git-diff.test.js +0 -292
- package/dist/server/server.d.ts +0 -11
- package/dist/server/server.test.d.ts +0 -1
- package/dist/server/server.test.js +0 -382
- package/dist/tui/App.d.ts +0 -8
- package/dist/tui/App.js +0 -92
- package/dist/tui/App.test.d.ts +0 -1
- package/dist/tui/App.test.js +0 -31
- package/dist/tui/components/DiffViewer.d.ts +0 -9
- package/dist/tui/components/DiffViewer.js +0 -88
- package/dist/tui/components/FileList.d.ts +0 -8
- package/dist/tui/components/FileList.js +0 -48
- package/dist/tui/components/SideBySideDiffViewer.d.ts +0 -9
- package/dist/tui/components/SideBySideDiffViewer.js +0 -237
- package/dist/tui/components/StatusBar.d.ts +0 -8
- package/dist/tui/components/StatusBar.js +0 -23
- package/dist/tui/utils/parseDiff.d.ts +0 -2
- package/dist/tui/utils/parseDiff.js +0 -68
- package/dist/types/diff.d.ts +0 -33
- package/dist/utils/fileUtils.d.ts +0 -12
- package/dist/utils/fileUtils.js +0 -21
package/dist/client/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>ReviewIt - Git Diff Viewer</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-hiGBtmpa.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-W2UC55JC.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<div id="root"></div>
|
|
@@ -26,17 +26,94 @@ export class CommentStore {
|
|
|
26
26
|
}
|
|
27
27
|
generatePrompt(comment, diffContent) {
|
|
28
28
|
const lines = diffContent.split('\n');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Find the relevant code context around the commented line
|
|
30
|
+
let relevantLines = [];
|
|
31
|
+
let foundTargetLine = false;
|
|
32
|
+
for (let i = 0; i < lines.length; i++) {
|
|
33
|
+
const line = lines[i];
|
|
34
|
+
// Skip chunk headers (start with @@)
|
|
35
|
+
if (line.startsWith('@@'))
|
|
36
|
+
continue;
|
|
37
|
+
// Extract line numbers and content
|
|
38
|
+
const addMatch = line.match(/^\+(\d+)/);
|
|
39
|
+
const delMatch = line.match(/^-(\d+)/);
|
|
40
|
+
const normalMatch = line.match(/^ /);
|
|
41
|
+
if (addMatch || delMatch || normalMatch) {
|
|
42
|
+
const lineNumber = addMatch
|
|
43
|
+
? parseInt(addMatch[1])
|
|
44
|
+
: delMatch
|
|
45
|
+
? parseInt(delMatch[1])
|
|
46
|
+
: null;
|
|
47
|
+
// Include lines around the target line (±5 lines context)
|
|
48
|
+
if (lineNumber && Math.abs(lineNumber - comment.line) <= 5) {
|
|
49
|
+
relevantLines.push(line);
|
|
50
|
+
if (lineNumber === comment.line) {
|
|
51
|
+
foundTargetLine = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (!lineNumber && relevantLines.length > 0 && relevantLines.length < 15) {
|
|
55
|
+
// Include context lines without line numbers if we're building context
|
|
56
|
+
relevantLines.push(line);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// If we didn't find the exact line, include more general context
|
|
61
|
+
if (!foundTargetLine && relevantLines.length === 0) {
|
|
62
|
+
const contextStart = Math.max(0, comment.line - 5);
|
|
63
|
+
const contextEnd = Math.min(lines.length, comment.line + 5);
|
|
64
|
+
relevantLines = lines.slice(contextStart, contextEnd);
|
|
65
|
+
}
|
|
66
|
+
const codeContext = relevantLines.join('\n');
|
|
32
67
|
return [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'
|
|
37
|
-
|
|
68
|
+
`File: ${comment.file}`,
|
|
69
|
+
`Line: ${comment.line}`,
|
|
70
|
+
'',
|
|
71
|
+
'Code Context:',
|
|
72
|
+
'```',
|
|
73
|
+
codeContext,
|
|
74
|
+
'```',
|
|
75
|
+
'',
|
|
76
|
+
`Comment: ${comment.body}`,
|
|
38
77
|
].join('\n');
|
|
39
78
|
}
|
|
79
|
+
generateAllCommentsPrompt(comments, diffFiles) {
|
|
80
|
+
if (comments.length === 0) {
|
|
81
|
+
return 'No comments available.';
|
|
82
|
+
}
|
|
83
|
+
const prompts = comments.map((comment, index) => {
|
|
84
|
+
const targetFile = diffFiles.find((f) => f.path === comment.file);
|
|
85
|
+
if (!targetFile) {
|
|
86
|
+
return [
|
|
87
|
+
`## Comment ${index + 1}`,
|
|
88
|
+
`File: ${comment.file}`,
|
|
89
|
+
`Line: ${comment.line}`,
|
|
90
|
+
'',
|
|
91
|
+
'Code Context:',
|
|
92
|
+
'```',
|
|
93
|
+
'File not found in diff',
|
|
94
|
+
'```',
|
|
95
|
+
'',
|
|
96
|
+
`Comment: ${comment.body}`,
|
|
97
|
+
].join('\n');
|
|
98
|
+
}
|
|
99
|
+
let diffContent = '';
|
|
100
|
+
for (const chunk of targetFile.chunks) {
|
|
101
|
+
diffContent += chunk.header + '\n';
|
|
102
|
+
for (const line of chunk.lines) {
|
|
103
|
+
const prefix = line.type === 'add' ? '+' : line.type === 'delete' ? '-' : ' ';
|
|
104
|
+
diffContent += prefix + line.content + '\n';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const individualPrompt = this.generatePrompt(comment, diffContent);
|
|
108
|
+
return [`## Comment ${index + 1}`, individualPrompt].join('\n');
|
|
109
|
+
});
|
|
110
|
+
return [
|
|
111
|
+
`All Code Review Comments (${comments.length} total)`,
|
|
112
|
+
'='.repeat(50),
|
|
113
|
+
'',
|
|
114
|
+
...prompts,
|
|
115
|
+
].join('\n\n');
|
|
116
|
+
}
|
|
40
117
|
async saveToFile() {
|
|
41
118
|
try {
|
|
42
119
|
await fs.mkdir(dirname(this.filePath), { recursive: true });
|
package/dist/server/git-diff.js
CHANGED
|
@@ -5,11 +5,13 @@ export class GitDiffParser {
|
|
|
5
5
|
}
|
|
6
6
|
async parseDiff(commitish) {
|
|
7
7
|
try {
|
|
8
|
+
// Resolve commitish to actual commit hash
|
|
9
|
+
const resolvedCommit = await this.git.revparse([commitish]);
|
|
8
10
|
const diffSummary = await this.git.diffSummary([`${commitish}^`, commitish]);
|
|
9
11
|
const diffRaw = await this.git.diff([`${commitish}^`, commitish]);
|
|
10
12
|
const files = await this.parseUnifiedDiff(diffRaw, diffSummary.files);
|
|
11
13
|
return {
|
|
12
|
-
commit:
|
|
14
|
+
commit: resolvedCommit,
|
|
13
15
|
files,
|
|
14
16
|
};
|
|
15
17
|
}
|
package/dist/server/server.js
CHANGED
|
@@ -70,6 +70,16 @@ export async function startServer(options) {
|
|
|
70
70
|
res.status(500).json({ error: 'Failed to generate prompt' });
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
+
app.post('/api/comments/all/prompt', async (_, res) => {
|
|
74
|
+
try {
|
|
75
|
+
const comments = await commentStore.getComments();
|
|
76
|
+
const prompt = commentStore.generateAllCommentsPrompt(comments, diffData.files);
|
|
77
|
+
res.json({ prompt });
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
res.status(500).json({ error: 'Failed to generate all comments prompt' });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
73
83
|
// Always runs in production mode when distributed as a CLI tool
|
|
74
84
|
const isProduction = process.env.NODE_ENV === 'production' || process.env.NODE_ENV !== 'development';
|
|
75
85
|
if (isProduction) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "difit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A lightweight command-line tool that spins up a local web server to display Git commit diffs in a GitHub-like Files changed view",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"commander": "^11.1.0",
|
|
38
38
|
"express": "^4.18.2",
|
|
39
|
+
"lucide-react": "^0.525.0",
|
|
39
40
|
"open": "^10.0.3",
|
|
40
41
|
"prism-react-renderer": "^2.4.1",
|
|
41
42
|
"prismjs": "^1.30.0",
|
|
@@ -88,5 +89,5 @@
|
|
|
88
89
|
"publishConfig": {
|
|
89
90
|
"access": "public"
|
|
90
91
|
},
|
|
91
|
-
"packageManager": "pnpm@10.10.0
|
|
92
|
+
"packageManager": "pnpm@10.10.0"
|
|
92
93
|
}
|
package/dist/cli/index.d.ts
DELETED
package/dist/cli/index.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|