-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.ts
More file actions
123 lines (113 loc) · 3.7 KB
/
Copy pathgit.ts
File metadata and controls
123 lines (113 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import type { IndexingState } from "../../engine/interfaces/index.js"
import type { Event, EmitterDisposable } from "@shofer/types"
/**
* A parsed commit message segment ready for embedding and storage.
*/
export interface GitCommitBlock {
/** Full SHA commit hash */
commit_hash: string
/** 7-char abbreviated hash */
short_hash: string
/** "Name <email>" formatted author */
author: string
/** ISO 8601 author date */
author_date: string
/** First line of commit message */
subject: string
/** Remaining lines of commit message (may be empty) */
body: string
/** subject + "\n\n" + body — what gets embedded */
content: string
/** SHA-256 of content (for cache skipping) */
contentHash: string
}
/**
* Returned by git history search.
*/
export interface GitSearchResult {
id: string | number
score: number
payload: {
commit_hash: string
short_hash: string
author: string
author_date: string
subject: string
body: string
}
}
/**
* Extracts commit history from the git repository.
*/
export interface IGitLogExtractor {
/**
* Extract commits from the git repository at `workspacePath`.
*
* @param workspacePath - Path to the git repository root
* @param maxHistoryDays - Maximum number of days of history to extract
* @param maxCommits - Hard cap on number of commits to extract
* @param branch - Git ref (branch name) to index; empty string = HEAD
* @returns Array of parsed commit blocks
*/
extractCommits(
workspacePath: string,
maxHistoryDays: number,
maxCommits: number,
branch: string,
): Promise<GitCommitBlock[]>
/**
* Extract commits since a specific ISO 8601 date (for incremental indexing).
*
* @param workspacePath - Path to the git repository root
* @param sinceDate - ISO 8601 date string (e.g. "2024-01-01T00:00:00+00:00")
* @param maxCommits - Hard cap on number of commits returned (safety ceiling)
* @param branch - Git ref (branch name) to index; empty string = HEAD
* @returns Array of parsed commit blocks since the given date
*/
extractCommitsSince(
workspacePath: string,
sinceDate: string,
maxCommits: number,
branch: string,
): Promise<GitCommitBlock[]>
}
/**
* Watches for new commits to incrementally index.
*
* Phase 2: polls `git log --since=<last-indexed-date>` every N minutes.
*/
export interface IGitWatcher extends EmitterDisposable {
/**
* Start polling for new commits.
* @param getLastCommitDate - Lazy getter for the ISO 8601 date of the most
* recent indexed commit. Called on each poll tick so the watcher always
* uses the freshest boundary.
* @param getBranch - Lazy getter for the configured git ref (branch name).
* Called on each poll tick so changes to the `codebaseIndexGitBranch`
* setting take effect on the next tick without restarting the watcher.
* Empty string = HEAD. Applied to the parent repo only — submodules are
* always polled with their own HEAD.
*/
start(getLastCommitDate: () => string | undefined, getBranch: () => string): void
/** Stop polling. */
stop(): void
/** Whether the watcher is currently running. */
readonly isRunning: boolean
/** Event emitted when new commits are discovered. */
readonly onNewCommits: Event<GitCommitBlock[]>
}
/**
* Service that embeds a query and searches the git Qdrant collection.
*/
export interface IGitSearchService {
/**
* Search git commit history by semantic similarity.
*
* @param query - Natural language search query
* @param minScore - Minimum cosine similarity threshold
* @param maxResults - Maximum number of results to return
* @returns Array of search results sorted by descending score
*/
search(query: string, minScore: number, maxResults: number): Promise<GitSearchResult[]>
}
export type { IndexingState }