raggrep 0.1.3 → 0.1.5
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 +1364 -220
- package/dist/cli/main.js.map +25 -15
- package/dist/composition.d.ts +7 -7
- package/dist/domain/entities/chunk.d.ts +1 -1
- package/dist/domain/entities/fileIndex.d.ts +1 -1
- 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 +1 -5
- 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
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configuration
|
|
2
|
+
* Configuration Loader
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Infrastructure adapter for loading and saving RAGgrep configuration.
|
|
5
|
+
* Handles file I/O operations for configuration management.
|
|
5
6
|
*/
|
|
6
|
-
import type { Config, ModuleConfig } from
|
|
7
|
-
import { EmbeddingConfig } from
|
|
7
|
+
import type { Config, ModuleConfig } from "../../domain/entities";
|
|
8
|
+
import type { EmbeddingConfig, EmbeddingModelName } from "../../domain/ports";
|
|
8
9
|
/** Default configuration instance */
|
|
9
10
|
export declare const DEFAULT_CONFIG: Config;
|
|
11
|
+
/** Available embedding models (for validation) */
|
|
12
|
+
export declare const EMBEDDING_MODELS: Record<EmbeddingModelName, string>;
|
|
10
13
|
/**
|
|
11
14
|
* Get the root .raggrep directory path
|
|
12
15
|
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and saving RAGgrep configuration from the filesystem.
|
|
5
|
+
*/
|
|
6
|
+
export { DEFAULT_CONFIG, EMBEDDING_MODELS, getRaggrepDir, getModuleIndexPath, getModuleManifestPath, getGlobalManifestPath, getConfigPath, loadConfig, saveConfig, getModuleConfig, getEmbeddingConfigFromModule, } from "./configLoader";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Embedding Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Provides embedding generation using Transformers.js.
|
|
3
5
|
*/
|
|
4
|
-
export { TransformersEmbeddingProvider, EMBEDDING_MODELS, getCacheDir, isModelCached } from
|
|
6
|
+
export { TransformersEmbeddingProvider, EMBEDDING_MODELS, getCacheDir, isModelCached, configureEmbeddings, getEmbeddingConfig, getEmbedding, getEmbeddings, } from "./transformersEmbedding";
|
|
@@ -32,3 +32,19 @@ export declare function getCacheDir(): string;
|
|
|
32
32
|
* Check if a model is already cached
|
|
33
33
|
*/
|
|
34
34
|
export declare function isModelCached(model: EmbeddingModelName): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Configure the global embedding provider.
|
|
37
|
+
*/
|
|
38
|
+
export declare function configureEmbeddings(config: Partial<EmbeddingConfig>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get current embedding configuration.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getEmbeddingConfig(): EmbeddingConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Get embedding for a single text using the global provider.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getEmbedding(text: string): Promise<number[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Get embeddings for multiple texts using the global provider.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getEmbeddings(texts: string[]): Promise<number[][]>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Contains adapters that implement domain ports.
|
|
5
5
|
* These connect the domain to external systems (filesystem, ML models, etc.)
|
|
6
6
|
*/
|
|
7
|
-
export { NodeFileSystem, nodeFileSystem } from
|
|
8
|
-
export { TransformersEmbeddingProvider,
|
|
9
|
-
export { FileIndexStorage } from
|
|
7
|
+
export { NodeFileSystem, nodeFileSystem } from "./filesystem";
|
|
8
|
+
export { TransformersEmbeddingProvider, getCacheDir, isModelCached, } from "./embeddings";
|
|
9
|
+
export { FileIndexStorage, SymbolicIndex, getSymbolicPath } from "./storage";
|
|
10
|
+
export { DEFAULT_CONFIG, EMBEDDING_MODELS, getRaggrepDir, getModuleIndexPath, getModuleManifestPath, getGlobalManifestPath, getConfigPath, loadConfig, saveConfig, getModuleConfig, getEmbeddingConfigFromModule, } from "./config";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Storage Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Handles persistence of index data to the filesystem.
|
|
3
5
|
*/
|
|
4
|
-
export { FileIndexStorage } from
|
|
6
|
+
export { FileIndexStorage } from "./fileIndexStorage";
|
|
7
|
+
export { SymbolicIndex, getSymbolicPath } from "./symbolicIndex";
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Symbolic Index
|
|
2
|
+
* Symbolic Index Storage
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Manages the keyword-based index for fast file filtering.
|
|
5
|
+
* Handles file I/O for persisting index data.
|
|
5
6
|
*
|
|
6
7
|
* Structure:
|
|
7
8
|
* .raggrep/index/<module>/symbolic/
|
|
8
9
|
* ├── _meta.json (BM25 statistics)
|
|
9
10
|
* └── <filepath>.json (per-file summaries)
|
|
10
|
-
*
|
|
11
|
-
* This approach scales well because:
|
|
12
|
-
* - Each file summary is stored separately
|
|
13
|
-
* - BM25 metadata is small and loads quickly
|
|
14
|
-
* - Summaries are loaded on-demand during search
|
|
15
11
|
*/
|
|
16
|
-
import type { FileSummary
|
|
17
|
-
export type { FileSummary, SymbolicIndexMeta } from '../domain/entities';
|
|
18
|
-
export { extractKeywords } from '../domain/services/keywords';
|
|
19
|
-
/** @deprecated Use SymbolicIndexMeta */
|
|
20
|
-
export type Tier1Manifest = SymbolicIndexMeta & {
|
|
21
|
-
files: Record<string, FileSummary>;
|
|
22
|
-
};
|
|
12
|
+
import type { FileSummary } from "../../domain/entities";
|
|
23
13
|
/**
|
|
24
14
|
* Symbolic Index Manager
|
|
25
15
|
*
|
|
@@ -93,8 +83,7 @@ export declare class SymbolicIndex {
|
|
|
93
83
|
*/
|
|
94
84
|
clear(): void;
|
|
95
85
|
}
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export declare function getTier1Path(rootDir: string, moduleId: string, indexDir?: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Get the symbolic index path for a module
|
|
88
|
+
*/
|
|
100
89
|
export declare function getSymbolicPath(rootDir: string, moduleId: string, indexDir?: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Introspection
|
|
3
|
+
*
|
|
4
|
+
* Extracts metadata from individual files for context-aware search.
|
|
5
|
+
*/
|
|
6
|
+
import type { FileIntrospection, ProjectStructure } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Extract introspection metadata for a file.
|
|
9
|
+
*/
|
|
10
|
+
export declare function introspectFile(filepath: string, structure: ProjectStructure, fileContent?: string): FileIntrospection;
|
|
11
|
+
/**
|
|
12
|
+
* Extract keywords from introspection for search boosting.
|
|
13
|
+
*/
|
|
14
|
+
export declare function introspectionToKeywords(intro: FileIntrospection): string[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Introspection Module
|
|
3
|
+
*
|
|
4
|
+
* Manages file metadata for context-aware search boosting.
|
|
5
|
+
*/
|
|
6
|
+
import type { FileIntrospection, ProjectStructure } from "./types";
|
|
7
|
+
import type { Config } from "../domain/entities";
|
|
8
|
+
export type { FileIntrospection, ProjectStructure, Project, Scope, ProjectType } from "./types";
|
|
9
|
+
export { introspectFile, introspectionToKeywords } from "./fileIntrospector";
|
|
10
|
+
export { detectProjectStructure, detectScopeFromName } from "./projectDetector";
|
|
11
|
+
/**
|
|
12
|
+
* Introspection index for a workspace.
|
|
13
|
+
*/
|
|
14
|
+
export declare class IntrospectionIndex {
|
|
15
|
+
private rootDir;
|
|
16
|
+
private structure;
|
|
17
|
+
private files;
|
|
18
|
+
private config;
|
|
19
|
+
constructor(rootDir: string);
|
|
20
|
+
/**
|
|
21
|
+
* Initialize by detecting project structure.
|
|
22
|
+
*/
|
|
23
|
+
initialize(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Get project structure.
|
|
26
|
+
*/
|
|
27
|
+
getStructure(): ProjectStructure | null;
|
|
28
|
+
/**
|
|
29
|
+
* Introspect a file and add to index.
|
|
30
|
+
*/
|
|
31
|
+
addFile(filepath: string, content?: string): FileIntrospection;
|
|
32
|
+
/**
|
|
33
|
+
* Get introspection for a file.
|
|
34
|
+
*/
|
|
35
|
+
getFile(filepath: string): FileIntrospection | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Get all introspected files.
|
|
38
|
+
*/
|
|
39
|
+
getAllFiles(): FileIntrospection[];
|
|
40
|
+
/**
|
|
41
|
+
* Apply config overrides to introspection.
|
|
42
|
+
*/
|
|
43
|
+
private applyOverrides;
|
|
44
|
+
/**
|
|
45
|
+
* Save introspection index to disk.
|
|
46
|
+
*/
|
|
47
|
+
save(config: Config): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Load introspection index from disk.
|
|
50
|
+
*/
|
|
51
|
+
load(config: Config): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Recursively load file introspections.
|
|
54
|
+
*/
|
|
55
|
+
private loadFilesRecursive;
|
|
56
|
+
/**
|
|
57
|
+
* Clear the index.
|
|
58
|
+
*/
|
|
59
|
+
clear(): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Calculate search boost based on introspection and query.
|
|
63
|
+
*
|
|
64
|
+
* @param intro - File introspection
|
|
65
|
+
* @param query - Search query
|
|
66
|
+
* @returns Boost multiplier (1.0 = no boost, >1.0 = positive boost)
|
|
67
|
+
*/
|
|
68
|
+
export declare function calculateIntrospectionBoost(intro: FileIntrospection, query: string): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Structure Detection
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects monorepo structure and project types from:
|
|
5
|
+
* - Folder layout (apps/, packages/, etc.)
|
|
6
|
+
* - package.json files (for TypeScript/JavaScript projects)
|
|
7
|
+
*/
|
|
8
|
+
import type { Project, ProjectStructure, Scope } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Detect scope from project name.
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectScopeFromName(name: string): Scope;
|
|
13
|
+
/**
|
|
14
|
+
* Detect project structure in a workspace.
|
|
15
|
+
*
|
|
16
|
+
* Uses two strategies:
|
|
17
|
+
* 1. Folder pattern detection (apps/, packages/, etc.)
|
|
18
|
+
* 2. package.json scanning for more accurate project boundaries
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectProjectStructure(rootDir: string): Promise<ProjectStructure>;
|
|
21
|
+
/**
|
|
22
|
+
* Find which project a file belongs to.
|
|
23
|
+
*
|
|
24
|
+
* Matches against detected projects (from package.json and folder patterns).
|
|
25
|
+
* For nested projects, returns the most specific (deepest) match.
|
|
26
|
+
*/
|
|
27
|
+
export declare function findProjectForFile(filepath: string, structure: ProjectStructure): Project;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Introspection Types
|
|
3
|
+
*
|
|
4
|
+
* Shared metadata extracted from file paths and project structure.
|
|
5
|
+
* Used by all index modules for context-aware scoring.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Project type detected from folder structure.
|
|
9
|
+
*/
|
|
10
|
+
export type ProjectType = "app" | "library" | "service" | "script" | "unknown";
|
|
11
|
+
/**
|
|
12
|
+
* Scope of the file in the overall system.
|
|
13
|
+
*/
|
|
14
|
+
export type Scope = "frontend" | "backend" | "shared" | "tooling" | "unknown";
|
|
15
|
+
/**
|
|
16
|
+
* Detected project within a monorepo.
|
|
17
|
+
*/
|
|
18
|
+
export interface Project {
|
|
19
|
+
/** Project name (from folder or package.json) */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Root path relative to workspace */
|
|
22
|
+
root: string;
|
|
23
|
+
/** Detected project type */
|
|
24
|
+
type: ProjectType;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* File introspection metadata.
|
|
28
|
+
* Computed once during indexing, used for search boosting.
|
|
29
|
+
*/
|
|
30
|
+
export interface FileIntrospection {
|
|
31
|
+
/** File path relative to workspace */
|
|
32
|
+
filepath: string;
|
|
33
|
+
/** Project context (from folder structure or package.json) */
|
|
34
|
+
project: Project;
|
|
35
|
+
/** Scope detection (frontend, backend, shared, tooling) */
|
|
36
|
+
scope: Scope;
|
|
37
|
+
/** Architectural layer (controller, service, repository, etc.) */
|
|
38
|
+
layer?: string;
|
|
39
|
+
/** Feature domain (auth, users, payments, etc.) */
|
|
40
|
+
domain?: string;
|
|
41
|
+
/** Detected programming language */
|
|
42
|
+
language: string;
|
|
43
|
+
/** Detected framework (nextjs, express, fastify, etc.) */
|
|
44
|
+
framework?: string;
|
|
45
|
+
/** Path depth from workspace root */
|
|
46
|
+
depth: number;
|
|
47
|
+
/** Path segments for keyword matching */
|
|
48
|
+
pathSegments: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Project structure metadata.
|
|
52
|
+
*/
|
|
53
|
+
export interface ProjectStructure {
|
|
54
|
+
/** Detected projects in the workspace */
|
|
55
|
+
projects: Project[];
|
|
56
|
+
/** Is this a monorepo? */
|
|
57
|
+
isMonorepo: boolean;
|
|
58
|
+
/** Root project type (if single project) */
|
|
59
|
+
rootType?: ProjectType;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Introspection configuration overrides.
|
|
63
|
+
*/
|
|
64
|
+
export interface IntrospectionConfig {
|
|
65
|
+
/** Manual project scope overrides */
|
|
66
|
+
projects?: Record<string, {
|
|
67
|
+
scope?: Scope;
|
|
68
|
+
framework?: string;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Index Module
|
|
3
|
+
*
|
|
4
|
+
* Language-agnostic text search using:
|
|
5
|
+
* - Regex-based symbol extraction
|
|
6
|
+
* - BM25 keyword matching
|
|
7
|
+
* - Line-based chunking
|
|
8
|
+
*
|
|
9
|
+
* Index location: .raggrep/index/core/
|
|
10
|
+
*
|
|
11
|
+
* This module provides fast, deterministic search without embeddings.
|
|
12
|
+
* It complements language-specific modules by catching symbol matches.
|
|
13
|
+
*/
|
|
14
|
+
import { IndexModule, IndexContext, SearchContext, SearchOptions } from "../../types";
|
|
15
|
+
import type { FileIndex, SearchResult, ModuleConfig } from "../../domain/entities";
|
|
16
|
+
import { type ExtractedSymbol } from "./symbols";
|
|
17
|
+
/**
|
|
18
|
+
* Core module-specific data stored with file index
|
|
19
|
+
*/
|
|
20
|
+
export interface CoreModuleData {
|
|
21
|
+
/** Extracted symbols */
|
|
22
|
+
symbols: ExtractedSymbol[];
|
|
23
|
+
/** BM25 tokens for this file */
|
|
24
|
+
tokens: string[];
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
export declare class CoreModule implements IndexModule {
|
|
28
|
+
readonly id = "core";
|
|
29
|
+
readonly name = "Core Search";
|
|
30
|
+
readonly description = "Language-agnostic text search with symbol extraction";
|
|
31
|
+
readonly version = "1.0.0";
|
|
32
|
+
private symbolIndex;
|
|
33
|
+
private bm25Index;
|
|
34
|
+
private rootDir;
|
|
35
|
+
initialize(_config: ModuleConfig): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Index a single file.
|
|
38
|
+
*/
|
|
39
|
+
indexFile(filepath: string, content: string, ctx: IndexContext): Promise<FileIndex | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Create line-based chunks from content.
|
|
42
|
+
*/
|
|
43
|
+
private createChunks;
|
|
44
|
+
/**
|
|
45
|
+
* Convert symbol type to chunk type.
|
|
46
|
+
*/
|
|
47
|
+
private symbolTypeToChunkType;
|
|
48
|
+
/**
|
|
49
|
+
* Finalize indexing - build BM25 index and save symbol index.
|
|
50
|
+
*/
|
|
51
|
+
finalize(ctx: IndexContext): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Search the index.
|
|
54
|
+
*/
|
|
55
|
+
search(query: string, ctx: SearchContext, options?: SearchOptions): Promise<SearchResult[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Find symbol name matches for query tokens.
|
|
58
|
+
*/
|
|
59
|
+
private findSymbolMatches;
|
|
60
|
+
/**
|
|
61
|
+
* Find the best matching chunk based on query tokens.
|
|
62
|
+
*/
|
|
63
|
+
private findBestChunk;
|
|
64
|
+
/**
|
|
65
|
+
* Load the symbol index from disk.
|
|
66
|
+
*/
|
|
67
|
+
private loadSymbolIndex;
|
|
68
|
+
dispose(): Promise<void>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex-based Symbol Extraction
|
|
3
|
+
*
|
|
4
|
+
* Extracts symbols from code using regular expressions.
|
|
5
|
+
* Language-agnostic but optimized for common patterns.
|
|
6
|
+
*/
|
|
7
|
+
export type SymbolType = "function" | "class" | "variable" | "interface" | "type" | "enum" | "method" | "other";
|
|
8
|
+
export interface ExtractedSymbol {
|
|
9
|
+
name: string;
|
|
10
|
+
type: SymbolType;
|
|
11
|
+
line: number;
|
|
12
|
+
isExported: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Extract symbols from code content using regex patterns.
|
|
16
|
+
*
|
|
17
|
+
* @param content - The source code content
|
|
18
|
+
* @returns Array of extracted symbols with their locations
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractSymbols(content: string): ExtractedSymbol[];
|
|
21
|
+
/**
|
|
22
|
+
* Extract symbol names as keywords for BM25 indexing.
|
|
23
|
+
*
|
|
24
|
+
* @param symbols - Array of extracted symbols
|
|
25
|
+
* @returns Array of unique symbol names
|
|
26
|
+
*/
|
|
27
|
+
export declare function symbolsToKeywords(symbols: ExtractedSymbol[]): string[];
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TypeScript Language Index Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
4
|
+
* Provides TypeScript/JavaScript-aware code search using:
|
|
5
|
+
* - AST parsing via TypeScript Compiler API
|
|
6
|
+
* - Local text embeddings for semantic similarity
|
|
7
|
+
* - BM25 keyword matching for fast filtering
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* efficient search by only loading relevant files.
|
|
9
|
+
* Index location: .raggrep/index/language/typescript/
|
|
11
10
|
*/
|
|
12
|
-
import { IndexModule, IndexContext, SearchContext, SearchOptions, FileIndex, SearchResult, ModuleConfig } from '
|
|
11
|
+
import { IndexModule, IndexContext, SearchContext, SearchOptions, FileIndex, SearchResult, ModuleConfig } from '../../../types';
|
|
13
12
|
/** Default minimum similarity score for search results */
|
|
14
13
|
export declare const DEFAULT_MIN_SCORE = 0.15;
|
|
15
14
|
/** Default number of results to return */
|
|
@@ -23,10 +22,10 @@ export interface SemanticModuleData {
|
|
|
23
22
|
embeddingModel: string;
|
|
24
23
|
[key: string]: unknown;
|
|
25
24
|
}
|
|
26
|
-
export declare class
|
|
27
|
-
readonly id = "
|
|
28
|
-
readonly name = "
|
|
29
|
-
readonly description = "
|
|
25
|
+
export declare class TypeScriptModule implements IndexModule {
|
|
26
|
+
readonly id = "language/typescript";
|
|
27
|
+
readonly name = "TypeScript Search";
|
|
28
|
+
readonly description = "TypeScript-aware code search with AST parsing and semantic embeddings";
|
|
30
29
|
readonly version = "1.0.0";
|
|
31
30
|
private embeddingConfig;
|
|
32
31
|
private symbolicIndex;
|
package/dist/types.d.ts
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* This file re-exports domain entities and defines module interfaces.
|
|
5
5
|
* For new code, prefer importing directly from 'domain/entities'.
|
|
6
6
|
*/
|
|
7
|
-
export type { Chunk, ChunkType, FileIndex, FileManifestEntry, ModuleManifest, GlobalManifest, FileSummary, Tier1Manifest, SearchResult, SearchOptions, Config, ModuleConfig, } from './domain/entities';
|
|
7
|
+
export type { Chunk, ChunkType, FileIndex, FileManifestEntry, ModuleManifest, GlobalManifest, FileSummary, Tier1Manifest, SearchResult, SearchOptions, SearchContributions, CoreContribution, LanguageContribution, IntrospectionContribution, Config, ModuleConfig, } from './domain/entities';
|
|
8
8
|
export { createChunkId, DEFAULT_SEARCH_OPTIONS, DEFAULT_IGNORE_PATHS, DEFAULT_EXTENSIONS, createDefaultConfig, } from './domain/entities';
|
|
9
9
|
import type { Config, FileIndex, SearchResult, SearchOptions, ModuleConfig } from './domain/entities';
|
|
10
10
|
/**
|
|
11
11
|
* Context provided to modules during indexing
|
|
12
12
|
*/
|
|
13
|
+
import type { FileIntrospection } from './introspection';
|
|
13
14
|
export interface IndexContext {
|
|
14
15
|
rootDir: string;
|
|
15
16
|
config: Config;
|
|
@@ -19,6 +20,8 @@ export interface IndexContext {
|
|
|
19
20
|
getFileStats: (filepath: string) => Promise<{
|
|
20
21
|
lastModified: string;
|
|
21
22
|
}>;
|
|
23
|
+
/** Get introspection data for a file (if available) */
|
|
24
|
+
getIntrospection?: (filepath: string) => FileIntrospection | undefined;
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* Context provided to modules during search
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raggrep",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Local filesystem-based RAG system for codebases - semantic search using local embeddings",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"raggrep": "
|
|
15
|
+
"raggrep": "dist/cli/main.js"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "bun run build:clean && bun run build:bundle && bun run build:types && bun run build:shebang",
|
|
24
24
|
"build:clean": "rm -rf dist",
|
|
25
|
-
"build:bundle": "bun build src/index.ts --outdir dist --target node --sourcemap=external --external '@xenova/transformers' --external 'glob' --external 'typescript' --external 'chokidar' && bun build src/cli/main.ts --outdir dist/cli --target node --sourcemap=external --external '@xenova/transformers' --external 'glob' --external 'typescript' --external 'chokidar'",
|
|
25
|
+
"build:bundle": "bun build src/index.ts --outdir dist --target node --sourcemap=external --external '@xenova/transformers' --external 'glob' --external 'typescript' --external 'chokidar' && bun build src/app/cli/main.ts --outdir dist/cli --target node --sourcemap=external --external '@xenova/transformers' --external 'glob' --external 'typescript' --external 'chokidar'",
|
|
26
26
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
27
27
|
"build:shebang": "echo '#!/usr/bin/env node' | cat - dist/cli/main.js > temp && mv temp dist/cli/main.js && chmod +x dist/cli/main.js",
|
|
28
28
|
"prepublishOnly": "bun run build",
|
|
29
|
-
"raggrep": "bun run src/cli/main.ts",
|
|
29
|
+
"raggrep": "bun run src/app/cli/main.ts",
|
|
30
30
|
"test": "bun test",
|
|
31
|
-
"dev": "bun run src/cli/main.ts"
|
|
31
|
+
"dev": "bun run src/app/cli/main.ts"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"rag",
|
package/dist/utils/bm25.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BM25 Search Utilities
|
|
3
|
-
*
|
|
4
|
-
* Re-exports BM25 functionality from the domain layer.
|
|
5
|
-
* This file exists for backwards compatibility with existing code.
|
|
6
|
-
*
|
|
7
|
-
* For new code, import directly from 'domain/services'.
|
|
8
|
-
*/
|
|
9
|
-
export { BM25Index, tokenize, normalizeScore, type BM25Document, type BM25Result, } from '../domain/services/bm25';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export declare const EMBEDDING_MODELS: {
|
|
2
|
-
readonly 'all-MiniLM-L6-v2': "Xenova/all-MiniLM-L6-v2";
|
|
3
|
-
readonly 'all-MiniLM-L12-v2': "Xenova/all-MiniLM-L12-v2";
|
|
4
|
-
readonly 'bge-small-en-v1.5': "Xenova/bge-small-en-v1.5";
|
|
5
|
-
readonly 'paraphrase-MiniLM-L3-v2': "Xenova/paraphrase-MiniLM-L3-v2";
|
|
6
|
-
};
|
|
7
|
-
export type EmbeddingModelName = keyof typeof EMBEDDING_MODELS;
|
|
8
|
-
export interface EmbeddingConfig {
|
|
9
|
-
model: EmbeddingModelName;
|
|
10
|
-
/** Show progress during model download */
|
|
11
|
-
showProgress?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Configure the embedding model
|
|
15
|
-
*/
|
|
16
|
-
export declare function configureEmbeddings(config: Partial<EmbeddingConfig>): void;
|
|
17
|
-
/**
|
|
18
|
-
* Get embedding for a single text
|
|
19
|
-
*/
|
|
20
|
-
export declare function getEmbedding(text: string): Promise<number[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Get embeddings for multiple texts (batched for efficiency)
|
|
23
|
-
*
|
|
24
|
-
* Processes texts in batches of BATCH_SIZE for better performance
|
|
25
|
-
* while avoiding memory issues with very large batches.
|
|
26
|
-
*
|
|
27
|
-
* @param texts - Array of texts to embed
|
|
28
|
-
* @returns Array of embedding vectors
|
|
29
|
-
*/
|
|
30
|
-
export declare function getEmbeddings(texts: string[]): Promise<number[][]>;
|
|
31
|
-
/**
|
|
32
|
-
* Calculate cosine similarity between two vectors
|
|
33
|
-
*/
|
|
34
|
-
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
35
|
-
/**
|
|
36
|
-
* Get current embedding configuration
|
|
37
|
-
*/
|
|
38
|
-
export declare function getEmbeddingConfig(): EmbeddingConfig;
|
|
39
|
-
/**
|
|
40
|
-
* Get the cache directory path
|
|
41
|
-
*/
|
|
42
|
-
export declare function getCacheDir(): string;
|
|
43
|
-
/**
|
|
44
|
-
* Check if a model is already cached
|
|
45
|
-
*/
|
|
46
|
-
export declare function isModelCached(model?: EmbeddingModelName): Promise<boolean>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|