@pratik7368patil/anchor-core 0.1.15 → 0.1.18

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
@@ -8,6 +8,18 @@ type FreshnessStatus = "current" | "possibly_stale" | "stale";
8
8
  type CoverageGrade = "empty" | "poor" | "fair" | "good" | "excellent";
9
9
  type ArchitectureArea = "api" | "service" | "component" | "hook" | "route" | "store" | "test" | "schema" | "type" | "config" | "util" | "unknown";
10
10
  type ReliabilityGateStatus = "passed" | "weak" | "failed";
11
+ type GitHubFetchBackend = "graphql" | "rest";
12
+ type GitHubGraphQLFetchCheckpoint = {
13
+ repo: string;
14
+ scope: string;
15
+ cursor?: string | null;
16
+ scannedPullRequests: number;
17
+ matchedMergedPullRequests: number;
18
+ pageSize: number;
19
+ resetAt?: string | null;
20
+ reason: string;
21
+ updatedAt: string;
22
+ };
11
23
  type EvidenceRef = {
12
24
  prNumber: number;
13
25
  prUrl: string;
@@ -306,6 +318,7 @@ type FetchPullRequestsProgress = {
306
318
  all: boolean;
307
319
  limit?: number;
308
320
  since?: string;
321
+ backend?: GitHubFetchBackend;
309
322
  } | {
310
323
  stage: "scanned_pull_request_page";
311
324
  repo: string;
@@ -313,6 +326,8 @@ type FetchPullRequestsProgress = {
313
326
  limit?: number;
314
327
  scannedPullRequests: number;
315
328
  matchedMergedPullRequests: number;
329
+ backend?: GitHubFetchBackend;
330
+ pageSize?: number;
316
331
  } | {
317
332
  stage: "discovered_pull_requests";
318
333
  repo: string;
@@ -320,6 +335,7 @@ type FetchPullRequestsProgress = {
320
335
  total: number;
321
336
  limit?: number;
322
337
  detailConcurrency: number;
338
+ backend?: GitHubFetchBackend;
323
339
  } | {
324
340
  stage: "fetching_pull_request_details";
325
341
  repo: string;
@@ -334,6 +350,61 @@ type FetchPullRequestsProgress = {
334
350
  total: number;
335
351
  prNumber: number;
336
352
  detailConcurrency: number;
353
+ } | {
354
+ stage: "enriching_pull_request_patches";
355
+ repo: string;
356
+ current: number;
357
+ total: number;
358
+ prNumber: number;
359
+ detailConcurrency: number;
360
+ } | {
361
+ stage: "enriched_pull_request_patches";
362
+ repo: string;
363
+ current: number;
364
+ total: number;
365
+ prNumber: number;
366
+ detailConcurrency: number;
367
+ patches: number;
368
+ } | {
369
+ stage: "skipped_pull_request_patch_enrichment";
370
+ repo: string;
371
+ current: number;
372
+ total: number;
373
+ prNumber: number;
374
+ reason: string;
375
+ } | {
376
+ stage: "github_fetch_backend_fallback";
377
+ repo: string;
378
+ from: GitHubFetchBackend;
379
+ to: GitHubFetchBackend;
380
+ reason: string;
381
+ } | {
382
+ stage: "github_graphql_page_size_reduced";
383
+ repo: string;
384
+ previousPageSize: number;
385
+ nextPageSize: number;
386
+ reason: string;
387
+ } | {
388
+ stage: "github_graphql_page_size_selected";
389
+ repo: string;
390
+ previousPageSize: number;
391
+ nextPageSize: number;
392
+ remaining?: number | null;
393
+ averageCostPerPr?: number;
394
+ } | {
395
+ stage: "github_graphql_budget_deferred";
396
+ repo: string;
397
+ remaining?: number | null;
398
+ reserve: number;
399
+ resetAt?: string | null;
400
+ matchedMergedPullRequests: number;
401
+ } | {
402
+ stage: "github_graphql_checkpoint_resumed";
403
+ repo: string;
404
+ scannedPullRequests: number;
405
+ matchedMergedPullRequests: number;
406
+ pageSize: number;
407
+ resetAt?: string | null;
337
408
  } | {
338
409
  stage: "github_rate_limited";
339
410
  repo: string;
@@ -632,6 +703,15 @@ declare function updateSyncState(db: AnchorDatabase, repo: string, lastIndexedPr
632
703
  historyLimit?: number;
633
704
  historySince?: string;
634
705
  }): void;
706
+ declare function graphQLFetchCheckpointScope(input: {
707
+ repo: string;
708
+ all?: boolean;
709
+ limit?: number;
710
+ since?: string;
711
+ }): string;
712
+ declare function getGraphQLFetchCheckpoint(db: AnchorDatabase, repo: string, scope: string): GitHubGraphQLFetchCheckpoint | undefined;
713
+ declare function saveGraphQLFetchCheckpoint(db: AnchorDatabase, checkpoint: GitHubGraphQLFetchCheckpoint): void;
714
+ declare function clearGraphQLFetchCheckpoint(db: AnchorDatabase, repo: string, scope?: string): void;
635
715
  declare function upsertPullRequest(db: AnchorDatabase, pr: PullRequestRecord, wisdomUnits: WisdomUnit[], regressionEvents?: RegressionEvent[]): {
636
716
  files: number;
637
717
  comments: number;
@@ -954,6 +1034,11 @@ type GitHubRateLimitController = {
954
1034
  now?: () => number;
955
1035
  blockedUntilMs?: number;
956
1036
  };
1037
+ type GitHubGraphQLRateLimitState = {
1038
+ cost?: number | null;
1039
+ remaining?: number | null;
1040
+ resetAt?: string | null;
1041
+ };
957
1042
  type GitHubRateLimitErrorLike = {
958
1043
  status?: number;
959
1044
  message?: string;
@@ -970,6 +1055,8 @@ declare function getGitHubRateLimitDelayMs(error: GitHubRateLimitErrorLike, atte
970
1055
  delayMs: number;
971
1056
  reason: string;
972
1057
  };
1058
+ declare function isGitHubGraphQLResourceLimitError(error: unknown): boolean;
1059
+ declare function updateGitHubGraphQLRateLimitState(controller: GitHubRateLimitController, rateLimit: GitHubGraphQLRateLimitState | undefined, requestName: string): void;
973
1060
  declare function requestWithGitHubRateLimit<T>(request: () => Promise<T>, options: {
974
1061
  controller: GitHubRateLimitController;
975
1062
  requestName: string;
@@ -978,8 +1065,35 @@ declare function requestWithGitHubRateLimit<T>(request: () => Promise<T>, option
978
1065
  declare function paginateWithGitHubRateLimit<T>(requestPage: (page: number) => Promise<GitHubResponse<T[]>>, options: {
979
1066
  controller: GitHubRateLimitController;
980
1067
  requestName: string;
1068
+ maxRetries?: number;
981
1069
  }): Promise<T[]>;
982
1070
 
1071
+ type GitHubGraphQLFetch = typeof fetch;
1072
+ type GitHubGraphQLResponse<T> = {
1073
+ data: T;
1074
+ headers: Record<string, string | number | undefined>;
1075
+ };
1076
+ declare class GitHubGraphQLError extends Error {
1077
+ readonly status: number;
1078
+ readonly response: {
1079
+ headers: Record<string, string | number | undefined>;
1080
+ };
1081
+ constructor(message: string, options: {
1082
+ status: number;
1083
+ headers: Record<string, string | number | undefined>;
1084
+ });
1085
+ }
1086
+ declare function createGitHubGraphQLRequester(options: {
1087
+ token: string;
1088
+ fetchImpl?: GitHubGraphQLFetch;
1089
+ }): <T extends {
1090
+ rateLimit?: GitHubGraphQLRateLimitState;
1091
+ }>(query: string, variables: Record<string, unknown>, requestOptions: {
1092
+ controller: GitHubRateLimitController;
1093
+ requestName: string;
1094
+ maxRetries?: number;
1095
+ }) => Promise<GitHubGraphQLResponse<T>>;
1096
+
983
1097
  type FetchPullRequestsOptions = {
984
1098
  token: string;
985
1099
  repo: string;
@@ -988,17 +1102,40 @@ type FetchPullRequestsOptions = {
988
1102
  detailConcurrency?: number;
989
1103
  since?: string;
990
1104
  onProgress?: (progress: FetchPullRequestsProgress) => void;
1105
+ fetchImpl?: GitHubGraphQLFetch;
1106
+ restClient?: Octokit;
1107
+ graphQLCheckpoint?: GitHubGraphQLFetchCheckpoint;
1108
+ onGraphQLCheckpoint?: (checkpoint: GitHubGraphQLFetchCheckpoint | null) => void;
991
1109
  };
992
1110
  declare function resolvePullRequestFetchLimit(options: Pick<FetchPullRequestsOptions, "all" | "limit">): number | undefined;
993
1111
  declare function resolvePullRequestDetailConcurrency(options: Pick<FetchPullRequestsOptions, "detailConcurrency">): number;
1112
+ declare function shouldFallbackToRestAfterGraphQLError(error: unknown): boolean;
994
1113
  declare function fetchMergedPullRequests(options: FetchPullRequestsOptions): Promise<PullRequestRecord[]>;
995
1114
 
1115
+ type FetchMergedPullRequestsGraphQLOptions = {
1116
+ token: string;
1117
+ repo: string;
1118
+ limit?: number;
1119
+ all?: boolean;
1120
+ detailConcurrency: number;
1121
+ since?: string;
1122
+ controller: GitHubRateLimitController;
1123
+ restController?: GitHubRateLimitController;
1124
+ graphQLCheckpoint?: GitHubGraphQLFetchCheckpoint;
1125
+ onGraphQLCheckpoint?: (checkpoint: GitHubGraphQLFetchCheckpoint | null) => void;
1126
+ onProgress?: (progress: FetchPullRequestsProgress) => void;
1127
+ fetchImpl?: GitHubGraphQLFetch;
1128
+ restClient?: Octokit;
1129
+ };
1130
+ declare function fetchMergedPullRequestsWithGraphQL(options: FetchMergedPullRequestsGraphQLOptions): Promise<PullRequestRecord[]>;
1131
+
996
1132
  declare function fetchPullRequestDetails(octokit: Octokit, repoFullName: string, pullNumber: number, controller?: GitHubRateLimitController): Promise<PullRequestRecord>;
997
1133
 
998
1134
  type DoctorOptions = {
999
1135
  cwd: string;
1000
1136
  env?: NodeJS.ProcessEnv;
1001
1137
  githubClientFactory?: (token: string) => Pick<Octokit, "repos">;
1138
+ githubGraphQLCheck?: (token: string) => Promise<boolean> | boolean;
1002
1139
  mcpServerCheck?: () => Promise<boolean> | boolean;
1003
1140
  };
1004
1141
  declare function runDoctor(options: DoctorOptions): Promise<DoctorReport>;
@@ -1008,4 +1145,4 @@ declare function getAnchorIndexHealth(cwd: string): AnchorIndexHealth & {
1008
1145
  indexStatus: IndexStatus;
1009
1146
  };
1010
1147
 
1011
- export { ANCHOR_CURSOR_RULE, ANCHOR_EVALS_FILE, ANCHOR_PLAYBOOKS_FILE, type AnchorCiInput, type AnchorContextInput, type AnchorDatabase, type AnchorExplainFileInput, type AnchorIndexHealth, 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 FetchPullRequestsOptions, type FetchPullRequestsProgress, type FormattedResult, type FreshnessResult, type FreshnessStatus, 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 Playbook, type PullRequestComment, type PullRequestCommit, type PullRequestFile, type PullRequestPerson, type PullRequestRecord, type RankedArchitecturePattern, type RankedCodeChunk, type RankedRegressionEvent, type RankedTeamRule, type RankedTestFile, type RankedWisdomUnit, 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, addRetrievalEval, addTeamRule, anchorMcpEntry, architectureFilesFromDiff, buildAnchorContextResult, buildArchitectureIndex, buildArchitectureMap, buildFtsQuery, buildOnboardingPack, buildQueryTerms, calculateCoverage, canonicalizeText, categorizeWisdom, checkArchitecture, checkSchema, checkTeamRuleEvidence, chunkCodeFile, chunkHistoricalText, claimKeyFor, clampMaxResults, classifyArchitectureArea, clipSentence, confidenceAtLeast, confidenceLevelFor, confidenceRank, confidenceReasonsFor, countValidTeamRules, createGitHubClient, defaultDatabasePath, detectGitHubRepo, detectGitRoot, detectTestCommands, detectTestCommandsForFile, discoverCodeFiles, emptyCodeIndexSummary, ensureAnchorGitExclude, ensureCursorConfig, ensureCursorRule, ensureRepository, ensureTeamRulesFile, evaluateFreshness, evaluateIndexHealth, evaluateReliabilityGate, evidenceForWisdom, explainFile, extractCodeImports, extractCodeSymbols, extractRegressionEvents, extractSymbols, extractWisdomUnits, feedbackAdjustedScore, fetchMergedPullRequests, fetchPullRequestDetails, filesFromDiff, formatAnchorContext, formatIndexStatus, formatSearchHistory, getAnchorIndexHealth, getArchitectureContext, getArchitectureMapContext, getGitHubRateLimitDelayMs, getIndexStatus, getLastSyncTime, getPlaybook, getSemanticStatus, getSuggestedPromptTexts, getSuggestedPrompts, getWisdomCategoryCounts, githubAuthFixMessage, hasHighSignalLanguage, indexCodebase, indexPullRequests, inferTestAwareness, initPlaybooks, initRetrievalEvals, initializeSchema, isGitHubRateLimitError, isHardExcludedCodePath, isTestFilePath, listFeedbackEvents, listPlaybooks, loadCurrentCodeSnapshot, loadTeamRulesFile, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, paginateWithGitHubRateLimit, parseGitHubRemote, planTask, rankArchitecturePatterns, rankCodeChunks, rankRegressionEvents, rankRelevantTests, rankTeamRules, rankWisdomUnits, recordFeedback, recordIndexRun, redactSecrets, redactedHistoricalText, refreshTestCommands, refreshWatchIndex, replaceCodeIndex, requestWithGitHubRateLimit, resolveGitHubToken, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, reviewDiff, runAnchorCi, runDoctor, runRetrievalEvals, sanitizeHistoricalText, shouldSyncSince, sourceTypeLabel, stripPromptInjection, suggestPlaybooks, suggestTeamRules, syncPlaybooksToDatabase, tokenizeSearchText, truncateText, uniqueStrings, updateSyncState, upsertPullRequest, validateTeamRulesFile, watchCodebase };
1148
+ export { ANCHOR_CURSOR_RULE, ANCHOR_EVALS_FILE, ANCHOR_PLAYBOOKS_FILE, type AnchorCiInput, type AnchorContextInput, type AnchorDatabase, type AnchorExplainFileInput, type AnchorIndexHealth, 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 GitHubFetchBackend, GitHubGraphQLError, type GitHubGraphQLFetch, type GitHubGraphQLFetchCheckpoint, type GitHubGraphQLRateLimitState, type GitHubGraphQLResponse, 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 Playbook, type PullRequestComment, type PullRequestCommit, type PullRequestFile, type PullRequestPerson, type PullRequestRecord, type RankedArchitecturePattern, type RankedCodeChunk, type RankedRegressionEvent, type RankedTeamRule, type RankedTestFile, type RankedWisdomUnit, 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, addRetrievalEval, addTeamRule, anchorMcpEntry, architectureFilesFromDiff, buildAnchorContextResult, buildArchitectureIndex, buildArchitectureMap, buildFtsQuery, buildOnboardingPack, buildQueryTerms, calculateCoverage, canonicalizeText, categorizeWisdom, checkArchitecture, checkSchema, checkTeamRuleEvidence, chunkCodeFile, chunkHistoricalText, claimKeyFor, clampMaxResults, classifyArchitectureArea, clearGraphQLFetchCheckpoint, clipSentence, confidenceAtLeast, confidenceLevelFor, confidenceRank, confidenceReasonsFor, countValidTeamRules, createGitHubClient, createGitHubGraphQLRequester, defaultDatabasePath, 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, formatAnchorContext, formatIndexStatus, formatSearchHistory, getAnchorIndexHealth, getArchitectureContext, getArchitectureMapContext, getGitHubRateLimitDelayMs, getGraphQLFetchCheckpoint, getIndexStatus, getLastSyncTime, getPlaybook, getSemanticStatus, getSuggestedPromptTexts, getSuggestedPrompts, getWisdomCategoryCounts, githubAuthFixMessage, graphQLFetchCheckpointScope, hasHighSignalLanguage, indexCodebase, indexPullRequests, inferTestAwareness, initPlaybooks, initRetrievalEvals, initializeSchema, isGitHubGraphQLResourceLimitError, isGitHubRateLimitError, isHardExcludedCodePath, isTestFilePath, listFeedbackEvents, listPlaybooks, loadCurrentCodeSnapshot, loadTeamRulesFile, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, paginateWithGitHubRateLimit, parseGitHubRemote, planTask, rankArchitecturePatterns, rankCodeChunks, rankRegressionEvents, rankRelevantTests, rankTeamRules, rankWisdomUnits, recordFeedback, recordIndexRun, redactSecrets, redactedHistoricalText, refreshTestCommands, refreshWatchIndex, replaceCodeIndex, requestWithGitHubRateLimit, resolveGitHubToken, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, reviewDiff, runAnchorCi, runDoctor, runRetrievalEvals, sanitizeHistoricalText, saveGraphQLFetchCheckpoint, shouldFallbackToRestAfterGraphQLError, shouldSyncSince, sourceTypeLabel, stripPromptInjection, suggestPlaybooks, suggestTeamRules, syncPlaybooksToDatabase, tokenizeSearchText, truncateText, uniqueStrings, updateGitHubGraphQLRateLimitState, updateSyncState, upsertPullRequest, validateTeamRulesFile, watchCodebase };