@mesadev/agentblame 0.1.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.
- package/dist/blame.d.ts +14 -0
- package/dist/blame.js +252 -0
- package/dist/blame.js.map +1 -0
- package/dist/capture.d.ts +16 -0
- package/dist/capture.js +284 -0
- package/dist/capture.js.map +1 -0
- package/dist/cleanup.d.ts +10 -0
- package/dist/cleanup.js +136 -0
- package/dist/cleanup.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +240 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/db.d.ts +53 -0
- package/dist/lib/db.js +290 -0
- package/dist/lib/db.js.map +1 -0
- package/dist/lib/diff.d.ts +13 -0
- package/dist/lib/diff.js +32 -0
- package/dist/lib/diff.js.map +1 -0
- package/dist/lib/git/gitBlame.d.ts +25 -0
- package/dist/lib/git/gitBlame.js +87 -0
- package/dist/lib/git/gitBlame.js.map +1 -0
- package/dist/lib/git/gitCli.d.ts +17 -0
- package/dist/lib/git/gitCli.js +57 -0
- package/dist/lib/git/gitCli.js.map +1 -0
- package/dist/lib/git/gitConfig.d.ts +20 -0
- package/dist/lib/git/gitConfig.js +91 -0
- package/dist/lib/git/gitConfig.js.map +1 -0
- package/dist/lib/git/gitDiff.d.ts +42 -0
- package/dist/lib/git/gitDiff.js +346 -0
- package/dist/lib/git/gitDiff.js.map +1 -0
- package/dist/lib/git/gitNotes.d.ts +31 -0
- package/dist/lib/git/gitNotes.js +93 -0
- package/dist/lib/git/gitNotes.js.map +1 -0
- package/dist/lib/git/index.d.ts +5 -0
- package/dist/lib/git/index.js +22 -0
- package/dist/lib/git/index.js.map +1 -0
- package/dist/lib/hooks.d.ts +65 -0
- package/dist/lib/hooks.js +423 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.js +33 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/types.d.ts +190 -0
- package/dist/lib/types.js +8 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/util.d.ts +24 -0
- package/dist/lib/util.js +82 -0
- package/dist/lib/util.js.map +1 -0
- package/dist/process.d.ts +14 -0
- package/dist/process.js +224 -0
- package/dist/process.js.map +1 -0
- package/dist/sync.d.ts +15 -0
- package/dist/sync.js +413 -0
- package/dist/sync.js.map +1 -0
- package/dist/transfer-notes.d.ts +16 -0
- package/dist/transfer-notes.js +426 -0
- package/dist/transfer-notes.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Diff Parser
|
|
3
|
+
*
|
|
4
|
+
* Parse git diffs to extract added/deleted content for attribution matching.
|
|
5
|
+
* Includes line-level hashing and move detection.
|
|
6
|
+
*/
|
|
7
|
+
import type { DiffHunk, DeletedBlock, MoveMapping } from "../types";
|
|
8
|
+
/**
|
|
9
|
+
* Get the diff for a specific commit (compared to its parent)
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCommitDiff(repoRoot: string, sha: string): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Get full diff including both additions and deletions (for move detection)
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFullCommitDiff(repoRoot: string, sha: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Parse a unified diff to extract added hunks with line-level data
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseDiff(diffOutput: string): DiffHunk[];
|
|
20
|
+
/**
|
|
21
|
+
* Parse deleted blocks from a diff (for move detection)
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseDeletedBlocks(diffOutput: string): DeletedBlock[];
|
|
24
|
+
/**
|
|
25
|
+
* Detect moved code blocks between deletions and additions
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectMoves(deletedBlocks: DeletedBlock[], addedHunks: DiffHunk[]): MoveMapping[];
|
|
28
|
+
/**
|
|
29
|
+
* Build a line-level move index for quick lookup
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildMoveIndex(moves: MoveMapping[]): Map<string, {
|
|
32
|
+
fromPath: string;
|
|
33
|
+
fromLine: number;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Get parsed diff hunks for a commit with line-level data
|
|
37
|
+
*/
|
|
38
|
+
export declare function getCommitHunks(repoRoot: string, sha: string): Promise<DiffHunk[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Get move mappings for a commit
|
|
41
|
+
*/
|
|
42
|
+
export declare function getCommitMoves(repoRoot: string, sha: string): Promise<MoveMapping[]>;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Git Diff Parser
|
|
4
|
+
*
|
|
5
|
+
* Parse git diffs to extract added/deleted content for attribution matching.
|
|
6
|
+
* Includes line-level hashing and move detection.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getCommitDiff = getCommitDiff;
|
|
10
|
+
exports.getFullCommitDiff = getFullCommitDiff;
|
|
11
|
+
exports.parseDiff = parseDiff;
|
|
12
|
+
exports.parseDeletedBlocks = parseDeletedBlocks;
|
|
13
|
+
exports.detectMoves = detectMoves;
|
|
14
|
+
exports.buildMoveIndex = buildMoveIndex;
|
|
15
|
+
exports.getCommitHunks = getCommitHunks;
|
|
16
|
+
exports.getCommitMoves = getCommitMoves;
|
|
17
|
+
const gitCli_1 = require("./gitCli");
|
|
18
|
+
const util_1 = require("../util");
|
|
19
|
+
// =============================================================================
|
|
20
|
+
// Commit Diff
|
|
21
|
+
// =============================================================================
|
|
22
|
+
/**
|
|
23
|
+
* Get the diff for a specific commit (compared to its parent)
|
|
24
|
+
*/
|
|
25
|
+
async function getCommitDiff(repoRoot, sha) {
|
|
26
|
+
const result = await (0, gitCli_1.runGit)(repoRoot, [
|
|
27
|
+
"diff",
|
|
28
|
+
`${sha}^`,
|
|
29
|
+
sha,
|
|
30
|
+
"--unified=0",
|
|
31
|
+
]);
|
|
32
|
+
if (result.exitCode !== 0) {
|
|
33
|
+
// First commit has no parent, try diffing against empty tree
|
|
34
|
+
const emptyTree = await (0, gitCli_1.runGit)(repoRoot, [
|
|
35
|
+
"diff",
|
|
36
|
+
"4b825dc642cb6eb9a060e54bf8d69288fbee4904", // empty tree hash
|
|
37
|
+
sha,
|
|
38
|
+
"--unified=0",
|
|
39
|
+
]);
|
|
40
|
+
return emptyTree.stdout;
|
|
41
|
+
}
|
|
42
|
+
return result.stdout;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get full diff including both additions and deletions (for move detection)
|
|
46
|
+
*/
|
|
47
|
+
async function getFullCommitDiff(repoRoot, sha) {
|
|
48
|
+
const result = await (0, gitCli_1.runGit)(repoRoot, [
|
|
49
|
+
"diff",
|
|
50
|
+
`${sha}^`,
|
|
51
|
+
sha,
|
|
52
|
+
"--unified=3", // Include context for better move detection
|
|
53
|
+
]);
|
|
54
|
+
if (result.exitCode !== 0) {
|
|
55
|
+
const emptyTree = await (0, gitCli_1.runGit)(repoRoot, [
|
|
56
|
+
"diff",
|
|
57
|
+
"4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
|
58
|
+
sha,
|
|
59
|
+
"--unified=3",
|
|
60
|
+
]);
|
|
61
|
+
return emptyTree.stdout;
|
|
62
|
+
}
|
|
63
|
+
return result.stdout;
|
|
64
|
+
}
|
|
65
|
+
// =============================================================================
|
|
66
|
+
// Diff Parsing
|
|
67
|
+
// =============================================================================
|
|
68
|
+
/**
|
|
69
|
+
* Parse a unified diff to extract added hunks with line-level data
|
|
70
|
+
*/
|
|
71
|
+
function parseDiff(diffOutput) {
|
|
72
|
+
const hunks = [];
|
|
73
|
+
const diffLines = diffOutput.split("\n");
|
|
74
|
+
let currentPath = null;
|
|
75
|
+
let hunkStartLine = 0;
|
|
76
|
+
let currentLineNum = 0;
|
|
77
|
+
let hunkLines = [];
|
|
78
|
+
for (const line of diffLines) {
|
|
79
|
+
// New file header: +++ b/path/to/file
|
|
80
|
+
if (line.startsWith("+++ b/")) {
|
|
81
|
+
// Save previous hunk if exists
|
|
82
|
+
if (currentPath && hunkLines.length > 0) {
|
|
83
|
+
const content = hunkLines.map((l) => l.content).join("\n");
|
|
84
|
+
hunks.push({
|
|
85
|
+
path: currentPath,
|
|
86
|
+
start_line: hunkStartLine,
|
|
87
|
+
end_line: hunkStartLine + hunkLines.length - 1,
|
|
88
|
+
content,
|
|
89
|
+
content_hash: (0, util_1.computeContentHash)(content),
|
|
90
|
+
content_hash_normalized: (0, util_1.computeNormalizedHash)(content),
|
|
91
|
+
lines: hunkLines,
|
|
92
|
+
});
|
|
93
|
+
hunkLines = [];
|
|
94
|
+
}
|
|
95
|
+
currentPath = line.slice(6); // Remove "+++ b/"
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// Hunk header: @@ -old,count +new,count @@
|
|
99
|
+
if (line.startsWith("@@")) {
|
|
100
|
+
// Save previous hunk if exists
|
|
101
|
+
if (currentPath && hunkLines.length > 0) {
|
|
102
|
+
const content = hunkLines.map((l) => l.content).join("\n");
|
|
103
|
+
hunks.push({
|
|
104
|
+
path: currentPath,
|
|
105
|
+
start_line: hunkStartLine,
|
|
106
|
+
end_line: hunkStartLine + hunkLines.length - 1,
|
|
107
|
+
content,
|
|
108
|
+
content_hash: (0, util_1.computeContentHash)(content),
|
|
109
|
+
content_hash_normalized: (0, util_1.computeNormalizedHash)(content),
|
|
110
|
+
lines: hunkLines,
|
|
111
|
+
});
|
|
112
|
+
hunkLines = [];
|
|
113
|
+
}
|
|
114
|
+
// Parse new file line number: @@ -X,Y +Z,W @@
|
|
115
|
+
const match = line.match(/@@ [^+]+ \+(\d+)/);
|
|
116
|
+
if (match) {
|
|
117
|
+
hunkStartLine = parseInt(match[1], 10);
|
|
118
|
+
currentLineNum = hunkStartLine;
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
// Added line (starts with +, but not +++ header)
|
|
123
|
+
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
124
|
+
const content = line.slice(1); // Remove leading +
|
|
125
|
+
hunkLines.push({
|
|
126
|
+
line_number: currentLineNum,
|
|
127
|
+
content,
|
|
128
|
+
hash: (0, util_1.computeContentHash)(content),
|
|
129
|
+
hash_normalized: (0, util_1.computeNormalizedHash)(content),
|
|
130
|
+
});
|
|
131
|
+
currentLineNum++;
|
|
132
|
+
}
|
|
133
|
+
else if (!line.startsWith("-") && !line.startsWith("\\")) {
|
|
134
|
+
// Context line - just increment line number
|
|
135
|
+
currentLineNum++;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Save final hunk
|
|
139
|
+
if (currentPath && hunkLines.length > 0) {
|
|
140
|
+
const content = hunkLines.map((l) => l.content).join("\n");
|
|
141
|
+
hunks.push({
|
|
142
|
+
path: currentPath,
|
|
143
|
+
start_line: hunkStartLine,
|
|
144
|
+
end_line: hunkStartLine + hunkLines.length - 1,
|
|
145
|
+
content,
|
|
146
|
+
content_hash: (0, util_1.computeContentHash)(content),
|
|
147
|
+
content_hash_normalized: (0, util_1.computeNormalizedHash)(content),
|
|
148
|
+
lines: hunkLines,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return hunks;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Parse deleted blocks from a diff (for move detection)
|
|
155
|
+
*/
|
|
156
|
+
function parseDeletedBlocks(diffOutput) {
|
|
157
|
+
const blocks = [];
|
|
158
|
+
const diffLines = diffOutput.split("\n");
|
|
159
|
+
let currentPath = null;
|
|
160
|
+
let deletedLines = [];
|
|
161
|
+
let deleteStartLine = 0;
|
|
162
|
+
let currentOldLine = 0;
|
|
163
|
+
for (const line of diffLines) {
|
|
164
|
+
// File header: --- a/path/to/file
|
|
165
|
+
if (line.startsWith("--- a/")) {
|
|
166
|
+
// Save previous block if exists
|
|
167
|
+
if (currentPath && deletedLines.length >= 3) {
|
|
168
|
+
blocks.push({
|
|
169
|
+
path: currentPath,
|
|
170
|
+
start_line: deleteStartLine,
|
|
171
|
+
lines: deletedLines,
|
|
172
|
+
normalized_content: deletedLines.map((l) => l.trim()).join("\n"),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
currentPath = line.slice(6);
|
|
176
|
+
deletedLines = [];
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
// Hunk header
|
|
180
|
+
if (line.startsWith("@@")) {
|
|
181
|
+
// Save previous block if exists
|
|
182
|
+
if (currentPath && deletedLines.length >= 3) {
|
|
183
|
+
blocks.push({
|
|
184
|
+
path: currentPath,
|
|
185
|
+
start_line: deleteStartLine,
|
|
186
|
+
lines: deletedLines,
|
|
187
|
+
normalized_content: deletedLines.map((l) => l.trim()).join("\n"),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
deletedLines = [];
|
|
191
|
+
// Parse old file line number: @@ -X,Y +Z,W @@
|
|
192
|
+
const match = line.match(/@@ -(\d+)/);
|
|
193
|
+
if (match) {
|
|
194
|
+
currentOldLine = parseInt(match[1], 10);
|
|
195
|
+
deleteStartLine = currentOldLine;
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
// Deleted line
|
|
200
|
+
if (line.startsWith("-") && !line.startsWith("---")) {
|
|
201
|
+
if (deletedLines.length === 0) {
|
|
202
|
+
deleteStartLine = currentOldLine;
|
|
203
|
+
}
|
|
204
|
+
deletedLines.push(line.slice(1));
|
|
205
|
+
currentOldLine++;
|
|
206
|
+
}
|
|
207
|
+
else if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
208
|
+
// Addition breaks the deletion block
|
|
209
|
+
if (currentPath && deletedLines.length >= 3) {
|
|
210
|
+
blocks.push({
|
|
211
|
+
path: currentPath,
|
|
212
|
+
start_line: deleteStartLine,
|
|
213
|
+
lines: deletedLines,
|
|
214
|
+
normalized_content: deletedLines.map((l) => l.trim()).join("\n"),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
deletedLines = [];
|
|
218
|
+
}
|
|
219
|
+
else if (!line.startsWith("\\")) {
|
|
220
|
+
// Context line breaks deletion block
|
|
221
|
+
if (currentPath && deletedLines.length >= 3) {
|
|
222
|
+
blocks.push({
|
|
223
|
+
path: currentPath,
|
|
224
|
+
start_line: deleteStartLine,
|
|
225
|
+
lines: deletedLines,
|
|
226
|
+
normalized_content: deletedLines.map((l) => l.trim()).join("\n"),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
deletedLines = [];
|
|
230
|
+
currentOldLine++;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Save final block
|
|
234
|
+
if (currentPath && deletedLines.length >= 3) {
|
|
235
|
+
blocks.push({
|
|
236
|
+
path: currentPath,
|
|
237
|
+
start_line: deleteStartLine,
|
|
238
|
+
lines: deletedLines,
|
|
239
|
+
normalized_content: deletedLines.map((l) => l.trim()).join("\n"),
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return blocks;
|
|
243
|
+
}
|
|
244
|
+
// =============================================================================
|
|
245
|
+
// Move Detection
|
|
246
|
+
// =============================================================================
|
|
247
|
+
const MOVE_THRESHOLD = 3; // Minimum lines for move detection
|
|
248
|
+
/**
|
|
249
|
+
* Detect moved code blocks between deletions and additions
|
|
250
|
+
*/
|
|
251
|
+
function detectMoves(deletedBlocks, addedHunks) {
|
|
252
|
+
const moves = [];
|
|
253
|
+
for (const deleted of deletedBlocks) {
|
|
254
|
+
if (deleted.lines.length < MOVE_THRESHOLD)
|
|
255
|
+
continue;
|
|
256
|
+
for (const added of addedHunks) {
|
|
257
|
+
if (added.lines.length < MOVE_THRESHOLD)
|
|
258
|
+
continue;
|
|
259
|
+
// Check for matching normalized content
|
|
260
|
+
const addedNormalized = added.lines.map((l) => l.content.trim()).join("\n");
|
|
261
|
+
if (deleted.normalized_content === addedNormalized) {
|
|
262
|
+
moves.push({
|
|
263
|
+
from_path: deleted.path,
|
|
264
|
+
from_start_line: deleted.start_line,
|
|
265
|
+
to_path: added.path,
|
|
266
|
+
to_start_line: added.start_line,
|
|
267
|
+
line_count: deleted.lines.length,
|
|
268
|
+
normalized_content: deleted.normalized_content,
|
|
269
|
+
});
|
|
270
|
+
break; // Only match once
|
|
271
|
+
}
|
|
272
|
+
// Check for partial moves (deleted content is subset of added)
|
|
273
|
+
if (addedNormalized.includes(deleted.normalized_content) &&
|
|
274
|
+
deleted.lines.length >= MOVE_THRESHOLD) {
|
|
275
|
+
// Find where in the added hunk the deleted content starts
|
|
276
|
+
const normalizedLines = deleted.lines.map((l) => l.trim());
|
|
277
|
+
let matchStartIdx = -1;
|
|
278
|
+
for (let i = 0; i <= added.lines.length - deleted.lines.length; i++) {
|
|
279
|
+
let matches = true;
|
|
280
|
+
for (let j = 0; j < deleted.lines.length; j++) {
|
|
281
|
+
if (added.lines[i + j].content.trim() !== normalizedLines[j]) {
|
|
282
|
+
matches = false;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (matches) {
|
|
287
|
+
matchStartIdx = i;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (matchStartIdx >= 0) {
|
|
292
|
+
moves.push({
|
|
293
|
+
from_path: deleted.path,
|
|
294
|
+
from_start_line: deleted.start_line,
|
|
295
|
+
to_path: added.path,
|
|
296
|
+
to_start_line: added.start_line + matchStartIdx,
|
|
297
|
+
line_count: deleted.lines.length,
|
|
298
|
+
normalized_content: deleted.normalized_content,
|
|
299
|
+
});
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return moves;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Build a line-level move index for quick lookup
|
|
309
|
+
*/
|
|
310
|
+
function buildMoveIndex(moves) {
|
|
311
|
+
const index = new Map();
|
|
312
|
+
for (const move of moves) {
|
|
313
|
+
for (let i = 0; i < move.line_count; i++) {
|
|
314
|
+
// Key: normalized content of each line
|
|
315
|
+
const lineContent = move.normalized_content.split("\n")[i];
|
|
316
|
+
if (lineContent) {
|
|
317
|
+
const key = `${move.to_path}:${move.to_start_line + i}`;
|
|
318
|
+
index.set(key, {
|
|
319
|
+
fromPath: move.from_path,
|
|
320
|
+
fromLine: move.from_start_line + i,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return index;
|
|
326
|
+
}
|
|
327
|
+
// =============================================================================
|
|
328
|
+
// Main Entry Points
|
|
329
|
+
// =============================================================================
|
|
330
|
+
/**
|
|
331
|
+
* Get parsed diff hunks for a commit with line-level data
|
|
332
|
+
*/
|
|
333
|
+
async function getCommitHunks(repoRoot, sha) {
|
|
334
|
+
const diffOutput = await getCommitDiff(repoRoot, sha);
|
|
335
|
+
return parseDiff(diffOutput);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get move mappings for a commit
|
|
339
|
+
*/
|
|
340
|
+
async function getCommitMoves(repoRoot, sha) {
|
|
341
|
+
const diffOutput = await getFullCommitDiff(repoRoot, sha);
|
|
342
|
+
const deletedBlocks = parseDeletedBlocks(diffOutput);
|
|
343
|
+
const addedHunks = parseDiff(diffOutput);
|
|
344
|
+
return detectMoves(deletedBlocks, addedHunks);
|
|
345
|
+
}
|
|
346
|
+
//# sourceMappingURL=gitDiff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitDiff.js","sourceRoot":"","sources":["../../../src/lib/git/gitDiff.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAaH,sCAuBC;AAKD,8CAsBC;AASD,8BA4FC;AAKD,gDA4FC;AAWD,kCAkEC;AAKD,wCAoBC;AASD,wCAMC;AAKD,wCAQC;AArYD,qCAAkC;AAClC,kCAAoE;AAGpE,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;GAEG;AACI,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,GAAW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,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Notes Operations
|
|
3
|
+
*
|
|
4
|
+
* Attach and read attribution data from git notes (refs/notes/agentblame)
|
|
5
|
+
*/
|
|
6
|
+
import type { GitNotesAttribution, RangeAttribution } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Attach attribution data as a git note to a commit
|
|
9
|
+
*/
|
|
10
|
+
export declare function attachNote(repoRoot: string, sha: string, attributions: RangeAttribution[]): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Read attribution note from a commit
|
|
13
|
+
*/
|
|
14
|
+
export declare function readNote(repoRoot: string, sha: string): Promise<GitNotesAttribution | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Push notes to remote
|
|
17
|
+
*/
|
|
18
|
+
export declare function pushNotes(repoRoot: string, remote?: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch notes from remote
|
|
21
|
+
*/
|
|
22
|
+
export declare function fetchNotes(repoRoot: string, remote?: string): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetch notes from remote, silently ignoring errors
|
|
25
|
+
* Use this in CLI commands where notes may not exist on remote yet
|
|
26
|
+
*/
|
|
27
|
+
export declare function fetchNotesQuiet(repoRoot: string, remote?: string, verbose?: boolean): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the notes ref name
|
|
30
|
+
*/
|
|
31
|
+
export declare function getNotesRef(): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Git Notes Operations
|
|
4
|
+
*
|
|
5
|
+
* Attach and read attribution data from git notes (refs/notes/agentblame)
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.attachNote = attachNote;
|
|
9
|
+
exports.readNote = readNote;
|
|
10
|
+
exports.pushNotes = pushNotes;
|
|
11
|
+
exports.fetchNotes = fetchNotes;
|
|
12
|
+
exports.fetchNotesQuiet = fetchNotesQuiet;
|
|
13
|
+
exports.getNotesRef = getNotesRef;
|
|
14
|
+
const gitCli_1 = require("./gitCli");
|
|
15
|
+
const NOTES_REF = "refs/notes/agentblame";
|
|
16
|
+
/**
|
|
17
|
+
* Attach attribution data as a git note to a commit
|
|
18
|
+
*/
|
|
19
|
+
async function attachNote(repoRoot, sha, attributions) {
|
|
20
|
+
const note = {
|
|
21
|
+
version: 1,
|
|
22
|
+
timestamp: new Date().toISOString(),
|
|
23
|
+
attributions: attributions.map((a) => ({
|
|
24
|
+
path: a.path,
|
|
25
|
+
start_line: a.start_line,
|
|
26
|
+
end_line: a.end_line,
|
|
27
|
+
category: "ai_generated",
|
|
28
|
+
provider: a.provider,
|
|
29
|
+
model: a.model,
|
|
30
|
+
confidence: a.confidence,
|
|
31
|
+
match_type: a.match_type,
|
|
32
|
+
content_hash: a.content_hash,
|
|
33
|
+
})),
|
|
34
|
+
};
|
|
35
|
+
const noteJson = JSON.stringify(note);
|
|
36
|
+
const result = await (0, gitCli_1.runGit)(repoRoot, ["notes", `--ref=${NOTES_REF}`, "add", "-f", "-m", noteJson, sha], 10000);
|
|
37
|
+
return result.exitCode === 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read attribution note from a commit
|
|
41
|
+
*/
|
|
42
|
+
async function readNote(repoRoot, sha) {
|
|
43
|
+
const result = await (0, gitCli_1.runGit)(repoRoot, ["notes", `--ref=${NOTES_REF}`, "show", sha], 5000);
|
|
44
|
+
if (result.exitCode !== 0)
|
|
45
|
+
return null;
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(result.stdout.trim());
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Push notes to remote
|
|
55
|
+
*/
|
|
56
|
+
async function pushNotes(repoRoot, remote = "origin") {
|
|
57
|
+
const result = await (0, gitCli_1.runGit)(repoRoot, ["push", remote, NOTES_REF], 30000);
|
|
58
|
+
return result.exitCode === 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetch notes from remote
|
|
62
|
+
*/
|
|
63
|
+
async function fetchNotes(repoRoot, remote = "origin") {
|
|
64
|
+
const result = await (0, gitCli_1.runGit)(repoRoot, ["fetch", remote, `${NOTES_REF}:${NOTES_REF}`], 30000);
|
|
65
|
+
return result.exitCode === 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Fetch notes from remote, silently ignoring errors
|
|
69
|
+
* Use this in CLI commands where notes may not exist on remote yet
|
|
70
|
+
*/
|
|
71
|
+
async function fetchNotesQuiet(repoRoot, remote = "origin", verbose = false) {
|
|
72
|
+
if (verbose) {
|
|
73
|
+
console.log("Fetching attribution notes from remote...");
|
|
74
|
+
}
|
|
75
|
+
const result = await (0, gitCli_1.runGit)(repoRoot, ["fetch", remote, `${NOTES_REF}:${NOTES_REF}`], 30000);
|
|
76
|
+
if (result.exitCode === 0) {
|
|
77
|
+
if (verbose) {
|
|
78
|
+
console.log("Notes fetched successfully.\n");
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (verbose) {
|
|
83
|
+
console.log("No remote notes found (this is normal for new repos).\n");
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the notes ref name
|
|
89
|
+
*/
|
|
90
|
+
function getNotesRef() {
|
|
91
|
+
return NOTES_REF;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=gitNotes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitNotes.js","sourceRoot":"","sources":["../../../src/lib/git/gitNotes.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAUH,gCA8BC;AAKD,4BAiBC;AAKD,8BAMC;AAKD,gCAUC;AAMD,0CA0BC;AAKD,kCAEC;AA5HD,qCAAkC;A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C;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./gitCli"), exports);
|
|
18
|
+
__exportStar(require("./gitDiff"), exports);
|
|
19
|
+
__exportStar(require("./gitBlame"), exports);
|
|
20
|
+
__exportStar(require("./gitNotes"), exports);
|
|
21
|
+
__exportStar(require("./gitConfig"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/git/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Installation
|
|
3
|
+
*
|
|
4
|
+
* Install and manage hooks for Cursor and Claude Code.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AGENTBLAME_ROOT: string;
|
|
7
|
+
export declare const AGENTBLAME_HOOKS_DIR: string;
|
|
8
|
+
export declare const AGENTBLAME_LOGS_DIR: string;
|
|
9
|
+
export declare const CURSOR_GENERATED_LOG: string;
|
|
10
|
+
export declare const CLAUDE_GENERATED_LOG: string;
|
|
11
|
+
export declare const CURSOR_HOOKS_CONFIG: string;
|
|
12
|
+
export declare const CLAUDE_SETTINGS_DIR: string;
|
|
13
|
+
export declare const CLAUDE_SETTINGS_FILE: string;
|
|
14
|
+
/**
|
|
15
|
+
* Ensure the ~/.agentblame/ directory structure exists.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ensureAgentBlameDirectories(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Install the Cursor hooks and configure ~/.cursor/hooks.json
|
|
20
|
+
*/
|
|
21
|
+
export declare function installCursorHooks(captureScript?: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Install the Claude Code hooks and configure ~/.claude/settings.json
|
|
24
|
+
*/
|
|
25
|
+
export declare function installClaudeHooks(captureScript?: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if Cursor hooks are installed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function areCursorHooksInstalled(): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if Claude Code hooks are installed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function areClaudeHooksInstalled(): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Install all hooks (Cursor and Claude Code)
|
|
36
|
+
*/
|
|
37
|
+
export declare function installAllHooks(captureScript?: string): Promise<{
|
|
38
|
+
cursor: boolean;
|
|
39
|
+
claude: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Install global git hook via core.hooksPath
|
|
43
|
+
* This makes agentblame work for ALL repos without per-repo setup
|
|
44
|
+
*/
|
|
45
|
+
export declare function installGlobalGitHook(): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Uninstall global git hook
|
|
48
|
+
*/
|
|
49
|
+
export declare function uninstallGlobalGitHook(): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Install git post-commit hook to auto-process commits (per-repo)
|
|
52
|
+
*/
|
|
53
|
+
export declare function installGitHook(repoRoot: string): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Uninstall git post-commit hook
|
|
56
|
+
*/
|
|
57
|
+
export declare function uninstallGitHook(repoRoot: string): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Uninstall Cursor hooks
|
|
60
|
+
*/
|
|
61
|
+
export declare function uninstallCursorHooks(): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Uninstall Claude Code hooks
|
|
64
|
+
*/
|
|
65
|
+
export declare function uninstallClaudeHooks(): Promise<boolean>;
|