codesearch-mcp 0.2.3-alpha → 0.3.0-alpha
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/CHANGELOG.md +31 -1
- package/README.md +46 -26
- package/dist/app.js +5 -19
- package/dist/src/chunking/AstChunker.d.ts +12 -0
- package/dist/src/chunking/AstChunker.js +30 -0
- package/dist/src/chunking/CharacterChunkStrategy.d.ts +8 -0
- package/dist/src/chunking/CharacterChunkStrategy.js +15 -0
- package/dist/src/chunking/DeclarationChunkStrategy.d.ts +15 -0
- package/dist/src/chunking/DeclarationChunkStrategy.js +87 -0
- package/dist/src/chunking/FragmentMerger.d.ts +11 -0
- package/dist/src/chunking/FragmentMerger.js +61 -0
- package/dist/src/chunking/ImportOnlyFilter.d.ts +5 -0
- package/dist/src/chunking/ImportOnlyFilter.js +14 -0
- package/dist/src/chunking/LangchainTextSplitter.d.ts +21 -0
- package/dist/src/chunking/LangchainTextSplitter.js +133 -0
- package/dist/src/chunking/MinSizeSplitPolicy.d.ts +9 -0
- package/dist/src/chunking/MinSizeSplitPolicy.js +18 -0
- package/dist/src/chunking/RunPacker.d.ts +12 -0
- package/dist/src/chunking/RunPacker.js +84 -0
- package/dist/src/chunking/create-chunker.d.ts +3 -0
- package/dist/src/chunking/create-chunker.js +15 -0
- package/dist/src/chunking/interfaces.d.ts +27 -0
- package/dist/src/chunking/interfaces.js +2 -0
- package/dist/src/commands/ConfigCommand.js +1 -9
- package/dist/src/commands/EvalCommand.d.ts +4 -3
- package/dist/src/commands/EvalCommand.js +85 -52
- package/dist/src/commands/IndexCommand.js +0 -22
- package/dist/src/commands/McpCommand.js +2 -8
- package/dist/src/commands/WebCommand.js +2 -5
- package/dist/src/config-error.d.ts +0 -4
- package/dist/src/config-error.js +0 -4
- package/dist/src/config-store.d.ts +1 -54
- package/dist/src/config-store.js +8 -69
- package/dist/src/config.d.ts +8 -17
- package/dist/src/config.js +35 -34
- package/dist/src/constants.d.ts +2 -28
- package/dist/src/constants.js +6 -28
- package/dist/src/container.d.ts +6 -0
- package/dist/src/container.js +12 -3
- package/dist/src/db/schema.d.ts +17 -0
- package/dist/src/db/schema.js +1 -6
- package/dist/src/declarations/DeclarationTree.d.ts +19 -0
- package/dist/src/declarations/DeclarationTree.js +66 -0
- package/dist/src/declarations/DeclarationTreeBuilder.d.ts +22 -0
- package/dist/src/declarations/DeclarationTreeBuilder.js +179 -0
- package/dist/src/declarations/SourceLines.d.ts +37 -0
- package/dist/src/declarations/SourceLines.js +415 -0
- package/dist/src/dependency-traversal.d.ts +0 -6
- package/dist/src/dependency-traversal.js +0 -6
- package/dist/src/enriched-prompt.d.ts +0 -6
- package/dist/src/enriched-prompt.js +0 -6
- package/dist/src/error-record.d.ts +12 -0
- package/dist/src/error-record.js +248 -0
- package/dist/src/eval-corpus.d.ts +16 -0
- package/dist/src/eval-corpus.js +169 -0
- package/dist/src/eval-results.d.ts +6 -3
- package/dist/src/eval-results.js +309 -26
- package/dist/src/file-utils.d.ts +0 -5
- package/dist/src/file-utils.js +0 -5
- package/dist/src/graph.d.ts +0 -25
- package/dist/src/graph.js +0 -28
- package/dist/src/hnsw-settings.d.ts +3 -0
- package/dist/src/hnsw-settings.js +24 -0
- package/dist/src/interfaces/IAstParser.d.ts +2 -39
- package/dist/src/interfaces/IChunker.d.ts +3 -12
- package/dist/src/interfaces/ICorpusInspector.d.ts +7 -0
- package/dist/src/interfaces/ICorpusInspector.js +2 -0
- package/dist/src/interfaces/IDatabase.d.ts +2 -22
- package/dist/src/interfaces/IEmbedder.d.ts +0 -9
- package/dist/src/interfaces/ILogger.d.ts +1 -11
- package/dist/src/interfaces/IMcpToolHandler.d.ts +0 -5
- package/dist/src/interfaces/IMonorepoResolver.d.ts +0 -22
- package/dist/src/interfaces/IProjectDiscovery.d.ts +0 -17
- package/dist/src/interfaces/IRetrievalEvaluator.d.ts +134 -12
- package/dist/src/interfaces/ISearcher.d.ts +16 -5
- package/dist/src/interrupt.js +0 -2
- package/dist/src/owner-path.d.ts +9 -10
- package/dist/src/owner-path.js +11 -23
- package/dist/src/project-scope.d.ts +0 -12
- package/dist/src/project-scope.js +0 -12
- package/dist/src/project-selector.d.ts +0 -5
- package/dist/src/project-selector.js +0 -11
- package/dist/src/retrieval-eval.d.ts +14 -6
- package/dist/src/retrieval-eval.js +345 -59
- package/dist/src/search/result-shaping.d.ts +4 -0
- package/dist/src/search/result-shaping.js +19 -0
- package/dist/src/services/AstParserService.d.ts +2 -62
- package/dist/src/services/AstParserService.js +25 -137
- package/dist/src/services/DatabaseService.d.ts +2 -7
- package/dist/src/services/DatabaseService.js +42 -29
- package/dist/src/services/EmbedderFactory.d.ts +0 -4
- package/dist/src/services/EmbedderFactory.js +0 -5
- package/dist/src/services/IndexerService.d.ts +0 -16
- package/dist/src/services/IndexerService.js +16 -45
- package/dist/src/services/InfinityEmbedder.d.ts +0 -21
- package/dist/src/services/InfinityEmbedder.js +0 -15
- package/dist/src/services/LoggerService.d.ts +7 -5
- package/dist/src/services/LoggerService.js +37 -41
- package/dist/src/services/McpServer.d.ts +22 -14
- package/dist/src/services/McpServer.js +70 -37
- package/dist/src/services/MonorepoAwareDiscoveryService.d.ts +1 -45
- package/dist/src/services/MonorepoAwareDiscoveryService.js +1 -51
- package/dist/src/services/NxMonorepoResolver.d.ts +0 -29
- package/dist/src/services/NxMonorepoResolver.js +5 -56
- package/dist/src/services/OpenAICompatibleEmbedder.d.ts +0 -6
- package/dist/src/services/OpenAICompatibleEmbedder.js +0 -14
- package/dist/src/services/ProjectDiscoveryService.d.ts +0 -4
- package/dist/src/services/ProjectDiscoveryService.js +0 -4
- package/dist/src/services/SearcherService.d.ts +9 -116
- package/dist/src/services/SearcherService.js +95 -176
- package/dist/src/services/VoyageEmbedder.d.ts +0 -6
- package/dist/src/services/VoyageEmbedder.js +0 -6
- package/dist/src/services/WebServerService.d.ts +1 -53
- package/dist/src/services/WebServerService.js +11 -57
- package/dist/src/services/http-retry.d.ts +0 -7
- package/dist/src/services/http-retry.js +1 -10
- package/dist/src/services/infinity-provisioning.d.ts +0 -74
- package/dist/src/services/infinity-provisioning.js +5 -88
- package/dist/src/services/legacy-ollama-index.d.ts +0 -16
- package/dist/src/services/legacy-ollama-index.js +0 -23
- package/dist/src/services/reranker.d.ts +0 -9
- package/dist/src/services/reranker.js +46 -12
- package/dist/src/setup.d.ts +11 -23
- package/dist/src/setup.js +98 -71
- package/dist/src/symbol-name.d.ts +0 -12
- package/dist/src/symbol-name.js +0 -13
- package/dist/src/symbol-rows.d.ts +0 -14
- package/dist/src/symbol-rows.js +0 -14
- package/dist/src/tool-call-log.d.ts +2 -0
- package/dist/src/tool-call-log.js +24 -0
- package/dist/src/tools/GetDependenciesTool.js +1 -1
- package/dist/src/tools/GetDependentsTool.js +1 -1
- package/dist/src/tools/SearchCodebaseTool.js +6 -3
- package/dist/src/tools/format-helpers.d.ts +0 -6
- package/dist/src/tools/format-helpers.js +87 -14
- package/dist/src/web/dashboard.d.ts +0 -8
- package/dist/src/web/dashboard.js +7 -10
- package/package.json +2 -2
- package/dist/src/services/AstChunker.d.ts +0 -42
- package/dist/src/services/AstChunker.js +0 -158
- package/docs/web-dashboard.md +0 -206
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ICorpusInspector {
|
|
2
|
+
headCommit(root: string): Promise<string>;
|
|
3
|
+
trackedChanges(root: string): Promise<string[]>;
|
|
4
|
+
untrackedFiles(root: string, skipDirs: readonly string[]): Promise<string[]>;
|
|
5
|
+
listFiles(dir: string): Promise<string[]>;
|
|
6
|
+
readFile(absPath: string): Promise<Buffer | null>;
|
|
7
|
+
}
|
|
@@ -1,44 +1,24 @@
|
|
|
1
1
|
import type { DrizzleDb, DrizzleTx } from '../services/DatabaseService';
|
|
2
|
-
/** Single-row record of which embedding model built the current index. */
|
|
3
2
|
export interface IndexMeta {
|
|
4
3
|
provider: string;
|
|
5
4
|
model: string;
|
|
6
5
|
dimensions: number;
|
|
7
6
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Database abstraction — services depend on this interface
|
|
10
|
-
* rather than the concrete DatabaseService.
|
|
11
|
-
*/
|
|
12
7
|
export interface IDatabase {
|
|
13
8
|
readonly orm: DrizzleDb;
|
|
14
9
|
query<T = any>(sql: string, params?: any[]): Promise<T>;
|
|
10
|
+
queryWithLocalSettings<T = any>(settings: Record<string, string | number>, sql: string, params?: any[]): Promise<T>;
|
|
11
|
+
pgvectorVersion(): Promise<string | null>;
|
|
15
12
|
transaction<T>(fn: (tx: DrizzleTx) => Promise<T>): Promise<T>;
|
|
16
13
|
initDb(): Promise<void>;
|
|
17
14
|
initDbWithSchema(): Promise<void>;
|
|
18
15
|
destroy(): Promise<void>;
|
|
19
|
-
/** Read the single `index_meta` row, or null when absent (table missing → null). */
|
|
20
16
|
readIndexMeta(): Promise<IndexMeta | null>;
|
|
21
|
-
/** Upsert the single `index_meta` row. */
|
|
22
17
|
writeIndexMeta(meta: IndexMeta): Promise<void>;
|
|
23
|
-
/** Create `code_chunk` (+ HNSW/service indexes) at `dimensions` if absent. */
|
|
24
18
|
ensureChunkTable(dimensions: number): Promise<void>;
|
|
25
|
-
/** Drop and recreate `code_chunk` at `dimensions` (dimension change). */
|
|
26
19
|
recreateChunkTable(dimensions: number): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Return all file paths referenced in any of the four index tables for `project`.
|
|
29
|
-
* Union of code_chunk.filePath, code_symbol.filePath, code_call.fromFile,
|
|
30
|
-
* code_dependency.fromFile. calleeFile and toFile are excluded (may belong to other projects).
|
|
31
|
-
*/
|
|
32
20
|
listKnownFiles(project: string): Promise<string[]>;
|
|
33
|
-
/**
|
|
34
|
-
* Delete rows for `filePaths` from all four index tables in one transaction.
|
|
35
|
-
* code_call rows where the file is either fromFile OR calleeFile are removed.
|
|
36
|
-
* code_dependency rows where the file is either fromFile OR toFile are removed.
|
|
37
|
-
* No-op when `filePaths` is empty.
|
|
38
|
-
*/
|
|
39
21
|
deleteFiles(project: string, filePaths: string[]): Promise<void>;
|
|
40
|
-
/** Return all project names referenced in any of the four index tables. */
|
|
41
22
|
listIndexedProjects(): Promise<string[]>;
|
|
42
|
-
/** Delete all rows for `name` from the four index tables in one transaction. */
|
|
43
23
|
deleteProject(name: string): Promise<void>;
|
|
44
24
|
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
export type InputType = 'query' | 'document';
|
|
2
2
|
export interface IEmbedder {
|
|
3
|
-
/**
|
|
4
|
-
* The vector width this embedder produces, when known without a probe:
|
|
5
|
-
* `embedding.dimensions` override → model registry, else `0` for models whose
|
|
6
|
-
* width is only knowable by embedding once (see `resolveDimension`). Read by
|
|
7
|
-
* `SearcherService.assertIndexMatches` to catch a dimension change on the
|
|
8
|
-
* search side (skipped when `0`). Indexing resolves the true width via
|
|
9
|
-
* `resolveDimension` (which probes when needed), not this field.
|
|
10
|
-
*/
|
|
11
3
|
readonly dimensions: number;
|
|
12
4
|
embed(text: string, inputType?: InputType): Promise<number[]>;
|
|
13
|
-
/** One vector per input, in input order. The indexing path. */
|
|
14
5
|
embedBatch(texts: string[], inputType?: InputType): Promise<number[][]>;
|
|
15
6
|
rerank?(query: string, documents: string[], topN: number): Promise<number[]>;
|
|
16
7
|
listModels?(): Promise<string[]>;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logger abstraction — allows services to depend on a contract
|
|
3
|
-
* rather than the concrete pino-based LoggerService.
|
|
4
|
-
*/
|
|
5
1
|
export interface ILogger {
|
|
6
2
|
debug(msg: string, data?: Record<string, unknown>): void;
|
|
7
3
|
info(msg: string, data?: Record<string, unknown>): void;
|
|
8
4
|
warn(msg: string, data?: Record<string, unknown>): void;
|
|
9
5
|
error(msg: string, data?: Record<string, unknown>): void;
|
|
10
|
-
|
|
11
|
-
* Structured telemetry emitted at `info` **independent of the configured log
|
|
12
|
-
* level** — so an operator can collect it in production without the full
|
|
13
|
-
* `debug` firehose. No-op when file logging is disabled (never writes to
|
|
14
|
-
* stdout, which the MCP transport owns).
|
|
15
|
-
*/
|
|
16
|
-
metric(msg: string, data?: Record<string, unknown>): void;
|
|
6
|
+
withContext<T>(context: Record<string, unknown>, fn: () => Promise<T>): Promise<T>;
|
|
17
7
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Tool Handler interface — each tool implements this contract.
|
|
3
|
-
* Follows the Open/Closed Principle: new tools are added by implementing
|
|
4
|
-
* this interface and registering them, not by modifying McpServer.
|
|
5
|
-
*/
|
|
6
1
|
export interface ToolDefinition {
|
|
7
2
|
name: string;
|
|
8
3
|
description: string;
|
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a discovered project within a monorepo workspace.
|
|
3
|
-
*/
|
|
4
1
|
export interface MonorepoProject {
|
|
5
|
-
/** Project name (e.g. "my-app", "shared-utils") */
|
|
6
2
|
name: string;
|
|
7
|
-
/** Absolute path to the project root */
|
|
8
3
|
path: string;
|
|
9
|
-
/** npm scope + package name (e.g. "@scope/my-app") — null if no package.json or no name */
|
|
10
4
|
packageName: string | null;
|
|
11
|
-
/** "app" | "lib" — derived from project.json or directory convention */
|
|
12
5
|
type: 'app' | 'lib';
|
|
13
6
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Monorepo resolver — detects and resolves workspace structure.
|
|
16
|
-
* Implementations handle specific monorepo tooling (Nx, Turborepo, etc.)
|
|
17
|
-
*/
|
|
18
7
|
export interface IMonorepoResolver {
|
|
19
|
-
/**
|
|
20
|
-
* Detect whether the given root directory is a monorepo workspace.
|
|
21
|
-
*/
|
|
22
8
|
isMonorepo(rootDir: string): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Discover all projects (apps + libs) in the monorepo.
|
|
25
|
-
*/
|
|
26
9
|
discoverProjects(rootDir: string): MonorepoProject[];
|
|
27
|
-
/**
|
|
28
|
-
* Get the root tsconfig path that contains workspace-wide path aliases.
|
|
29
|
-
* For Nx this is typically tsconfig.base.json at the workspace root.
|
|
30
|
-
* The AST parser uses this to resolve cross-project imports (@scope/*).
|
|
31
|
-
*/
|
|
32
10
|
getRootTsConfigPath(rootDir: string): string | null;
|
|
33
11
|
}
|
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
export interface DiscoveredProject {
|
|
2
2
|
name: string;
|
|
3
3
|
path: string;
|
|
4
|
-
/** npm scope + package name (e.g. "@scope/my-app") — only set for monorepo projects */
|
|
5
4
|
packageName?: string | null;
|
|
6
|
-
/** "app" | "lib" — only set for monorepo projects */
|
|
7
5
|
type?: 'app' | 'lib';
|
|
8
|
-
/**
|
|
9
|
-
* Path to the workspace-wide tsconfig (e.g. tsconfig.base.json) that holds
|
|
10
|
-
* cross-project path aliases. Set for monorepo projects; undefined for flat
|
|
11
|
-
* workspaces (where each project uses its own local tsconfig.json).
|
|
12
|
-
*/
|
|
13
6
|
rootTsConfigPath?: string | null;
|
|
14
|
-
/**
|
|
15
|
-
* When a top-level directory is itself a nested monorepo (e.g. an Nx repo
|
|
16
|
-
* under a flat workspaceRoot), this holds its expanded sub-projects. The
|
|
17
|
-
* repo stays a single selectable unit; `toLeafProjects` expands `children`
|
|
18
|
-
* into the actual projects to index. Absent/undefined for ordinary projects.
|
|
19
|
-
*/
|
|
20
7
|
children?: DiscoveredProject[];
|
|
21
8
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Project discovery abstraction — decouples project enumeration
|
|
24
|
-
* from the indexing service (Single Responsibility Principle).
|
|
25
|
-
*/
|
|
26
9
|
export interface IProjectDiscovery {
|
|
27
10
|
discover(rootDir: string): DiscoveredProject[];
|
|
28
11
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { StageName } from './ISearcher';
|
|
2
|
+
export type { StageName };
|
|
1
3
|
export type EvalCategory = 'identifier' | 'behaviour' | 'concept';
|
|
2
4
|
export interface ExpectedAnswer {
|
|
3
5
|
file: string;
|
|
@@ -10,20 +12,38 @@ export interface EvalCase {
|
|
|
10
12
|
query: string;
|
|
11
13
|
expect: ExpectedAnswer[];
|
|
12
14
|
threshold?: number;
|
|
15
|
+
corpus?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface CorpusRef {
|
|
18
|
+
root: string;
|
|
19
|
+
commit: string;
|
|
13
20
|
}
|
|
14
21
|
export interface EvalSuite {
|
|
15
22
|
version: 1;
|
|
23
|
+
corpus?: CorpusRef;
|
|
16
24
|
cases: EvalCase[];
|
|
17
25
|
}
|
|
18
26
|
export interface SearchHit {
|
|
19
27
|
filePath: string;
|
|
20
28
|
ownerPath: string | null;
|
|
21
29
|
}
|
|
22
|
-
export
|
|
23
|
-
|
|
30
|
+
export interface StagedHits {
|
|
31
|
+
pool: SearchHit[];
|
|
32
|
+
stages: {
|
|
33
|
+
vector: SearchHit[];
|
|
34
|
+
} & Partial<Record<StageName, SearchHit[]>>;
|
|
35
|
+
rerankFailed: boolean;
|
|
36
|
+
fetchLimit: number;
|
|
37
|
+
indexParams: {
|
|
38
|
+
efSearch: number | null;
|
|
39
|
+
iterativeScan: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export type SearchFn = (query: string, limit: number, project: string | null, threshold?: number) => Promise<StagedHits>;
|
|
24
43
|
export interface IndexInspector {
|
|
25
44
|
isFileIndexed(project: string, file: string): Promise<boolean>;
|
|
26
45
|
ownerPathsOfFile(project: string, file: string): Promise<string[]>;
|
|
46
|
+
projectDir(project: string): Promise<string | null>;
|
|
27
47
|
}
|
|
28
48
|
export interface Metrics {
|
|
29
49
|
count: number;
|
|
@@ -31,14 +51,20 @@ export interface Metrics {
|
|
|
31
51
|
hit5: number;
|
|
32
52
|
mrr10: number;
|
|
33
53
|
}
|
|
54
|
+
export interface StageRank {
|
|
55
|
+
rank: number | null;
|
|
56
|
+
matched: SearchHit | null;
|
|
57
|
+
}
|
|
34
58
|
export interface CaseResult {
|
|
35
59
|
id: string;
|
|
36
60
|
project: string;
|
|
37
61
|
category: EvalCategory;
|
|
38
62
|
query: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
stages: Partial<Record<StageName, StageRank>>;
|
|
64
|
+
poolRank: number | null;
|
|
65
|
+
poolSize: number;
|
|
66
|
+
rerankFailed: boolean;
|
|
67
|
+
corpus: string | null;
|
|
42
68
|
}
|
|
43
69
|
export interface InvalidCase {
|
|
44
70
|
id: string;
|
|
@@ -49,17 +75,82 @@ export interface PartialWarning {
|
|
|
49
75
|
id: string;
|
|
50
76
|
droppedExpects: ExpectedAnswer[];
|
|
51
77
|
}
|
|
78
|
+
export interface StageMetrics {
|
|
79
|
+
overall: Metrics;
|
|
80
|
+
byCategory: Partial<Record<EvalCategory, Metrics>>;
|
|
81
|
+
}
|
|
82
|
+
export interface PoolMetrics {
|
|
83
|
+
count: number;
|
|
84
|
+
recall: number;
|
|
85
|
+
short: number;
|
|
86
|
+
}
|
|
87
|
+
export interface PairCounts {
|
|
88
|
+
improved: number;
|
|
89
|
+
worsened: number;
|
|
90
|
+
unchanged: number;
|
|
91
|
+
signTestP: number;
|
|
92
|
+
}
|
|
93
|
+
export interface PairedChange {
|
|
94
|
+
overall: PairCounts;
|
|
95
|
+
byCategory: Partial<Record<EvalCategory, PairCounts>>;
|
|
96
|
+
hit5Gained: string[];
|
|
97
|
+
hit5Lost: string[];
|
|
98
|
+
}
|
|
99
|
+
export interface StageChange {
|
|
100
|
+
from: StageName;
|
|
101
|
+
to: StageName;
|
|
102
|
+
change: PairedChange;
|
|
103
|
+
}
|
|
52
104
|
export interface EvalRunResult {
|
|
53
105
|
cases: CaseResult[];
|
|
54
106
|
invalid: InvalidCase[];
|
|
55
107
|
warnings: PartialWarning[];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
108
|
+
stages: StageName[];
|
|
109
|
+
metrics: Partial<Record<StageName, StageMetrics>>;
|
|
110
|
+
pool: {
|
|
111
|
+
overall: PoolMetrics;
|
|
112
|
+
byCategory: Partial<Record<EvalCategory, PoolMetrics>>;
|
|
113
|
+
};
|
|
114
|
+
stageChanges: StageChange[];
|
|
115
|
+
rerankFailures: number;
|
|
116
|
+
byCorpus: Record<string, CorpusRunMetrics>;
|
|
117
|
+
}
|
|
118
|
+
export interface CorpusRunMetrics {
|
|
119
|
+
cases: number;
|
|
120
|
+
metrics: Partial<Record<StageName, StageMetrics>>;
|
|
121
|
+
pool: {
|
|
122
|
+
overall: PoolMetrics;
|
|
123
|
+
byCategory: Partial<Record<EvalCategory, PoolMetrics>>;
|
|
59
124
|
};
|
|
125
|
+
stageChanges: StageChange[];
|
|
126
|
+
}
|
|
127
|
+
export interface ObservedSearchParams {
|
|
128
|
+
fetchLimit: number[];
|
|
129
|
+
efSearch: (number | null)[];
|
|
130
|
+
iterativeScan: string[];
|
|
131
|
+
}
|
|
132
|
+
export interface EvalOutcome {
|
|
133
|
+
run: EvalRunResult;
|
|
134
|
+
observed: ObservedSearchParams;
|
|
135
|
+
}
|
|
136
|
+
export interface CaseProgress {
|
|
137
|
+
index: number;
|
|
138
|
+
total: number;
|
|
139
|
+
id: string;
|
|
140
|
+
result: CaseResult | null;
|
|
141
|
+
invalid: InvalidCase | null;
|
|
142
|
+
ms: number;
|
|
60
143
|
}
|
|
61
144
|
export interface IRetrievalEvaluator {
|
|
62
|
-
evaluate(suite: EvalSuite, search: SearchFn, inspect: IndexInspector): Promise<
|
|
145
|
+
evaluate(suite: EvalSuite, search: SearchFn, inspect: IndexInspector, onCase?: (p: CaseProgress) => void): Promise<EvalOutcome>;
|
|
146
|
+
}
|
|
147
|
+
export interface SearchConditions {
|
|
148
|
+
similarityThreshold: number;
|
|
149
|
+
overfetch: number;
|
|
150
|
+
candidateFloor: number;
|
|
151
|
+
fetchLimit: number[];
|
|
152
|
+
efSearch: (number | null)[];
|
|
153
|
+
iterativeScan: string[];
|
|
63
154
|
}
|
|
64
155
|
export interface ResultMetadata {
|
|
65
156
|
suitePath: string;
|
|
@@ -74,10 +165,21 @@ export interface ResultMetadata {
|
|
|
74
165
|
} | null;
|
|
75
166
|
gitCommit: string;
|
|
76
167
|
timestamp: string;
|
|
168
|
+
conditions: SearchConditions | null;
|
|
169
|
+
corpora: CorpusRecord[];
|
|
170
|
+
liveCases: number;
|
|
171
|
+
}
|
|
172
|
+
export interface CorpusRecord {
|
|
173
|
+
root: string;
|
|
174
|
+
commit: string;
|
|
175
|
+
projects: string[];
|
|
176
|
+
chunks: number;
|
|
177
|
+
fingerprint: string;
|
|
77
178
|
}
|
|
78
179
|
export interface EvalResultFile {
|
|
79
180
|
metadata: ResultMetadata;
|
|
80
181
|
run: EvalRunResult;
|
|
182
|
+
legacy?: true;
|
|
81
183
|
}
|
|
82
184
|
export interface MetricDelta {
|
|
83
185
|
baseline: number;
|
|
@@ -85,10 +187,30 @@ export interface MetricDelta {
|
|
|
85
187
|
delta: number;
|
|
86
188
|
}
|
|
87
189
|
export type MetricsDelta = Record<keyof Metrics, MetricDelta>;
|
|
88
|
-
export interface
|
|
190
|
+
export interface StageComparison {
|
|
191
|
+
stage: StageName;
|
|
89
192
|
overall: MetricsDelta;
|
|
90
193
|
byCategory: Partial<Record<EvalCategory, MetricsDelta>>;
|
|
91
|
-
|
|
92
|
-
|
|
194
|
+
change: PairedChange;
|
|
195
|
+
}
|
|
196
|
+
export interface PoolValueDelta {
|
|
197
|
+
baseline: number | null;
|
|
198
|
+
current: number;
|
|
199
|
+
delta: number | null;
|
|
200
|
+
}
|
|
201
|
+
export interface PoolDelta {
|
|
202
|
+
recall: PoolValueDelta;
|
|
203
|
+
short: PoolValueDelta;
|
|
204
|
+
}
|
|
205
|
+
export interface CompareResult {
|
|
206
|
+
stages: StageComparison[];
|
|
207
|
+
unmatchedStages: {
|
|
208
|
+
stage: StageName;
|
|
209
|
+
side: 'baseline' | 'current';
|
|
210
|
+
}[];
|
|
211
|
+
pool: {
|
|
212
|
+
overall: PoolDelta;
|
|
213
|
+
byCategory: Partial<Record<EvalCategory, PoolDelta>>;
|
|
214
|
+
};
|
|
93
215
|
conditionWarnings: string[];
|
|
94
216
|
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import type { SearchResult, NeighborResult, GraphContext, DependencyRow, ProjectRow, SymbolKind, SymbolHit, CallerRow, FileRangeResult, ListFilesResult, GrepSymbolResult, ResolvedToolPath, PathFailure } from '../services/SearcherService';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export type StageName = 'vector' | 'reranked';
|
|
3
|
+
export interface StagedSearchResult {
|
|
4
|
+
pool: SearchResult[];
|
|
5
|
+
stages: {
|
|
6
|
+
vector: SearchResult[];
|
|
7
|
+
reranked?: SearchResult[];
|
|
8
|
+
};
|
|
9
|
+
rerankFailed: boolean;
|
|
10
|
+
fetchLimit: number;
|
|
11
|
+
indexParams: {
|
|
12
|
+
efSearch: number | null;
|
|
13
|
+
iterativeScan: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
6
16
|
export interface ISearcher {
|
|
7
17
|
prepareQuery(raw: string): Promise<{
|
|
8
18
|
query: string;
|
|
@@ -14,7 +24,8 @@ export interface ISearcher {
|
|
|
14
24
|
from: string;
|
|
15
25
|
to: string;
|
|
16
26
|
}[]>;
|
|
17
|
-
searchChunks(query: string, limit: number, project: string | null, threshold?: number, rerankOverride?: boolean): Promise<SearchResult[]>;
|
|
27
|
+
searchChunks(query: string, limit: number, project: string | null, threshold?: number, rerankOverride?: boolean, perFile?: number): Promise<SearchResult[]>;
|
|
28
|
+
searchChunksWithStages(query: string, limit: number, project: string | null, threshold?: number, rerankOverride?: boolean, perFile?: number): Promise<StagedSearchResult>;
|
|
18
29
|
fetchNeighbors(results: SearchResult[]): Promise<NeighborResult[]>;
|
|
19
30
|
fetchGraphContext(results: SearchResult[]): Promise<Map<string, GraphContext>>;
|
|
20
31
|
getDependencies(filePath: string, symbol?: string | null, transitive?: boolean): Promise<DependencyRow[]>;
|
package/dist/src/interrupt.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupInterrupt = setupInterrupt;
|
|
4
|
-
// Graceful interruption for long-running CLI operations.
|
|
5
|
-
// Caller creates the AbortController; this function wires stdin and returns a cleanup function.
|
|
6
4
|
function setupInterrupt(controller) {
|
|
7
5
|
if (!process.stdin.isTTY)
|
|
8
6
|
return () => { };
|
package/dist/src/owner-path.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare function resolveOwnerPath(startLine: number, ranges: OwnerRange[]): string | null;
|
|
1
|
+
import type { DeclarationTree } from './declarations/DeclarationTree';
|
|
2
|
+
import type { SourceLines } from './declarations/SourceLines';
|
|
3
|
+
interface LineSpan {
|
|
4
|
+
startLine: number;
|
|
5
|
+
endLine: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function ownedLines(piece: LineSpan, declarations: DeclarationTree, lines: SourceLines): number[];
|
|
8
|
+
export declare function ownerOf(piece: LineSpan, declarations: DeclarationTree, lines: SourceLines): string | null;
|
|
9
|
+
export {};
|
package/dist/src/owner-path.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* start line lies outside every range (imports / module-scope gaps).
|
|
11
|
-
*/
|
|
12
|
-
function resolveOwnerPath(startLine, ranges) {
|
|
13
|
-
let best = null;
|
|
14
|
-
let bestSpan = Infinity;
|
|
15
|
-
for (const r of ranges) {
|
|
16
|
-
if (r.line <= startLine && startLine <= r.endLine) {
|
|
17
|
-
const span = r.endLine - r.line;
|
|
18
|
-
if (span < bestSpan) {
|
|
19
|
-
bestSpan = span;
|
|
20
|
-
best = r;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
3
|
+
exports.ownedLines = ownedLines;
|
|
4
|
+
exports.ownerOf = ownerOf;
|
|
5
|
+
function ownedLines(piece, declarations, lines) {
|
|
6
|
+
const owned = [];
|
|
7
|
+
for (let n = piece.startLine; n <= piece.endLine; n++) {
|
|
8
|
+
if (lines.isSignificant(n) && declarations.contains(n))
|
|
9
|
+
owned.push(n);
|
|
23
10
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
return owned;
|
|
12
|
+
}
|
|
13
|
+
function ownerOf(piece, declarations, lines) {
|
|
14
|
+
return declarations.smallestContaining(ownedLines(piece, declarations, lines))?.qualifiedName ?? null;
|
|
27
15
|
}
|
|
@@ -3,17 +3,5 @@ export interface ResolveProjectNamesResult {
|
|
|
3
3
|
targets: DiscoveredProject[];
|
|
4
4
|
notFound: string[];
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* Resolve one or more `--project`-style names against discovered units: a
|
|
8
|
-
* unit name expands to all of its children, a leaf name resolves to itself.
|
|
9
|
-
* Units are tried before leaves so a top-level project named the same as a
|
|
10
|
-
* nested-monorepo child's bare name can never shadow it. Targets are
|
|
11
|
-
* deduplicated by leaf name and ordered by first-resolving input name.
|
|
12
|
-
*/
|
|
13
6
|
export declare function resolveProjectNames(names: string[], units: DiscoveredProject[]): ResolveProjectNamesResult;
|
|
14
|
-
/**
|
|
15
|
-
* Every name `--project` would accept as a match, in discovery order: each
|
|
16
|
-
* unit's own name, immediately followed by its expanded leaf names (an
|
|
17
|
-
* ordinary project — no children — contributes only its own name once).
|
|
18
|
-
*/
|
|
19
7
|
export declare function listAvailableNames(units: DiscoveredProject[]): string[];
|
|
@@ -3,13 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveProjectNames = resolveProjectNames;
|
|
4
4
|
exports.listAvailableNames = listAvailableNames;
|
|
5
5
|
const MonorepoAwareDiscoveryService_1 = require("./services/MonorepoAwareDiscoveryService");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve one or more `--project`-style names against discovered units: a
|
|
8
|
-
* unit name expands to all of its children, a leaf name resolves to itself.
|
|
9
|
-
* Units are tried before leaves so a top-level project named the same as a
|
|
10
|
-
* nested-monorepo child's bare name can never shadow it. Targets are
|
|
11
|
-
* deduplicated by leaf name and ordered by first-resolving input name.
|
|
12
|
-
*/
|
|
13
6
|
function resolveProjectNames(names, units) {
|
|
14
7
|
const leaves = (0, MonorepoAwareDiscoveryService_1.toLeafProjects)(units);
|
|
15
8
|
const targets = [];
|
|
@@ -31,11 +24,6 @@ function resolveProjectNames(names, units) {
|
|
|
31
24
|
}
|
|
32
25
|
return { targets, notFound };
|
|
33
26
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Every name `--project` would accept as a match, in discovery order: each
|
|
36
|
-
* unit's own name, immediately followed by its expanded leaf names (an
|
|
37
|
-
* ordinary project — no children — contributes only its own name once).
|
|
38
|
-
*/
|
|
39
27
|
function listAvailableNames(units) {
|
|
40
28
|
const names = [];
|
|
41
29
|
for (const unit of units) {
|
|
@@ -2,11 +2,6 @@ export interface Project {
|
|
|
2
2
|
name: string;
|
|
3
3
|
path: string;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
6
|
-
* One-off single-choice prompt for `--project` with no name — distinct from
|
|
7
|
-
* the multi-select `checkbox` flow: it reads/writes nothing persisted.
|
|
8
|
-
* Resolves to `undefined` if the user cancels (e.g. Ctrl+C).
|
|
9
|
-
*/
|
|
10
5
|
export declare function selectSingleProject(units: Project[]): Promise<string | undefined>;
|
|
11
6
|
export declare class ProjectSelector {
|
|
12
7
|
private readonly workspaceDir;
|
|
@@ -38,11 +38,6 @@ exports.selectSingleProject = selectSingleProject;
|
|
|
38
38
|
const fs = __importStar(require("fs"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
const prompts_1 = require("@inquirer/prompts");
|
|
41
|
-
/**
|
|
42
|
-
* One-off single-choice prompt for `--project` with no name — distinct from
|
|
43
|
-
* the multi-select `checkbox` flow: it reads/writes nothing persisted.
|
|
44
|
-
* Resolves to `undefined` if the user cancels (e.g. Ctrl+C).
|
|
45
|
-
*/
|
|
46
41
|
async function selectSingleProject(units) {
|
|
47
42
|
try {
|
|
48
43
|
return await (0, prompts_1.select)({
|
|
@@ -66,9 +61,6 @@ async function loadLines(filePath) {
|
|
|
66
61
|
return new Set();
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
|
-
// Write the set if non-empty, otherwise delete the file so state is deterministic.
|
|
70
|
-
// Previously .ragskip could be left stale (last entry removed but file not rewritten);
|
|
71
|
-
// treating both files the same way avoids that drift.
|
|
72
64
|
async function saveLines(filePath, names) {
|
|
73
65
|
if (names.size > 0) {
|
|
74
66
|
await fs.promises.writeFile(filePath, [...names].sort().join('\n') + '\n');
|
|
@@ -94,13 +86,10 @@ class ProjectSelector {
|
|
|
94
86
|
await this.load();
|
|
95
87
|
const newProjects = allProjects.filter(p => !this.included.has(p.name) && !this.skipped.has(p.name));
|
|
96
88
|
const previouslySelected = allProjects.filter(p => this.included.has(p.name));
|
|
97
|
-
// Nothing new and something already selected — return silently
|
|
98
89
|
if (newProjects.length === 0 && !forceSelect && previouslySelected.length > 0) {
|
|
99
90
|
return previouslySelected;
|
|
100
91
|
}
|
|
101
|
-
// No previous selection — treat as implicit --select so the user picks projects now
|
|
102
92
|
const autoSelect = !forceSelect && previouslySelected.length === 0;
|
|
103
|
-
// In --select / auto-select mode show all non-skipped projects; otherwise only new ones
|
|
104
93
|
const toShow = (forceSelect || autoSelect)
|
|
105
94
|
? allProjects.filter(p => !this.skipped.has(p.name))
|
|
106
95
|
: newProjects;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import type { EvalSuite, SearchFn, IndexInspector, IRetrievalEvaluator,
|
|
2
|
-
|
|
1
|
+
import type { EvalSuite, EvalCase, EvalCategory, CorpusRef, SearchFn, IndexInspector, IRetrievalEvaluator, EvalOutcome, StageName, PairedChange, CaseProgress, EvalResultFile, CompareResult } from './interfaces/IRetrievalEvaluator';
|
|
2
|
+
export declare const STAGE_ORDER: readonly StageName[];
|
|
3
3
|
export declare class EvalSuiteError extends Error {
|
|
4
4
|
readonly caseId: string | null;
|
|
5
5
|
readonly field: string | null;
|
|
6
6
|
constructor(message: string, caseId: string | null, field: string | null);
|
|
7
7
|
}
|
|
8
|
-
/** Validates a loaded suite object against the schema; rejects before any search runs. */
|
|
9
8
|
export declare function parseSuite(raw: unknown): EvalSuite;
|
|
10
|
-
|
|
9
|
+
export declare function corporaOf(suites: EvalSuite[]): CorpusRef[];
|
|
10
|
+
export declare function isUnderRoot(dir: string, root: string): boolean;
|
|
11
|
+
export declare function checkCaseCorpora(cases: EvalCase[], projectDir: (project: string) => Promise<string | null>): Promise<void>;
|
|
11
12
|
export declare function mergeSuites(suites: EvalSuite[]): EvalSuite;
|
|
13
|
+
export declare function signTest(improved: number, worsened: number): number;
|
|
14
|
+
export interface RankedCase {
|
|
15
|
+
id: string;
|
|
16
|
+
category: EvalCategory;
|
|
17
|
+
rank: number | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function pairedChange(from: RankedCase[], to: RankedCase[]): PairedChange;
|
|
20
|
+
export declare const LIVE_GROUP = "live";
|
|
12
21
|
export declare class RetrievalEvaluator implements IRetrievalEvaluator {
|
|
13
|
-
evaluate(suite: EvalSuite, search: SearchFn, inspect: IndexInspector): Promise<
|
|
22
|
+
evaluate(suite: EvalSuite, search: SearchFn, inspect: IndexInspector, onCase?: (p: CaseProgress) => void): Promise<EvalOutcome>;
|
|
14
23
|
}
|
|
15
|
-
/** Pure comparison of two result files; prints a warning (never refuses) on mismatched conditions. */
|
|
16
24
|
export declare function compare(baseline: EvalResultFile, current: EvalResultFile): CompareResult;
|