@pratik7368patil/anchor-core 0.1.30 → 0.1.31

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 CHANGED
@@ -271,9 +271,16 @@ type RetrievalEvalResult = {
271
271
  expectedPrs: number[];
272
272
  foundPrs: number[];
273
273
  missingPrs: number[];
274
+ expectedPrRanks: Array<{
275
+ prNumber: number;
276
+ rank?: number;
277
+ }>;
274
278
  expectedCategories: WisdomCategory[];
275
279
  foundCategories: WisdomCategory[];
276
280
  missingCategories: WisdomCategory[];
281
+ precisionAtK: number;
282
+ recallAtK: number;
283
+ reciprocalRank: number;
277
284
  };
278
285
  type RetrievalEvalRunResult = {
279
286
  ok: boolean;
@@ -281,6 +288,10 @@ type RetrievalEvalRunResult = {
281
288
  total: number;
282
289
  passed: number;
283
290
  failed: number;
291
+ precisionAtK: number;
292
+ recallAtK: number;
293
+ mrr: number;
294
+ k: number;
284
295
  results: RetrievalEvalResult[];
285
296
  };
286
297
  type FeedbackRating = "useful" | "not-useful";
@@ -1081,14 +1092,44 @@ declare function redactedHistoricalText(text: string): string;
1081
1092
  type AnchorDatabase = Database.Database;
1082
1093
  type CodeIndexWriteOptions = {
1083
1094
  onProgress?: (progress: CodeIndexProgress) => void;
1095
+ deletedPaths?: string[];
1096
+ changedImports?: CodeImport[];
1097
+ currentCommit?: string;
1098
+ testAwareness?: {
1099
+ testFiles: TestFileRecord[];
1100
+ testLinks: TestLink[];
1101
+ };
1102
+ };
1103
+ type RepoCodeIndexState = {
1104
+ repo: string;
1105
+ lastIndexedAt?: string;
1106
+ indexedFiles: number;
1107
+ codeChunks: number;
1108
+ skippedFiles: number;
1109
+ lastIndexedCommit?: string;
1084
1110
  };
1085
1111
  declare function defaultDatabasePath(cwd: string): string;
1086
1112
  declare function openAnchorDatabase(cwd: string, databasePath?: string): AnchorDatabase;
1087
1113
  declare function openAnchorDatabaseReadOnly(databasePath: string): AnchorDatabase;
1114
+ declare function runDatabaseMaintenance(db: AnchorDatabase): void;
1088
1115
  declare function initializeSchema(db: AnchorDatabase): void;
1089
1116
  declare function checkSchema(db: AnchorDatabase): boolean;
1090
1117
  declare function ensureRepository(db: AnchorDatabase, fullName: string): number;
1091
1118
  declare function getLastSyncTime(db: AnchorDatabase, repo: string): string | undefined;
1119
+ declare function getCodeIndexStateForRepo(db: AnchorDatabase, repo: string): RepoCodeIndexState | undefined;
1120
+ declare function getRepoCodeFileHashes(db: AnchorDatabase, repo: string): Map<string, string>;
1121
+ declare function getRepoCodeFiles(db: AnchorDatabase, repo: string): CodeFileRecord[];
1122
+ declare function getRepoCodeChunkSymbols(db: AnchorDatabase, repo: string): CodeChunk[];
1123
+ declare function getRepoTestChunks(db: AnchorDatabase, repo: string): CodeChunk[];
1124
+ declare function getRepoCodeImports(db: AnchorDatabase, repo: string): CodeImport[];
1125
+ declare function getRepoCodeCounts(db: AnchorDatabase, repo: string): {
1126
+ files: number;
1127
+ chunks: number;
1128
+ };
1129
+ declare function touchCodeIndexState(db: AnchorDatabase, repo: string, skippedFiles: number, currentCommit?: string): {
1130
+ files: number;
1131
+ chunks: number;
1132
+ };
1092
1133
  declare function updateSyncState(db: AnchorDatabase, repo: string, lastIndexedPr?: number, metadata?: {
1093
1134
  historyCoverage?: "limited" | "all" | "unknown";
1094
1135
  historyLimit?: number;
@@ -1134,21 +1175,41 @@ type BuildArchitectureIndexOptions = {
1134
1175
  declare function classifyArchitectureArea(filePath: string, language?: string, content?: string): ArchitectureArea;
1135
1176
  declare function extractCodeImports(sourcePath: string, content: string, codePaths: Set<string>, repo?: string): CodeImport[];
1136
1177
  declare function buildArchitectureIndex(repo: string, files: ChunkableCodeFile[], chunks: CodeChunk[], options?: BuildArchitectureIndexOptions): ArchitectureIndexData;
1178
+ declare function buildArchitectureFromIndexedData(repo: string, files: CodeFileRecord[], chunks: CodeChunk[], imports: CodeImport[], options?: BuildArchitectureIndexOptions): ArchitectureIndexData;
1137
1179
 
1138
1180
  declare const DEFAULT_MAX_CODE_FILE_BYTES: number;
1139
1181
  type DiscoveredCodeFile = CodeFileRecord & {
1140
1182
  absolutePath: string;
1141
- content: string;
1183
+ content?: string;
1142
1184
  };
1143
1185
  type CodeFileDiscoveryResult = {
1144
1186
  files: DiscoveredCodeFile[];
1145
1187
  skippedFiles: number;
1146
1188
  };
1189
+ type CodeIndexChangePlan = {
1190
+ currentCommit?: string;
1191
+ trackedPaths: string[];
1192
+ changedPaths: string[];
1193
+ deletedPaths: string[];
1194
+ dirtyWorkingTree: boolean;
1195
+ fallbackToFullHashCompare: boolean;
1196
+ reason: string;
1197
+ };
1147
1198
  declare function isHardExcludedCodePath(filePath: string): boolean;
1199
+ declare function readGitHeadCommit(cwd: string): string | undefined;
1200
+ declare function hasDirtyWorkingTree(cwd: string): boolean;
1201
+ declare function planIncrementalCodeIndex(cwd: string, lastIndexedCommit: string | undefined, existingIndexedPaths: Set<string>): CodeIndexChangePlan;
1148
1202
  declare function discoverCodeFiles(cwd: string, repo: string, options?: {
1203
+ includeContent?: boolean;
1204
+ maxFileBytes?: number;
1205
+ onScan?: (scanned: number, total: number) => void;
1206
+ }): CodeFileDiscoveryResult;
1207
+ declare function discoverCodeFilesByPaths(cwd: string, repo: string, filePaths: string[], options?: {
1208
+ includeContent?: boolean;
1149
1209
  maxFileBytes?: number;
1150
1210
  onScan?: (scanned: number, total: number) => void;
1151
1211
  }): CodeFileDiscoveryResult;
1212
+ declare function readDiscoveredCodeFileContent(file: DiscoveredCodeFile): string;
1152
1213
 
1153
1214
  declare function indexCodebase(db: AnchorDatabase, options: {
1154
1215
  cwd: string;
@@ -1789,4 +1850,4 @@ declare function getAnchorIndexHealth(cwd: string): AnchorIndexHealth & {
1789
1850
  indexStatus: IndexStatus;
1790
1851
  };
1791
1852
 
1792
- export { ANCHOR_CURSOR_RULE, ANCHOR_EVALS_FILE, ANCHOR_PLAYBOOKS_FILE, type AnchorCiInput, type AnchorContextInput, type AnchorDatabase, type AnchorExplainFileInput, type AnchorIndexHealth, type AnchorOrgConfig, type AnchorOrgRepoConfig, type AnchorReviewDiffInput, type ArchitectureArea, type ArchitectureCheckInput, type ArchitectureComponent, type ArchitectureContextInput, type ArchitectureIndexData, type ArchitectureMap, type ArchitectureMapEdge, type ArchitectureMapFormat, type ArchitectureMapInput, type ArchitectureMapNode, type ArchitecturePattern, type ArchitectureQueryInput, type ChunkableCodeFile, type CodeChunk, type CodeFileDiscoveryResult, type CodeFileRecord, type CodeImport, type CodeIndexProgress, type CodeIndexSummary, type ConfidenceLevel, type CoverageGrade, type CoverageInput, type CoverageReport, type CurrentCodeSnapshot, type CursorMcpConfig, DEFAULT_MAX_CODE_FILE_BYTES, DEMO_CODE_FILES, DEMO_PULL_REQUESTS, DEMO_REPO, type DiscoveredCodeFile, type DoctorCheck, type DoctorOptions, type DoctorReport, type EvidenceRef, type FeedbackEvent, type FeedbackRating, type FetchMergedPullRequestsGraphQLOptions, type FetchPullRequestsOptions, type FetchPullRequestsProgress, type FormattedResult, type FreshnessResult, type FreshnessStatus, type GitCommandRunner, type GitHubFetchBackend, GitHubGraphQLError, type GitHubGraphQLFetch, type GitHubGraphQLFetchCheckpoint, type GitHubGraphQLRateLimitState, type GitHubGraphQLResponse, type GitHubGraphQLTransientRetry, type GitHubRateLimitController, type GitHubRateLimitErrorLike, type GitHubRateLimitProgress, type GitHubRepo, type GitHubTokenResolution, type GitHubTokenResolverOptions, type GitHubTokenSource, type IndexPullRequestsProgress, type IndexRunRecord, type IndexStatus, type IndexSummary, type LocalEmbeddingProvider, type OnboardingInput, type OnboardingPack, type OrgAnomaly, type OrgAnomalyCategory, type OrgApiConsumer, type OrgCloneProgress, type OrgCloneResult, type OrgCrossRepoEdge, type OrgCrossRepoRelationship, type OrgFormattedResult, type OrgGraphProgress, type OrgGraphResult, type OrgGraphState, type OrgImpactResult, type OrgIndexOptions, type OrgIndexResult, type OrgLifecycleProgress, type OrgRepoCloneState, type OrgRepoGroup, type OrgRepoIndexResult, type OrgRunHeartbeat, type OrgRunHeartbeatStatus, type OrgRunTimelineRepoSummary, type OrgRunTimelineSnapshot, type OrgRunTimelineStep, type OrgRunTimelineStepStatus, type OrgStatus, type Playbook, type PullRequestComment, type PullRequestCommit, type PullRequestFile, type PullRequestPerson, type PullRequestRecord, type RankedArchitecturePattern, type RankedCodeChunk, type RankedRegressionEvent, type RankedTeamRule, type RankedTestFile, type RankedWisdomUnit, type RebuildOrgGraphOptions, type RegressionEvent, type ReliabilityGate, type ReliabilityGateRejection, type ReliabilityGateResult, type ReliabilityGateStatus, type RetrievalEvalCase, type RetrievalEvalResult, type RetrievalEvalRunResult, type RulesAddInput, type RulesAddResult, type RulesEvidenceCheckResult, type RulesInitResult, type RulesSuggestOptions, SCHEMA_SQL, type SearchHistoryInput, type SemanticStatus, type SourceType, type SuggestedPrompt, TEAM_RULES_FILE, type TaskPlan, type TeamRule, type TeamRuleSuggestion, type TeamRulesValidationResult, type TestCommand, type TestFileRecord, type TestLink, type WatchRefreshInput, type WisdomCategory, type WisdomUnit, addOrgRepoConfig, addRetrievalEval, addTeamRule, anchorMcpEntry, architectureFilesFromDiff, buildAnchorContextResult, buildArchitectureIndex, buildArchitectureMap, buildFtsQuery, buildOnboardingPack, buildOrgContextResult, buildQueryTerms, calculateCoverage, canonicalizeText, categorizeWisdom, checkArchitecture, checkOrgImpact, checkSchema, checkTeamRuleEvidence, chunkCodeFile, chunkHistoricalText, claimKeyFor, clampMaxResults, classifyArchitectureArea, clearGraphQLFetchCheckpoint, clearOrgHeartbeat, clipSentence, cloneOrPullOrgRepo, cloneOrgRepos, confidenceAtLeast, confidenceLevelFor, confidenceRank, confidenceReasonsFor, countValidTeamRules, createGitHubClient, createGitHubGraphQLRequester, defaultDatabasePath, defaultGitCommandRunner, defaultOrgBaseDir, defaultOrgCloneUrl, detectGitHubRepo, detectGitRoot, detectTestCommands, detectTestCommandsForFile, discoverCodeFiles, emptyCodeIndexSummary, ensureAnchorGitExclude, ensureCursorConfig, ensureCursorRule, ensureRepository, ensureTeamRulesFile, evaluateFreshness, evaluateIndexHealth, evaluateReliabilityGate, evidenceForWisdom, explainFile, extractCodeImports, extractCodeSymbols, extractRegressionEvents, extractSymbols, extractWisdomUnits, feedbackAdjustedScore, fetchMergedPullRequests, fetchMergedPullRequestsWithGraphQL, fetchPullRequestDetails, filesFromDiff, findOrgApiConsumers, formatAnchorContext, formatIndexStatus, formatSearchHistory, getAnchorIndexHealth, getArchitectureContext, getArchitectureMapContext, getGitHubRateLimitDelayMs, getGraphQLFetchCheckpoint, getIndexStatus, getLastSyncTime, getOrgArchitectureMap, getOrgGraphCounts, getOrgGraphState, getOrgRepoState, getOrgStatus, getPlaybook, getSemanticStatus, getSuggestedPromptTexts, getSuggestedPrompts, getWisdomCategoryCounts, githubAuthFixMessage, graphQLFetchCheckpointScope, hasHighSignalLanguage, indexCodebase, indexOrgRepos, indexPullRequests, inferTestAwareness, initOrgConfig, initPlaybooks, initRetrievalEvals, initializeSchema, isGitHubGraphQLResourceLimitError, isGitHubRateLimitError, isHardExcludedCodePath, isTestFilePath, listFeedbackEvents, listOrgNames, listPlaybooks, loadCurrentCodeSnapshot, loadOrgConfig, loadTeamRulesFile, maybeLoadOrgConfig, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, openAnchorDatabaseReadOnly, openOrgDatabase, openOrgDatabaseReadOnly, orgCloneStateFromResult, orgConfigPath, orgDatabasePath, orgHeartbeatPath, orgRepoLocalPath, orgReposRoot, orgRoot, paginateWithGitHubRateLimit, parseGitHubRemote, planTask, plannedOrgCloneCommands, rankArchitecturePatterns, rankCodeChunks, rankRegressionEvents, rankRelevantTests, rankTeamRules, rankWisdomUnits, readOrgHeartbeat, rebuildOrgGraph, recordFeedback, recordIndexRun, recordOrgGraphState, recordOrgIndexRun, redactSecrets, redactedHistoricalText, refreshTestCommands, refreshWatchIndex, removeOrgRepoConfig, replaceCodeIndex, repoAliasFromFullName, requestWithGitHubRateLimit, resolveGitHubToken, resolveOrgForTool, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, reviewDiff, runAnchorCi, runDoctor, runRetrievalEvals, sanitizeHistoricalText, saveGraphQLFetchCheckpoint, saveOrgConfig, shouldFallbackToRestAfterGraphQLError, shouldSyncSince, sourceTypeLabel, stripPromptInjection, suggestPlaybooks, suggestTeamRules, syncOrgConfigToDatabase, syncPlaybooksToDatabase, tokenizeSearchText, truncateText, uniqueStrings, updateGitHubGraphQLRateLimitState, updateOrgRepoState, updateSyncState, upsertPullRequest, validateOrgName, validateOrgRepoFullName, validateOrgRepoGroup, validateTeamRulesFile, watchCodebase, writeOrgHeartbeat };
1853
+ export { ANCHOR_CURSOR_RULE, ANCHOR_EVALS_FILE, ANCHOR_PLAYBOOKS_FILE, type AnchorCiInput, type AnchorContextInput, type AnchorDatabase, type AnchorExplainFileInput, type AnchorIndexHealth, type AnchorOrgConfig, type AnchorOrgRepoConfig, type AnchorReviewDiffInput, type ArchitectureArea, type ArchitectureCheckInput, type ArchitectureComponent, type ArchitectureContextInput, type ArchitectureIndexData, type ArchitectureMap, type ArchitectureMapEdge, type ArchitectureMapFormat, type ArchitectureMapInput, type ArchitectureMapNode, type ArchitecturePattern, type ArchitectureQueryInput, type ChunkableCodeFile, type CodeChunk, type CodeFileDiscoveryResult, type CodeFileRecord, type CodeImport, type CodeIndexChangePlan, type CodeIndexProgress, type CodeIndexSummary, type ConfidenceLevel, type CoverageGrade, type CoverageInput, type CoverageReport, type CurrentCodeSnapshot, type CursorMcpConfig, DEFAULT_MAX_CODE_FILE_BYTES, DEMO_CODE_FILES, DEMO_PULL_REQUESTS, DEMO_REPO, type DiscoveredCodeFile, type DoctorCheck, type DoctorOptions, type DoctorReport, type EvidenceRef, type FeedbackEvent, type FeedbackRating, type FetchMergedPullRequestsGraphQLOptions, type FetchPullRequestsOptions, type FetchPullRequestsProgress, type FormattedResult, type FreshnessResult, type FreshnessStatus, type GitCommandRunner, type GitHubFetchBackend, GitHubGraphQLError, type GitHubGraphQLFetch, type GitHubGraphQLFetchCheckpoint, type GitHubGraphQLRateLimitState, type GitHubGraphQLResponse, type GitHubGraphQLTransientRetry, type GitHubRateLimitController, type GitHubRateLimitErrorLike, type GitHubRateLimitProgress, type GitHubRepo, type GitHubTokenResolution, type GitHubTokenResolverOptions, type GitHubTokenSource, type IndexPullRequestsProgress, type IndexRunRecord, type IndexStatus, type IndexSummary, type LocalEmbeddingProvider, type OnboardingInput, type OnboardingPack, type OrgAnomaly, type OrgAnomalyCategory, type OrgApiConsumer, type OrgCloneProgress, type OrgCloneResult, type OrgCrossRepoEdge, type OrgCrossRepoRelationship, type OrgFormattedResult, type OrgGraphProgress, type OrgGraphResult, type OrgGraphState, type OrgImpactResult, type OrgIndexOptions, type OrgIndexResult, type OrgLifecycleProgress, type OrgRepoCloneState, type OrgRepoGroup, type OrgRepoIndexResult, type OrgRunHeartbeat, type OrgRunHeartbeatStatus, type OrgRunTimelineRepoSummary, type OrgRunTimelineSnapshot, type OrgRunTimelineStep, type OrgRunTimelineStepStatus, type OrgStatus, type Playbook, type PullRequestComment, type PullRequestCommit, type PullRequestFile, type PullRequestPerson, type PullRequestRecord, type RankedArchitecturePattern, type RankedCodeChunk, type RankedRegressionEvent, type RankedTeamRule, type RankedTestFile, type RankedWisdomUnit, type RebuildOrgGraphOptions, type RegressionEvent, type ReliabilityGate, type ReliabilityGateRejection, type ReliabilityGateResult, type ReliabilityGateStatus, type RepoCodeIndexState, type RetrievalEvalCase, type RetrievalEvalResult, type RetrievalEvalRunResult, type RulesAddInput, type RulesAddResult, type RulesEvidenceCheckResult, type RulesInitResult, type RulesSuggestOptions, SCHEMA_SQL, type SearchHistoryInput, type SemanticStatus, type SourceType, type SuggestedPrompt, TEAM_RULES_FILE, type TaskPlan, type TeamRule, type TeamRuleSuggestion, type TeamRulesValidationResult, type TestCommand, type TestFileRecord, type TestLink, type WatchRefreshInput, type WisdomCategory, type WisdomUnit, addOrgRepoConfig, addRetrievalEval, addTeamRule, anchorMcpEntry, architectureFilesFromDiff, buildAnchorContextResult, buildArchitectureFromIndexedData, buildArchitectureIndex, buildArchitectureMap, buildFtsQuery, buildOnboardingPack, buildOrgContextResult, buildQueryTerms, calculateCoverage, canonicalizeText, categorizeWisdom, checkArchitecture, checkOrgImpact, checkSchema, checkTeamRuleEvidence, chunkCodeFile, chunkHistoricalText, claimKeyFor, clampMaxResults, classifyArchitectureArea, clearGraphQLFetchCheckpoint, clearOrgHeartbeat, clipSentence, cloneOrPullOrgRepo, cloneOrgRepos, confidenceAtLeast, confidenceLevelFor, confidenceRank, confidenceReasonsFor, countValidTeamRules, createGitHubClient, createGitHubGraphQLRequester, defaultDatabasePath, defaultGitCommandRunner, defaultOrgBaseDir, defaultOrgCloneUrl, detectGitHubRepo, detectGitRoot, detectTestCommands, detectTestCommandsForFile, discoverCodeFiles, discoverCodeFilesByPaths, emptyCodeIndexSummary, ensureAnchorGitExclude, ensureCursorConfig, ensureCursorRule, ensureRepository, ensureTeamRulesFile, evaluateFreshness, evaluateIndexHealth, evaluateReliabilityGate, evidenceForWisdom, explainFile, extractCodeImports, extractCodeSymbols, extractRegressionEvents, extractSymbols, extractWisdomUnits, feedbackAdjustedScore, fetchMergedPullRequests, fetchMergedPullRequestsWithGraphQL, fetchPullRequestDetails, filesFromDiff, findOrgApiConsumers, formatAnchorContext, formatIndexStatus, formatSearchHistory, getAnchorIndexHealth, getArchitectureContext, getArchitectureMapContext, getCodeIndexStateForRepo, getGitHubRateLimitDelayMs, getGraphQLFetchCheckpoint, getIndexStatus, getLastSyncTime, getOrgArchitectureMap, getOrgGraphCounts, getOrgGraphState, getOrgRepoState, getOrgStatus, getPlaybook, getRepoCodeChunkSymbols, getRepoCodeCounts, getRepoCodeFileHashes, getRepoCodeFiles, getRepoCodeImports, getRepoTestChunks, getSemanticStatus, getSuggestedPromptTexts, getSuggestedPrompts, getWisdomCategoryCounts, githubAuthFixMessage, graphQLFetchCheckpointScope, hasDirtyWorkingTree, hasHighSignalLanguage, indexCodebase, indexOrgRepos, indexPullRequests, inferTestAwareness, initOrgConfig, initPlaybooks, initRetrievalEvals, initializeSchema, isGitHubGraphQLResourceLimitError, isGitHubRateLimitError, isHardExcludedCodePath, isTestFilePath, listFeedbackEvents, listOrgNames, listPlaybooks, loadCurrentCodeSnapshot, loadOrgConfig, loadTeamRulesFile, maybeLoadOrgConfig, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, openAnchorDatabaseReadOnly, openOrgDatabase, openOrgDatabaseReadOnly, orgCloneStateFromResult, orgConfigPath, orgDatabasePath, orgHeartbeatPath, orgRepoLocalPath, orgReposRoot, orgRoot, paginateWithGitHubRateLimit, parseGitHubRemote, planIncrementalCodeIndex, planTask, plannedOrgCloneCommands, rankArchitecturePatterns, rankCodeChunks, rankRegressionEvents, rankRelevantTests, rankTeamRules, rankWisdomUnits, readDiscoveredCodeFileContent, readGitHeadCommit, readOrgHeartbeat, rebuildOrgGraph, recordFeedback, recordIndexRun, recordOrgGraphState, recordOrgIndexRun, redactSecrets, redactedHistoricalText, refreshTestCommands, refreshWatchIndex, removeOrgRepoConfig, replaceCodeIndex, repoAliasFromFullName, requestWithGitHubRateLimit, resolveGitHubToken, resolveOrgForTool, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, reviewDiff, runAnchorCi, runDatabaseMaintenance, runDoctor, runRetrievalEvals, sanitizeHistoricalText, saveGraphQLFetchCheckpoint, saveOrgConfig, shouldFallbackToRestAfterGraphQLError, shouldSyncSince, sourceTypeLabel, stripPromptInjection, suggestPlaybooks, suggestTeamRules, syncOrgConfigToDatabase, syncPlaybooksToDatabase, tokenizeSearchText, touchCodeIndexState, truncateText, uniqueStrings, updateGitHubGraphQLRateLimitState, updateOrgRepoState, updateSyncState, upsertPullRequest, validateOrgName, validateOrgRepoFullName, validateOrgRepoGroup, validateTeamRulesFile, watchCodebase, writeOrgHeartbeat };