raggrep 0.1.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/LICENSE +22 -0
- package/README.md +15 -0
- package/dist/application/index.d.ts +7 -0
- package/dist/application/usecases/cleanupIndex.d.ts +54 -0
- package/dist/application/usecases/index.d.ts +9 -0
- package/dist/application/usecases/indexDirectory.d.ts +54 -0
- package/dist/application/usecases/searchIndex.d.ts +48 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +1596 -0
- package/dist/cli/main.js.map +22 -0
- package/dist/composition.d.ts +52 -0
- package/dist/domain/entities/chunk.d.ts +41 -0
- package/dist/domain/entities/config.d.ts +43 -0
- package/dist/domain/entities/fileIndex.d.ts +58 -0
- package/dist/domain/entities/fileSummary.d.ts +61 -0
- package/dist/domain/entities/index.d.ts +14 -0
- package/dist/domain/entities/searchResult.d.ts +36 -0
- package/dist/domain/index.d.ts +11 -0
- package/dist/domain/ports/embedding.d.ts +60 -0
- package/dist/domain/ports/filesystem.d.ts +78 -0
- package/dist/domain/ports/index.d.ts +10 -0
- package/dist/domain/ports/storage.d.ts +79 -0
- package/dist/domain/services/bm25.d.ts +82 -0
- package/dist/domain/services/bm25.test.d.ts +4 -0
- package/dist/domain/services/index.d.ts +8 -0
- package/dist/domain/services/keywords.d.ts +27 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +1378 -0
- package/dist/index.js.map +22 -0
- package/dist/indexer/index.d.ts +33 -0
- package/dist/infrastructure/embeddings/index.d.ts +4 -0
- package/dist/infrastructure/embeddings/transformersEmbedding.d.ts +34 -0
- package/dist/infrastructure/filesystem/index.d.ts +4 -0
- package/dist/infrastructure/filesystem/nodeFileSystem.d.ts +28 -0
- package/dist/infrastructure/index.d.ts +9 -0
- package/dist/infrastructure/storage/fileIndexStorage.d.ts +68 -0
- package/dist/infrastructure/storage/index.d.ts +4 -0
- package/dist/modules/registry.d.ts +3 -0
- package/dist/modules/semantic/index.d.ts +55 -0
- package/dist/modules/semantic/parseCode.d.ts +44 -0
- package/dist/modules/semantic/parseCode.test.d.ts +4 -0
- package/dist/search/index.d.ts +11 -0
- package/dist/types.d.ts +84 -0
- package/dist/utils/bm25.d.ts +9 -0
- package/dist/utils/config.d.ts +45 -0
- package/dist/utils/embeddings.d.ts +46 -0
- package/dist/utils/embeddings.test.d.ts +4 -0
- package/dist/utils/tieredIndex.d.ts +100 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 RAGgrep Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cleanup Index Use Case
|
|
3
|
+
*
|
|
4
|
+
* Removes stale index entries for files that no longer exist.
|
|
5
|
+
*/
|
|
6
|
+
import type { Config, ModuleManifest } from '../../domain/entities';
|
|
7
|
+
import type { FileSystem } from '../../domain/ports';
|
|
8
|
+
import type { IndexModule } from '../../types';
|
|
9
|
+
/**
|
|
10
|
+
* Result of cleanup for a single module
|
|
11
|
+
*/
|
|
12
|
+
export interface CleanupResult {
|
|
13
|
+
moduleId: string;
|
|
14
|
+
/** Number of stale entries removed */
|
|
15
|
+
removed: number;
|
|
16
|
+
/** Number of valid entries kept */
|
|
17
|
+
kept: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options for the cleanup use case
|
|
21
|
+
*/
|
|
22
|
+
export interface CleanupIndexOptions {
|
|
23
|
+
/** Show verbose output */
|
|
24
|
+
verbose?: boolean;
|
|
25
|
+
/** Callback for progress updates */
|
|
26
|
+
onProgress?: (message: string) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Dependencies required by this use case
|
|
30
|
+
*/
|
|
31
|
+
export interface CleanupIndexDependencies {
|
|
32
|
+
/** Filesystem abstraction */
|
|
33
|
+
fileSystem: FileSystem;
|
|
34
|
+
/** Load configuration */
|
|
35
|
+
loadConfig: (rootDir: string) => Promise<Config>;
|
|
36
|
+
/** Get enabled modules */
|
|
37
|
+
getEnabledModules: (config: Config) => IndexModule[];
|
|
38
|
+
/** Load module manifest */
|
|
39
|
+
loadModuleManifest: (rootDir: string, moduleId: string, config: Config) => Promise<ModuleManifest | null>;
|
|
40
|
+
/** Save module manifest */
|
|
41
|
+
saveModuleManifest: (rootDir: string, moduleId: string, manifest: ModuleManifest, config: Config) => Promise<void>;
|
|
42
|
+
/** Delete file index */
|
|
43
|
+
deleteFileIndex: (rootDir: string, moduleId: string, filepath: string, config: Config) => Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Clean up stale index entries.
|
|
47
|
+
*
|
|
48
|
+
* This use case:
|
|
49
|
+
* 1. Loads configuration
|
|
50
|
+
* 2. For each module, checks if indexed files still exist
|
|
51
|
+
* 3. Removes index entries for deleted files
|
|
52
|
+
* 4. Updates manifests
|
|
53
|
+
*/
|
|
54
|
+
export declare function cleanupIndex(rootDir: string, deps: CleanupIndexDependencies, options?: CleanupIndexOptions): Promise<CleanupResult[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application Use Cases
|
|
3
|
+
*
|
|
4
|
+
* Business logic orchestration layer.
|
|
5
|
+
* Use cases coordinate domain entities and infrastructure services.
|
|
6
|
+
*/
|
|
7
|
+
export { indexDirectory, type IndexResult, type IndexDirectoryOptions, type IndexDirectoryDependencies } from './indexDirectory';
|
|
8
|
+
export { searchIndex, formatSearchResults, type SearchIndexOptions, type SearchIndexDependencies } from './searchIndex';
|
|
9
|
+
export { cleanupIndex, type CleanupResult, type CleanupIndexOptions, type CleanupIndexDependencies } from './cleanupIndex';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Index Directory Use Case
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the indexing of a codebase directory.
|
|
5
|
+
* This is an application-level use case that coordinates domain entities
|
|
6
|
+
* and infrastructure services.
|
|
7
|
+
*/
|
|
8
|
+
import type { Config } from '../../domain/entities';
|
|
9
|
+
import type { FileSystem } from '../../domain/ports';
|
|
10
|
+
import type { IndexModule } from '../../types';
|
|
11
|
+
/**
|
|
12
|
+
* Result of indexing with a single module
|
|
13
|
+
*/
|
|
14
|
+
export interface IndexResult {
|
|
15
|
+
moduleId: string;
|
|
16
|
+
indexed: number;
|
|
17
|
+
skipped: number;
|
|
18
|
+
errors: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for the index directory use case
|
|
22
|
+
*/
|
|
23
|
+
export interface IndexDirectoryOptions {
|
|
24
|
+
/** Override configuration */
|
|
25
|
+
config?: Partial<Config>;
|
|
26
|
+
/** Show verbose output */
|
|
27
|
+
verbose?: boolean;
|
|
28
|
+
/** Callback for progress updates */
|
|
29
|
+
onProgress?: (message: string) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Dependencies required by this use case
|
|
33
|
+
*/
|
|
34
|
+
export interface IndexDirectoryDependencies {
|
|
35
|
+
/** Filesystem abstraction */
|
|
36
|
+
fileSystem: FileSystem;
|
|
37
|
+
/** Load configuration */
|
|
38
|
+
loadConfig: (rootDir: string) => Promise<Config>;
|
|
39
|
+
/** Get enabled modules */
|
|
40
|
+
getEnabledModules: (config: Config) => IndexModule[];
|
|
41
|
+
/** Initialize a module */
|
|
42
|
+
initializeModule: (module: IndexModule, config: Config) => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Index a directory using all enabled modules.
|
|
46
|
+
*
|
|
47
|
+
* This use case:
|
|
48
|
+
* 1. Loads configuration
|
|
49
|
+
* 2. Finds all files matching extensions
|
|
50
|
+
* 3. Indexes files with each enabled module
|
|
51
|
+
* 4. Builds secondary indexes (Tier 1)
|
|
52
|
+
* 5. Updates manifests
|
|
53
|
+
*/
|
|
54
|
+
export declare function indexDirectory(rootDir: string, deps: IndexDirectoryDependencies, options?: IndexDirectoryOptions): Promise<IndexResult[]>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Index Use Case
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates searching the indexed codebase.
|
|
5
|
+
*/
|
|
6
|
+
import type { Config, SearchResult, SearchOptions } from '../../domain/entities';
|
|
7
|
+
import type { FileSystem } from '../../domain/ports';
|
|
8
|
+
import type { IndexModule, FileIndex } from '../../types';
|
|
9
|
+
/**
|
|
10
|
+
* Options for the search use case
|
|
11
|
+
*/
|
|
12
|
+
export interface SearchIndexOptions extends SearchOptions {
|
|
13
|
+
/** Callback for progress updates */
|
|
14
|
+
onProgress?: (message: string) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Dependencies required by this use case
|
|
18
|
+
*/
|
|
19
|
+
export interface SearchIndexDependencies {
|
|
20
|
+
/** Filesystem abstraction */
|
|
21
|
+
fileSystem: FileSystem;
|
|
22
|
+
/** Load configuration */
|
|
23
|
+
loadConfig: (rootDir: string) => Promise<Config>;
|
|
24
|
+
/** Get indexed modules from global manifest */
|
|
25
|
+
getIndexedModules: (rootDir: string, config: Config) => Promise<string[]>;
|
|
26
|
+
/** Get module by ID */
|
|
27
|
+
getModule: (moduleId: string) => IndexModule | undefined;
|
|
28
|
+
/** Initialize a module */
|
|
29
|
+
initializeModule: (module: IndexModule, config: Config) => Promise<void>;
|
|
30
|
+
/** Load file index */
|
|
31
|
+
loadFileIndex: (rootDir: string, moduleId: string, filepath: string, config: Config) => Promise<FileIndex | null>;
|
|
32
|
+
/** List indexed files for a module */
|
|
33
|
+
listIndexedFiles: (rootDir: string, moduleId: string, config: Config) => Promise<string[]>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Search the indexed codebase.
|
|
37
|
+
*
|
|
38
|
+
* This use case:
|
|
39
|
+
* 1. Loads configuration
|
|
40
|
+
* 2. Finds modules that have indexes
|
|
41
|
+
* 3. Searches each module
|
|
42
|
+
* 4. Aggregates and ranks results
|
|
43
|
+
*/
|
|
44
|
+
export declare function searchIndex(rootDir: string, query: string, deps: SearchIndexDependencies, options?: SearchIndexOptions): Promise<SearchResult[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Format search results for display
|
|
47
|
+
*/
|
|
48
|
+
export declare function formatSearchResults(results: SearchResult[]): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|