raggrep 0.1.3 → 0.1.4
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/{indexer → app/indexer}/index.d.ts +1 -1
- package/dist/{search → app/search}/index.d.ts +1 -1
- package/dist/cli/main.js +1294 -217
- package/dist/cli/main.js.map +25 -15
- package/dist/composition.d.ts +7 -7
- package/dist/domain/entities/index.d.ts +1 -1
- package/dist/domain/entities/searchResult.d.ts +47 -2
- package/dist/domain/index.d.ts +5 -3
- package/dist/domain/ports/embedding.d.ts +0 -4
- package/dist/domain/ports/index.d.ts +3 -4
- package/dist/domain/services/bm25.d.ts +24 -0
- package/dist/domain/services/index.d.ts +3 -2
- package/dist/domain/services/similarity.d.ts +23 -0
- package/dist/{application → domain}/usecases/cleanupIndex.d.ts +2 -2
- package/dist/{application → domain}/usecases/indexDirectory.d.ts +2 -2
- package/dist/{application → domain}/usecases/searchIndex.d.ts +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1305 -239
- package/dist/index.js.map +25 -15
- package/dist/{utils/config.d.ts → infrastructure/config/configLoader.d.ts} +7 -4
- package/dist/infrastructure/config/index.d.ts +6 -0
- package/dist/infrastructure/embeddings/index.d.ts +3 -1
- package/dist/infrastructure/embeddings/transformersEmbedding.d.ts +16 -0
- package/dist/infrastructure/index.d.ts +4 -3
- package/dist/infrastructure/storage/index.d.ts +4 -1
- package/dist/{utils/tieredIndex.d.ts → infrastructure/storage/symbolicIndex.d.ts} +7 -18
- package/dist/introspection/fileIntrospector.d.ts +14 -0
- package/dist/introspection/index.d.ts +68 -0
- package/dist/introspection/introspection.test.d.ts +4 -0
- package/dist/introspection/projectDetector.d.ts +27 -0
- package/dist/introspection/types.d.ts +70 -0
- package/dist/modules/core/index.d.ts +69 -0
- package/dist/modules/core/symbols.d.ts +27 -0
- package/dist/modules/core/symbols.test.d.ts +4 -0
- package/dist/modules/{semantic → language/typescript}/index.d.ts +11 -12
- package/dist/types.d.ts +4 -1
- package/package.json +5 -5
- package/dist/application/index.d.ts +0 -7
- package/dist/utils/bm25.d.ts +0 -9
- package/dist/utils/embeddings.d.ts +0 -46
- /package/dist/{cli → app/cli}/main.d.ts +0 -0
- /package/dist/{indexer → app/indexer}/watcher.d.ts +0 -0
- /package/dist/{application → domain}/usecases/index.d.ts +0 -0
- /package/dist/{utils → infrastructure/embeddings}/embeddings.test.d.ts +0 -0
- /package/dist/modules/{semantic → language/typescript}/parseCode.d.ts +0 -0
- /package/dist/modules/{semantic → language/typescript}/parseCode.test.d.ts +0 -0
package/dist/composition.d.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* This is the only file that knows about concrete implementations.
|
|
9
9
|
* Everything else depends only on interfaces (ports).
|
|
10
10
|
*/
|
|
11
|
-
import type { Config } from
|
|
12
|
-
import type { FileSystem } from
|
|
13
|
-
import type { IndexModule, IndexContext, SearchContext } from
|
|
14
|
-
import { FileIndexStorage } from
|
|
11
|
+
import type { Config } from "./domain/entities";
|
|
12
|
+
import type { FileSystem } from "./domain/ports";
|
|
13
|
+
import type { IndexModule, IndexContext, SearchContext } from "./types";
|
|
14
|
+
import { FileIndexStorage } from "./infrastructure/storage";
|
|
15
15
|
/**
|
|
16
16
|
* Container for all application services.
|
|
17
17
|
* Created once and passed to use cases.
|
|
@@ -27,9 +27,9 @@ export interface ServiceContainer {
|
|
|
27
27
|
* Create a service container for a specific project directory.
|
|
28
28
|
*/
|
|
29
29
|
export declare function createServiceContainer(rootDir: string): Promise<ServiceContainer>;
|
|
30
|
-
import type { IndexDirectoryDependencies } from
|
|
31
|
-
import type { SearchIndexDependencies } from
|
|
32
|
-
import type { CleanupIndexDependencies } from
|
|
30
|
+
import type { IndexDirectoryDependencies } from "./domain/usecases/indexDirectory";
|
|
31
|
+
import type { SearchIndexDependencies } from "./domain/usecases/searchIndex";
|
|
32
|
+
import type { CleanupIndexDependencies } from "./domain/usecases/cleanupIndex";
|
|
33
33
|
/**
|
|
34
34
|
* Create dependencies for the indexDirectory use case.
|
|
35
35
|
*/
|
|
@@ -8,7 +8,7 @@ export type { Chunk, ChunkType } from "./chunk";
|
|
|
8
8
|
export { createChunkId } from "./chunk";
|
|
9
9
|
export type { FileIndex, FileManifestEntry, ModuleManifest, GlobalManifest, } from "./fileIndex";
|
|
10
10
|
export type { FileSummary, SymbolicIndexMeta, Tier1Manifest, } from "./fileSummary";
|
|
11
|
-
export type { SearchResult, SearchOptions } from "./searchResult";
|
|
11
|
+
export type { SearchResult, SearchOptions, SearchContributions, CoreContribution, LanguageContribution, IntrospectionContribution, } from "./searchResult";
|
|
12
12
|
export { DEFAULT_SEARCH_OPTIONS } from "./searchResult";
|
|
13
13
|
export type { Config, ModuleConfig } from "./config";
|
|
14
14
|
export { DEFAULT_IGNORE_PATHS, DEFAULT_EXTENSIONS, createDefaultConfig, } from "./config";
|
|
@@ -3,7 +3,50 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Represents a single result from a search query.
|
|
5
5
|
*/
|
|
6
|
-
import type { Chunk } from
|
|
6
|
+
import type { Chunk } from "./chunk";
|
|
7
|
+
/**
|
|
8
|
+
* Contribution from the core index.
|
|
9
|
+
*/
|
|
10
|
+
export interface CoreContribution {
|
|
11
|
+
/** Symbol name match score (0-1) */
|
|
12
|
+
symbolMatch: number;
|
|
13
|
+
/** BM25 keyword match score (0-1) */
|
|
14
|
+
keywordMatch: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Contribution from a language-specific index.
|
|
18
|
+
*/
|
|
19
|
+
export interface LanguageContribution {
|
|
20
|
+
/** Semantic embedding similarity (0-1) */
|
|
21
|
+
semanticMatch: number;
|
|
22
|
+
/** BM25 keyword match score (0-1) */
|
|
23
|
+
keywordMatch: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Contribution from introspection boosting.
|
|
27
|
+
*/
|
|
28
|
+
export interface IntrospectionContribution {
|
|
29
|
+
/** Boost from domain match */
|
|
30
|
+
domainBoost: number;
|
|
31
|
+
/** Boost from layer match */
|
|
32
|
+
layerBoost: number;
|
|
33
|
+
/** Boost from scope match */
|
|
34
|
+
scopeBoost: number;
|
|
35
|
+
/** Boost from path segment match */
|
|
36
|
+
pathBoost: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tracks which indexes contributed to a search result's score.
|
|
40
|
+
* Used for learning and tuning.
|
|
41
|
+
*/
|
|
42
|
+
export interface SearchContributions {
|
|
43
|
+
/** Core index contribution */
|
|
44
|
+
core?: CoreContribution;
|
|
45
|
+
/** Language-specific index contribution (keyed by module ID) */
|
|
46
|
+
language?: Record<string, LanguageContribution>;
|
|
47
|
+
/** Introspection boost contribution */
|
|
48
|
+
introspection?: IntrospectionContribution;
|
|
49
|
+
}
|
|
7
50
|
/**
|
|
8
51
|
* A search result with relevance score and source information.
|
|
9
52
|
*/
|
|
@@ -12,10 +55,12 @@ export interface SearchResult {
|
|
|
12
55
|
filepath: string;
|
|
13
56
|
/** The matching chunk */
|
|
14
57
|
chunk: Chunk;
|
|
15
|
-
/**
|
|
58
|
+
/** Final relevance score (0-1, higher is better) */
|
|
16
59
|
score: number;
|
|
17
60
|
/** ID of the module that produced this result */
|
|
18
61
|
moduleId: string;
|
|
62
|
+
/** Contribution tracking for learning */
|
|
63
|
+
contributions?: SearchContributions;
|
|
19
64
|
/** Additional context from the search (e.g., semantic vs keyword scores) */
|
|
20
65
|
context?: Record<string, unknown>;
|
|
21
66
|
}
|
package/dist/domain/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* - Entities: Core data structures
|
|
6
6
|
* - Ports: Interfaces for external dependencies
|
|
7
7
|
* - Services: Pure business logic and algorithms
|
|
8
|
+
* - Use Cases: Application business logic
|
|
8
9
|
*/
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
10
|
+
export * from "./entities";
|
|
11
|
+
export * from "./ports";
|
|
12
|
+
export * from "./services";
|
|
13
|
+
export * from "./usecases";
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Interfaces defining what the domain needs from external systems.
|
|
5
5
|
* These are implemented by infrastructure adapters.
|
|
6
6
|
*/
|
|
7
|
-
export type { FileSystem, FileStats } from
|
|
8
|
-
export type { EmbeddingProvider, EmbeddingConfig, EmbeddingModelName } from
|
|
9
|
-
export {
|
|
10
|
-
export type { IndexStorage } from './storage';
|
|
7
|
+
export type { FileSystem, FileStats } from "./filesystem";
|
|
8
|
+
export type { EmbeddingProvider, EmbeddingConfig, EmbeddingModelName } from "./embedding";
|
|
9
|
+
export type { IndexStorage } from "./storage";
|
|
@@ -71,6 +71,30 @@ export declare class BM25Index {
|
|
|
71
71
|
* Clear the index.
|
|
72
72
|
*/
|
|
73
73
|
clear(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Add a single document by ID and pre-computed tokens.
|
|
76
|
+
*
|
|
77
|
+
* @param id - Document identifier
|
|
78
|
+
* @param tokens - Pre-computed tokens
|
|
79
|
+
*/
|
|
80
|
+
addDocument(id: string, tokens: string[]): void;
|
|
81
|
+
/**
|
|
82
|
+
* Serialize the index to a JSON-compatible object.
|
|
83
|
+
*/
|
|
84
|
+
serialize(): BM25SerializedData;
|
|
85
|
+
/**
|
|
86
|
+
* Deserialize a BM25 index from saved data.
|
|
87
|
+
*/
|
|
88
|
+
static deserialize(data: BM25SerializedData): BM25Index;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Serialized BM25 index data.
|
|
92
|
+
*/
|
|
93
|
+
export interface BM25SerializedData {
|
|
94
|
+
documents: Record<string, string[]>;
|
|
95
|
+
avgDocLength: number;
|
|
96
|
+
documentFrequencies: Record<string, number>;
|
|
97
|
+
totalDocs: number;
|
|
74
98
|
}
|
|
75
99
|
/**
|
|
76
100
|
* Normalize a raw score to 0-1 range using sigmoid function.
|
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
* Pure algorithms and business logic with no external dependencies.
|
|
5
5
|
* These services operate only on domain entities and primitive data.
|
|
6
6
|
*/
|
|
7
|
-
export { BM25Index, tokenize, normalizeScore, type BM25Document, type BM25Result, } from
|
|
8
|
-
export { extractKeywords, extractPathKeywords, COMMON_KEYWORDS, } from
|
|
7
|
+
export { BM25Index, tokenize, normalizeScore, type BM25Document, type BM25Result, type BM25SerializedData, } from "./bm25";
|
|
8
|
+
export { extractKeywords, extractPathKeywords, parsePathContext, formatPathContextForEmbedding, COMMON_KEYWORDS, type PathContext, } from "./keywords";
|
|
9
|
+
export { cosineSimilarity, euclideanDistance } from "./similarity";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Similarity Service
|
|
3
|
+
*
|
|
4
|
+
* Pure mathematical functions for computing vector similarity.
|
|
5
|
+
* No external dependencies.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Calculate cosine similarity between two vectors.
|
|
9
|
+
*
|
|
10
|
+
* @param a - First vector
|
|
11
|
+
* @param b - Second vector
|
|
12
|
+
* @returns Similarity score between -1 and 1 (1 = identical, 0 = orthogonal, -1 = opposite)
|
|
13
|
+
* @throws Error if vectors have different lengths
|
|
14
|
+
*/
|
|
15
|
+
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate Euclidean distance between two vectors.
|
|
18
|
+
*
|
|
19
|
+
* @param a - First vector
|
|
20
|
+
* @param b - Second vector
|
|
21
|
+
* @returns Distance (0 = identical, larger = more different)
|
|
22
|
+
*/
|
|
23
|
+
export declare function euclideanDistance(a: number[], b: number[]): number;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Removes stale index entries for files that no longer exist.
|
|
5
5
|
*/
|
|
6
|
-
import type { Config, ModuleManifest } from '
|
|
7
|
-
import type { FileSystem } from '
|
|
6
|
+
import type { Config, ModuleManifest } from '../entities';
|
|
7
|
+
import type { FileSystem } from '../ports';
|
|
8
8
|
import type { IndexModule } from '../../types';
|
|
9
9
|
/**
|
|
10
10
|
* Result of cleanup for a single module
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* This is an application-level use case that coordinates domain entities
|
|
6
6
|
* and infrastructure services.
|
|
7
7
|
*/
|
|
8
|
-
import type { Config } from '
|
|
9
|
-
import type { FileSystem } from '
|
|
8
|
+
import type { Config } from '../entities';
|
|
9
|
+
import type { FileSystem } from '../ports';
|
|
10
10
|
import type { IndexModule } from '../../types';
|
|
11
11
|
/**
|
|
12
12
|
* Result of indexing with a single module
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Orchestrates searching the indexed codebase.
|
|
5
5
|
*/
|
|
6
|
-
import type { Config, SearchResult, SearchOptions } from '
|
|
7
|
-
import type { FileSystem } from '
|
|
6
|
+
import type { Config, SearchResult, SearchOptions } from '../entities';
|
|
7
|
+
import type { FileSystem } from '../ports';
|
|
8
8
|
import type { IndexModule, FileIndex } from '../../types';
|
|
9
9
|
/**
|
|
10
10
|
* Options for the search use case
|
package/dist/index.d.ts
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
* await raggrep.cleanup('/path/to/project');
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import type { IndexResult, IndexOptions, CleanupResult } from
|
|
21
|
-
import { formatSearchResults } from
|
|
22
|
-
import type { SearchOptions, SearchResult } from
|
|
23
|
-
export type { IndexResult, IndexOptions, CleanupResult } from
|
|
24
|
-
export type { SearchOptions, SearchResult, Chunk, FileIndex } from
|
|
20
|
+
import type { IndexResult, IndexOptions, CleanupResult } from "./app/indexer";
|
|
21
|
+
import { formatSearchResults } from "./app/search";
|
|
22
|
+
import type { SearchOptions, SearchResult } from "./types";
|
|
23
|
+
export type { IndexResult, IndexOptions, CleanupResult } from "./app/indexer";
|
|
24
|
+
export type { SearchOptions, SearchResult, Chunk, FileIndex } from "./types";
|
|
25
25
|
/**
|
|
26
26
|
* Index a directory for semantic search.
|
|
27
27
|
*
|