raggrep 0.2.3 → 0.4.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/app/indexer/index.d.ts +30 -4
- package/dist/app/search/index.d.ts +1 -1
- package/dist/cli/main.js +427 -115
- package/dist/cli/main.js.map +18 -15
- package/dist/domain/entities/searchResult.d.ts +11 -0
- package/dist/domain/ports/embedding.d.ts +4 -1
- package/dist/domain/ports/index.d.ts +2 -1
- package/dist/domain/ports/logger.d.ts +66 -0
- package/dist/index.d.ts +45 -8
- package/dist/index.js +601 -71
- package/dist/index.js.map +17 -14
- package/dist/infrastructure/embeddings/transformersEmbedding.d.ts +1 -1
- package/dist/infrastructure/index.d.ts +1 -0
- package/dist/infrastructure/logger/index.d.ts +6 -0
- package/dist/infrastructure/logger/loggers.d.ts +75 -0
- package/dist/modules/language/typescript/index.d.ts +1 -0
- package/dist/tests/ranking.test.d.ts +12 -0
- package/package.json +1 -1
|
@@ -74,6 +74,17 @@ export interface SearchOptions {
|
|
|
74
74
|
minScore?: number;
|
|
75
75
|
/** Filter to specific file patterns (e.g., ['*.ts', '*.tsx']) */
|
|
76
76
|
filePatterns?: string[];
|
|
77
|
+
/**
|
|
78
|
+
* Ensure the index is fresh before searching (default: true).
|
|
79
|
+
*
|
|
80
|
+
* When true, the search will automatically:
|
|
81
|
+
* - Create the index if it doesn't exist
|
|
82
|
+
* - Re-index any modified files
|
|
83
|
+
* - Remove entries for deleted files
|
|
84
|
+
*
|
|
85
|
+
* Set to false if you've already ensured freshness or want explicit control.
|
|
86
|
+
*/
|
|
87
|
+
ensureFresh?: boolean;
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
79
90
|
* Default search options.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* This allows the domain to remain independent of the actual embedding implementation
|
|
6
6
|
* (e.g., Transformers.js, OpenAI API, local models).
|
|
7
7
|
*/
|
|
8
|
+
import type { Logger } from "./logger";
|
|
8
9
|
/**
|
|
9
10
|
* Available embedding model names
|
|
10
11
|
*/
|
|
@@ -15,8 +16,10 @@ export type EmbeddingModelName = "all-MiniLM-L6-v2" | "all-MiniLM-L12-v2" | "bge
|
|
|
15
16
|
export interface EmbeddingConfig {
|
|
16
17
|
/** Model name to use */
|
|
17
18
|
model: EmbeddingModelName;
|
|
18
|
-
/** Whether to show progress during model loading */
|
|
19
|
+
/** Whether to show progress during model loading (deprecated, use logger instead) */
|
|
19
20
|
showProgress?: boolean;
|
|
21
|
+
/** Logger for reporting download progress */
|
|
22
|
+
logger?: Logger;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Abstract embedding provider interface.
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* These are implemented by infrastructure adapters.
|
|
6
6
|
*/
|
|
7
7
|
export type { FileSystem, FileStats } from "./filesystem";
|
|
8
|
-
export type { EmbeddingProvider, EmbeddingConfig, EmbeddingModelName } from "./embedding";
|
|
8
|
+
export type { EmbeddingProvider, EmbeddingConfig, EmbeddingModelName, } from "./embedding";
|
|
9
9
|
export type { IndexStorage } from "./storage";
|
|
10
|
+
export type { Logger, ProgressInfo, LoggerFactory } from "./logger";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger Port
|
|
3
|
+
*
|
|
4
|
+
* Abstract interface for logging progress and messages.
|
|
5
|
+
* This allows the domain and application layers to remain independent
|
|
6
|
+
* of the actual logging implementation (console, file, etc.).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Progress information for long-running operations
|
|
10
|
+
*/
|
|
11
|
+
export interface ProgressInfo {
|
|
12
|
+
/** Current item being processed */
|
|
13
|
+
current: number;
|
|
14
|
+
/** Total number of items */
|
|
15
|
+
total: number;
|
|
16
|
+
/** Optional descriptive message */
|
|
17
|
+
message?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Abstract logger interface.
|
|
21
|
+
*
|
|
22
|
+
* Implementations might:
|
|
23
|
+
* - Log to console (ConsoleLogger)
|
|
24
|
+
* - Log to console with inline replacement for progress (InlineProgressLogger)
|
|
25
|
+
* - Be silent (SilentLogger)
|
|
26
|
+
* - Log to a file or external service
|
|
27
|
+
*/
|
|
28
|
+
export interface Logger {
|
|
29
|
+
/**
|
|
30
|
+
* Log an info message (general progress updates)
|
|
31
|
+
*/
|
|
32
|
+
info(message: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Log a warning message
|
|
35
|
+
*/
|
|
36
|
+
warn(message: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Log an error message
|
|
39
|
+
*/
|
|
40
|
+
error(message: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Log a debug message (only shown in verbose mode)
|
|
43
|
+
*/
|
|
44
|
+
debug(message: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Log a progress update that can replace the current line.
|
|
47
|
+
* Used for download progress, file processing counters, etc.
|
|
48
|
+
*
|
|
49
|
+
* In terminal environments, this may overwrite the current line.
|
|
50
|
+
* In non-terminal environments (SDK), this may just log normally.
|
|
51
|
+
*
|
|
52
|
+
* @param message - Progress message to display
|
|
53
|
+
*/
|
|
54
|
+
progress(message: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Clear any inline progress output.
|
|
57
|
+
* Call this before switching from progress() to info/warn/error.
|
|
58
|
+
*/
|
|
59
|
+
clearProgress(): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Factory function type for creating loggers
|
|
63
|
+
*/
|
|
64
|
+
export type LoggerFactory = (options?: {
|
|
65
|
+
verbose?: boolean;
|
|
66
|
+
}) => Logger;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,25 +7,42 @@
|
|
|
7
7
|
* ```ts
|
|
8
8
|
* import raggrep from 'raggrep';
|
|
9
9
|
*
|
|
10
|
-
* // Index a directory
|
|
10
|
+
* // Index a directory (automatically cleans up deleted files)
|
|
11
11
|
* await raggrep.index('/path/to/project');
|
|
12
12
|
*
|
|
13
13
|
* // Search the index
|
|
14
14
|
* const results = await raggrep.search('/path/to/project', 'user authentication');
|
|
15
15
|
*
|
|
16
|
-
* //
|
|
17
|
-
* await raggrep.
|
|
16
|
+
* // Reset (clear) the index completely
|
|
17
|
+
* await raggrep.reset('/path/to/project');
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example With custom logger
|
|
21
|
+
* ```ts
|
|
22
|
+
* import raggrep, { createLogger, createInlineLogger } from 'raggrep';
|
|
23
|
+
*
|
|
24
|
+
* // Create a logger (defaults to console)
|
|
25
|
+
* const logger = createLogger({ verbose: true });
|
|
26
|
+
*
|
|
27
|
+
* // Or use inline logger for CLI-style progress
|
|
28
|
+
* const inlineLogger = createInlineLogger({ verbose: false });
|
|
29
|
+
*
|
|
30
|
+
* await raggrep.index('/path/to/project', { logger: inlineLogger });
|
|
18
31
|
* ```
|
|
19
32
|
*/
|
|
20
|
-
import type { IndexResult, IndexOptions, CleanupResult } from "./app/indexer";
|
|
33
|
+
import type { IndexResult, IndexOptions, CleanupResult, CleanupOptions, ResetResult } from "./app/indexer";
|
|
21
34
|
import { formatSearchResults } from "./app/search";
|
|
22
35
|
import type { SearchOptions, SearchResult } from "./types";
|
|
23
|
-
|
|
36
|
+
import { ConsoleLogger, InlineProgressLogger, SilentLogger, createLogger, createInlineLogger, createSilentLogger } from "./infrastructure/logger";
|
|
37
|
+
export type { IndexResult, IndexOptions, CleanupResult, CleanupOptions, ResetResult, } from "./app/indexer";
|
|
24
38
|
export type { SearchOptions, SearchResult, Chunk, FileIndex } from "./types";
|
|
39
|
+
export type { Logger, LoggerFactory } from "./domain/ports";
|
|
40
|
+
export { ConsoleLogger, InlineProgressLogger, SilentLogger, createLogger, createInlineLogger, createSilentLogger, };
|
|
25
41
|
/**
|
|
26
42
|
* Index a directory for semantic search.
|
|
27
43
|
*
|
|
28
44
|
* Creates a `.raggrep/` folder with the index data.
|
|
45
|
+
* Automatically cleans up stale entries for deleted files.
|
|
29
46
|
*
|
|
30
47
|
* @param directory - Path to the directory to index
|
|
31
48
|
* @param options - Index options
|
|
@@ -69,6 +86,9 @@ export declare function search(directory: string, query: string, options?: Searc
|
|
|
69
86
|
/**
|
|
70
87
|
* Clean up stale index entries for files that no longer exist.
|
|
71
88
|
*
|
|
89
|
+
* Note: Cleanup is now automatic during indexing. This function is provided
|
|
90
|
+
* for explicit cleanup without re-indexing.
|
|
91
|
+
*
|
|
72
92
|
* @param directory - Path to the indexed directory
|
|
73
93
|
* @param options - Cleanup options
|
|
74
94
|
* @returns Array of cleanup results per module
|
|
@@ -79,9 +99,25 @@ export declare function search(directory: string, query: string, options?: Searc
|
|
|
79
99
|
* console.log(`Removed ${results[0].removed} stale entries`);
|
|
80
100
|
* ```
|
|
81
101
|
*/
|
|
82
|
-
export declare function cleanup(directory: string, options?:
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
export declare function cleanup(directory: string, options?: CleanupOptions): Promise<CleanupResult[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Reset (completely clear) the index for a directory.
|
|
105
|
+
*
|
|
106
|
+
* @param directory - Path to the indexed directory
|
|
107
|
+
* @returns Result with success status and removed index path
|
|
108
|
+
* @throws Error if no index exists for the directory
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* try {
|
|
113
|
+
* const result = await raggrep.reset('./my-project');
|
|
114
|
+
* console.log(`Cleared index at: ${result.indexDir}`);
|
|
115
|
+
* } catch (error) {
|
|
116
|
+
* console.error('No index found');
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function reset(directory: string): Promise<ResetResult>;
|
|
85
121
|
/**
|
|
86
122
|
* Format search results for display.
|
|
87
123
|
*
|
|
@@ -93,6 +129,7 @@ declare const raggrep: {
|
|
|
93
129
|
index: typeof index;
|
|
94
130
|
search: typeof search;
|
|
95
131
|
cleanup: typeof cleanup;
|
|
132
|
+
reset: typeof reset;
|
|
96
133
|
formatSearchResults: typeof formatSearchResults;
|
|
97
134
|
};
|
|
98
135
|
export default raggrep;
|