ragcode-context-engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +366 -0
  3. package/README.zh-CN.md +363 -0
  4. package/dist/src/cli/configure/app.d.ts +6 -0
  5. package/dist/src/cli/configure/app.js +81 -0
  6. package/dist/src/cli/configure/run.d.ts +5 -0
  7. package/dist/src/cli/configure/run.js +85 -0
  8. package/dist/src/cli/configure/state.d.ts +42 -0
  9. package/dist/src/cli/configure/state.js +174 -0
  10. package/dist/src/cli/configure.d.ts +31 -0
  11. package/dist/src/cli/configure.js +101 -0
  12. package/dist/src/cli/index.d.ts +2 -0
  13. package/dist/src/cli/index.js +503 -0
  14. package/dist/src/cli/tui/index-progress.d.ts +12 -0
  15. package/dist/src/cli/tui/index-progress.js +49 -0
  16. package/dist/src/cli/tui/watch-status.d.ts +10 -0
  17. package/dist/src/cli/tui/watch-status.js +27 -0
  18. package/dist/src/cli/update.d.ts +18 -0
  19. package/dist/src/cli/update.js +111 -0
  20. package/dist/src/config/dotenv.d.ts +1 -0
  21. package/dist/src/config/dotenv.js +14 -0
  22. package/dist/src/config/graph-runtime.d.ts +13 -0
  23. package/dist/src/config/graph-runtime.js +29 -0
  24. package/dist/src/config/runtime-config.d.ts +87 -0
  25. package/dist/src/config/runtime-config.js +215 -0
  26. package/dist/src/config/semantic-runtime.d.ts +24 -0
  27. package/dist/src/config/semantic-runtime.js +89 -0
  28. package/dist/src/context/context-builder.d.ts +20 -0
  29. package/dist/src/context/context-builder.js +277 -0
  30. package/dist/src/context/expansion-policy.d.ts +6 -0
  31. package/dist/src/context/expansion-policy.js +49 -0
  32. package/dist/src/context/skeletonizer.d.ts +2 -0
  33. package/dist/src/context/skeletonizer.js +79 -0
  34. package/dist/src/context/snippet-renderer.d.ts +2 -0
  35. package/dist/src/context/snippet-renderer.js +67 -0
  36. package/dist/src/core/contracts.d.ts +74 -0
  37. package/dist/src/core/contracts.js +1 -0
  38. package/dist/src/core/engine.d.ts +64 -0
  39. package/dist/src/core/engine.js +442 -0
  40. package/dist/src/core/types.d.ts +490 -0
  41. package/dist/src/core/types.js +1 -0
  42. package/dist/src/diagnostics/doctor.d.ts +66 -0
  43. package/dist/src/diagnostics/doctor.js +193 -0
  44. package/dist/src/diagnostics/embedding-test.d.ts +24 -0
  45. package/dist/src/diagnostics/embedding-test.js +83 -0
  46. package/dist/src/graph/diff-files.d.ts +1 -0
  47. package/dist/src/graph/diff-files.js +14 -0
  48. package/dist/src/graph/impact-report.d.ts +10 -0
  49. package/dist/src/graph/impact-report.js +173 -0
  50. package/dist/src/graph/in-memory-graph-store.d.ts +36 -0
  51. package/dist/src/graph/in-memory-graph-store.js +395 -0
  52. package/dist/src/graph/owner-ranking.d.ts +2 -0
  53. package/dist/src/graph/owner-ranking.js +41 -0
  54. package/dist/src/graph/sqlite-graph-store.d.ts +51 -0
  55. package/dist/src/graph/sqlite-graph-store.js +724 -0
  56. package/dist/src/graph/sqlite-statements.d.ts +36 -0
  57. package/dist/src/graph/sqlite-statements.js +105 -0
  58. package/dist/src/graph/target-matcher.d.ts +13 -0
  59. package/dist/src/graph/target-matcher.js +64 -0
  60. package/dist/src/index.d.ts +32 -0
  61. package/dist/src/index.js +32 -0
  62. package/dist/src/indexing/analyzers/fallback-analyzer.d.ts +6 -0
  63. package/dist/src/indexing/analyzers/fallback-analyzer.js +45 -0
  64. package/dist/src/indexing/analyzers/go-treesitter-analyzer.d.ts +2 -0
  65. package/dist/src/indexing/analyzers/go-treesitter-analyzer.js +87 -0
  66. package/dist/src/indexing/analyzers/java-treesitter-analyzer.d.ts +2 -0
  67. package/dist/src/indexing/analyzers/java-treesitter-analyzer.js +88 -0
  68. package/dist/src/indexing/analyzers/python-treesitter-analyzer.d.ts +2 -0
  69. package/dist/src/indexing/analyzers/python-treesitter-analyzer.js +96 -0
  70. package/dist/src/indexing/analyzers/registry.d.ts +5 -0
  71. package/dist/src/indexing/analyzers/registry.js +23 -0
  72. package/dist/src/indexing/analyzers/rust-treesitter-analyzer.d.ts +2 -0
  73. package/dist/src/indexing/analyzers/rust-treesitter-analyzer.js +96 -0
  74. package/dist/src/indexing/analyzers/tree-sitter-base.d.ts +30 -0
  75. package/dist/src/indexing/analyzers/tree-sitter-base.js +163 -0
  76. package/dist/src/indexing/analyzers/types.d.ts +17 -0
  77. package/dist/src/indexing/analyzers/types.js +1 -0
  78. package/dist/src/indexing/analyzers/typescript-analyzer.d.ts +5 -0
  79. package/dist/src/indexing/analyzers/typescript-analyzer.js +199 -0
  80. package/dist/src/indexing/ast-analyzer.d.ts +11 -0
  81. package/dist/src/indexing/ast-analyzer.js +11 -0
  82. package/dist/src/indexing/chunker.d.ts +11 -0
  83. package/dist/src/indexing/chunker.js +157 -0
  84. package/dist/src/indexing/ignore-policy.d.ts +6 -0
  85. package/dist/src/indexing/ignore-policy.js +40 -0
  86. package/dist/src/indexing/indexer.d.ts +13 -0
  87. package/dist/src/indexing/indexer.js +189 -0
  88. package/dist/src/indexing/language.d.ts +3 -0
  89. package/dist/src/indexing/language.js +24 -0
  90. package/dist/src/indexing/scanner.d.ts +13 -0
  91. package/dist/src/indexing/scanner.js +87 -0
  92. package/dist/src/lsp/definition-resolver.d.ts +6 -0
  93. package/dist/src/lsp/definition-resolver.js +60 -0
  94. package/dist/src/lsp/typescript-language-service.d.ts +21 -0
  95. package/dist/src/lsp/typescript-language-service.js +82 -0
  96. package/dist/src/mcp/server.d.ts +11 -0
  97. package/dist/src/mcp/server.js +64 -0
  98. package/dist/src/mcp/tools.d.ts +266 -0
  99. package/dist/src/mcp/tools.js +309 -0
  100. package/dist/src/project/project-identity.d.ts +2 -0
  101. package/dist/src/project/project-identity.js +24 -0
  102. package/dist/src/project/project-registry.d.ts +12 -0
  103. package/dist/src/project/project-registry.js +49 -0
  104. package/dist/src/project/workspace-resolver.d.ts +20 -0
  105. package/dist/src/project/workspace-resolver.js +62 -0
  106. package/dist/src/retrieval/graph-reranker.d.ts +11 -0
  107. package/dist/src/retrieval/graph-reranker.js +0 -0
  108. package/dist/src/retrieval/hybrid-retriever.d.ts +31 -0
  109. package/dist/src/retrieval/hybrid-retriever.js +111 -0
  110. package/dist/src/retrieval/path-classification.d.ts +6 -0
  111. package/dist/src/retrieval/path-classification.js +22 -0
  112. package/dist/src/retrieval/query-matching.d.ts +22 -0
  113. package/dist/src/retrieval/query-matching.js +166 -0
  114. package/dist/src/retrieval/query-planner.d.ts +5 -0
  115. package/dist/src/retrieval/query-planner.js +77 -0
  116. package/dist/src/retrieval/ranking-signals.d.ts +19 -0
  117. package/dist/src/retrieval/ranking-signals.js +97 -0
  118. package/dist/src/retrieval/topology-distance.d.ts +21 -0
  119. package/dist/src/retrieval/topology-distance.js +116 -0
  120. package/dist/src/reuse/reuse-detector.d.ts +12 -0
  121. package/dist/src/reuse/reuse-detector.js +564 -0
  122. package/dist/src/semantic/deterministic-embedding.d.ts +7 -0
  123. package/dist/src/semantic/deterministic-embedding.js +31 -0
  124. package/dist/src/semantic/in-memory-semantic-store.d.ts +11 -0
  125. package/dist/src/semantic/in-memory-semantic-store.js +65 -0
  126. package/dist/src/semantic/lance-semantic-store.d.ts +131 -0
  127. package/dist/src/semantic/lance-semantic-store.js +623 -0
  128. package/dist/src/semantic/openai-compatible-embedding.d.ts +19 -0
  129. package/dist/src/semantic/openai-compatible-embedding.js +75 -0
  130. package/dist/src/service/service-identity.d.ts +13 -0
  131. package/dist/src/service/service-identity.js +48 -0
  132. package/dist/src/service/service-manager.d.ts +29 -0
  133. package/dist/src/service/service-manager.js +231 -0
  134. package/dist/src/service/service-templates.d.ts +22 -0
  135. package/dist/src/service/service-templates.js +101 -0
  136. package/dist/src/subgraph/impact-explainer.d.ts +2 -0
  137. package/dist/src/subgraph/impact-explainer.js +54 -0
  138. package/dist/src/subgraph/node-expander.d.ts +13 -0
  139. package/dist/src/subgraph/node-expander.js +139 -0
  140. package/dist/src/subgraph/output-preset.d.ts +3 -0
  141. package/dist/src/subgraph/output-preset.js +102 -0
  142. package/dist/src/subgraph/subgraph-builder.d.ts +17 -0
  143. package/dist/src/subgraph/subgraph-builder.js +688 -0
  144. package/dist/src/topology/export-index.d.ts +7 -0
  145. package/dist/src/topology/export-index.js +14 -0
  146. package/dist/src/topology/framework-topology.d.ts +3 -0
  147. package/dist/src/topology/framework-topology.js +460 -0
  148. package/dist/src/topology/import-resolver.d.ts +2 -0
  149. package/dist/src/topology/import-resolver.js +29 -0
  150. package/dist/src/topology/orm-topology.d.ts +3 -0
  151. package/dist/src/topology/orm-topology.js +200 -0
  152. package/dist/src/topology/runtime-topology.d.ts +3 -0
  153. package/dist/src/topology/runtime-topology.js +204 -0
  154. package/dist/src/topology/symbol-resolver.d.ts +6 -0
  155. package/dist/src/topology/symbol-resolver.js +74 -0
  156. package/dist/src/topology/test-topology.d.ts +2 -0
  157. package/dist/src/topology/test-topology.js +82 -0
  158. package/dist/src/utils/hash.d.ts +2 -0
  159. package/dist/src/utils/hash.js +7 -0
  160. package/dist/src/utils/path.d.ts +2 -0
  161. package/dist/src/utils/path.js +7 -0
  162. package/dist/src/watch/event-journal.d.ts +17 -0
  163. package/dist/src/watch/event-journal.js +81 -0
  164. package/dist/src/watch/file-event-coalescer.d.ts +9 -0
  165. package/dist/src/watch/file-event-coalescer.js +39 -0
  166. package/dist/src/watch/index-scheduler.d.ts +52 -0
  167. package/dist/src/watch/index-scheduler.js +190 -0
  168. package/dist/src/watch/watch-daemon.d.ts +73 -0
  169. package/dist/src/watch/watch-daemon.js +368 -0
  170. package/dist/src/watch/watcher-liveness.d.ts +47 -0
  171. package/dist/src/watch/watcher-liveness.js +168 -0
  172. package/dist/src/web/server.d.ts +1 -0
  173. package/dist/src/web/server.js +375 -0
  174. package/package.json +94 -0
@@ -0,0 +1,82 @@
1
+ import path from "node:path";
2
+ import ts from "typescript";
3
+ import { normalizeRepoPath } from "../utils/path.js";
4
+ export class TypeScriptLanguageService {
5
+ repoRoot;
6
+ service;
7
+ absoluteByRepoPath = new Map();
8
+ contentByAbsolutePath = new Map();
9
+ constructor(repoRoot, sources) {
10
+ this.repoRoot = repoRoot;
11
+ for (const source of sources) {
12
+ const absolutePath = normalizeAbsolutePath(source.absolutePath);
13
+ this.absoluteByRepoPath.set(source.filePath, absolutePath);
14
+ this.contentByAbsolutePath.set(absolutePath, source.content);
15
+ }
16
+ this.service = ts.createLanguageService(this.createHost());
17
+ }
18
+ getDefinitionAt(repoFilePath, position) {
19
+ const absolutePath = this.absoluteByRepoPath.get(repoFilePath);
20
+ if (!absolutePath)
21
+ return [];
22
+ const definitions = this.service.getDefinitionAtPosition(absolutePath, position) ?? [];
23
+ return definitions
24
+ .map((definition) => this.toDefinitionLocation(definition))
25
+ .filter((definition) => Boolean(definition));
26
+ }
27
+ createHost() {
28
+ return {
29
+ getCompilationSettings: () => ({
30
+ allowJs: true,
31
+ checkJs: false,
32
+ esModuleInterop: true,
33
+ jsx: ts.JsxEmit.Preserve,
34
+ module: ts.ModuleKind.NodeNext,
35
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
36
+ noEmit: true,
37
+ skipLibCheck: true,
38
+ target: ts.ScriptTarget.ES2022
39
+ }),
40
+ getCurrentDirectory: () => this.repoRoot,
41
+ getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
42
+ getScriptFileNames: () => [...this.contentByAbsolutePath.keys()],
43
+ getScriptVersion: () => "1",
44
+ getScriptSnapshot: (fileName) => {
45
+ const normalized = normalizeAbsolutePath(fileName);
46
+ const content = this.contentByAbsolutePath.get(normalized) ?? ts.sys.readFile(normalized);
47
+ return content === undefined ? undefined : ts.ScriptSnapshot.fromString(content);
48
+ },
49
+ fileExists: (fileName) => this.contentByAbsolutePath.has(normalizeAbsolutePath(fileName)) || ts.sys.fileExists(fileName),
50
+ readFile: (fileName) => this.contentByAbsolutePath.get(normalizeAbsolutePath(fileName)) ?? ts.sys.readFile(fileName),
51
+ readDirectory: ts.sys.readDirectory,
52
+ directoryExists: ts.sys.directoryExists,
53
+ getDirectories: ts.sys.getDirectories
54
+ };
55
+ }
56
+ toDefinitionLocation(definition) {
57
+ const absolutePath = normalizeAbsolutePath(definition.fileName);
58
+ const content = this.contentByAbsolutePath.get(absolutePath);
59
+ if (!content)
60
+ return undefined;
61
+ const start = lineAt(content, definition.textSpan.start);
62
+ const end = lineAt(content, definition.textSpan.start + definition.textSpan.length);
63
+ return {
64
+ filePath: normalizeRepoPath(this.repoRoot, absolutePath),
65
+ startLine: start,
66
+ endLine: end,
67
+ name: definition.name
68
+ };
69
+ }
70
+ }
71
+ function normalizeAbsolutePath(filePath) {
72
+ return path.resolve(filePath);
73
+ }
74
+ function lineAt(content, position) {
75
+ const safePosition = Math.max(0, Math.min(position, content.length));
76
+ let line = 1;
77
+ for (let index = 0; index < safePosition; index += 1) {
78
+ if (content.charCodeAt(index) === 10)
79
+ line += 1;
80
+ }
81
+ return line;
82
+ }
@@ -0,0 +1,11 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { ContextEngine } from "../core/contracts.js";
3
+ import { type RagCodeEngineOptions } from "../core/engine.js";
4
+ export interface McpServerOptions {
5
+ name?: string;
6
+ version?: string;
7
+ }
8
+ export interface StdioMcpServerOptions extends McpServerOptions, RagCodeEngineOptions {
9
+ }
10
+ export declare function createMcpServer(engine: ContextEngine, options?: McpServerOptions): McpServer;
11
+ export declare function startStdioMcpServer(options?: StdioMcpServerOptions): Promise<void>;
@@ -0,0 +1,64 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { createRuntimeComponentsForRepo } from "../config/runtime-config.js";
4
+ import { RagCodeEngine } from "../core/engine.js";
5
+ import { callTool, listRuntimeToolDefinitions } from "./tools.js";
6
+ export function createMcpServer(engine, options = {}) {
7
+ const server = new McpServer({
8
+ name: options.name ?? "ragcode-context-engine",
9
+ version: options.version ?? "0.1.0"
10
+ });
11
+ for (const tool of listRuntimeToolDefinitions()) {
12
+ server.registerTool(tool.name, {
13
+ title: tool.name,
14
+ description: tool.description,
15
+ inputSchema: tool.inputSchema
16
+ }, async (args) => ({
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: JSON.stringify(await callTool(engine, tool.name, args), null, 2)
21
+ }
22
+ ]
23
+ }));
24
+ }
25
+ return server;
26
+ }
27
+ export async function startStdioMcpServer(options = {}) {
28
+ // Entry points resolve runtime config through the shared loader (CLI args > env >
29
+ // .ragcode/config.json > offline-first defaults). The engine constructor itself stays
30
+ // env-driven so embedded/library/test usage keeps its lightweight in-memory defaults.
31
+ const components = (options.graphStore && options.semanticStore && options.embeddingProvider)
32
+ ? undefined
33
+ : createRuntimeComponentsForRepo({ cwd: options.cwd, env: options.env });
34
+ const engine = new RagCodeEngine({
35
+ ...options,
36
+ graphStore: options.graphStore ?? components?.graphStore,
37
+ semanticStore: options.semanticStore ?? components?.semanticStore,
38
+ embeddingProvider: options.embeddingProvider ?? components?.embeddingProvider
39
+ });
40
+ const server = createMcpServer(engine, options);
41
+ const transport = new StdioServerTransport();
42
+ let closed = false;
43
+ const close = async () => {
44
+ if (closed)
45
+ return;
46
+ closed = true;
47
+ try {
48
+ await server.close();
49
+ }
50
+ finally {
51
+ engine.close();
52
+ }
53
+ };
54
+ process.once("SIGINT", () => {
55
+ void close().finally(() => process.exit(0));
56
+ });
57
+ process.once("SIGTERM", () => {
58
+ void close().finally(() => process.exit(0));
59
+ });
60
+ process.once("exit", () => {
61
+ engine.close();
62
+ });
63
+ await server.connect(transport);
64
+ }
@@ -0,0 +1,266 @@
1
+ import { z } from "zod";
2
+ import type { ContextEngine } from "../core/contracts.js";
3
+ export declare const ToolNameSchema: z.ZodEnum<{
4
+ index_repo: "index_repo";
5
+ refresh_index: "refresh_index";
6
+ index_status: "index_status";
7
+ watch_status: "watch_status";
8
+ record_file_events: "record_file_events";
9
+ search_code: "search_code";
10
+ get_context: "get_context";
11
+ topology_map: "topology_map";
12
+ find_symbol: "find_symbol";
13
+ explain_file: "explain_file";
14
+ expand_node: "expand_node";
15
+ find_owner: "find_owner";
16
+ find_reuse_candidates: "find_reuse_candidates";
17
+ impact_analysis: "impact_analysis";
18
+ explain_impact: "explain_impact";
19
+ related_tests: "related_tests";
20
+ trace_flow: "trace_flow";
21
+ trace_request_flow: "trace_request_flow";
22
+ review_diff: "review_diff";
23
+ }>;
24
+ export type ToolName = z.infer<typeof ToolNameSchema>;
25
+ export declare const IndexRepoInput: z.ZodObject<{
26
+ repoRoot: z.ZodString;
27
+ }, z.core.$strip>;
28
+ export declare const ContextModeSchema: z.ZodEnum<{
29
+ auto: "auto";
30
+ debug: "debug";
31
+ feature: "feature";
32
+ refactor: "refactor";
33
+ review: "review";
34
+ explain: "explain";
35
+ }>;
36
+ export declare const ExpansionLevelSchema: z.ZodEnum<{
37
+ file_card: "file_card";
38
+ skeleton: "skeleton";
39
+ focused_body: "focused_body";
40
+ full_body: "full_body";
41
+ }>;
42
+ export declare const SubgraphOutputPresetSchema: z.ZodEnum<{
43
+ compact: "compact";
44
+ agent_edit: "agent_edit";
45
+ debug_trace: "debug_trace";
46
+ review_risk: "review_risk";
47
+ }>;
48
+ export declare const WorkspaceHintInput: z.ZodOptional<z.ZodObject<{
49
+ root: z.ZodOptional<z.ZodString>;
50
+ filePath: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>>;
52
+ export declare const RefreshIndexInput: z.ZodObject<{
53
+ repoRoot: z.ZodOptional<z.ZodString>;
54
+ workspace: z.ZodOptional<z.ZodObject<{
55
+ root: z.ZodOptional<z.ZodString>;
56
+ filePath: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ export declare const IndexStatusInput: z.ZodObject<{
60
+ repoRoot: z.ZodOptional<z.ZodString>;
61
+ workspace: z.ZodOptional<z.ZodObject<{
62
+ root: z.ZodOptional<z.ZodString>;
63
+ filePath: z.ZodOptional<z.ZodString>;
64
+ }, z.core.$strip>>;
65
+ }, z.core.$strip>;
66
+ export declare const WatchStatusInput: z.ZodObject<{
67
+ repoRoot: z.ZodOptional<z.ZodString>;
68
+ workspace: z.ZodOptional<z.ZodObject<{
69
+ root: z.ZodOptional<z.ZodString>;
70
+ filePath: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strip>>;
72
+ }, z.core.$strip>;
73
+ export declare const RecordFileEventsInput: z.ZodObject<{
74
+ repoRoot: z.ZodOptional<z.ZodString>;
75
+ workspace: z.ZodOptional<z.ZodObject<{
76
+ root: z.ZodOptional<z.ZodString>;
77
+ filePath: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strip>>;
79
+ filePaths: z.ZodArray<z.ZodString>;
80
+ burstThreshold: z.ZodOptional<z.ZodNumber>;
81
+ maxDirtyFiles: z.ZodOptional<z.ZodNumber>;
82
+ }, z.core.$strip>;
83
+ export declare const SearchCodeInput: z.ZodObject<{
84
+ repoRoot: z.ZodOptional<z.ZodString>;
85
+ workspace: z.ZodOptional<z.ZodObject<{
86
+ root: z.ZodOptional<z.ZodString>;
87
+ filePath: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strip>>;
89
+ query: z.ZodString;
90
+ limit: z.ZodOptional<z.ZodNumber>;
91
+ mode: z.ZodOptional<z.ZodEnum<{
92
+ auto: "auto";
93
+ debug: "debug";
94
+ feature: "feature";
95
+ refactor: "refactor";
96
+ review: "review";
97
+ explain: "explain";
98
+ }>>;
99
+ }, z.core.$strip>;
100
+ export declare const GetContextInput: z.ZodObject<{
101
+ repoRoot: z.ZodOptional<z.ZodString>;
102
+ workspace: z.ZodOptional<z.ZodObject<{
103
+ root: z.ZodOptional<z.ZodString>;
104
+ filePath: z.ZodOptional<z.ZodString>;
105
+ }, z.core.$strip>>;
106
+ query: z.ZodString;
107
+ limit: z.ZodOptional<z.ZodNumber>;
108
+ mode: z.ZodOptional<z.ZodEnum<{
109
+ auto: "auto";
110
+ debug: "debug";
111
+ feature: "feature";
112
+ refactor: "refactor";
113
+ review: "review";
114
+ explain: "explain";
115
+ }>>;
116
+ budgetChars: z.ZodOptional<z.ZodNumber>;
117
+ }, z.core.$strip>;
118
+ export declare const TopologyMapInput: z.ZodObject<{
119
+ repoRoot: z.ZodOptional<z.ZodString>;
120
+ workspace: z.ZodOptional<z.ZodObject<{
121
+ root: z.ZodOptional<z.ZodString>;
122
+ filePath: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$strip>>;
124
+ query: z.ZodString;
125
+ limit: z.ZodOptional<z.ZodNumber>;
126
+ mode: z.ZodOptional<z.ZodEnum<{
127
+ auto: "auto";
128
+ debug: "debug";
129
+ feature: "feature";
130
+ refactor: "refactor";
131
+ review: "review";
132
+ explain: "explain";
133
+ }>>;
134
+ budgetChars: z.ZodOptional<z.ZodNumber>;
135
+ maxEdges: z.ZodOptional<z.ZodNumber>;
136
+ }, z.core.$strip>;
137
+ export declare const FindSymbolInput: z.ZodObject<{
138
+ repoRoot: z.ZodOptional<z.ZodString>;
139
+ workspace: z.ZodOptional<z.ZodObject<{
140
+ root: z.ZodOptional<z.ZodString>;
141
+ filePath: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strip>>;
143
+ name: z.ZodString;
144
+ }, z.core.$strip>;
145
+ export declare const ExplainFileInput: z.ZodObject<{
146
+ repoRoot: z.ZodOptional<z.ZodString>;
147
+ workspace: z.ZodOptional<z.ZodObject<{
148
+ root: z.ZodOptional<z.ZodString>;
149
+ filePath: z.ZodOptional<z.ZodString>;
150
+ }, z.core.$strip>>;
151
+ filePath: z.ZodString;
152
+ }, z.core.$strip>;
153
+ export declare const ExpandNodeInput: z.ZodObject<{
154
+ repoRoot: z.ZodOptional<z.ZodString>;
155
+ workspace: z.ZodOptional<z.ZodObject<{
156
+ root: z.ZodOptional<z.ZodString>;
157
+ filePath: z.ZodOptional<z.ZodString>;
158
+ }, z.core.$strip>>;
159
+ nodeRef: z.ZodString;
160
+ expansionLevel: z.ZodOptional<z.ZodEnum<{
161
+ file_card: "file_card";
162
+ skeleton: "skeleton";
163
+ focused_body: "focused_body";
164
+ full_body: "full_body";
165
+ }>>;
166
+ budgetChars: z.ZodOptional<z.ZodNumber>;
167
+ }, z.core.$strip>;
168
+ export declare const FindOwnerInput: z.ZodObject<{
169
+ repoRoot: z.ZodOptional<z.ZodString>;
170
+ workspace: z.ZodOptional<z.ZodObject<{
171
+ root: z.ZodOptional<z.ZodString>;
172
+ filePath: z.ZodOptional<z.ZodString>;
173
+ }, z.core.$strip>>;
174
+ query: z.ZodString;
175
+ limit: z.ZodOptional<z.ZodNumber>;
176
+ }, z.core.$strip>;
177
+ export declare const FindReuseCandidatesInput: z.ZodObject<{
178
+ repoRoot: z.ZodOptional<z.ZodString>;
179
+ workspace: z.ZodOptional<z.ZodObject<{
180
+ root: z.ZodOptional<z.ZodString>;
181
+ filePath: z.ZodOptional<z.ZodString>;
182
+ }, z.core.$strip>>;
183
+ query: z.ZodString;
184
+ limit: z.ZodOptional<z.ZodNumber>;
185
+ reuseGuard: z.ZodOptional<z.ZodBoolean>;
186
+ }, z.core.$strip>;
187
+ export declare const ImpactAnalysisInput: z.ZodObject<{
188
+ repoRoot: z.ZodOptional<z.ZodString>;
189
+ workspace: z.ZodOptional<z.ZodObject<{
190
+ root: z.ZodOptional<z.ZodString>;
191
+ filePath: z.ZodOptional<z.ZodString>;
192
+ }, z.core.$strip>>;
193
+ target: z.ZodString;
194
+ }, z.core.$strip>;
195
+ export declare const ExplainImpactInput: z.ZodObject<{
196
+ repoRoot: z.ZodOptional<z.ZodString>;
197
+ workspace: z.ZodOptional<z.ZodObject<{
198
+ root: z.ZodOptional<z.ZodString>;
199
+ filePath: z.ZodOptional<z.ZodString>;
200
+ }, z.core.$strip>>;
201
+ target: z.ZodString;
202
+ budgetChars: z.ZodOptional<z.ZodNumber>;
203
+ maxHops: z.ZodOptional<z.ZodNumber>;
204
+ preset: z.ZodOptional<z.ZodEnum<{
205
+ compact: "compact";
206
+ agent_edit: "agent_edit";
207
+ debug_trace: "debug_trace";
208
+ review_risk: "review_risk";
209
+ }>>;
210
+ }, z.core.$strip>;
211
+ export declare const RelatedTestsInput: z.ZodObject<{
212
+ repoRoot: z.ZodOptional<z.ZodString>;
213
+ workspace: z.ZodOptional<z.ZodObject<{
214
+ root: z.ZodOptional<z.ZodString>;
215
+ filePath: z.ZodOptional<z.ZodString>;
216
+ }, z.core.$strip>>;
217
+ target: z.ZodString;
218
+ }, z.core.$strip>;
219
+ export declare const TraceFlowInput: z.ZodObject<{
220
+ repoRoot: z.ZodOptional<z.ZodString>;
221
+ workspace: z.ZodOptional<z.ZodObject<{
222
+ root: z.ZodOptional<z.ZodString>;
223
+ filePath: z.ZodOptional<z.ZodString>;
224
+ }, z.core.$strip>>;
225
+ entry: z.ZodString;
226
+ maxSteps: z.ZodOptional<z.ZodNumber>;
227
+ }, z.core.$strip>;
228
+ export declare const TraceRequestFlowInput: z.ZodObject<{
229
+ repoRoot: z.ZodOptional<z.ZodString>;
230
+ workspace: z.ZodOptional<z.ZodObject<{
231
+ root: z.ZodOptional<z.ZodString>;
232
+ filePath: z.ZodOptional<z.ZodString>;
233
+ }, z.core.$strip>>;
234
+ entry: z.ZodString;
235
+ query: z.ZodOptional<z.ZodString>;
236
+ budgetChars: z.ZodOptional<z.ZodNumber>;
237
+ maxHops: z.ZodOptional<z.ZodNumber>;
238
+ preset: z.ZodOptional<z.ZodEnum<{
239
+ compact: "compact";
240
+ agent_edit: "agent_edit";
241
+ debug_trace: "debug_trace";
242
+ review_risk: "review_risk";
243
+ }>>;
244
+ }, z.core.$strip>;
245
+ export declare const ReviewDiffInput: z.ZodObject<{
246
+ repoRoot: z.ZodOptional<z.ZodString>;
247
+ workspace: z.ZodOptional<z.ZodObject<{
248
+ root: z.ZodOptional<z.ZodString>;
249
+ filePath: z.ZodOptional<z.ZodString>;
250
+ }, z.core.$strip>>;
251
+ diff: z.ZodOptional<z.ZodString>;
252
+ changedFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
253
+ }, z.core.$strip>;
254
+ export interface McpToolDefinition {
255
+ name: ToolName;
256
+ description: string;
257
+ inputSchema: Record<string, unknown>;
258
+ }
259
+ export interface McpRuntimeToolDefinition {
260
+ name: ToolName;
261
+ description: string;
262
+ inputSchema: z.ZodType;
263
+ }
264
+ export declare function listToolDefinitions(): McpToolDefinition[];
265
+ export declare function listRuntimeToolDefinitions(): McpRuntimeToolDefinition[];
266
+ export declare function callTool(engine: ContextEngine, name: ToolName, rawInput: unknown): Promise<unknown>;