midnight-mcp 0.0.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/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/vectorStore.d.ts +66 -0
- package/dist/db/vectorStore.d.ts.map +1 -0
- package/dist/db/vectorStore.js +196 -0
- package/dist/db/vectorStore.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/embeddings.d.ts +25 -0
- package/dist/pipeline/embeddings.d.ts.map +1 -0
- package/dist/pipeline/embeddings.js +103 -0
- package/dist/pipeline/embeddings.js.map +1 -0
- package/dist/pipeline/github.d.ts +67 -0
- package/dist/pipeline/github.d.ts.map +1 -0
- package/dist/pipeline/github.js +287 -0
- package/dist/pipeline/github.js.map +1 -0
- package/dist/pipeline/index.d.ts +11 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +6 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/indexer.d.ts +38 -0
- package/dist/pipeline/indexer.d.ts.map +1 -0
- package/dist/pipeline/indexer.js +222 -0
- package/dist/pipeline/indexer.js.map +1 -0
- package/dist/pipeline/parser.d.ts +46 -0
- package/dist/pipeline/parser.d.ts.map +1 -0
- package/dist/pipeline/parser.js +436 -0
- package/dist/pipeline/parser.js.map +1 -0
- package/dist/pipeline/releases.d.ts +112 -0
- package/dist/pipeline/releases.d.ts.map +1 -0
- package/dist/pipeline/releases.js +298 -0
- package/dist/pipeline/releases.js.map +1 -0
- package/dist/pipeline/repository.d.ts +372 -0
- package/dist/pipeline/repository.d.ts.map +1 -0
- package/dist/pipeline/repository.js +517 -0
- package/dist/pipeline/repository.js.map +1 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +2 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/templates.d.ts +26 -0
- package/dist/prompts/templates.d.ts.map +1 -0
- package/dist/prompts/templates.js +353 -0
- package/dist/prompts/templates.js.map +1 -0
- package/dist/resources/code.d.ts +16 -0
- package/dist/resources/code.d.ts.map +1 -0
- package/dist/resources/code.js +630 -0
- package/dist/resources/code.js.map +1 -0
- package/dist/resources/docs.d.ts +16 -0
- package/dist/resources/docs.d.ts.map +1 -0
- package/dist/resources/docs.js +989 -0
- package/dist/resources/docs.js.map +1 -0
- package/dist/resources/index.d.ts +6 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +13 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/schemas.d.ts +16 -0
- package/dist/resources/schemas.d.ts.map +1 -0
- package/dist/resources/schemas.js +407 -0
- package/dist/resources/schemas.js.map +1 -0
- package/dist/scripts/index-repos.d.ts +12 -0
- package/dist/scripts/index-repos.d.ts.map +1 -0
- package/dist/scripts/index-repos.js +53 -0
- package/dist/scripts/index-repos.js.map +1 -0
- package/dist/server.d.ts +14 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +231 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/analyze.d.ts +140 -0
- package/dist/tools/analyze.d.ts.map +1 -0
- package/dist/tools/analyze.js +270 -0
- package/dist/tools/analyze.js.map +1 -0
- package/dist/tools/index.d.ts +392 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/repository.d.ts +537 -0
- package/dist/tools/repository.d.ts.map +1 -0
- package/dist/tools/repository.js +654 -0
- package/dist/tools/repository.js.map +1 -0
- package/dist/tools/search.d.ts +204 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +210 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/utils/config.d.ts +66 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +161 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +43 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { RepositoryConfig } from "../utils/index.js";
|
|
2
|
+
export interface GitHubFile {
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
sha: string;
|
|
6
|
+
size: number;
|
|
7
|
+
encoding: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GitHubCommit {
|
|
10
|
+
sha: string;
|
|
11
|
+
message: string;
|
|
12
|
+
author: string;
|
|
13
|
+
date: string;
|
|
14
|
+
url: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RepositoryInfo {
|
|
17
|
+
owner: string;
|
|
18
|
+
repo: string;
|
|
19
|
+
branch: string;
|
|
20
|
+
lastCommit: GitHubCommit | null;
|
|
21
|
+
fileCount: number;
|
|
22
|
+
}
|
|
23
|
+
export declare class GitHubClient {
|
|
24
|
+
private octokit;
|
|
25
|
+
private fileCache;
|
|
26
|
+
private treeCache;
|
|
27
|
+
private repoInfoCache;
|
|
28
|
+
constructor(token?: string);
|
|
29
|
+
/**
|
|
30
|
+
* Get repository information
|
|
31
|
+
*/
|
|
32
|
+
getRepositoryInfo(owner: string, repo: string): Promise<RepositoryInfo>;
|
|
33
|
+
/**
|
|
34
|
+
* Get file content from a repository
|
|
35
|
+
*/
|
|
36
|
+
getFileContent(owner: string, repo: string, path: string, ref?: string): Promise<GitHubFile | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Get repository tree (list of all files)
|
|
39
|
+
*/
|
|
40
|
+
getRepositoryTree(owner: string, repo: string, ref?: string): Promise<string[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Filter files by patterns
|
|
43
|
+
*/
|
|
44
|
+
filterFilesByPatterns(files: string[], patterns: string[], exclude: string[]): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Fetch all files from a repository matching patterns
|
|
47
|
+
*/
|
|
48
|
+
fetchRepositoryFiles(repoConfig: RepositoryConfig): Promise<GitHubFile[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Get recent commits
|
|
51
|
+
*/
|
|
52
|
+
getRecentCommits(owner: string, repo: string, since?: string, perPage?: number): Promise<GitHubCommit[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Get files changed in recent commits
|
|
55
|
+
*/
|
|
56
|
+
getChangedFiles(owner: string, repo: string, since: string): Promise<string[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Search code in repositories
|
|
59
|
+
*/
|
|
60
|
+
searchCode(query: string, owner?: string, repo?: string, language?: string): Promise<Array<{
|
|
61
|
+
path: string;
|
|
62
|
+
repository: string;
|
|
63
|
+
url: string;
|
|
64
|
+
}>>;
|
|
65
|
+
}
|
|
66
|
+
export declare const githubClient: GitHubClient;
|
|
67
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/pipeline/github.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAmCrE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAA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AAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,EAAE,CAAC;IA4BpB;;OAEG;IACG,UAAU,CACd,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CA6BrE;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { Octokit } from "octokit";
|
|
2
|
+
import { config, logger } from "../utils/index.js";
|
|
3
|
+
class SimpleCache {
|
|
4
|
+
cache = new Map();
|
|
5
|
+
ttlMs;
|
|
6
|
+
constructor(ttlMinutes = 10) {
|
|
7
|
+
this.ttlMs = ttlMinutes * 60 * 1000;
|
|
8
|
+
}
|
|
9
|
+
get(key) {
|
|
10
|
+
const entry = this.cache.get(key);
|
|
11
|
+
if (!entry)
|
|
12
|
+
return null;
|
|
13
|
+
if (Date.now() - entry.timestamp > this.ttlMs) {
|
|
14
|
+
this.cache.delete(key);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return entry.data;
|
|
18
|
+
}
|
|
19
|
+
set(key, data) {
|
|
20
|
+
this.cache.set(key, { data, timestamp: Date.now() });
|
|
21
|
+
}
|
|
22
|
+
clear() {
|
|
23
|
+
this.cache.clear();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class GitHubClient {
|
|
27
|
+
octokit;
|
|
28
|
+
fileCache = new SimpleCache(15); // 15 min cache for files
|
|
29
|
+
treeCache = new SimpleCache(10); // 10 min cache for trees
|
|
30
|
+
repoInfoCache = new SimpleCache(10); // 10 min cache for repo info
|
|
31
|
+
constructor(token) {
|
|
32
|
+
this.octokit = new Octokit({
|
|
33
|
+
auth: token || config.githubToken,
|
|
34
|
+
request: {
|
|
35
|
+
timeout: 10000, // 10 second timeout for API calls
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get repository information
|
|
41
|
+
*/
|
|
42
|
+
async getRepositoryInfo(owner, repo) {
|
|
43
|
+
const cacheKey = `repo:${owner}/${repo}`;
|
|
44
|
+
const cached = this.repoInfoCache.get(cacheKey);
|
|
45
|
+
if (cached) {
|
|
46
|
+
logger.debug(`Cache hit for repo info: ${cacheKey}`);
|
|
47
|
+
return cached;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const { data: repoData } = await this.octokit.rest.repos.get({
|
|
51
|
+
owner,
|
|
52
|
+
repo,
|
|
53
|
+
});
|
|
54
|
+
const { data: commits } = await this.octokit.rest.repos.listCommits({
|
|
55
|
+
owner,
|
|
56
|
+
repo,
|
|
57
|
+
per_page: 1,
|
|
58
|
+
});
|
|
59
|
+
const lastCommit = commits[0]
|
|
60
|
+
? {
|
|
61
|
+
sha: commits[0].sha,
|
|
62
|
+
message: commits[0].commit.message,
|
|
63
|
+
author: commits[0].commit.author?.name || "Unknown",
|
|
64
|
+
date: commits[0].commit.author?.date || "",
|
|
65
|
+
url: commits[0].html_url,
|
|
66
|
+
}
|
|
67
|
+
: null;
|
|
68
|
+
const result = {
|
|
69
|
+
owner,
|
|
70
|
+
repo,
|
|
71
|
+
branch: repoData.default_branch,
|
|
72
|
+
lastCommit,
|
|
73
|
+
fileCount: 0, // Will be updated during tree fetch
|
|
74
|
+
};
|
|
75
|
+
this.repoInfoCache.set(cacheKey, result);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
logger.error(`Failed to get repository info for ${owner}/${repo}`, {
|
|
80
|
+
error: String(error),
|
|
81
|
+
});
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get file content from a repository
|
|
87
|
+
*/
|
|
88
|
+
async getFileContent(owner, repo, path, ref) {
|
|
89
|
+
const cacheKey = `file:${owner}/${repo}/${path}@${ref || "main"}`;
|
|
90
|
+
const cached = this.fileCache.get(cacheKey);
|
|
91
|
+
if (cached) {
|
|
92
|
+
logger.debug(`Cache hit for file: ${cacheKey}`);
|
|
93
|
+
return cached;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const { data } = await this.octokit.rest.repos.getContent({
|
|
97
|
+
owner,
|
|
98
|
+
repo,
|
|
99
|
+
path,
|
|
100
|
+
ref,
|
|
101
|
+
});
|
|
102
|
+
if (Array.isArray(data) || data.type !== "file") {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const content = data.encoding === "base64"
|
|
106
|
+
? Buffer.from(data.content, "base64").toString("utf-8")
|
|
107
|
+
: data.content;
|
|
108
|
+
const result = {
|
|
109
|
+
path: data.path,
|
|
110
|
+
content,
|
|
111
|
+
sha: data.sha,
|
|
112
|
+
size: data.size,
|
|
113
|
+
encoding: data.encoding,
|
|
114
|
+
};
|
|
115
|
+
this.fileCache.set(cacheKey, result);
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
logger.warn(`Failed to get file ${path} from ${owner}/${repo}`, {
|
|
120
|
+
error: String(error),
|
|
121
|
+
});
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get repository tree (list of all files)
|
|
127
|
+
*/
|
|
128
|
+
async getRepositoryTree(owner, repo, ref) {
|
|
129
|
+
const cacheKey = `tree:${owner}/${repo}@${ref || "main"}`;
|
|
130
|
+
const cached = this.treeCache.get(cacheKey);
|
|
131
|
+
if (cached) {
|
|
132
|
+
logger.debug(`Cache hit for tree: ${cacheKey}`);
|
|
133
|
+
return cached;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const { data: refData } = await this.octokit.rest.git.getRef({
|
|
137
|
+
owner,
|
|
138
|
+
repo,
|
|
139
|
+
ref: `heads/${ref || "main"}`,
|
|
140
|
+
});
|
|
141
|
+
const { data: treeData } = await this.octokit.rest.git.getTree({
|
|
142
|
+
owner,
|
|
143
|
+
repo,
|
|
144
|
+
tree_sha: refData.object.sha,
|
|
145
|
+
recursive: "true",
|
|
146
|
+
});
|
|
147
|
+
const result = treeData.tree
|
|
148
|
+
.filter((item) => item.type === "blob" && item.path)
|
|
149
|
+
.map((item) => item.path);
|
|
150
|
+
this.treeCache.set(cacheKey, result);
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
logger.error(`Failed to get repository tree for ${owner}/${repo}`, {
|
|
155
|
+
error: String(error),
|
|
156
|
+
});
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Filter files by patterns
|
|
162
|
+
*/
|
|
163
|
+
filterFilesByPatterns(files, patterns, exclude) {
|
|
164
|
+
const matchPattern = (file, pattern) => {
|
|
165
|
+
// Convert glob pattern to regex
|
|
166
|
+
const regexPattern = pattern
|
|
167
|
+
.replace(/\*\*/g, ".*")
|
|
168
|
+
.replace(/\*/g, "[^/]*")
|
|
169
|
+
.replace(/\./g, "\\.");
|
|
170
|
+
return new RegExp(`^${regexPattern}$`).test(file);
|
|
171
|
+
};
|
|
172
|
+
return files.filter((file) => {
|
|
173
|
+
const matchesInclude = patterns.some((p) => matchPattern(file, p));
|
|
174
|
+
const matchesExclude = exclude.some((p) => matchPattern(file, p));
|
|
175
|
+
return matchesInclude && !matchesExclude;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Fetch all files from a repository matching patterns
|
|
180
|
+
*/
|
|
181
|
+
async fetchRepositoryFiles(repoConfig) {
|
|
182
|
+
const { owner, repo, branch, patterns, exclude } = repoConfig;
|
|
183
|
+
logger.info(`Fetching files from ${owner}/${repo}...`);
|
|
184
|
+
const allFiles = await this.getRepositoryTree(owner, repo, branch);
|
|
185
|
+
const filteredFiles = this.filterFilesByPatterns(allFiles, patterns, exclude);
|
|
186
|
+
logger.info(`Found ${filteredFiles.length} matching files in ${owner}/${repo}`);
|
|
187
|
+
const files = [];
|
|
188
|
+
for (const filePath of filteredFiles) {
|
|
189
|
+
const file = await this.getFileContent(owner, repo, filePath, branch);
|
|
190
|
+
if (file) {
|
|
191
|
+
files.push(file);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return files;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get recent commits
|
|
198
|
+
*/
|
|
199
|
+
async getRecentCommits(owner, repo, since, perPage = 30) {
|
|
200
|
+
try {
|
|
201
|
+
const params = {
|
|
202
|
+
owner,
|
|
203
|
+
repo,
|
|
204
|
+
per_page: perPage,
|
|
205
|
+
};
|
|
206
|
+
if (since) {
|
|
207
|
+
params.since = since;
|
|
208
|
+
}
|
|
209
|
+
const { data } = await this.octokit.rest.repos.listCommits(params);
|
|
210
|
+
return data.map((commit) => ({
|
|
211
|
+
sha: commit.sha,
|
|
212
|
+
message: commit.commit.message,
|
|
213
|
+
author: commit.commit.author?.name || "Unknown",
|
|
214
|
+
date: commit.commit.author?.date || "",
|
|
215
|
+
url: commit.html_url,
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
logger.error(`Failed to get commits for ${owner}/${repo}`, {
|
|
220
|
+
error: String(error),
|
|
221
|
+
});
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get files changed in recent commits
|
|
227
|
+
*/
|
|
228
|
+
async getChangedFiles(owner, repo, since) {
|
|
229
|
+
try {
|
|
230
|
+
const commits = await this.getRecentCommits(owner, repo, since);
|
|
231
|
+
const changedFiles = new Set();
|
|
232
|
+
for (const commit of commits) {
|
|
233
|
+
const { data } = await this.octokit.rest.repos.getCommit({
|
|
234
|
+
owner,
|
|
235
|
+
repo,
|
|
236
|
+
ref: commit.sha,
|
|
237
|
+
});
|
|
238
|
+
data.files?.forEach((file) => {
|
|
239
|
+
if (file.filename) {
|
|
240
|
+
changedFiles.add(file.filename);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return Array.from(changedFiles);
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
logger.error(`Failed to get changed files for ${owner}/${repo}`, {
|
|
248
|
+
error: String(error),
|
|
249
|
+
});
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Search code in repositories
|
|
255
|
+
*/
|
|
256
|
+
async searchCode(query, owner, repo, language) {
|
|
257
|
+
try {
|
|
258
|
+
let q = query;
|
|
259
|
+
if (owner && repo) {
|
|
260
|
+
q += ` repo:${owner}/${repo}`;
|
|
261
|
+
}
|
|
262
|
+
else if (owner) {
|
|
263
|
+
q += ` user:${owner}`;
|
|
264
|
+
}
|
|
265
|
+
if (language) {
|
|
266
|
+
q += ` language:${language}`;
|
|
267
|
+
}
|
|
268
|
+
const { data } = await this.octokit.rest.search.code({
|
|
269
|
+
q,
|
|
270
|
+
per_page: 30,
|
|
271
|
+
});
|
|
272
|
+
return data.items.map((item) => ({
|
|
273
|
+
path: item.path,
|
|
274
|
+
repository: item.repository.full_name,
|
|
275
|
+
url: item.html_url,
|
|
276
|
+
}));
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
logger.warn(`Code search failed for query: ${query}`, {
|
|
280
|
+
error: String(error),
|
|
281
|
+
});
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
export const githubClient = new GitHubClient();
|
|
287
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot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AAa,QAAQ,EAAE,CAAC;YAC/B,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBACnD,CAAC;gBACD,QAAQ,EAAE,EAAE;aACb,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC/B,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS;gBACrC,GAAG,EAAE,IAAI,CAAC,QAAQ;aACnB,CAAC,CAAC,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,iCAAiC,KAAK,EAAE,EAAE;gBACpD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;aACrB,CAAC,CAAC;YACH,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { GitHubClient, githubClient } from "./github.js";
|
|
2
|
+
export type { GitHubFile, GitHubCommit, RepositoryInfo } from "./github.js";
|
|
3
|
+
export { parseFile, parseCompactFile, parseTypeScriptFile, parseMarkdownFile, } from "./parser.js";
|
|
4
|
+
export type { ParsedFile, CodeUnit } from "./parser.js";
|
|
5
|
+
export { EmbeddingGenerator, embeddingGenerator } from "./embeddings.js";
|
|
6
|
+
export type { EmbeddingResult } from "./embeddings.js";
|
|
7
|
+
export { indexRepository, indexAllRepositories, incrementalUpdate, } from "./indexer.js";
|
|
8
|
+
export type { IndexStats } from "./indexer.js";
|
|
9
|
+
export { ReleaseTracker, releaseTracker } from "./releases.js";
|
|
10
|
+
export type { Release, ChangelogEntry, VersionInfo } from "./releases.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipeline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { GitHubClient, githubClient } from "./github.js";
|
|
2
|
+
export { parseFile, parseCompactFile, parseTypeScriptFile, parseMarkdownFile, } from "./parser.js";
|
|
3
|
+
export { EmbeddingGenerator, embeddingGenerator } from "./embeddings.js";
|
|
4
|
+
export { indexRepository, indexAllRepositories, incrementalUpdate, } from "./indexer.js";
|
|
5
|
+
export { ReleaseTracker, releaseTracker } from "./releases.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pipeline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RepositoryConfig } from "../utils/index.js";
|
|
2
|
+
export interface IndexStats {
|
|
3
|
+
totalFiles: number;
|
|
4
|
+
totalChunks: number;
|
|
5
|
+
totalCodeUnits: number;
|
|
6
|
+
repositoriesIndexed: string[];
|
|
7
|
+
lastIndexed: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChunkMetadata {
|
|
10
|
+
repository: string;
|
|
11
|
+
filePath: string;
|
|
12
|
+
language: string;
|
|
13
|
+
chunkType: "code_unit" | "file_chunk";
|
|
14
|
+
codeUnitType?: string;
|
|
15
|
+
codeUnitName?: string;
|
|
16
|
+
startLine: number;
|
|
17
|
+
endLine: number;
|
|
18
|
+
isPublic: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Index a single repository
|
|
22
|
+
*/
|
|
23
|
+
export declare function indexRepository(repoConfig: RepositoryConfig): Promise<{
|
|
24
|
+
fileCount: number;
|
|
25
|
+
chunkCount: number;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Index all configured repositories
|
|
29
|
+
*/
|
|
30
|
+
export declare function indexAllRepositories(): Promise<IndexStats>;
|
|
31
|
+
/**
|
|
32
|
+
* Incremental update - only index changed files
|
|
33
|
+
*/
|
|
34
|
+
export declare function incrementalUpdate(repoConfig: RepositoryConfig, since: string): Promise<{
|
|
35
|
+
fileCount: number;
|
|
36
|
+
chunkCount: number;
|
|
37
|
+
}>;
|
|
38
|
+
//# sourceMappingURL=indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../src/pipeline/indexer.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,WAAW,GAAG,YAAY,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAsFD;;GAEG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CA6DpD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,CA0BhE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAiFpD"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { githubClient } from "./github.js";
|
|
2
|
+
import { parseFile } from "./parser.js";
|
|
3
|
+
import { embeddingGenerator } from "./embeddings.js";
|
|
4
|
+
import { vectorStore } from "../db/vectorStore.js";
|
|
5
|
+
import { logger, DEFAULT_REPOSITORIES, } from "../utils/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Create chunks from a parsed file
|
|
8
|
+
* Uses intelligent chunking based on code structure
|
|
9
|
+
*/
|
|
10
|
+
function createChunks(file, repository) {
|
|
11
|
+
const chunks = [];
|
|
12
|
+
// Add code units as individual chunks
|
|
13
|
+
for (const unit of file.codeUnits) {
|
|
14
|
+
chunks.push({
|
|
15
|
+
text: unit.code,
|
|
16
|
+
metadata: {
|
|
17
|
+
repository,
|
|
18
|
+
filePath: file.path,
|
|
19
|
+
language: file.language,
|
|
20
|
+
chunkType: "code_unit",
|
|
21
|
+
codeUnitType: unit.type,
|
|
22
|
+
codeUnitName: unit.name,
|
|
23
|
+
startLine: unit.startLine,
|
|
24
|
+
endLine: unit.endLine,
|
|
25
|
+
isPublic: unit.isPublic,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// If no code units were extracted, chunk the entire file
|
|
30
|
+
if (file.codeUnits.length === 0 && file.content.length > 0) {
|
|
31
|
+
const chunkSize = 2000; // characters
|
|
32
|
+
const overlapLines = 5; // lines to overlap
|
|
33
|
+
const lines = file.content.split("\n");
|
|
34
|
+
let currentChunk = "";
|
|
35
|
+
let startLine = 1;
|
|
36
|
+
let currentLine = 1;
|
|
37
|
+
for (const line of lines) {
|
|
38
|
+
if (currentChunk.length + line.length > chunkSize &&
|
|
39
|
+
currentChunk.length > 0) {
|
|
40
|
+
chunks.push({
|
|
41
|
+
text: currentChunk,
|
|
42
|
+
metadata: {
|
|
43
|
+
repository,
|
|
44
|
+
filePath: file.path,
|
|
45
|
+
language: file.language,
|
|
46
|
+
chunkType: "file_chunk",
|
|
47
|
+
startLine,
|
|
48
|
+
endLine: currentLine - 1,
|
|
49
|
+
isPublic: true,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
// Start new chunk with overlap
|
|
53
|
+
const prevLines = currentChunk.split("\n").slice(-overlapLines);
|
|
54
|
+
currentChunk = prevLines.join("\n") + "\n";
|
|
55
|
+
startLine = Math.max(1, currentLine - overlapLines);
|
|
56
|
+
}
|
|
57
|
+
currentChunk += line + "\n";
|
|
58
|
+
currentLine++;
|
|
59
|
+
}
|
|
60
|
+
// Add remaining content
|
|
61
|
+
if (currentChunk.trim().length > 0) {
|
|
62
|
+
chunks.push({
|
|
63
|
+
text: currentChunk,
|
|
64
|
+
metadata: {
|
|
65
|
+
repository,
|
|
66
|
+
filePath: file.path,
|
|
67
|
+
language: file.language,
|
|
68
|
+
chunkType: "file_chunk",
|
|
69
|
+
startLine,
|
|
70
|
+
endLine: currentLine - 1,
|
|
71
|
+
isPublic: true,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return chunks;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Index a single repository
|
|
80
|
+
*/
|
|
81
|
+
export async function indexRepository(repoConfig) {
|
|
82
|
+
const repoName = `${repoConfig.owner}/${repoConfig.repo}`;
|
|
83
|
+
logger.info(`Starting index for ${repoName}...`);
|
|
84
|
+
try {
|
|
85
|
+
// Fetch all files from the repository
|
|
86
|
+
const files = await githubClient.fetchRepositoryFiles(repoConfig);
|
|
87
|
+
logger.info(`Fetched ${files.length} files from ${repoName}`);
|
|
88
|
+
let chunkCount = 0;
|
|
89
|
+
const documents = [];
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
// Parse the file
|
|
92
|
+
const parsed = parseFile(file.path, file.content);
|
|
93
|
+
// Create chunks
|
|
94
|
+
const chunks = createChunks(parsed, repoName);
|
|
95
|
+
for (const chunk of chunks) {
|
|
96
|
+
documents.push({
|
|
97
|
+
id: `${repoName}:${file.path}:${chunk.metadata.startLine}`,
|
|
98
|
+
content: chunk.text,
|
|
99
|
+
metadata: {
|
|
100
|
+
repository: chunk.metadata.repository,
|
|
101
|
+
filePath: chunk.metadata.filePath,
|
|
102
|
+
language: chunk.metadata.language,
|
|
103
|
+
startLine: chunk.metadata.startLine,
|
|
104
|
+
endLine: chunk.metadata.endLine,
|
|
105
|
+
codeType: chunk.metadata.codeUnitType || "unknown",
|
|
106
|
+
codeName: chunk.metadata.codeUnitName || "",
|
|
107
|
+
isPublic: chunk.metadata.isPublic,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
chunkCount++;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Generate embeddings and store in vector database
|
|
114
|
+
if (documents.length > 0) {
|
|
115
|
+
logger.info(`Generating embeddings for ${documents.length} chunks...`);
|
|
116
|
+
const texts = documents.map((d) => d.content);
|
|
117
|
+
const embeddings = await embeddingGenerator.generateEmbeddings(texts);
|
|
118
|
+
// Add embeddings to documents
|
|
119
|
+
for (let i = 0; i < documents.length; i++) {
|
|
120
|
+
documents[i].embedding = embeddings[i].embedding;
|
|
121
|
+
}
|
|
122
|
+
// Store in vector database
|
|
123
|
+
await vectorStore.addDocuments(documents);
|
|
124
|
+
logger.info(`Stored ${documents.length} documents in vector store`);
|
|
125
|
+
}
|
|
126
|
+
return { fileCount: files.length, chunkCount };
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
logger.error(`Failed to index repository ${repoName}`, {
|
|
130
|
+
error: String(error),
|
|
131
|
+
});
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Index all configured repositories
|
|
137
|
+
*/
|
|
138
|
+
export async function indexAllRepositories() {
|
|
139
|
+
logger.info("Starting full index of all repositories...");
|
|
140
|
+
const stats = {
|
|
141
|
+
totalFiles: 0,
|
|
142
|
+
totalChunks: 0,
|
|
143
|
+
totalCodeUnits: 0,
|
|
144
|
+
repositoriesIndexed: [],
|
|
145
|
+
lastIndexed: new Date().toISOString(),
|
|
146
|
+
};
|
|
147
|
+
for (const repoConfig of DEFAULT_REPOSITORIES) {
|
|
148
|
+
try {
|
|
149
|
+
const { fileCount, chunkCount } = await indexRepository(repoConfig);
|
|
150
|
+
stats.totalFiles += fileCount;
|
|
151
|
+
stats.totalChunks += chunkCount;
|
|
152
|
+
stats.repositoriesIndexed.push(`${repoConfig.owner}/${repoConfig.repo}`);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
logger.error(`Failed to index ${repoConfig.owner}/${repoConfig.repo}`, {
|
|
156
|
+
error: String(error),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
logger.info("Indexing complete", stats);
|
|
161
|
+
return stats;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Incremental update - only index changed files
|
|
165
|
+
*/
|
|
166
|
+
export async function incrementalUpdate(repoConfig, since) {
|
|
167
|
+
const repoName = `${repoConfig.owner}/${repoConfig.repo}`;
|
|
168
|
+
logger.info(`Starting incremental update for ${repoName} since ${since}...`);
|
|
169
|
+
try {
|
|
170
|
+
// Get changed files
|
|
171
|
+
const changedPaths = await githubClient.getChangedFiles(repoConfig.owner, repoConfig.repo, since);
|
|
172
|
+
// Filter by patterns
|
|
173
|
+
const filteredPaths = githubClient.filterFilesByPatterns(changedPaths, repoConfig.patterns, repoConfig.exclude);
|
|
174
|
+
logger.info(`Found ${filteredPaths.length} changed files matching patterns`);
|
|
175
|
+
let chunkCount = 0;
|
|
176
|
+
const documents = [];
|
|
177
|
+
for (const filePath of filteredPaths) {
|
|
178
|
+
// Delete existing documents for this file
|
|
179
|
+
await vectorStore.deleteByPath(repoName, filePath);
|
|
180
|
+
// Fetch new content
|
|
181
|
+
const file = await githubClient.getFileContent(repoConfig.owner, repoConfig.repo, filePath, repoConfig.branch);
|
|
182
|
+
if (file) {
|
|
183
|
+
const parsed = parseFile(file.path, file.content);
|
|
184
|
+
const chunks = createChunks(parsed, repoName);
|
|
185
|
+
for (const chunk of chunks) {
|
|
186
|
+
documents.push({
|
|
187
|
+
id: `${repoName}:${filePath}:${chunk.metadata.startLine}`,
|
|
188
|
+
content: chunk.text,
|
|
189
|
+
metadata: {
|
|
190
|
+
repository: chunk.metadata.repository,
|
|
191
|
+
filePath: chunk.metadata.filePath,
|
|
192
|
+
language: chunk.metadata.language,
|
|
193
|
+
startLine: chunk.metadata.startLine,
|
|
194
|
+
endLine: chunk.metadata.endLine,
|
|
195
|
+
codeType: chunk.metadata.codeUnitType || "unknown",
|
|
196
|
+
codeName: chunk.metadata.codeUnitName || "",
|
|
197
|
+
isPublic: chunk.metadata.isPublic,
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
chunkCount++;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// Generate embeddings and store
|
|
205
|
+
if (documents.length > 0) {
|
|
206
|
+
const texts = documents.map((d) => d.content);
|
|
207
|
+
const embeddings = await embeddingGenerator.generateEmbeddings(texts);
|
|
208
|
+
for (let i = 0; i < documents.length; i++) {
|
|
209
|
+
documents[i].embedding = embeddings[i].embedding;
|
|
210
|
+
}
|
|
211
|
+
await vectorStore.addDocuments(documents);
|
|
212
|
+
}
|
|
213
|
+
return { fileCount: filteredPaths.length, chunkCount };
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
logger.error(`Failed incremental update for ${repoName}`, {
|
|
217
|
+
error: String(error),
|
|
218
|
+
});
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=indexer.js.map
|