@pratik7368patil/anchor-core 0.1.10 → 0.1.12
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 +85 -4
- package/dist/index.js +803 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/db/schema.sql +60 -0
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type WisdomCategory = "architecture_decision" | "constraint" | "rejected_approac
|
|
|
6
6
|
type ConfidenceLevel = "strong" | "moderate" | "weak";
|
|
7
7
|
type FreshnessStatus = "current" | "possibly_stale" | "stale";
|
|
8
8
|
type CoverageGrade = "empty" | "poor" | "fair" | "good" | "excellent";
|
|
9
|
+
type ArchitectureArea = "api" | "service" | "component" | "hook" | "route" | "store" | "test" | "schema" | "type" | "config" | "util" | "unknown";
|
|
9
10
|
type EvidenceRef = {
|
|
10
11
|
prNumber: number;
|
|
11
12
|
prUrl: string;
|
|
@@ -50,6 +51,49 @@ type CodeChunk = {
|
|
|
50
51
|
contentHash: string;
|
|
51
52
|
updatedAt: string;
|
|
52
53
|
};
|
|
54
|
+
type CodeImport = {
|
|
55
|
+
repo: string;
|
|
56
|
+
sourcePath: string;
|
|
57
|
+
specifier: string;
|
|
58
|
+
importedPath?: string;
|
|
59
|
+
importedSymbols: string[];
|
|
60
|
+
kind: "static" | "dynamic" | "require";
|
|
61
|
+
};
|
|
62
|
+
type ArchitectureComponent = {
|
|
63
|
+
repo: string;
|
|
64
|
+
path: string;
|
|
65
|
+
area: ArchitectureArea;
|
|
66
|
+
kind: string;
|
|
67
|
+
language?: string;
|
|
68
|
+
symbols: string[];
|
|
69
|
+
imports: string[];
|
|
70
|
+
relatedTests: string[];
|
|
71
|
+
confidence: number;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
};
|
|
74
|
+
type ArchitecturePattern = {
|
|
75
|
+
id: string;
|
|
76
|
+
repo: string;
|
|
77
|
+
area: ArchitectureArea;
|
|
78
|
+
name: string;
|
|
79
|
+
summary: string;
|
|
80
|
+
sanitizedSummary: string;
|
|
81
|
+
sourceFiles: string[];
|
|
82
|
+
symbols: string[];
|
|
83
|
+
evidence: EvidenceRef[];
|
|
84
|
+
confidence: number;
|
|
85
|
+
createdAt: string;
|
|
86
|
+
};
|
|
87
|
+
type RankedArchitecturePattern = ArchitecturePattern & {
|
|
88
|
+
score: number;
|
|
89
|
+
matchReasons: string[];
|
|
90
|
+
rankSignals: Record<string, number>;
|
|
91
|
+
};
|
|
92
|
+
type ArchitectureIndexData = {
|
|
93
|
+
components: ArchitectureComponent[];
|
|
94
|
+
patterns: ArchitecturePattern[];
|
|
95
|
+
imports: CodeImport[];
|
|
96
|
+
};
|
|
53
97
|
type RankedCodeChunk = CodeChunk & {
|
|
54
98
|
score: number;
|
|
55
99
|
scoreParts: {
|
|
@@ -236,6 +280,12 @@ type CodeIndexProgress = {
|
|
|
236
280
|
total: number;
|
|
237
281
|
filePath: string;
|
|
238
282
|
chunks: number;
|
|
283
|
+
} | {
|
|
284
|
+
stage: "indexed_architecture";
|
|
285
|
+
repo: string;
|
|
286
|
+
components: number;
|
|
287
|
+
patterns: number;
|
|
288
|
+
imports: number;
|
|
239
289
|
};
|
|
240
290
|
type IndexSummary = {
|
|
241
291
|
indexedPrs: number;
|
|
@@ -251,6 +301,9 @@ type CodeIndexSummary = {
|
|
|
251
301
|
codeChunksCreated: number;
|
|
252
302
|
testFilesIndexed: number;
|
|
253
303
|
testLinksCreated: number;
|
|
304
|
+
architectureComponentsIndexed: number;
|
|
305
|
+
architecturePatternsIndexed: number;
|
|
306
|
+
architectureImportsIndexed: number;
|
|
254
307
|
skippedFiles: number;
|
|
255
308
|
databasePath: string;
|
|
256
309
|
};
|
|
@@ -353,12 +406,16 @@ type IndexStatus = {
|
|
|
353
406
|
testFileCount: number;
|
|
354
407
|
testLinkCount: number;
|
|
355
408
|
regressionEventCount: number;
|
|
409
|
+
architectureComponentCount: number;
|
|
410
|
+
architecturePatternCount: number;
|
|
411
|
+
architectureImportCount: number;
|
|
356
412
|
historyCoverage?: "limited" | "all" | "unknown";
|
|
357
413
|
historyLimit?: number;
|
|
358
414
|
staleEvidenceCount: number;
|
|
359
415
|
teamRuleCount: number;
|
|
360
416
|
lastSyncTime?: string;
|
|
361
417
|
lastCodeIndexTime?: string;
|
|
418
|
+
lastArchitectureIndexTime?: string;
|
|
362
419
|
lastRuleIndexTime?: string;
|
|
363
420
|
lastSuccessfulRun?: string;
|
|
364
421
|
lastFailedRun?: string;
|
|
@@ -456,7 +513,7 @@ declare function upsertPullRequest(db: AnchorDatabase, pr: PullRequestRecord, wi
|
|
|
456
513
|
wisdom: number;
|
|
457
514
|
regressions: number;
|
|
458
515
|
};
|
|
459
|
-
declare function replaceCodeIndex(db: AnchorDatabase, repo: string, codeFiles: CodeFileRecord[], codeChunks: CodeChunk[], skippedFiles: number, cwd: string): CodeIndexSummary;
|
|
516
|
+
declare function replaceCodeIndex(db: AnchorDatabase, repo: string, codeFiles: CodeFileRecord[], codeChunks: CodeChunk[], skippedFiles: number, cwd: string, architecture?: ArchitectureIndexData): CodeIndexSummary;
|
|
460
517
|
declare function recordIndexRun(db: AnchorDatabase, run: IndexRunRecord): void;
|
|
461
518
|
declare function getIndexStatus(cwd: string, githubTokenConfigured?: boolean, databasePath?: string): IndexStatus;
|
|
462
519
|
declare function getWisdomCategoryCounts(db: AnchorDatabase): Record<WisdomCategory, number>;
|
|
@@ -475,6 +532,10 @@ declare function chunkCodeFile(file: ChunkableCodeFile, options?: {
|
|
|
475
532
|
overlapLines?: number;
|
|
476
533
|
}): CodeChunk[];
|
|
477
534
|
|
|
535
|
+
declare function classifyArchitectureArea(filePath: string, language?: string, content?: string): ArchitectureArea;
|
|
536
|
+
declare function extractCodeImports(sourcePath: string, content: string, codePaths: Set<string>, repo?: string): CodeImport[];
|
|
537
|
+
declare function buildArchitectureIndex(repo: string, files: ChunkableCodeFile[], chunks: CodeChunk[]): ArchitectureIndexData;
|
|
538
|
+
|
|
478
539
|
declare const DEFAULT_MAX_CODE_FILE_BYTES: number;
|
|
479
540
|
type DiscoveredCodeFile = CodeFileRecord & {
|
|
480
541
|
absolutePath: string;
|
|
@@ -531,6 +592,11 @@ declare function rankWisdomUnits(db: AnchorDatabase, input: AnchorContextInput |
|
|
|
531
592
|
|
|
532
593
|
declare function rankCodeChunks(db: AnchorDatabase, input: AnchorContextInput): RankedCodeChunk[];
|
|
533
594
|
|
|
595
|
+
type ArchitectureQueryInput = AnchorContextInput & {
|
|
596
|
+
area?: ArchitectureArea;
|
|
597
|
+
};
|
|
598
|
+
declare function rankArchitecturePatterns(db: AnchorDatabase, input: ArchitectureQueryInput): RankedArchitecturePattern[];
|
|
599
|
+
|
|
534
600
|
declare function rankRelevantTests(db: AnchorDatabase, input: AnchorContextInput): RankedTestFile[];
|
|
535
601
|
|
|
536
602
|
declare function rankRegressionEvents(db: AnchorDatabase, input: AnchorContextInput | SearchHistoryInput): RankedRegressionEvent[];
|
|
@@ -539,7 +605,7 @@ type FormattedResult = {
|
|
|
539
605
|
markdown: string;
|
|
540
606
|
metadata: Record<string, unknown>;
|
|
541
607
|
};
|
|
542
|
-
declare function formatAnchorContext(units: RankedWisdomUnit[], input: AnchorContextInput, codeChunks?: RankedCodeChunk[], teamRules?: RankedTeamRule[], warnings?: string[], relevantTests?: RankedTestFile[], regressionEvents?: RankedRegressionEvent[], extraMetadata?: Record<string, unknown>): FormattedResult;
|
|
608
|
+
declare function formatAnchorContext(units: RankedWisdomUnit[], input: AnchorContextInput, codeChunks?: RankedCodeChunk[], teamRules?: RankedTeamRule[], warnings?: string[], relevantTests?: RankedTestFile[], regressionEvents?: RankedRegressionEvent[], architecturePatterns?: RankedArchitecturePattern[], extraMetadata?: Record<string, unknown>): FormattedResult;
|
|
543
609
|
declare function formatSearchHistory(units: RankedWisdomUnit[]): FormattedResult;
|
|
544
610
|
declare function formatIndexStatus(status: IndexStatus): FormattedResult;
|
|
545
611
|
|
|
@@ -547,6 +613,21 @@ declare function buildAnchorContextResult(db: AnchorDatabase, cwd: string, input
|
|
|
547
613
|
|
|
548
614
|
declare function explainFile(db: AnchorDatabase, cwd: string, input: AnchorExplainFileInput): FormattedResult;
|
|
549
615
|
|
|
616
|
+
type ArchitectureContextInput = {
|
|
617
|
+
file?: string;
|
|
618
|
+
area?: ArchitectureArea;
|
|
619
|
+
query?: string;
|
|
620
|
+
maxResults?: number;
|
|
621
|
+
};
|
|
622
|
+
type ArchitectureCheckInput = {
|
|
623
|
+
diff: string;
|
|
624
|
+
files?: string[];
|
|
625
|
+
maxResults?: number;
|
|
626
|
+
};
|
|
627
|
+
declare function architectureFilesFromDiff(diff: string): string[];
|
|
628
|
+
declare function getArchitectureContext(db: AnchorDatabase, _cwd: string, input?: ArchitectureContextInput): FormattedResult;
|
|
629
|
+
declare function checkArchitecture(db: AnchorDatabase, _cwd: string, input: ArchitectureCheckInput): FormattedResult;
|
|
630
|
+
|
|
550
631
|
declare function filesFromDiff(diff: string): string[];
|
|
551
632
|
declare function reviewDiff(db: AnchorDatabase, cwd: string, input: AnchorReviewDiffInput): FormattedResult;
|
|
552
633
|
|
|
@@ -634,7 +715,7 @@ declare function countValidTeamRules(cwd: string): {
|
|
|
634
715
|
lastRuleIndexTime?: string;
|
|
635
716
|
};
|
|
636
717
|
|
|
637
|
-
type CoverageInput = Pick<IndexStatus, "prCount" | "wisdomUnitCount" | "codeFileCount" | "codeChunkCount" | "testLinkCount" | "regressionEventCount" | "teamRuleCount" | "historyCoverage" | "staleEvidenceCount" | "staleCodeIndex">;
|
|
718
|
+
type CoverageInput = Pick<IndexStatus, "prCount" | "wisdomUnitCount" | "codeFileCount" | "codeChunkCount" | "testLinkCount" | "regressionEventCount" | "architecturePatternCount" | "teamRuleCount" | "historyCoverage" | "staleEvidenceCount" | "staleCodeIndex">;
|
|
638
719
|
type CoverageReport = {
|
|
639
720
|
coverageScore: number;
|
|
640
721
|
coverageGrade: CoverageGrade;
|
|
@@ -685,4 +766,4 @@ declare function getAnchorIndexHealth(cwd: string): AnchorIndexHealth & {
|
|
|
685
766
|
indexStatus: IndexStatus;
|
|
686
767
|
};
|
|
687
768
|
|
|
688
|
-
export { ANCHOR_CURSOR_RULE, type AnchorContextInput, type AnchorDatabase, type AnchorExplainFileInput, type AnchorIndexHealth, type AnchorReviewDiffInput, type ChunkableCodeFile, type CodeChunk, type CodeFileDiscoveryResult, type CodeFileRecord, 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 FetchPullRequestsOptions, type FetchPullRequestsProgress, type FormattedResult, type FreshnessResult, type FreshnessStatus, type GitHubRepo, type GitHubTokenResolution, type GitHubTokenResolverOptions, type GitHubTokenSource, type IndexPullRequestsProgress, type IndexRunRecord, type IndexStatus, type IndexSummary, type LocalEmbeddingProvider, type PullRequestComment, type PullRequestCommit, type PullRequestFile, type PullRequestPerson, type PullRequestRecord, type RankedCodeChunk, type RankedRegressionEvent, type RankedTeamRule, type RankedTestFile, type RankedWisdomUnit, type RegressionEvent, type RulesAddInput, type RulesAddResult, type RulesEvidenceCheckResult, type RulesInitResult, type RulesSuggestOptions, SCHEMA_SQL, type SearchHistoryInput, type SemanticStatus, type SourceType, type SuggestedPrompt, TEAM_RULES_FILE, type TeamRule, type TeamRuleSuggestion, type TeamRulesValidationResult, type TestFileRecord, type TestLink, type WisdomCategory, type WisdomUnit, addTeamRule, anchorMcpEntry, buildAnchorContextResult, buildFtsQuery, buildQueryTerms, calculateCoverage, canonicalizeText, categorizeWisdom, checkSchema, checkTeamRuleEvidence, chunkCodeFile, chunkHistoricalText, claimKeyFor, clampMaxResults, clipSentence, confidenceAtLeast, confidenceLevelFor, confidenceRank, confidenceReasonsFor, countValidTeamRules, createGitHubClient, defaultDatabasePath, detectGitHubRepo, detectGitRoot, discoverCodeFiles, emptyCodeIndexSummary, ensureAnchorGitExclude, ensureCursorConfig, ensureCursorRule, ensureRepository, ensureTeamRulesFile, evaluateFreshness, evaluateIndexHealth, evidenceForWisdom, explainFile, extractCodeSymbols, extractRegressionEvents, extractSymbols, extractWisdomUnits, fetchMergedPullRequests, fetchPullRequestDetails, filesFromDiff, formatAnchorContext, formatIndexStatus, formatSearchHistory, getAnchorIndexHealth, getIndexStatus, getLastSyncTime, getSemanticStatus, getSuggestedPromptTexts, getSuggestedPrompts, getWisdomCategoryCounts, githubAuthFixMessage, hasHighSignalLanguage, indexCodebase, indexPullRequests, inferTestAwareness, initializeSchema, isHardExcludedCodePath, isTestFilePath, loadCurrentCodeSnapshot, loadTeamRulesFile, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, parseGitHubRemote, rankCodeChunks, rankRegressionEvents, rankRelevantTests, rankTeamRules, rankWisdomUnits, recordIndexRun, redactSecrets, redactedHistoricalText, replaceCodeIndex, resolveGitHubToken, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, reviewDiff, runDoctor, sanitizeHistoricalText, shouldSyncSince, sourceTypeLabel, stripPromptInjection, suggestTeamRules, tokenizeSearchText, truncateText, uniqueStrings, updateSyncState, upsertPullRequest, validateTeamRulesFile };
|
|
769
|
+
export { ANCHOR_CURSOR_RULE, type AnchorContextInput, type AnchorDatabase, type AnchorExplainFileInput, type AnchorIndexHealth, type AnchorReviewDiffInput, type ArchitectureArea, type ArchitectureCheckInput, type ArchitectureComponent, type ArchitectureContextInput, type ArchitectureIndexData, 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 FetchPullRequestsOptions, type FetchPullRequestsProgress, type FormattedResult, type FreshnessResult, type FreshnessStatus, type GitHubRepo, type GitHubTokenResolution, type GitHubTokenResolverOptions, type GitHubTokenSource, type IndexPullRequestsProgress, type IndexRunRecord, type IndexStatus, type IndexSummary, type LocalEmbeddingProvider, 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 RulesAddInput, type RulesAddResult, type RulesEvidenceCheckResult, type RulesInitResult, type RulesSuggestOptions, SCHEMA_SQL, type SearchHistoryInput, type SemanticStatus, type SourceType, type SuggestedPrompt, TEAM_RULES_FILE, type TeamRule, type TeamRuleSuggestion, type TeamRulesValidationResult, type TestFileRecord, type TestLink, type WisdomCategory, type WisdomUnit, addTeamRule, anchorMcpEntry, architectureFilesFromDiff, buildAnchorContextResult, buildArchitectureIndex, buildFtsQuery, buildQueryTerms, calculateCoverage, canonicalizeText, categorizeWisdom, checkArchitecture, checkSchema, checkTeamRuleEvidence, chunkCodeFile, chunkHistoricalText, claimKeyFor, clampMaxResults, classifyArchitectureArea, clipSentence, confidenceAtLeast, confidenceLevelFor, confidenceRank, confidenceReasonsFor, countValidTeamRules, createGitHubClient, defaultDatabasePath, detectGitHubRepo, detectGitRoot, discoverCodeFiles, emptyCodeIndexSummary, ensureAnchorGitExclude, ensureCursorConfig, ensureCursorRule, ensureRepository, ensureTeamRulesFile, evaluateFreshness, evaluateIndexHealth, evidenceForWisdom, explainFile, extractCodeImports, extractCodeSymbols, extractRegressionEvents, extractSymbols, extractWisdomUnits, fetchMergedPullRequests, fetchPullRequestDetails, filesFromDiff, formatAnchorContext, formatIndexStatus, formatSearchHistory, getAnchorIndexHealth, getArchitectureContext, getIndexStatus, getLastSyncTime, getSemanticStatus, getSuggestedPromptTexts, getSuggestedPrompts, getWisdomCategoryCounts, githubAuthFixMessage, hasHighSignalLanguage, indexCodebase, indexPullRequests, inferTestAwareness, initializeSchema, isHardExcludedCodePath, isTestFilePath, loadCurrentCodeSnapshot, loadTeamRulesFile, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, parseGitHubRemote, rankArchitecturePatterns, rankCodeChunks, rankRegressionEvents, rankRelevantTests, rankTeamRules, rankWisdomUnits, recordIndexRun, redactSecrets, redactedHistoricalText, replaceCodeIndex, resolveGitHubToken, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, reviewDiff, runDoctor, sanitizeHistoricalText, shouldSyncSince, sourceTypeLabel, stripPromptInjection, suggestTeamRules, tokenizeSearchText, truncateText, uniqueStrings, updateSyncState, upsertPullRequest, validateTeamRulesFile };
|