@pratik7368patil/anchor-core 0.1.14 → 0.1.15

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
@@ -211,6 +211,95 @@ type RankedRegressionEvent = RegressionEvent & {
211
211
  matchReasons: string[];
212
212
  rankSignals: Record<string, number>;
213
213
  };
214
+ type TestCommand = {
215
+ command: string;
216
+ reason: string;
217
+ confidence: ConfidenceLevel;
218
+ filePath?: string;
219
+ };
220
+ type TaskPlan = {
221
+ targetFiles: string[];
222
+ likelySymbols: string[];
223
+ implementationSteps: string[];
224
+ risks: string[];
225
+ recommendedTests: string[];
226
+ evidence: EvidenceRef[];
227
+ testCommands: TestCommand[];
228
+ };
229
+ type ArchitectureMapFormat = "mermaid" | "json";
230
+ type ArchitectureMapNode = {
231
+ id: string;
232
+ label: string;
233
+ area: ArchitectureArea;
234
+ path?: string;
235
+ };
236
+ type ArchitectureMapEdge = {
237
+ source: string;
238
+ target: string;
239
+ relationship: string;
240
+ weight: number;
241
+ };
242
+ type ArchitectureMap = {
243
+ format: ArchitectureMapFormat;
244
+ nodes: ArchitectureMapNode[];
245
+ edges: ArchitectureMapEdge[];
246
+ mermaid?: string;
247
+ };
248
+ type RetrievalEvalCase = {
249
+ id: string;
250
+ task: string;
251
+ files: string[];
252
+ expectedPrs: number[];
253
+ expectedCategories: WisdomCategory[];
254
+ };
255
+ type RetrievalEvalResult = {
256
+ id: string;
257
+ task: string;
258
+ passed: boolean;
259
+ expectedPrs: number[];
260
+ foundPrs: number[];
261
+ missingPrs: number[];
262
+ expectedCategories: WisdomCategory[];
263
+ foundCategories: WisdomCategory[];
264
+ missingCategories: WisdomCategory[];
265
+ };
266
+ type RetrievalEvalRunResult = {
267
+ ok: boolean;
268
+ path: string;
269
+ total: number;
270
+ passed: number;
271
+ failed: number;
272
+ results: RetrievalEvalResult[];
273
+ };
274
+ type FeedbackRating = "useful" | "not-useful";
275
+ type FeedbackEvent = {
276
+ resultId: string;
277
+ rating: FeedbackRating;
278
+ note?: string;
279
+ createdAt: string;
280
+ };
281
+ type Playbook = {
282
+ id: string;
283
+ title: string;
284
+ body: string;
285
+ evidence: EvidenceRef[];
286
+ createdAt: string;
287
+ };
288
+ type OnboardingPack = {
289
+ title: string;
290
+ areas: Array<{
291
+ area: ArchitectureArea;
292
+ files: string[];
293
+ patternCount: number;
294
+ }>;
295
+ importantFiles: string[];
296
+ riskyModules: string[];
297
+ relevantTests: string[];
298
+ topRules: TeamRule[];
299
+ playbooks: Playbook[];
300
+ starterPrompts: string[];
301
+ architectureMap: ArchitectureMap;
302
+ };
214
303
  type FetchPullRequestsProgress = {
215
304
  stage: "discovering_pull_requests";
216
305
  repo: string;
@@ -439,6 +528,11 @@ type IndexStatus = {
439
528
  architectureComponentCount: number;
440
529
  architecturePatternCount: number;
441
530
  architectureImportCount: number;
531
+ architectureMapEdgeCount: number;
532
+ testCommandCount: number;
533
+ retrievalEvalCount: number;
534
+ feedbackEventCount: number;
535
+ playbookCount: number;
442
536
  historyCoverage?: "limited" | "all" | "unknown";
443
537
  historyLimit?: number;
444
538
  staleEvidenceCount: number;
@@ -447,6 +541,7 @@ type IndexStatus = {
447
541
  lastCodeIndexTime?: string;
448
542
  lastArchitectureIndexTime?: string;
449
543
  lastRuleIndexTime?: string;
544
+ lastWatchIndexTime?: string;
450
545
  lastSuccessfulRun?: string;
451
546
  lastFailedRun?: string;
452
547
  staleCodeIndex?: boolean;
@@ -635,7 +730,7 @@ type FormattedResult = {
635
730
  markdown: string;
636
731
  metadata: Record<string, unknown>;
637
732
  };
638
- declare function formatAnchorContext(units: RankedWisdomUnit[], input: AnchorContextInput, codeChunks?: RankedCodeChunk[], teamRules?: RankedTeamRule[], warnings?: string[], relevantTests?: RankedTestFile[], regressionEvents?: RankedRegressionEvent[], architecturePatterns?: RankedArchitecturePattern[], extraMetadata?: Record<string, unknown>): FormattedResult;
733
+ declare function formatAnchorContext(units: RankedWisdomUnit[], input: AnchorContextInput, codeChunks?: RankedCodeChunk[], teamRules?: RankedTeamRule[], warnings?: string[], relevantTests?: RankedTestFile[], regressionEvents?: RankedRegressionEvent[], architecturePatterns?: RankedArchitecturePattern[], extraMetadata?: Record<string, unknown>, testCommands?: TestCommand[]): FormattedResult;
639
734
  declare function formatSearchHistory(units: RankedWisdomUnit[]): FormattedResult;
640
735
  declare function formatIndexStatus(status: IndexStatus): FormattedResult;
641
736
 
@@ -643,11 +738,21 @@ declare function buildAnchorContextResult(db: AnchorDatabase, cwd: string, input
643
738
 
644
739
  declare function explainFile(db: AnchorDatabase, cwd: string, input: AnchorExplainFileInput): FormattedResult;
645
740
 
741
+ type ArchitectureMapInput = {
742
+ file?: string;
743
+ area?: ArchitectureArea;
744
+ format?: ArchitectureMapFormat;
745
+ maxNodes?: number;
746
+ };
747
+ declare function buildArchitectureMap(db: AnchorDatabase, input?: ArchitectureMapInput): ArchitectureMap;
748
+
646
749
  type ArchitectureContextInput = {
647
750
  file?: string;
648
751
  area?: ArchitectureArea;
649
752
  query?: string;
650
753
  maxResults?: number;
754
+ map?: boolean;
755
+ format?: "mermaid" | "json";
651
756
  };
652
757
  type ArchitectureCheckInput = {
653
758
  diff: string;
@@ -655,12 +760,25 @@ type ArchitectureCheckInput = {
655
760
  maxResults?: number;
656
761
  };
657
762
  declare function architectureFilesFromDiff(diff: string): string[];
763
+ declare function getArchitectureMapContext(db: AnchorDatabase, input?: ArchitectureMapInput): FormattedResult;
658
764
  declare function getArchitectureContext(db: AnchorDatabase, _cwd: string, input?: ArchitectureContextInput): FormattedResult;
659
765
  declare function checkArchitecture(db: AnchorDatabase, _cwd: string, input: ArchitectureCheckInput): FormattedResult;
660
766
 
661
767
  declare function filesFromDiff(diff: string): string[];
662
768
  declare function reviewDiff(db: AnchorDatabase, cwd: string, input: AnchorReviewDiffInput): FormattedResult;
663
769
 
770
+ declare function planTask(db: AnchorDatabase, cwd: string, input: AnchorContextInput): FormattedResult;
771
+
772
+ declare function detectTestCommandsForFile(db: AnchorDatabase, cwd: string, filePath: string): TestCommand[];
773
+ declare function detectTestCommands(db: AnchorDatabase, cwd: string, files?: string[]): TestCommand[];
774
+ declare function refreshTestCommands(db: AnchorDatabase, cwd: string, repo: string, files?: string[]): TestCommand[];
775
+
776
+ type OnboardingInput = {
777
+ file?: string;
778
+ area?: ArchitectureArea;
779
+ };
780
+ declare function buildOnboardingPack(db: AnchorDatabase, cwd: string, input?: OnboardingInput): FormattedResult;
781
+
664
782
  type LocalEmbeddingProvider = {
665
783
  name: string;
666
784
  isAvailable(): boolean;
@@ -753,7 +871,7 @@ declare function countValidTeamRules(cwd: string): {
753
871
  lastRuleIndexTime?: string;
754
872
  };
755
873
 
756
- type CoverageInput = Pick<IndexStatus, "prCount" | "wisdomUnitCount" | "codeFileCount" | "codeChunkCount" | "testLinkCount" | "regressionEventCount" | "architecturePatternCount" | "teamRuleCount" | "historyCoverage" | "staleEvidenceCount" | "staleCodeIndex">;
874
+ type CoverageInput = Pick<IndexStatus, "prCount" | "wisdomUnitCount" | "codeFileCount" | "codeChunkCount" | "testLinkCount" | "testCommandCount" | "regressionEventCount" | "architecturePatternCount" | "architectureMapEdgeCount" | "teamRuleCount" | "retrievalEvalCount" | "playbookCount" | "historyCoverage" | "staleEvidenceCount" | "staleCodeIndex">;
757
875
  type CoverageReport = {
758
876
  coverageScore: number;
759
877
  coverageGrade: CoverageGrade;
@@ -763,13 +881,60 @@ type CoverageReport = {
763
881
  declare function calculateCoverage(input: CoverageInput): CoverageReport;
764
882
 
765
883
  type SuggestedPrompt = {
766
- id: "before_edit" | "explain_file" | "strict_mode" | "review_diff";
884
+ id: "before_edit" | "plan_task" | "test_command" | "explain_file" | "strict_mode" | "review_diff" | "onboarding" | "playbook";
767
885
  title: string;
768
886
  prompt: string;
769
887
  };
770
888
  declare function getSuggestedPrompts(): SuggestedPrompt[];
771
889
  declare function getSuggestedPromptTexts(): string[];
772
890
 
891
+ declare const ANCHOR_EVALS_FILE = "anchor.evals.json";
892
+ declare function initRetrievalEvals(cwd: string): {
893
+ path: string;
894
+ created: boolean;
895
+ };
896
+ declare function addRetrievalEval(db: AnchorDatabase, cwd: string, input: {
897
+ task: string;
898
+ files?: string[];
899
+ expectedPrs?: number[];
900
+ expectedCategories?: WisdomCategory[];
901
+ }): RetrievalEvalCase;
902
+ declare function runRetrievalEvals(db: AnchorDatabase, cwd: string): RetrievalEvalRunResult;
903
+
904
+ declare function recordFeedback(db: AnchorDatabase, input: {
905
+ resultId: string;
906
+ rating: FeedbackRating;
907
+ note?: string;
908
+ }): FeedbackEvent;
909
+ declare function feedbackAdjustedScore(db: AnchorDatabase, resultId: string, baseScore: number): number;
910
+ declare function listFeedbackEvents(db: AnchorDatabase, limit?: number): FeedbackEvent[];
911
+
912
+ declare const ANCHOR_PLAYBOOKS_FILE = "anchor.playbooks.json";
913
+ declare function initPlaybooks(cwd: string): {
914
+ path: string;
915
+ created: boolean;
916
+ };
917
+ declare function listPlaybooks(cwd: string): Playbook[];
918
+ declare function getPlaybook(cwd: string, id: string): Playbook | undefined;
919
+ declare function suggestPlaybooks(db: AnchorDatabase, _cwd: string): Playbook[];
920
+ declare function syncPlaybooksToDatabase(db: AnchorDatabase, cwd: string): number;
921
+
922
+ type WatchRefreshInput = {
923
+ cwd: string;
924
+ repo?: string;
925
+ };
926
+ declare function refreshWatchIndex(db: AnchorDatabase, input: WatchRefreshInput): CodeIndexSummary;
927
+ declare function watchCodebase(db: AnchorDatabase, input: WatchRefreshInput & {
928
+ intervalSeconds?: number;
929
+ onRefresh?: (summary: CodeIndexSummary) => void;
930
+ }): () => void;
931
+
932
+ type AnchorCiInput = {
933
+ strict?: boolean;
934
+ minCoverage?: number;
935
+ };
936
+ declare function runAnchorCi(db: AnchorDatabase, cwd: string, input?: AnchorCiInput): FormattedResult;
937
+
773
938
  declare const DEMO_REPO = "anchor/demo";
774
939
  declare const DEMO_PULL_REQUESTS: PullRequestRecord[];
775
940
  declare const DEMO_CODE_FILES: Record<string, string>;
@@ -843,4 +1008,4 @@ declare function getAnchorIndexHealth(cwd: string): AnchorIndexHealth & {
843
1008
  indexStatus: IndexStatus;
844
1009
  };
845
1010
 
846
- 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 GitHubRateLimitController, type GitHubRateLimitErrorLike, type GitHubRateLimitProgress, 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 ReliabilityGate, type ReliabilityGateRejection, type ReliabilityGateResult, type ReliabilityGateStatus, 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, evaluateReliabilityGate, evidenceForWisdom, explainFile, extractCodeImports, extractCodeSymbols, extractRegressionEvents, extractSymbols, extractWisdomUnits, fetchMergedPullRequests, fetchPullRequestDetails, filesFromDiff, formatAnchorContext, formatIndexStatus, formatSearchHistory, getAnchorIndexHealth, getArchitectureContext, getGitHubRateLimitDelayMs, getIndexStatus, getLastSyncTime, getSemanticStatus, getSuggestedPromptTexts, getSuggestedPrompts, getWisdomCategoryCounts, githubAuthFixMessage, hasHighSignalLanguage, indexCodebase, indexPullRequests, inferTestAwareness, initializeSchema, isGitHubRateLimitError, isHardExcludedCodePath, isTestFilePath, loadCurrentCodeSnapshot, loadTeamRulesFile, mergeAnchorMcpConfig, normalizePullRequest, openAnchorDatabase, paginateWithGitHubRateLimit, parseGitHubRemote, rankArchitecturePatterns, rankCodeChunks, rankRegressionEvents, rankRelevantTests, rankTeamRules, rankWisdomUnits, recordIndexRun, redactSecrets, redactedHistoricalText, replaceCodeIndex, requestWithGitHubRateLimit, resolveGitHubToken, resolvePullRequestDetailConcurrency, resolvePullRequestFetchLimit, reviewDiff, runDoctor, sanitizeHistoricalText, shouldSyncSince, sourceTypeLabel, stripPromptInjection, suggestTeamRules, tokenizeSearchText, truncateText, uniqueStrings, updateSyncState, upsertPullRequest, validateTeamRulesFile };
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 };