@pratik7368patil/anchor-core 0.1.6 → 0.1.7
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/index.d.ts +96 -2
- package/dist/index.js +608 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/db/schema.sql +44 -0
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,35 @@ type WisdomUnit = {
|
|
|
19
19
|
mergedAt?: string;
|
|
20
20
|
confidence: number;
|
|
21
21
|
};
|
|
22
|
+
type CodeFileRecord = {
|
|
23
|
+
repo: string;
|
|
24
|
+
path: string;
|
|
25
|
+
language?: string;
|
|
26
|
+
sizeBytes: number;
|
|
27
|
+
contentHash: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
};
|
|
30
|
+
type CodeChunk = {
|
|
31
|
+
id: string;
|
|
32
|
+
repo: string;
|
|
33
|
+
filePath: string;
|
|
34
|
+
language?: string;
|
|
35
|
+
startLine: number;
|
|
36
|
+
endLine: number;
|
|
37
|
+
sanitizedText: string;
|
|
38
|
+
symbols: string[];
|
|
39
|
+
contentHash: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
};
|
|
42
|
+
type RankedCodeChunk = CodeChunk & {
|
|
43
|
+
score: number;
|
|
44
|
+
scoreParts: {
|
|
45
|
+
filePathMatch: number;
|
|
46
|
+
symbolMatch: number;
|
|
47
|
+
textMatch: number;
|
|
48
|
+
recency: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
22
51
|
type PullRequestFile = {
|
|
23
52
|
filename: string;
|
|
24
53
|
patch?: string | null;
|
|
@@ -108,6 +137,28 @@ type IndexPullRequestsProgress = {
|
|
|
108
137
|
prNumber: number;
|
|
109
138
|
wisdomUnitsCreated: number;
|
|
110
139
|
};
|
|
140
|
+
type CodeIndexProgress = {
|
|
141
|
+
stage: "discovering_code_files";
|
|
142
|
+
repo: string;
|
|
143
|
+
} | {
|
|
144
|
+
stage: "discovered_code_files";
|
|
145
|
+
repo: string;
|
|
146
|
+
files: number;
|
|
147
|
+
skippedFiles: number;
|
|
148
|
+
} | {
|
|
149
|
+
stage: "indexing_code_file";
|
|
150
|
+
repo: string;
|
|
151
|
+
current: number;
|
|
152
|
+
total: number;
|
|
153
|
+
filePath: string;
|
|
154
|
+
} | {
|
|
155
|
+
stage: "indexed_code_file";
|
|
156
|
+
repo: string;
|
|
157
|
+
current: number;
|
|
158
|
+
total: number;
|
|
159
|
+
filePath: string;
|
|
160
|
+
chunks: number;
|
|
161
|
+
};
|
|
111
162
|
type IndexSummary = {
|
|
112
163
|
indexedPrs: number;
|
|
113
164
|
indexedFiles: number;
|
|
@@ -116,6 +167,12 @@ type IndexSummary = {
|
|
|
116
167
|
skippedItems: number;
|
|
117
168
|
databasePath: string;
|
|
118
169
|
};
|
|
170
|
+
type CodeIndexSummary = {
|
|
171
|
+
indexedFiles: number;
|
|
172
|
+
codeChunksCreated: number;
|
|
173
|
+
skippedFiles: number;
|
|
174
|
+
databasePath: string;
|
|
175
|
+
};
|
|
119
176
|
type AnchorContextInput = {
|
|
120
177
|
task: string;
|
|
121
178
|
files?: string[];
|
|
@@ -149,7 +206,10 @@ type IndexStatus = {
|
|
|
149
206
|
fileCount: number;
|
|
150
207
|
commentCount: number;
|
|
151
208
|
wisdomUnitCount: number;
|
|
209
|
+
codeFileCount: number;
|
|
210
|
+
codeChunkCount: number;
|
|
152
211
|
lastSyncTime?: string;
|
|
212
|
+
lastCodeIndexTime?: string;
|
|
153
213
|
githubTokenConfigured: boolean;
|
|
154
214
|
health: "ok" | "missing_database" | "schema_invalid" | "empty_index";
|
|
155
215
|
};
|
|
@@ -233,6 +293,7 @@ declare function upsertPullRequest(db: AnchorDatabase, pr: PullRequestRecord, wi
|
|
|
233
293
|
comments: number;
|
|
234
294
|
wisdom: number;
|
|
235
295
|
};
|
|
296
|
+
declare function replaceCodeIndex(db: AnchorDatabase, repo: string, codeFiles: CodeFileRecord[], codeChunks: CodeChunk[], skippedFiles: number, cwd: string): CodeIndexSummary;
|
|
236
297
|
declare function getIndexStatus(cwd: string, githubTokenConfigured?: boolean, databasePath?: string): IndexStatus;
|
|
237
298
|
|
|
238
299
|
declare const SCHEMA_SQL: string;
|
|
@@ -240,6 +301,37 @@ declare const SCHEMA_SQL: string;
|
|
|
240
301
|
declare function hasHighSignalLanguage(text: string): boolean;
|
|
241
302
|
declare function chunkHistoricalText(text: string, maxChunkLength?: number): string[];
|
|
242
303
|
|
|
304
|
+
type ChunkableCodeFile = CodeFileRecord & {
|
|
305
|
+
content: string;
|
|
306
|
+
};
|
|
307
|
+
declare function extractCodeSymbols(text: string, filePath: string): string[];
|
|
308
|
+
declare function chunkCodeFile(file: ChunkableCodeFile, options?: {
|
|
309
|
+
chunkLines?: number;
|
|
310
|
+
overlapLines?: number;
|
|
311
|
+
}): CodeChunk[];
|
|
312
|
+
|
|
313
|
+
declare const DEFAULT_MAX_CODE_FILE_BYTES: number;
|
|
314
|
+
type DiscoveredCodeFile = CodeFileRecord & {
|
|
315
|
+
absolutePath: string;
|
|
316
|
+
content: string;
|
|
317
|
+
};
|
|
318
|
+
type CodeFileDiscoveryResult = {
|
|
319
|
+
files: DiscoveredCodeFile[];
|
|
320
|
+
skippedFiles: number;
|
|
321
|
+
};
|
|
322
|
+
declare function isHardExcludedCodePath(filePath: string): boolean;
|
|
323
|
+
declare function discoverCodeFiles(cwd: string, repo: string, options?: {
|
|
324
|
+
maxFileBytes?: number;
|
|
325
|
+
}): CodeFileDiscoveryResult;
|
|
326
|
+
|
|
327
|
+
declare function indexCodebase(db: AnchorDatabase, options: {
|
|
328
|
+
cwd: string;
|
|
329
|
+
repo: string;
|
|
330
|
+
maxFileBytes?: number;
|
|
331
|
+
onProgress?: (progress: CodeIndexProgress) => void;
|
|
332
|
+
}): CodeIndexSummary;
|
|
333
|
+
declare function emptyCodeIndexSummary(cwd: string): CodeIndexSummary;
|
|
334
|
+
|
|
243
335
|
declare function categorizeWisdom(text: string): WisdomCategory;
|
|
244
336
|
declare function extractSymbols(text: string, filePaths: string[]): string[];
|
|
245
337
|
declare function extractWisdomUnits(pr: PullRequestRecord): WisdomUnit[];
|
|
@@ -260,11 +352,13 @@ declare function clampMaxResults(value: number | undefined, defaultValue: number
|
|
|
260
352
|
|
|
261
353
|
declare function rankWisdomUnits(db: AnchorDatabase, input: AnchorContextInput | SearchHistoryInput): RankedWisdomUnit[];
|
|
262
354
|
|
|
355
|
+
declare function rankCodeChunks(db: AnchorDatabase, input: AnchorContextInput): RankedCodeChunk[];
|
|
356
|
+
|
|
263
357
|
type FormattedResult = {
|
|
264
358
|
markdown: string;
|
|
265
359
|
metadata: Record<string, unknown>;
|
|
266
360
|
};
|
|
267
|
-
declare function formatAnchorContext(units: RankedWisdomUnit[], input: AnchorContextInput): FormattedResult;
|
|
361
|
+
declare function formatAnchorContext(units: RankedWisdomUnit[], input: AnchorContextInput, codeChunks?: RankedCodeChunk[]): FormattedResult;
|
|
268
362
|
declare function formatSearchHistory(units: RankedWisdomUnit[]): FormattedResult;
|
|
269
363
|
declare function formatIndexStatus(status: IndexStatus): FormattedResult;
|
|
270
364
|
|
|
@@ -293,4 +387,4 @@ type DoctorOptions = {
|
|
|
293
387
|
};
|
|
294
388
|
declare function runDoctor(options: DoctorOptions): Promise<DoctorReport>;
|
|
295
389
|
|
|
296
|
-
export { ANCHOR_CURSOR_RULE, type AnchorContextInput, type AnchorDatabase, type CursorMcpConfig, type DoctorCheck, type DoctorOptions, type DoctorReport, type FetchPullRequestsOptions, type FetchPullRequestsProgress, type FormattedResult, type GitHubRepo, type GitHubTokenResolution, type GitHubTokenResolverOptions, type GitHubTokenSource, type IndexPullRequestsProgress, type IndexStatus, type IndexSummary, type PullRequestComment, type PullRequestCommit, type PullRequestFile, type PullRequestPerson, type PullRequestRecord, type RankedWisdomUnit, SCHEMA_SQL, type SearchHistoryInput, type SourceType, type WisdomCategory, type WisdomUnit, anchorMcpEntry, buildFtsQuery, canonicalizeText, categorizeWisdom, checkSchema, chunkHistoricalText, clampMaxResults, clipSentence, createGitHubClient, defaultDatabasePath, detectGitHubRepo, detectGitRoot, ensureAnchorGitExclude, ensureCursorConfig, ensureCursorRule, ensureRepository, extractSymbols, extractWisdomUnits, fetchMergedPullRequests, fetchPullRequestDetails, formatAnchorContext, formatIndexStatus, formatSearchHistory, getIndexStatus, getLastSyncTime, githubAuthFixMessage, hasHighSignalLanguage, indexPullRequests, initializeSchema, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, parseGitHubRemote, rankWisdomUnits, redactSecrets, redactedHistoricalText, resolveGitHubToken, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, runDoctor, sanitizeHistoricalText, shouldSyncSince, stripPromptInjection, tokenizeSearchText, truncateText, uniqueStrings, updateSyncState, upsertPullRequest };
|
|
390
|
+
export { ANCHOR_CURSOR_RULE, type AnchorContextInput, type AnchorDatabase, type ChunkableCodeFile, type CodeChunk, type CodeFileDiscoveryResult, type CodeFileRecord, type CodeIndexProgress, type CodeIndexSummary, type CursorMcpConfig, DEFAULT_MAX_CODE_FILE_BYTES, type DiscoveredCodeFile, type DoctorCheck, type DoctorOptions, type DoctorReport, type FetchPullRequestsOptions, type FetchPullRequestsProgress, type FormattedResult, type GitHubRepo, type GitHubTokenResolution, type GitHubTokenResolverOptions, type GitHubTokenSource, type IndexPullRequestsProgress, type IndexStatus, type IndexSummary, type PullRequestComment, type PullRequestCommit, type PullRequestFile, type PullRequestPerson, type PullRequestRecord, type RankedCodeChunk, type RankedWisdomUnit, SCHEMA_SQL, type SearchHistoryInput, type SourceType, type WisdomCategory, type WisdomUnit, anchorMcpEntry, buildFtsQuery, canonicalizeText, categorizeWisdom, checkSchema, chunkCodeFile, chunkHistoricalText, clampMaxResults, clipSentence, createGitHubClient, defaultDatabasePath, detectGitHubRepo, detectGitRoot, discoverCodeFiles, emptyCodeIndexSummary, ensureAnchorGitExclude, ensureCursorConfig, ensureCursorRule, ensureRepository, extractCodeSymbols, extractSymbols, extractWisdomUnits, fetchMergedPullRequests, fetchPullRequestDetails, formatAnchorContext, formatIndexStatus, formatSearchHistory, getIndexStatus, getLastSyncTime, githubAuthFixMessage, hasHighSignalLanguage, indexCodebase, indexPullRequests, initializeSchema, isHardExcludedCodePath, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, parseGitHubRemote, rankCodeChunks, rankWisdomUnits, redactSecrets, redactedHistoricalText, replaceCodeIndex, resolveGitHubToken, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, runDoctor, sanitizeHistoricalText, shouldSyncSince, stripPromptInjection, tokenizeSearchText, truncateText, uniqueStrings, updateSyncState, upsertPullRequest };
|