codesearch-mcp 0.3.0-alpha → 0.4.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.
Files changed (224) hide show
  1. package/CHANGELOG.md +59 -6
  2. package/LICENSE +661 -21
  3. package/README.md +33 -17
  4. package/dist/app.js +13 -20
  5. package/dist/src/ast/CallExtractor.d.ts +8 -0
  6. package/dist/src/ast/CallExtractor.js +68 -0
  7. package/dist/src/ast/GraphqlNameExtractor.d.ts +22 -0
  8. package/dist/src/ast/GraphqlNameExtractor.js +240 -0
  9. package/dist/src/ast/ImportEdgeExtractor.d.ts +11 -0
  10. package/dist/src/ast/ImportEdgeExtractor.js +129 -0
  11. package/dist/src/ast/IndexedNodeResolver.d.ts +14 -0
  12. package/dist/src/ast/IndexedNodeResolver.js +217 -0
  13. package/dist/src/ast/MemberExtractor.d.ts +8 -0
  14. package/dist/src/ast/MemberExtractor.js +129 -0
  15. package/dist/src/ast/TopLevelSymbolExtractor.d.ts +5 -0
  16. package/dist/src/ast/TopLevelSymbolExtractor.js +86 -0
  17. package/dist/src/ast/graphql-grammar.d.ts +24 -0
  18. package/dist/src/ast/graphql-grammar.js +93 -0
  19. package/dist/src/ast/node-helpers.d.ts +11 -0
  20. package/dist/src/ast/node-helpers.js +55 -0
  21. package/dist/src/commands/EvalCommand.d.ts +7 -3
  22. package/dist/src/commands/EvalCommand.js +36 -158
  23. package/dist/src/commands/IndexCommand.d.ts +10 -4
  24. package/dist/src/commands/IndexCommand.js +52 -124
  25. package/dist/src/commands/McpCommand.d.ts +6 -3
  26. package/dist/src/commands/McpCommand.js +19 -14
  27. package/dist/src/commands/WebCommand.d.ts +9 -3
  28. package/dist/src/commands/WebCommand.js +17 -8
  29. package/dist/src/commands/eval/baseline-comparison.d.ts +6 -0
  30. package/dist/src/commands/eval/baseline-comparison.js +54 -0
  31. package/dist/src/commands/eval/eval-args.d.ts +6 -0
  32. package/dist/src/commands/eval/eval-args.js +71 -0
  33. package/dist/src/commands/eval/eval-corpora.d.ts +6 -0
  34. package/dist/src/commands/eval/eval-corpora.js +76 -0
  35. package/dist/src/commands/eval/eval-metadata.d.ts +17 -0
  36. package/dist/src/commands/eval/eval-metadata.js +75 -0
  37. package/dist/src/commands/eval/index-inspector.d.ts +3 -0
  38. package/dist/src/commands/eval/index-inspector.js +21 -0
  39. package/dist/src/commands/eval/staged-search.d.ts +3 -0
  40. package/dist/src/commands/eval/staged-search.js +20 -0
  41. package/dist/src/commands/eval/suite-loader.d.ts +8 -0
  42. package/dist/src/commands/eval/suite-loader.js +52 -0
  43. package/dist/src/commands/index/backend-probe.d.ts +2 -0
  44. package/dist/src/commands/index/backend-probe.js +15 -0
  45. package/dist/src/commands/index/embedding-setup.d.ts +3 -0
  46. package/dist/src/commands/index/embedding-setup.js +16 -0
  47. package/dist/src/commands/index/index-summary.d.ts +2 -0
  48. package/dist/src/commands/index/index-summary.js +22 -0
  49. package/dist/src/commands/index/legacy-ollama-guard.d.ts +3 -0
  50. package/dist/src/commands/index/legacy-ollama-guard.js +23 -0
  51. package/dist/src/commands/index/prune-step.d.ts +3 -0
  52. package/dist/src/commands/index/prune-step.js +22 -0
  53. package/dist/src/commands/index/scan-targets.d.ts +8 -0
  54. package/dist/src/commands/index/scan-targets.js +107 -0
  55. package/dist/src/config-store.d.ts +0 -1
  56. package/dist/src/config-store.js +3 -4
  57. package/dist/src/config.d.ts +1 -1
  58. package/dist/src/config.js +1 -1
  59. package/dist/src/constants.d.ts +15 -0
  60. package/dist/src/constants.js +34 -6
  61. package/dist/src/container.d.ts +4 -2
  62. package/dist/src/container.js +7 -5
  63. package/dist/src/db/drizzle-types.d.ts +7 -0
  64. package/dist/src/db/index.d.ts +1 -0
  65. package/dist/src/db/schema-steps.d.ts +8 -0
  66. package/dist/src/db/schema-steps.js +105 -0
  67. package/dist/src/declarations/DeclarationTree.d.ts +1 -1
  68. package/dist/src/eval-results.js +16 -2
  69. package/dist/src/eval-vector-index.d.ts +5 -0
  70. package/dist/src/eval-vector-index.js +60 -0
  71. package/dist/src/help.js +9 -1
  72. package/dist/src/index-args.d.ts +13 -0
  73. package/dist/src/index-args.js +48 -0
  74. package/dist/src/indexing/AnalysisBatcher.d.ts +12 -0
  75. package/dist/src/indexing/AnalysisBatcher.js +28 -0
  76. package/dist/src/indexing/ChunkEmbedder.d.ts +24 -0
  77. package/dist/src/indexing/ChunkEmbedder.js +37 -0
  78. package/dist/src/indexing/ConsoleScanReporter.d.ts +10 -0
  79. package/dist/src/indexing/ConsoleScanReporter.js +73 -0
  80. package/dist/src/indexing/EmbeddingSchemaPreparer.d.ts +14 -0
  81. package/dist/src/indexing/EmbeddingSchemaPreparer.js +66 -0
  82. package/dist/src/indexing/FileIngestor.d.ts +22 -0
  83. package/dist/src/indexing/FileIngestor.js +116 -0
  84. package/dist/src/indexing/IndexStore.d.ts +24 -0
  85. package/dist/src/indexing/IndexStore.js +69 -0
  86. package/dist/src/indexing/StaleFilePruner.d.ts +8 -0
  87. package/dist/src/indexing/StaleFilePruner.js +55 -0
  88. package/dist/src/indexing/analysis-rows.d.ts +4 -0
  89. package/dist/src/indexing/analysis-rows.js +65 -0
  90. package/dist/src/indexing/project-notices.d.ts +2 -0
  91. package/dist/src/indexing/project-notices.js +63 -0
  92. package/dist/src/interfaces/IAstParser.d.ts +2 -1
  93. package/dist/src/interfaces/ICallGraph.d.ts +28 -0
  94. package/dist/src/interfaces/ICallGraph.js +2 -0
  95. package/dist/src/interfaces/IChunkSearch.d.ts +42 -0
  96. package/dist/src/interfaces/IChunkSearch.js +2 -0
  97. package/dist/src/interfaces/IDatabase.d.ts +6 -2
  98. package/dist/src/interfaces/IDependencyGraph.d.ts +24 -0
  99. package/dist/src/interfaces/IDependencyGraph.js +2 -0
  100. package/dist/src/interfaces/IIndexIdentityGuard.d.ts +3 -0
  101. package/dist/src/interfaces/IIndexIdentityGuard.js +2 -0
  102. package/dist/src/interfaces/IIndexedNodeResolver.d.ts +10 -0
  103. package/dist/src/interfaces/IIndexedNodeResolver.js +2 -0
  104. package/dist/src/interfaces/IMcpReadiness.d.ts +12 -0
  105. package/dist/src/interfaces/IMcpReadiness.js +2 -0
  106. package/dist/src/interfaces/IProjectCatalog.d.ts +13 -0
  107. package/dist/src/interfaces/IProjectCatalog.js +2 -0
  108. package/dist/src/interfaces/IProjectRoots.d.ts +3 -0
  109. package/dist/src/interfaces/IProjectRoots.js +2 -0
  110. package/dist/src/interfaces/IRetrievalEvaluator.d.ts +21 -2
  111. package/dist/src/interfaces/IScanReporter.d.ts +13 -0
  112. package/dist/src/interfaces/IScanReporter.js +2 -0
  113. package/dist/src/interfaces/ISymbolLookup.d.ts +49 -0
  114. package/dist/src/interfaces/ISymbolLookup.js +2 -0
  115. package/dist/src/interfaces/IToolPaths.d.ts +62 -0
  116. package/dist/src/interfaces/IToolPaths.js +2 -0
  117. package/dist/src/interfaces/IWorkspaceFiles.d.ts +28 -0
  118. package/dist/src/interfaces/IWorkspaceFiles.js +2 -0
  119. package/dist/src/interfaces/SymbolKind.d.ts +1 -0
  120. package/dist/src/interfaces/SymbolKind.js +2 -0
  121. package/dist/src/interfaces/index.d.ts +12 -1
  122. package/dist/src/project-scope.d.ts +1 -0
  123. package/dist/src/project-scope.js +5 -0
  124. package/dist/src/retrieval-eval.d.ts +2 -1
  125. package/dist/src/retrieval-eval.js +45 -2
  126. package/dist/src/search/CallGraph.d.ts +9 -0
  127. package/dist/src/search/CallGraph.js +84 -0
  128. package/dist/src/search/ChunkSearch.d.ts +23 -0
  129. package/dist/src/search/ChunkSearch.js +115 -0
  130. package/dist/src/search/DependencyGraph.d.ts +19 -0
  131. package/dist/src/search/DependencyGraph.js +180 -0
  132. package/dist/src/search/IndexIdentityGuard.d.ts +11 -0
  133. package/dist/src/search/IndexIdentityGuard.js +37 -0
  134. package/dist/src/search/ProjectCatalog.d.ts +11 -0
  135. package/dist/src/search/ProjectCatalog.js +38 -0
  136. package/dist/src/search/SymbolLookup.d.ts +24 -0
  137. package/dist/src/search/SymbolLookup.js +97 -0
  138. package/dist/src/search/chunks/CandidateFetcher.d.ts +19 -0
  139. package/dist/src/search/chunks/CandidateFetcher.js +40 -0
  140. package/dist/src/search/chunks/IterativeScanGate.d.ts +10 -0
  141. package/dist/src/search/chunks/IterativeScanGate.js +42 -0
  142. package/dist/src/search/chunks/RerankStage.d.ts +15 -0
  143. package/dist/src/search/chunks/RerankStage.js +42 -0
  144. package/dist/src/search/chunks/search-metrics.d.ts +18 -0
  145. package/dist/src/search/chunks/search-metrics.js +32 -0
  146. package/dist/src/search/chunks/search-plan.d.ts +18 -0
  147. package/dist/src/search/chunks/search-plan.js +19 -0
  148. package/dist/src/search/create-search-services.d.ts +26 -0
  149. package/dist/src/search/create-search-services.js +29 -0
  150. package/dist/src/search/index-paths.d.ts +1 -0
  151. package/dist/src/search/index-paths.js +5 -0
  152. package/dist/src/search/symbol-sql.d.ts +13 -0
  153. package/dist/src/search/symbol-sql.js +66 -0
  154. package/dist/src/search/symbols/SymbolGrepFallback.d.ts +19 -0
  155. package/dist/src/search/symbols/SymbolGrepFallback.js +106 -0
  156. package/dist/src/search/symbols/SymbolIndexQuery.d.ts +14 -0
  157. package/dist/src/search/symbols/SymbolIndexQuery.js +52 -0
  158. package/dist/src/search/symbols/SymbolTextSearch.d.ts +13 -0
  159. package/dist/src/search/symbols/SymbolTextSearch.js +84 -0
  160. package/dist/src/search/symbols/TargetColumnGate.d.ts +7 -0
  161. package/dist/src/search/symbols/TargetColumnGate.js +23 -0
  162. package/dist/src/search/symbols/find-symbol-constants.d.ts +4 -0
  163. package/dist/src/search/symbols/find-symbol-constants.js +8 -0
  164. package/dist/src/search/symbols/grep-args.d.ts +3 -0
  165. package/dist/src/search/symbols/grep-args.js +7 -0
  166. package/dist/src/search/symbols/grep-patterns.d.ts +4 -0
  167. package/dist/src/search/symbols/grep-patterns.js +60 -0
  168. package/dist/src/services/AstParserService.d.ts +8 -44
  169. package/dist/src/services/AstParserService.js +19 -938
  170. package/dist/src/services/DatabaseService.d.ts +8 -10
  171. package/dist/src/services/DatabaseService.js +29 -86
  172. package/dist/src/services/IndexerService.d.ts +7 -10
  173. package/dist/src/services/IndexerService.js +36 -255
  174. package/dist/src/services/McpReadiness.d.ts +18 -0
  175. package/dist/src/services/McpReadiness.js +73 -0
  176. package/dist/src/services/McpServer.d.ts +32 -9
  177. package/dist/src/services/McpServer.js +78 -41
  178. package/dist/src/services/WebServerService.d.ts +4 -3
  179. package/dist/src/services/WebServerService.js +16 -8
  180. package/dist/src/setup.d.ts +16 -4
  181. package/dist/src/setup.js +115 -40
  182. package/dist/src/symbol-name.d.ts +1 -0
  183. package/dist/src/symbol-name.js +16 -12
  184. package/dist/src/tools/FindSymbolTool.d.ts +17 -7
  185. package/dist/src/tools/FindSymbolTool.js +54 -35
  186. package/dist/src/tools/GetCallersTool.d.ts +16 -8
  187. package/dist/src/tools/GetCallersTool.js +65 -35
  188. package/dist/src/tools/GetDependenciesTool.d.ts +16 -8
  189. package/dist/src/tools/GetDependenciesTool.js +35 -28
  190. package/dist/src/tools/GetDependentsTool.d.ts +20 -8
  191. package/dist/src/tools/GetDependentsTool.js +47 -33
  192. package/dist/src/tools/ListFilesTool.d.ts +16 -8
  193. package/dist/src/tools/ListFilesTool.js +20 -26
  194. package/dist/src/tools/ListProjectsTool.d.ts +11 -7
  195. package/dist/src/tools/ListProjectsTool.js +13 -11
  196. package/dist/src/tools/McpTool.d.ts +17 -0
  197. package/dist/src/tools/McpTool.js +28 -0
  198. package/dist/src/tools/ReadFileRangeTool.d.ts +16 -8
  199. package/dist/src/tools/ReadFileRangeTool.js +23 -25
  200. package/dist/src/tools/ReadFileTool.d.ts +15 -8
  201. package/dist/src/tools/ReadFileTool.js +19 -24
  202. package/dist/src/tools/SearchCodebaseTool.d.ts +22 -10
  203. package/dist/src/tools/SearchCodebaseTool.js +69 -51
  204. package/dist/src/tools/format-helpers.d.ts +9 -3
  205. package/dist/src/tools/format-helpers.js +59 -14
  206. package/dist/src/tools/tool-args.d.ts +38 -0
  207. package/dist/src/tools/tool-args.js +95 -0
  208. package/dist/src/workspace/GrepRunner.d.ts +15 -0
  209. package/dist/src/workspace/GrepRunner.js +104 -0
  210. package/dist/src/workspace/ProjectRoots.d.ts +22 -0
  211. package/dist/src/workspace/ProjectRoots.js +102 -0
  212. package/dist/src/workspace/ToolPaths.d.ts +31 -0
  213. package/dist/src/workspace/ToolPaths.js +312 -0
  214. package/dist/src/workspace/WorkspaceFiles.d.ts +19 -0
  215. package/dist/src/workspace/WorkspaceFiles.js +285 -0
  216. package/dist/src/workspace/fs-access.d.ts +9 -0
  217. package/dist/src/workspace/fs-access.js +47 -0
  218. package/dist/src/workspace/path-helpers.d.ts +3 -0
  219. package/dist/src/workspace/path-helpers.js +43 -0
  220. package/package.json +4 -3
  221. package/dist/src/interfaces/ISearcher.d.ts +0 -46
  222. package/dist/src/services/SearcherService.d.ts +0 -235
  223. package/dist/src/services/SearcherService.js +0 -1118
  224. /package/dist/src/{interfaces/ISearcher.js → db/drizzle-types.js} +0 -0
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.workspaceEdges = workspaceEdges;
37
+ exports.workspaceCalls = workspaceCalls;
38
+ exports.toPromptEdges = toPromptEdges;
39
+ const path = __importStar(require("path"));
40
+ function workspaceEdges(rawEdges, workspaceRoot) {
41
+ return rawEdges
42
+ .filter(e => e.toFile.startsWith(workspaceRoot))
43
+ .map(e => ({
44
+ ...e,
45
+ fromFile: path.relative(workspaceRoot, e.fromFile),
46
+ toFile: path.relative(workspaceRoot, e.toFile),
47
+ }));
48
+ }
49
+ function workspaceCalls(rawCalls, serviceName, relFilePath, workspaceRoot) {
50
+ return rawCalls
51
+ .filter(c => c.calleeFile.startsWith(workspaceRoot))
52
+ .map(c => ({
53
+ project: serviceName,
54
+ fromFile: relFilePath,
55
+ fromSymbol: c.fromSymbol,
56
+ calleeName: c.calleeName,
57
+ calleeFile: path.relative(workspaceRoot, c.calleeFile),
58
+ calleeSymbol: c.calleeSymbol,
59
+ line: c.line,
60
+ col: c.col,
61
+ }));
62
+ }
63
+ function toPromptEdges(edges) {
64
+ return edges.filter(e => e.depType !== 'import-side-effect');
65
+ }
@@ -0,0 +1,2 @@
1
+ import type { ProjectNotice } from '../interfaces';
2
+ export declare function collectProjectNotices(dir: string, fileCount: number, batchSize: number): ProjectNotice[];
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.collectProjectNotices = collectProjectNotices;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const file_utils_1 = require("../file-utils");
40
+ function collectProjectNotices(dir, fileCount, batchSize) {
41
+ const notices = [];
42
+ const meta = (0, file_utils_1.readRagMeta)(dir);
43
+ if (meta === 'invalid') {
44
+ const msg = `.ragmeta.json found but invalid JSON`;
45
+ notices.push({ mark: '⚠', message: msg, warning: true });
46
+ }
47
+ else if (meta !== 'missing') {
48
+ const parts = [meta.description, meta.stack && `[${meta.stack}]`].filter(Boolean).join(' ');
49
+ notices.push({ mark: '✓', message: `.ragmeta.json: ${parts || '(no fields)'}`, warning: false });
50
+ }
51
+ else {
52
+ const msg = `No .ragmeta.json — add {"description":"...","stack":"...","notes":"..."} so list_projects can describe this project`;
53
+ notices.push({ mark: '⚠', message: msg, warning: true });
54
+ }
55
+ if (!fs.existsSync(path.join(dir, '.ragignore'))) {
56
+ const msg = `No .ragignore — create one to exclude generated/codegen files (e.g. src/gql/graphql.ts, **/__snapshots__/**)`;
57
+ notices.push({ mark: '⚠', message: msg, warning: true });
58
+ }
59
+ if (fileCount > batchSize) {
60
+ notices.push({ mark: '⚠', message: `Large project (${fileCount} files) — AST analysis uses batches of ${batchSize}; cross-batch dependency edges may be incomplete`, warning: false });
61
+ }
62
+ return notices;
63
+ }
@@ -7,7 +7,8 @@ export interface DepEdge {
7
7
  toSymbol: string | null;
8
8
  depType: string;
9
9
  }
10
- export type SymbolKind = 'function' | 'class' | 'interface' | 'type' | 'variable' | 'method' | 'get_accessor' | 'set_accessor' | 'constructor' | 'function_property' | 'method_signature' | 'graphql_query' | 'graphql_mutation' | 'graphql_subscription' | 'graphql_field' | 'graphql_type';
10
+ import type { SymbolKind } from './SymbolKind';
11
+ export type { SymbolKind };
11
12
  export interface SymbolEntry {
12
13
  project: string;
13
14
  filePath: string;
@@ -0,0 +1,28 @@
1
+ export interface CallerRow {
2
+ fromFile: string;
3
+ fromSymbol: string | null;
4
+ calleeName: string;
5
+ calleeFile: string;
6
+ line: number | null;
7
+ }
8
+ export type NoCallersCause = {
9
+ kind: 'no-call-graph';
10
+ } | {
11
+ kind: 'unknown-symbol';
12
+ suggestions: string[];
13
+ truncated: boolean;
14
+ } | {
15
+ kind: 'no-recorded-calls';
16
+ definitions: {
17
+ qualified: string;
18
+ filePath: string;
19
+ line: number | null;
20
+ }[];
21
+ truncated: boolean;
22
+ } | {
23
+ kind: 'lookup-failed';
24
+ };
25
+ export interface ICallGraph {
26
+ getCallers(symbol: string, project: string, calleeFile?: string | null): Promise<CallerRow[]>;
27
+ explainNoCallers(symbol: string, project: string): Promise<NoCallersCause>;
28
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,42 @@
1
+ import type { ResolvedThreshold } from '../constants';
2
+ export interface ChunkRow {
3
+ serviceName: string;
4
+ filePath: string;
5
+ startLine: number;
6
+ content: string;
7
+ ownerPath?: string | null;
8
+ }
9
+ export interface SearchResult extends ChunkRow {
10
+ score: number;
11
+ }
12
+ export interface NeighborResult {
13
+ result: SearchResult;
14
+ prevChunk: ChunkRow | null;
15
+ nextChunk: ChunkRow | null;
16
+ }
17
+ export type StageName = 'vector' | 'reranked';
18
+ export interface StagedSearchResult {
19
+ pool: SearchResult[];
20
+ stages: {
21
+ vector: SearchResult[];
22
+ reranked?: SearchResult[];
23
+ };
24
+ rerankFailed: boolean;
25
+ fetchLimit: number;
26
+ indexParams: {
27
+ efSearch: number | null;
28
+ iterativeScan: string;
29
+ };
30
+ threshold: ResolvedThreshold;
31
+ }
32
+ export type NoResultsCause = 'empty-scope' | 'no-candidates' | 'lookup-failed';
33
+ export interface IChunkSearch {
34
+ prepareQuery(raw: string): Promise<{
35
+ query: string;
36
+ translated: boolean;
37
+ }>;
38
+ searchChunks(query: string, limit: number, project: string | null, threshold?: number, rerankOverride?: boolean, perFile?: number): Promise<SearchResult[]>;
39
+ searchChunksWithStages(query: string, limit: number, project: string | null, threshold?: number, rerankOverride?: boolean, perFile?: number): Promise<StagedSearchResult>;
40
+ explainNoResults(project: string | null): Promise<NoResultsCause>;
41
+ fetchNeighbors(results: SearchResult[]): Promise<NeighborResult[]>;
42
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +1,20 @@
1
- import type { DrizzleDb, DrizzleTx } from '../services/DatabaseService';
1
+ import type { DrizzleDb, DrizzleTx } from '../db';
2
2
  export interface IndexMeta {
3
3
  provider: string;
4
4
  model: string;
5
5
  dimensions: number;
6
6
  }
7
+ export interface InitDbOptions {
8
+ connectionTimeoutMs?: number;
9
+ }
7
10
  export interface IDatabase {
8
11
  readonly orm: DrizzleDb;
9
12
  query<T = any>(sql: string, params?: any[]): Promise<T>;
10
13
  queryWithLocalSettings<T = any>(settings: Record<string, string | number>, sql: string, params?: any[]): Promise<T>;
11
14
  pgvectorVersion(): Promise<string | null>;
12
15
  transaction<T>(fn: (tx: DrizzleTx) => Promise<T>): Promise<T>;
13
- initDb(): Promise<void>;
16
+ initDb(options?: InitDbOptions): Promise<void>;
17
+ probe(): Promise<void>;
14
18
  initDbWithSchema(): Promise<void>;
15
19
  destroy(): Promise<void>;
16
20
  readIndexMeta(): Promise<IndexMeta | null>;
@@ -0,0 +1,24 @@
1
+ import type { SearchResult } from './IChunkSearch';
2
+ export interface GraphContext {
3
+ imports: string[];
4
+ usedBy: string[];
5
+ }
6
+ export interface DependencyRow {
7
+ fromFile: string;
8
+ fromSymbol: string | null;
9
+ toFile: string;
10
+ toSymbol: string | null;
11
+ depType: string;
12
+ depth?: number;
13
+ via?: string;
14
+ id?: string;
15
+ }
16
+ export interface IDependencyGraph {
17
+ getProjectEdges(): Promise<{
18
+ from: string;
19
+ to: string;
20
+ }[]>;
21
+ fetchGraphContext(results: SearchResult[]): Promise<Map<string, GraphContext>>;
22
+ getDependencies(filePath: string, symbol?: string | null, transitive?: boolean): Promise<DependencyRow[]>;
23
+ getDependents(filePath: string, symbol?: string | null, transitive?: boolean): Promise<DependencyRow[]>;
24
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export interface IIndexIdentityGuard {
2
+ assertIndexMatches(): Promise<void>;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import type { Node } from 'ts-morph';
2
+ export interface IndexedNodeDescription {
3
+ name: string;
4
+ container: string[];
5
+ }
6
+ export interface IIndexedNodeResolver {
7
+ describeIndexedNode(node: Node): IndexedNodeDescription | null;
8
+ qualifiedName(described: IndexedNodeDescription): string;
9
+ findFromSymbol(node: Node): string | null;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ export interface ReadinessFailure {
2
+ ok: false;
3
+ err: unknown;
4
+ }
5
+ export type ReadinessCheck = {
6
+ ok: true;
7
+ } | ReadinessFailure;
8
+ export interface IMcpReadiness {
9
+ start(): Promise<ReadinessCheck>;
10
+ ensureReady(): Promise<ReadinessCheck>;
11
+ readonly ready: boolean;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import type { ProjectMeta } from '../file-utils';
2
+ export interface ProjectRow extends ProjectMeta {
3
+ serviceName: string;
4
+ chunks: number;
5
+ packageName?: string | null;
6
+ type?: 'app' | 'lib';
7
+ path?: string;
8
+ relPath?: string;
9
+ rootError?: string | null;
10
+ }
11
+ export interface IProjectCatalog {
12
+ listProjects(): Promise<ProjectRow[]>;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export interface IProjectRoots {
2
+ fallbackRoot(relPath: string): string | null;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
- import type { StageName } from './ISearcher';
1
+ import type { StageName } from './IChunkSearch';
2
+ import type { ResolvedThreshold, ThresholdSource } from '../constants';
2
3
  export type { StageName };
3
4
  export type EvalCategory = 'identifier' | 'behaviour' | 'concept';
4
5
  export interface ExpectedAnswer {
@@ -38,6 +39,7 @@ export interface StagedHits {
38
39
  efSearch: number | null;
39
40
  iterativeScan: string;
40
41
  };
42
+ threshold: ResolvedThreshold;
41
43
  }
42
44
  export type SearchFn = (query: string, limit: number, project: string | null, threshold?: number) => Promise<StagedHits>;
43
45
  export interface IndexInspector {
@@ -128,6 +130,7 @@ export interface ObservedSearchParams {
128
130
  fetchLimit: number[];
129
131
  efSearch: (number | null)[];
130
132
  iterativeScan: string[];
133
+ thresholds: ResolvedThreshold[];
131
134
  }
132
135
  export interface EvalOutcome {
133
136
  run: EvalRunResult;
@@ -144,8 +147,12 @@ export interface CaseProgress {
144
147
  export interface IRetrievalEvaluator {
145
148
  evaluate(suite: EvalSuite, search: SearchFn, inspect: IndexInspector, onCase?: (p: CaseProgress) => void): Promise<EvalOutcome>;
146
149
  }
150
+ export interface ThresholdCondition {
151
+ value: number;
152
+ source: ThresholdSource | 'not recorded';
153
+ }
147
154
  export interface SearchConditions {
148
- similarityThreshold: number;
155
+ thresholds: ThresholdCondition[];
149
156
  overfetch: number;
150
157
  candidateFloor: number;
151
158
  fetchLimit: number[];
@@ -166,9 +173,21 @@ export interface ResultMetadata {
166
173
  gitCommit: string;
167
174
  timestamp: string;
168
175
  conditions: SearchConditions | null;
176
+ vectorIndex: VectorIndexRecord | null;
169
177
  corpora: CorpusRecord[];
170
178
  liveCases: number;
171
179
  }
180
+ export interface VectorIndexRecord {
181
+ pgvector: string | null;
182
+ indexes: {
183
+ name: string;
184
+ method: string;
185
+ opclass: string;
186
+ params: Record<string, string>;
187
+ }[];
188
+ maxScanTuples: number | null;
189
+ scanMemMultiplier: number | null;
190
+ }
172
191
  export interface CorpusRecord {
173
192
  root: string;
174
193
  commit: string;
@@ -0,0 +1,13 @@
1
+ export interface ProjectNotice {
2
+ mark: '✓' | '⚠';
3
+ message: string;
4
+ warning: boolean;
5
+ }
6
+ export interface IScanReporter {
7
+ staleRemoved(relFile: string): void;
8
+ begin(serviceName: string, fileCount: number, notices: ProjectNotice[]): void;
9
+ file(relToDir: string): void;
10
+ advance(): void;
11
+ interrupted(serviceName: string): void;
12
+ end(): void;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,49 @@
1
+ export type GrepSymbolResult = {
2
+ ok: true;
3
+ matches: GrepMatch[];
4
+ truncated: boolean;
5
+ partial: boolean;
6
+ } | {
7
+ ok: false;
8
+ };
9
+ export interface GrepMatch {
10
+ filePath: string;
11
+ line: number;
12
+ }
13
+ export type SymbolKind = 'function' | 'class' | 'type' | 'interface' | 'variable' | 'method' | 'get_accessor' | 'set_accessor' | 'constructor' | 'function_property' | 'method_signature' | 'graphql_query' | 'graphql_mutation' | 'graphql_subscription' | 'graphql_field' | 'graphql_type' | 'all';
14
+ export interface SymbolHit {
15
+ filePath: string;
16
+ line: number;
17
+ column: number;
18
+ kind: Exclude<SymbolKind, 'all'>;
19
+ signature: string;
20
+ qualified: string;
21
+ isStatic: boolean;
22
+ source: 'index' | 'grep';
23
+ target: string | null;
24
+ }
25
+ export type FindSymbolGrep = {
26
+ outcome: 'complete';
27
+ } | {
28
+ outcome: 'partial';
29
+ } | {
30
+ outcome: 'failed';
31
+ cause: string;
32
+ } | {
33
+ outcome: 'no-project-directory';
34
+ } | {
35
+ outcome: 'other-container';
36
+ };
37
+ export interface FindSymbolResult {
38
+ hits: SymbolHit[];
39
+ truncated: boolean;
40
+ grep: FindSymbolGrep;
41
+ similar: {
42
+ names: string[];
43
+ truncated: boolean;
44
+ };
45
+ }
46
+ export interface ISymbolLookup {
47
+ grepSymbol(symbol: string, rootDir: string, excludeFile: string): Promise<GrepSymbolResult>;
48
+ findSymbol(name: string, project: string | null, kind: SymbolKind): Promise<FindSymbolResult>;
49
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,62 @@
1
+ import type { IndexingExclusion } from '../file-utils';
2
+ export type PathRefusal = {
3
+ ok: false;
4
+ reason: 'invalid';
5
+ missing: boolean;
6
+ } | {
7
+ ok: false;
8
+ reason: 'absolute';
9
+ relative: string;
10
+ } | {
11
+ ok: false;
12
+ reason: 'outside_workspace';
13
+ } | {
14
+ ok: false;
15
+ reason: 'unreadable';
16
+ code: string;
17
+ };
18
+ export type ResolvedToolPath = {
19
+ ok: true;
20
+ relPath: string;
21
+ absPath: string;
22
+ } | PathRefusal;
23
+ export type NotIndexedExplanation = IndexingExclusion | {
24
+ kind: 'no_project';
25
+ } | {
26
+ kind: 'project_not_indexed';
27
+ project: string;
28
+ } | {
29
+ kind: 'unknown';
30
+ };
31
+ export type PathFailure = {
32
+ ok: false;
33
+ reason: 'outside_workspace';
34
+ } | {
35
+ ok: false;
36
+ reason: 'unreadable';
37
+ code: string;
38
+ } | {
39
+ ok: false;
40
+ reason: 'not_found';
41
+ candidates: string[];
42
+ } | {
43
+ ok: false;
44
+ reason: 'deleted';
45
+ } | {
46
+ ok: false;
47
+ reason: 'not_indexed';
48
+ explanation: NotIndexedExplanation;
49
+ } | {
50
+ ok: false;
51
+ reason: 'not_a_file';
52
+ } | {
53
+ ok: false;
54
+ reason: 'not_a_directory';
55
+ } | {
56
+ ok: false;
57
+ reason: 'binary';
58
+ };
59
+ export interface IToolPaths {
60
+ resolveToolPath(input: string | null | undefined): Promise<ResolvedToolPath>;
61
+ checkGraphPath(relPath: string): Promise<PathFailure | null>;
62
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,28 @@
1
+ import type { PathFailure } from './IToolPaths';
2
+ export type FileRangeResult = {
3
+ ok: true;
4
+ filePath: string;
5
+ startLine: number;
6
+ endLine: number;
7
+ lines: string[];
8
+ hasMore: boolean;
9
+ } | PathFailure | {
10
+ ok: false;
11
+ reason: 'past_end';
12
+ lineCount: number;
13
+ startLine: number;
14
+ } | {
15
+ ok: false;
16
+ reason: 'bad_range';
17
+ startLine: number;
18
+ endLine: number;
19
+ };
20
+ export type ListFilesResult = {
21
+ ok: true;
22
+ tree: string;
23
+ } | PathFailure;
24
+ export interface IWorkspaceFiles {
25
+ listFiles(relPath: string, depth: number, pattern: string | null): Promise<ListFilesResult>;
26
+ readFile(relPath: string, maxLines: number): Promise<FileRangeResult>;
27
+ readFileRange(relPath: string, startLine: number, endLine: number): Promise<FileRangeResult>;
28
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type SymbolKind = 'function' | 'class' | 'interface' | 'type' | 'variable' | 'method' | 'get_accessor' | 'set_accessor' | 'constructor' | 'function_property' | 'method_signature' | 'graphql_query' | 'graphql_mutation' | 'graphql_subscription' | 'graphql_field' | 'graphql_type';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,7 +3,18 @@ export type { IAstParser, DepEdge, SymbolEntry, CallEdge, FileAnalysis } from '.
3
3
  export type { IChunker, ChunkPiece, ChunkOpts } from './IChunker';
4
4
  export type { ILogger } from './ILogger';
5
5
  export type { IDatabase } from './IDatabase';
6
- export type { ISearcher } from './ISearcher';
6
+ export type { IToolPaths } from './IToolPaths';
7
+ export type { IProjectRoots } from './IProjectRoots';
8
+ export type { IWorkspaceFiles } from './IWorkspaceFiles';
9
+ export type { IChunkSearch } from './IChunkSearch';
10
+ export type { IDependencyGraph } from './IDependencyGraph';
11
+ export type { ICallGraph } from './ICallGraph';
12
+ export type { ISymbolLookup } from './ISymbolLookup';
13
+ export type { IProjectCatalog } from './IProjectCatalog';
14
+ export type { IIndexIdentityGuard } from './IIndexIdentityGuard';
15
+ export type { IIndexedNodeResolver, IndexedNodeDescription } from './IIndexedNodeResolver';
7
16
  export type { IProjectDiscovery, DiscoveredProject } from './IProjectDiscovery';
17
+ export type { IMcpReadiness, ReadinessCheck, ReadinessFailure } from './IMcpReadiness';
8
18
  export type { IMcpToolHandler, ToolDefinition, ToolResponse } from './IMcpToolHandler';
19
+ export type { IScanReporter, ProjectNotice } from './IScanReporter';
9
20
  export type { EvalCategory, ExpectedAnswer, EvalCase, EvalSuite, SearchHit, SearchFn, IndexInspector, Metrics, CaseResult, InvalidCase, PartialWarning, EvalRunResult, IRetrievalEvaluator, ResultMetadata, EvalResultFile, MetricDelta, MetricsDelta, CompareResult, } from './IRetrievalEvaluator';
@@ -4,4 +4,5 @@ export interface ResolveProjectNamesResult {
4
4
  notFound: string[];
5
5
  }
6
6
  export declare function resolveProjectNames(names: string[], units: DiscoveredProject[]): ResolveProjectNamesResult;
7
+ export declare function matchedProjectDir(name: string, units: DiscoveredProject[]): string | undefined;
7
8
  export declare function listAvailableNames(units: DiscoveredProject[]): string[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveProjectNames = resolveProjectNames;
4
+ exports.matchedProjectDir = matchedProjectDir;
4
5
  exports.listAvailableNames = listAvailableNames;
5
6
  const MonorepoAwareDiscoveryService_1 = require("./services/MonorepoAwareDiscoveryService");
6
7
  function resolveProjectNames(names, units) {
@@ -24,6 +25,10 @@ function resolveProjectNames(names, units) {
24
25
  }
25
26
  return { targets, notFound };
26
27
  }
28
+ function matchedProjectDir(name, units) {
29
+ const unit = units.find(u => u.name === name);
30
+ return unit ? unit.path : (0, MonorepoAwareDiscoveryService_1.toLeafProjects)(units).find(l => l.name === name)?.path;
31
+ }
27
32
  function listAvailableNames(units) {
28
33
  const names = [];
29
34
  for (const unit of units) {
@@ -1,4 +1,4 @@
1
- import type { EvalSuite, EvalCase, EvalCategory, CorpusRef, SearchFn, IndexInspector, IRetrievalEvaluator, EvalOutcome, StageName, PairedChange, CaseProgress, EvalResultFile, CompareResult } from './interfaces/IRetrievalEvaluator';
1
+ import type { EvalSuite, EvalCase, EvalCategory, CorpusRef, SearchFn, IndexInspector, IRetrievalEvaluator, EvalOutcome, StageName, PairedChange, CaseProgress, EvalResultFile, ThresholdCondition, CompareResult } from './interfaces/IRetrievalEvaluator';
2
2
  export declare const STAGE_ORDER: readonly StageName[];
3
3
  export declare class EvalSuiteError extends Error {
4
4
  readonly caseId: string | null;
@@ -18,6 +18,7 @@ export interface RankedCase {
18
18
  }
19
19
  export declare function pairedChange(from: RankedCase[], to: RankedCase[]): PairedChange;
20
20
  export declare const LIVE_GROUP = "live";
21
+ export declare function formatThresholdConditions(pairs: ThresholdCondition[]): string;
21
22
  export declare class RetrievalEvaluator implements IRetrievalEvaluator {
22
23
  evaluate(suite: EvalSuite, search: SearchFn, inspect: IndexInspector, onCase?: (p: CaseProgress) => void): Promise<EvalOutcome>;
23
24
  }