@ninjaxtools/slopdex 0.13.0 → 0.14.0

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
@@ -3,6 +3,7 @@ declare class CodeIndex {
3
3
  readonly rootDir: string;
4
4
  readonly indexPath: string;
5
5
  readonly provider: EmbeddingProvider;
6
+ readonly reranker: Reranker | undefined;
6
7
  readonly descriptionProvider: DescriptionProvider;
7
8
  constructor(options: CodeIndexOptions);
8
9
  close(): void;
@@ -105,6 +106,24 @@ interface EmbeddingProvider {
105
106
  signal?: AbortSignal;
106
107
  }): Promise<number[]>;
107
108
  }
109
+ interface RerankerProfile {
110
+ provider: string;
111
+ model: string;
112
+ }
113
+ interface Reranker {
114
+ readonly profile: RerankerProfile;
115
+ /** Preferred embedding-ranked candidate pool size for this reranker. */
116
+ readonly candidateCount?: number;
117
+ /** Maximum candidate/result count accepted by this reranker. */
118
+ readonly maximumCandidateCount?: number;
119
+ rerank(query: string, documents: readonly string[], options?: {
120
+ limit?: number;
121
+ signal?: AbortSignal;
122
+ }): Promise<Array<{
123
+ index: number;
124
+ score: number;
125
+ }>>;
126
+ }
108
127
  interface DescriptionProfile {
109
128
  provider: string;
110
129
  model: string;
@@ -149,6 +168,8 @@ interface CodeIndexOptions {
149
168
  rootDir: string;
150
169
  indexPath?: string;
151
170
  provider: EmbeddingProvider;
171
+ /** Optional second-stage ranker for natural-language query searches. */
172
+ reranker?: Reranker;
152
173
  descriptionProvider?: DescriptionProvider;
153
174
  onWarning?: (message: string) => void;
154
175
  include?: readonly string[];
@@ -218,6 +239,8 @@ interface AnalysisSimilarity {
218
239
  }
219
240
  interface SimilarityResult extends SimilarityScores {
220
241
  function: IndexedFunction;
242
+ /** Provider relevance score when a second-stage reranker ordered this result. */
243
+ rerankScore?: number;
221
244
  }
222
245
  type CrossSearchSourceFilter = ({
223
246
  type: "all";
@@ -243,6 +266,8 @@ interface CrossSearchOptions {
243
266
  maxSimilarity?: number;
244
267
  includeSymmetricDuplicates?: boolean;
245
268
  crossFileOnly?: boolean;
269
+ /** Re-rank each source's semantic matches from greatest to least physical path distance. */
270
+ cohesion?: boolean;
246
271
  minLines?: number;
247
272
  nameRegex?: string;
248
273
  signal?: AbortSignal;
@@ -251,9 +276,13 @@ interface CrossSearchOptions {
251
276
  total: number;
252
277
  }) => void;
253
278
  }
279
+ interface CrossSearchMatch extends SimilarityResult {
280
+ /** Present when cohesion re-ranking is enabled. */
281
+ physicalDistance?: number;
282
+ }
254
283
  interface CrossSearchResult {
255
284
  source: IndexedFunction;
256
- matches: SimilarityResult[];
285
+ matches: CrossSearchMatch[];
257
286
  scoring?: AnalysisSimilarity & {
258
287
  sourceDescriptionProfile: DescriptionProfile | null;
259
288
  targetDescriptionProfile: DescriptionProfile | null;
@@ -455,6 +484,66 @@ declare class JinaEmbeddingProvider implements EmbeddingProvider {
455
484
  }): Promise<number[]>;
456
485
  }
457
486
 
487
+ interface HostedRerankerOptions {
488
+ apiKey?: string;
489
+ model?: string;
490
+ baseUrl?: string;
491
+ }
492
+ interface HostedRerankerSettings {
493
+ provider: "cohere" | "jina";
494
+ apiKeyName: "COHERE_API_KEY" | "JINA_API_KEY";
495
+ defaultModel: string;
496
+ defaultUrl: string;
497
+ returnDocuments?: boolean;
498
+ }
499
+ declare abstract class HostedReranker implements Reranker {
500
+ #private;
501
+ readonly profile: {
502
+ readonly provider: "jina" | "cohere";
503
+ readonly model: string;
504
+ };
505
+ protected constructor(options: HostedRerankerOptions, settings: HostedRerankerSettings);
506
+ rerank(query: string, documents: readonly string[], options?: {
507
+ limit?: number;
508
+ signal?: AbortSignal;
509
+ }): Promise<Array<{
510
+ index: number;
511
+ score: number;
512
+ }>>;
513
+ }
514
+ type CohereRerankerOptions = HostedRerankerOptions;
515
+ declare class CohereReranker extends HostedReranker {
516
+ constructor(options?: CohereRerankerOptions);
517
+ }
518
+ type JinaRerankerOptions = HostedRerankerOptions;
519
+ declare class JinaReranker extends HostedReranker {
520
+ constructor(options?: JinaRerankerOptions);
521
+ }
522
+
523
+ interface OpenAILLMRerankerOptions {
524
+ apiKey?: string;
525
+ model?: string;
526
+ baseUrl?: string;
527
+ candidateCount?: number;
528
+ }
529
+ declare class OpenAILLMReranker implements Reranker {
530
+ #private;
531
+ readonly profile: {
532
+ readonly provider: "openai";
533
+ readonly model: string;
534
+ };
535
+ readonly candidateCount: number;
536
+ readonly maximumCandidateCount = 100;
537
+ constructor(options?: OpenAILLMRerankerOptions);
538
+ rerank(query: string, documents: readonly string[], options?: {
539
+ limit?: number;
540
+ signal?: AbortSignal;
541
+ }): Promise<Array<{
542
+ index: number;
543
+ score: number;
544
+ }>>;
545
+ }
546
+
458
547
  declare class CodeIndexError extends Error {
459
548
  constructor(message: string, options?: ErrorOptions);
460
549
  }
@@ -482,4 +571,4 @@ declare function searchDescription(index: CodeIndex, options: SimilaritySearchOp
482
571
  declare function crossSearchFunctions(options: CrossSearchOptions): AsyncGenerator<CrossSearchResult, any, any>;
483
572
  declare function analyzeCodeCohesion(options: CohesionAnalysisOptions): Promise<CohesionReport<IndexedFunction>>;
484
573
 
485
- export { type AnalysisSimilarity, type CallableKind, CodeIndex, CodeIndexError, type CodeIndexOptions, type CohesionAnalysisOptions, type CohesionFileReport, type CohesionFunctionReference, type CohesionGroup, type CohesionJsonReport, type CohesionLocation, type CohesionLocationCategory, type CohesionMetrics, type CohesionPair, type CohesionReport, type CrossSearchOptions, type CrossSearchResult, type CrossSearchSourceFilter, type DescriptionFileInput, type DescriptionFileSession, type DescriptionInput, type DescriptionProfile, type DescriptionProvider, type DescriptionProviderName, type DescriptionStats, type EmbeddingProfile, type EmbeddingProvider, GitDivergenceError, GitUnavailableError, IncompatibleIndexError, type IndexStatus, type IndexedFunction, type IndexingError, type IndexingIssue, JinaEmbeddingProvider, type JinaEmbeddingProviderOptions, OpenAIDescriptionProvider, type OpenAIDescriptionProviderOptions, OpenAIEmbeddingProvider, type OpenAIEmbeddingProviderOptions, type ParsedCallable, type ReindexFilesOptions, type ReindexFilesStats, type SimilarityResult, type SimilarityScores, type SimilaritySearchOptions, type SourceMode, type SupportedLanguage, type UpdateFilesOptions, type UpdateFromGitOptions, type UpdateFromWorkingTreeOptions, type UpdateStats, analyzeCodeCohesion, analyzeCohesion, cohesionLocation, crossSearch, crossSearchFunctions, disableDescriptions, openCodeIndex, readIndexErrors, reindexFiles, searchDescription, similaritySearch, updateFiles, updateFromGit, updateFromWorkingTree, useDescriptions };
574
+ export { type AnalysisSimilarity, type CallableKind, CodeIndex, CodeIndexError, type CodeIndexOptions, CohereReranker, type CohereRerankerOptions, type CohesionAnalysisOptions, type CohesionFileReport, type CohesionFunctionReference, type CohesionGroup, type CohesionJsonReport, type CohesionLocation, type CohesionLocationCategory, type CohesionMetrics, type CohesionPair, type CohesionReport, type CrossSearchMatch, type CrossSearchOptions, type CrossSearchResult, type CrossSearchSourceFilter, type DescriptionFileInput, type DescriptionFileSession, type DescriptionInput, type DescriptionProfile, type DescriptionProvider, type DescriptionProviderName, type DescriptionStats, type EmbeddingProfile, type EmbeddingProvider, GitDivergenceError, GitUnavailableError, IncompatibleIndexError, type IndexStatus, type IndexedFunction, type IndexingError, type IndexingIssue, JinaEmbeddingProvider, type JinaEmbeddingProviderOptions, JinaReranker, type JinaRerankerOptions, OpenAIDescriptionProvider, type OpenAIDescriptionProviderOptions, OpenAIEmbeddingProvider, type OpenAIEmbeddingProviderOptions, OpenAILLMReranker, type OpenAILLMRerankerOptions, type ParsedCallable, type ReindexFilesOptions, type ReindexFilesStats, type Reranker, type RerankerProfile, type SimilarityResult, type SimilarityScores, type SimilaritySearchOptions, type SourceMode, type SupportedLanguage, type UpdateFilesOptions, type UpdateFromGitOptions, type UpdateFromWorkingTreeOptions, type UpdateStats, analyzeCodeCohesion, analyzeCohesion, cohesionLocation, crossSearch, crossSearchFunctions, disableDescriptions, openCodeIndex, readIndexErrors, reindexFiles, searchDescription, similaritySearch, updateFiles, updateFromGit, updateFromWorkingTree, useDescriptions };