@dimassetoid/septum-mcp 0.3.0 → 0.5.1
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/README.md +38 -55
- package/package.json +7 -5
- package/src/cli/commands/check.ts +14 -10
- package/src/cli/commands/hook.ts +41 -6
- package/src/cli/commands/init.ts +10 -1
- package/src/cli/commands/stats.ts +33 -0
- package/src/cli/commands/sync-progress.ts +71 -0
- package/src/cli/commands/sync.ts +32 -4
- package/src/cli/index.ts +7 -0
- package/src/cli/templates/hooks.ts +3 -14
- package/src/cli/templates/skill.ts +17 -10
- package/src/core/boundary/audit.ts +383 -0
- package/src/core/boundary/evaluator.ts +251 -114
- package/src/core/boundary/staged-auditor.ts +147 -55
- package/src/core/config/domain-ownership.ts +6 -4
- package/src/core/config/domain-registration.ts +141 -0
- package/src/core/config/loader.ts +1 -25
- package/src/core/config/schema.ts +24 -36
- package/src/core/database/client.ts +2 -0
- package/src/core/database/repositories/dependency.repository.ts +334 -572
- package/src/core/database/repositories/domain.repository.ts +2 -1
- package/src/core/database/repositories/file.repository.ts +10 -0
- package/src/core/database/repositories/symbol.repository.ts +97 -398
- package/src/core/database/repository.ts +68 -9
- package/src/core/database/schema.ts +26 -0
- package/src/core/discovery/declarative-routes.ts +69 -0
- package/src/core/discovery/framework-detector.ts +149 -0
- package/src/core/discovery/navigation.ts +222 -58
- package/src/core/discovery/topology-detector.ts +93 -168
- package/src/core/errors.ts +19 -0
- package/src/core/ingestion/pipeline.ts +287 -88
- package/src/core/parser/extractors/base.ts +11 -3
- package/src/core/parser/extractors/csharp.ts +2 -2
- package/src/core/parser/extractors/django-routing.ts +163 -0
- package/src/core/parser/extractors/django-semantic.ts +397 -481
- package/src/core/parser/extractors/elysia-semantic.ts +172 -475
- package/src/core/parser/extractors/express-semantic.ts +195 -383
- package/src/core/parser/extractors/fastapi-semantic.ts +178 -361
- package/src/core/parser/extractors/fastify-semantic.ts +216 -717
- package/src/core/parser/extractors/flask-semantic.ts +89 -352
- package/src/core/parser/extractors/go-routing.ts +344 -0
- package/src/core/parser/extractors/go-semantic.ts +205 -562
- package/src/core/parser/extractors/go.ts +6 -3
- package/src/core/parser/extractors/graphql-entrypoint.ts +146 -0
- package/src/core/parser/extractors/hono-semantic.ts +132 -509
- package/src/core/parser/extractors/java.ts +2 -2
- package/src/core/parser/extractors/laravel-routing.ts +263 -0
- package/src/core/parser/extractors/laravel-semantic.ts +143 -335
- package/src/core/parser/extractors/manifest-helpers.ts +64 -0
- package/src/core/parser/extractors/mcp-cli-dispatch.ts +268 -0
- package/src/core/parser/extractors/mcp-cli-semantic.ts +82 -333
- package/src/core/parser/extractors/nestjs-semantic.ts +238 -494
- package/src/core/parser/extractors/nextjs-semantic.ts +164 -0
- package/src/core/parser/extractors/php-ast-helpers.ts +51 -0
- package/src/core/parser/extractors/php.ts +1 -1
- package/src/core/parser/extractors/python-route-ast.ts +249 -0
- package/src/core/parser/extractors/python.ts +5 -9
- package/src/core/parser/extractors/registry.ts +2 -0
- package/src/core/parser/extractors/route-prefixes.ts +43 -0
- package/src/core/parser/extractors/ruby.ts +2 -2
- package/src/core/parser/extractors/rust.ts +4 -4
- package/src/core/parser/extractors/symfony-routing.ts +114 -0
- package/src/core/parser/extractors/symfony-semantic.ts +72 -226
- package/src/core/parser/extractors/typescript-bindings.ts +333 -0
- package/src/core/parser/extractors/typescript-compiler-fallback.ts +380 -0
- package/src/core/parser/extractors/typescript-fallback.ts +207 -0
- package/src/core/parser/extractors/typescript-route-context.ts +58 -0
- package/src/core/parser/extractors/typescript.ts +23 -216
- package/src/core/parser/language-capabilities.ts +1 -1
- package/src/core/parser/schema/providers/laravel-migration-provider.ts +4 -1
- package/src/core/parser/wasm-loader.ts +6 -2
- package/src/core/resolver/ast-method-tracer.ts +230 -0
- package/src/core/resolver/call-graph-helpers.ts +72 -0
- package/src/core/resolver/call-graph-tracer.ts +169 -414
- package/src/core/resolver/dependency-analysis.ts +593 -0
- package/src/core/resolver/import-candidates.ts +120 -0
- package/src/core/resolver/import-evidence.ts +88 -0
- package/src/core/resolver/import-resolver.ts +60 -7
- package/src/core/resolver/interpretation-inputs.ts +60 -2
- package/src/core/resolver/languages/python.ts +31 -13
- package/src/core/resolver/languages/shared.ts +4 -1
- package/src/core/resolver/module-resolver.ts +10 -3
- package/src/core/resolver/path-resolver.ts +6 -3
- package/src/core/resolver/polyglot-slice-tracer.ts +197 -0
- package/src/core/resolver/slice-catalog.ts +21 -6
- package/src/core/resolver/slice-format.ts +13 -0
- package/src/core/resolver/slice-selection.ts +237 -0
- package/src/core/resolver/symbol-impact.ts +104 -8
- package/src/core/resolver/symbol-locator.ts +82 -15
- package/src/core/resolver/vertical-slice-tracer.ts +31 -230
- package/src/core/resources/ignore.ts +0 -1
- package/src/core/resources/limits.ts +2 -1
- package/src/core/resources/work-queue.ts +167 -4
- package/src/core/retrieval/context-page.ts +11 -4
- package/src/core/retrieval/context.ts +363 -226
- package/src/{mcp/tools/get-symbol.ts → core/retrieval/source-context.ts} +145 -96
- package/src/core/retrieval/symbol-details.ts +453 -0
- package/src/core/retrieval/symbol-evidence.ts +3 -3
- package/src/core/retrieval/typescript-references.ts +38 -7
- package/src/core/retrieval/universal-context.ts +182 -0
- package/src/core/telemetry/summary.ts +114 -0
- package/src/core/telemetry/telemetry.ts +192 -49
- package/src/mcp/formatters/compact-text.ts +439 -0
- package/src/mcp/resources-and-prompts.ts +255 -0
- package/src/mcp/schemas/boundary.ts +145 -0
- package/src/mcp/schemas/map.ts +250 -0
- package/src/mcp/schemas/shared.ts +52 -0
- package/src/mcp/schemas/slice.ts +60 -0
- package/src/mcp/schemas/symbol.ts +268 -0
- package/src/mcp/schemas.ts +5 -746
- package/src/mcp/server.ts +269 -429
- package/src/mcp/tool-catalog.ts +331 -0
- package/src/mcp/tools/boundary.ts +68 -3
- package/src/mcp/tools/map.ts +104 -4
- package/src/mcp/tools/slice.ts +101 -3
- package/src/mcp/tools/symbol.ts +469 -17
- package/src/mcp/ui/app-client.ts +899 -0
- package/src/mcp/ui/app.html +478 -0
- package/src/mcp/workflow-playbooks.ts +181 -0
- package/src/mcp/workspace-boundary.ts +50 -0
- package/src/mcp/workspace-manager.ts +88 -15
- package/src/mcp/workspace-watcher.ts +30 -11
- package/src/types/index.ts +12 -0
- package/src/mcp/tools/check-boundary.ts +0 -382
- package/src/mcp/tools/get-domain-catalog.ts +0 -39
- package/src/mcp/tools/get-symbol-impact.ts +0 -104
- package/src/mcp/tools/locate-symbol.ts +0 -236
- package/src/mcp/tools/register-domain.ts +0 -113
- package/src/mcp/tools/trace-vertical-slice.ts +0 -106
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export function withAliases(raw: unknown, aliases: Record<string, string>): unknown {
|
|
4
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
|
|
5
|
+
const obj = { ...(raw as Record<string, unknown>) };
|
|
6
|
+
for (const [alias, target] of Object.entries(aliases)) {
|
|
7
|
+
if (obj[alias] !== undefined && obj[target] === undefined) {
|
|
8
|
+
obj[target] = obj[alias];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function extractSingleStringFallback(
|
|
15
|
+
raw: unknown,
|
|
16
|
+
targetField: string,
|
|
17
|
+
ignoredKeys: string[] = ["workspace_path", "workspacePath", "workspace", "project_root", "projectRoot"]
|
|
18
|
+
): unknown {
|
|
19
|
+
if (typeof raw === "string") {
|
|
20
|
+
return { [targetField]: raw };
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(raw) && raw.length === 1 && typeof raw[0] === "string") {
|
|
23
|
+
return { [targetField]: raw[0] };
|
|
24
|
+
}
|
|
25
|
+
if (typeof raw === "object" && raw !== null && !Array.isArray(raw)) {
|
|
26
|
+
const obj = { ...(raw as Record<string, unknown>) };
|
|
27
|
+
if (obj[targetField] !== undefined && typeof obj[targetField] === "string" && (obj[targetField] as string).trim() !== "") {
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
const nonIgnoredEntries = Object.entries(obj).filter(
|
|
31
|
+
([key, val]) => !ignoredKeys.includes(key) && typeof val === "string" && (val as string).trim() !== ""
|
|
32
|
+
);
|
|
33
|
+
if (nonIgnoredEntries.length === 1) {
|
|
34
|
+
obj[targetField] = nonIgnoredEntries[0][1];
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
return raw;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const SymbolReferenceSchema = z.object({
|
|
42
|
+
file_path: z.string().min(1),
|
|
43
|
+
language: z.string().min(1),
|
|
44
|
+
name: z.string().min(1),
|
|
45
|
+
kind: z.string().min(1),
|
|
46
|
+
signature: z.string(),
|
|
47
|
+
start_line: z.number().int().positive(),
|
|
48
|
+
end_line: z.number().int().positive(),
|
|
49
|
+
indexed_content_hash: z.string().min(1),
|
|
50
|
+
container: z.string().optional(),
|
|
51
|
+
receiver: z.string().optional(),
|
|
52
|
+
}).refine(ref => ref.end_line >= ref.start_line, { message: "end_line must be at or after start_line" });
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { extractSingleStringFallback, withAliases } from "./shared.ts";
|
|
3
|
+
|
|
4
|
+
export function normalizeTraceVerticalSliceArgs(raw: unknown): unknown {
|
|
5
|
+
const coerced = extractSingleStringFallback(raw, "query", [
|
|
6
|
+
"workspace_path", "workspacePath", "workspace", "project_root", "projectRoot", "controller_file",
|
|
7
|
+
"format", "output_format", "outputFormat",
|
|
8
|
+
]);
|
|
9
|
+
if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
|
|
10
|
+
const obj = withAliases(coerced, {
|
|
11
|
+
route: "query",
|
|
12
|
+
uri: "query",
|
|
13
|
+
route_uri: "query",
|
|
14
|
+
routeUri: "query",
|
|
15
|
+
entry_file: "query",
|
|
16
|
+
entryFile: "query",
|
|
17
|
+
file_path: "query",
|
|
18
|
+
filePath: "query",
|
|
19
|
+
file: "query",
|
|
20
|
+
path: "query",
|
|
21
|
+
symbol: "query",
|
|
22
|
+
name: "query",
|
|
23
|
+
feature: "query",
|
|
24
|
+
feature_key: "query",
|
|
25
|
+
featureKey: "query",
|
|
26
|
+
maxDepth: "max_depth",
|
|
27
|
+
depth: "max_depth",
|
|
28
|
+
output_format: "format",
|
|
29
|
+
outputFormat: "format",
|
|
30
|
+
workspace: "workspace_path",
|
|
31
|
+
workspacePath: "workspace_path",
|
|
32
|
+
project_root: "workspace_path",
|
|
33
|
+
projectRoot: "workspace_path",
|
|
34
|
+
}) as Record<string, unknown>;
|
|
35
|
+
if (obj.query !== undefined && obj.symbol === undefined) {
|
|
36
|
+
obj.symbol = obj.query;
|
|
37
|
+
} else if (obj.symbol !== undefined && obj.query === undefined) {
|
|
38
|
+
obj.query = obj.symbol;
|
|
39
|
+
}
|
|
40
|
+
if (obj.max_depth !== undefined && obj.max_depth !== null && !Number.isNaN(Number(obj.max_depth))) {
|
|
41
|
+
obj.max_depth = Math.min(Math.max(Math.trunc(Number(obj.max_depth)), 1), 8);
|
|
42
|
+
}
|
|
43
|
+
return obj;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const TraceVerticalSliceSchema = z.preprocess(
|
|
47
|
+
normalizeTraceVerticalSliceArgs,
|
|
48
|
+
z.object({
|
|
49
|
+
query: z.string().min(1, "query is required"),
|
|
50
|
+
symbol: z.string().optional(),
|
|
51
|
+
controller_file: z.string().min(1).optional(),
|
|
52
|
+
max_depth: z.number().int().min(1).max(8).optional().default(5),
|
|
53
|
+
format: z.enum(["json", "text"]).optional().default("text"),
|
|
54
|
+
workspace_path: z.string().optional(),
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
export type TraceVerticalSliceArgs = z.infer<typeof TraceVerticalSliceSchema>;
|
|
58
|
+
|
|
59
|
+
export const SliceToolSchema = TraceVerticalSliceSchema;
|
|
60
|
+
export type SliceToolArgs = TraceVerticalSliceArgs;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { extractSingleStringFallback, SymbolReferenceSchema, withAliases } from "./shared.ts";
|
|
3
|
+
|
|
4
|
+
export function normalizeLocateSymbolArgs(raw: unknown): unknown {
|
|
5
|
+
const coerced = extractSingleStringFallback(raw, "query", [
|
|
6
|
+
"workspace_path",
|
|
7
|
+
"workspacePath",
|
|
8
|
+
"workspace",
|
|
9
|
+
"project_root",
|
|
10
|
+
"projectRoot",
|
|
11
|
+
"target_path",
|
|
12
|
+
"path",
|
|
13
|
+
"domain",
|
|
14
|
+
"domain_name",
|
|
15
|
+
"domainName",
|
|
16
|
+
"file_path",
|
|
17
|
+
"filePath",
|
|
18
|
+
]);
|
|
19
|
+
if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
|
|
20
|
+
const obj = withAliases(coerced, {
|
|
21
|
+
symbol: "query",
|
|
22
|
+
name: "query",
|
|
23
|
+
symbol_name: "query",
|
|
24
|
+
symbolName: "query",
|
|
25
|
+
target: "query",
|
|
26
|
+
domain_name: "domain",
|
|
27
|
+
domainName: "domain",
|
|
28
|
+
max: "limit",
|
|
29
|
+
workspace: "workspace_path",
|
|
30
|
+
workspacePath: "workspace_path",
|
|
31
|
+
project_root: "workspace_path",
|
|
32
|
+
projectRoot: "workspace_path",
|
|
33
|
+
target_path: "workspace_path",
|
|
34
|
+
path: "workspace_path",
|
|
35
|
+
}) as Record<string, unknown>;
|
|
36
|
+
if (obj.query !== undefined && obj.symbol === undefined) {
|
|
37
|
+
obj.symbol = obj.query;
|
|
38
|
+
} else if (obj.symbol !== undefined && obj.query === undefined) {
|
|
39
|
+
obj.query = obj.symbol;
|
|
40
|
+
}
|
|
41
|
+
if (!obj.query && !obj.symbol && typeof obj.symbol_ref === "object" && obj.symbol_ref !== null) {
|
|
42
|
+
obj.query = (obj.symbol_ref as Record<string, unknown>).name;
|
|
43
|
+
obj.symbol = obj.query;
|
|
44
|
+
}
|
|
45
|
+
return obj;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const LocateSymbolSchema = z.preprocess(
|
|
49
|
+
normalizeLocateSymbolArgs,
|
|
50
|
+
z.object({
|
|
51
|
+
query: z.string().min(1, "query is required"),
|
|
52
|
+
symbol: z.string().optional(),
|
|
53
|
+
domain: z.string().optional(),
|
|
54
|
+
symbol_ref: SymbolReferenceSchema.optional(),
|
|
55
|
+
file_path: z.string().min(1).optional(),
|
|
56
|
+
limit: z.number().int().min(1).max(50).optional().default(10),
|
|
57
|
+
format: z.enum(["json", "text"]).optional().default("text"),
|
|
58
|
+
workspace_path: z.string().optional(),
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
export type LocateSymbolArgs = z.infer<typeof LocateSymbolSchema>;
|
|
62
|
+
|
|
63
|
+
export function normalizeGetSymbolArgs(raw: unknown): unknown {
|
|
64
|
+
const coerced = extractSingleStringFallback(raw, "symbol", [
|
|
65
|
+
"workspace_path",
|
|
66
|
+
"workspacePath",
|
|
67
|
+
"workspace",
|
|
68
|
+
"project_root",
|
|
69
|
+
"projectRoot",
|
|
70
|
+
"domain",
|
|
71
|
+
"domain_name",
|
|
72
|
+
"domainName",
|
|
73
|
+
"file_path",
|
|
74
|
+
"filePath",
|
|
75
|
+
]);
|
|
76
|
+
if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
|
|
77
|
+
const obj = withAliases(coerced, {
|
|
78
|
+
query: "symbol",
|
|
79
|
+
name: "symbol",
|
|
80
|
+
symbol_name: "symbol",
|
|
81
|
+
symbolName: "symbol",
|
|
82
|
+
target: "symbol",
|
|
83
|
+
domain_name: "domain",
|
|
84
|
+
domainName: "domain",
|
|
85
|
+
includeDependencies: "include_dependencies",
|
|
86
|
+
include_deps: "include_dependencies",
|
|
87
|
+
includeDeps: "include_dependencies",
|
|
88
|
+
dependencies: "include_dependencies",
|
|
89
|
+
deps: "include_dependencies",
|
|
90
|
+
workspace: "workspace_path",
|
|
91
|
+
workspacePath: "workspace_path",
|
|
92
|
+
project_root: "workspace_path",
|
|
93
|
+
projectRoot: "workspace_path",
|
|
94
|
+
}) as Record<string, unknown>;
|
|
95
|
+
if (obj.symbol !== undefined && obj.query === undefined) {
|
|
96
|
+
obj.query = obj.symbol;
|
|
97
|
+
} else if (obj.query !== undefined && obj.symbol === undefined) {
|
|
98
|
+
obj.symbol = obj.query;
|
|
99
|
+
}
|
|
100
|
+
if (!obj.query && !obj.symbol && typeof obj.symbol_ref === "object" && obj.symbol_ref !== null) {
|
|
101
|
+
obj.query = (obj.symbol_ref as Record<string, unknown>).name;
|
|
102
|
+
obj.symbol = obj.query;
|
|
103
|
+
}
|
|
104
|
+
return obj;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const GetSymbolSchema = z.preprocess(
|
|
108
|
+
normalizeGetSymbolArgs,
|
|
109
|
+
z.object({
|
|
110
|
+
symbol: z.string().min(1, "symbol is required"),
|
|
111
|
+
query: z.string().optional(),
|
|
112
|
+
domain: z.string().optional(),
|
|
113
|
+
symbol_ref: SymbolReferenceSchema.optional(),
|
|
114
|
+
include_dependencies: z.boolean().optional().default(true),
|
|
115
|
+
workspace_path: z.string().optional(),
|
|
116
|
+
file_path: z.string().min(1).optional(),
|
|
117
|
+
include_source: z.boolean().optional().default(false),
|
|
118
|
+
source_start_line: z.number().int().positive().optional(),
|
|
119
|
+
source_line_limit: z.number().int().positive().max(200).optional().default(120),
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
export type GetSymbolArgs = z.infer<typeof GetSymbolSchema>;
|
|
123
|
+
|
|
124
|
+
export function normalizeGetSymbolImpactArgs(raw: unknown): unknown {
|
|
125
|
+
const coerced = extractSingleStringFallback(raw, "symbol");
|
|
126
|
+
if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
|
|
127
|
+
const obj = withAliases(coerced, {
|
|
128
|
+
query: "symbol",
|
|
129
|
+
name: "symbol",
|
|
130
|
+
symbol_name: "symbol",
|
|
131
|
+
symbolName: "symbol",
|
|
132
|
+
file_path: "symbol",
|
|
133
|
+
filePath: "symbol",
|
|
134
|
+
file: "symbol",
|
|
135
|
+
path: "symbol",
|
|
136
|
+
target: "symbol",
|
|
137
|
+
workspace: "workspace_path",
|
|
138
|
+
workspacePath: "workspace_path",
|
|
139
|
+
project_root: "workspace_path",
|
|
140
|
+
projectRoot: "workspace_path",
|
|
141
|
+
}) as Record<string, unknown>;
|
|
142
|
+
if (obj.symbol !== undefined && obj.query === undefined) {
|
|
143
|
+
obj.query = obj.symbol;
|
|
144
|
+
} else if (obj.query !== undefined && obj.symbol === undefined) {
|
|
145
|
+
obj.symbol = obj.query;
|
|
146
|
+
}
|
|
147
|
+
return obj;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const GetSymbolImpactSchema = z.preprocess(
|
|
151
|
+
normalizeGetSymbolImpactArgs,
|
|
152
|
+
z.object({
|
|
153
|
+
symbol: z.string().min(1, "symbol is required"),
|
|
154
|
+
query: z.string().optional(),
|
|
155
|
+
domain: z.string().optional(),
|
|
156
|
+
workspace_path: z.string().optional(),
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
export type GetSymbolImpactArgs = z.infer<typeof GetSymbolImpactSchema>;
|
|
160
|
+
|
|
161
|
+
export function normalizeSymbolToolArgs(raw: unknown): unknown {
|
|
162
|
+
const coerced = extractSingleStringFallback(raw, "query", [
|
|
163
|
+
"workspace_path",
|
|
164
|
+
"workspacePath",
|
|
165
|
+
"workspace",
|
|
166
|
+
"project_root",
|
|
167
|
+
"projectRoot",
|
|
168
|
+
"action",
|
|
169
|
+
"domain",
|
|
170
|
+
"domain_name",
|
|
171
|
+
"domainName",
|
|
172
|
+
"file_path",
|
|
173
|
+
"filePath",
|
|
174
|
+
"limit",
|
|
175
|
+
"format",
|
|
176
|
+
"output_format",
|
|
177
|
+
"outputFormat",
|
|
178
|
+
]);
|
|
179
|
+
if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
|
|
180
|
+
const obj = withAliases(coerced, {
|
|
181
|
+
symbol: "query",
|
|
182
|
+
name: "query",
|
|
183
|
+
symbol_name: "query",
|
|
184
|
+
symbolName: "query",
|
|
185
|
+
target: "query",
|
|
186
|
+
domain_name: "domain",
|
|
187
|
+
domainName: "domain",
|
|
188
|
+
includeDependencies: "include_dependencies",
|
|
189
|
+
include_deps: "include_dependencies",
|
|
190
|
+
includeDeps: "include_dependencies",
|
|
191
|
+
dependencies: "include_dependencies",
|
|
192
|
+
deps: "include_dependencies",
|
|
193
|
+
max: "limit",
|
|
194
|
+
workspace: "workspace_path",
|
|
195
|
+
workspacePath: "workspace_path",
|
|
196
|
+
project_root: "workspace_path",
|
|
197
|
+
projectRoot: "workspace_path",
|
|
198
|
+
filePath: "file_path",
|
|
199
|
+
sourceStartLine: "source_start_line",
|
|
200
|
+
sourceLineLimit: "source_line_limit",
|
|
201
|
+
semanticDepth: "semantic_depth",
|
|
202
|
+
maxDepth: "max_depth",
|
|
203
|
+
output_format: "format",
|
|
204
|
+
outputFormat: "format",
|
|
205
|
+
}) as Record<string, unknown>;
|
|
206
|
+
|
|
207
|
+
if (obj.query !== undefined && obj.symbol === undefined) {
|
|
208
|
+
obj.symbol = obj.query;
|
|
209
|
+
} else if (obj.symbol !== undefined && obj.query === undefined) {
|
|
210
|
+
obj.query = obj.symbol;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!obj.action) {
|
|
214
|
+
if (obj.budget_bytes !== undefined || obj.continuation !== undefined || obj.context_mode !== undefined || obj.max_depth !== undefined) {
|
|
215
|
+
obj.action = "context";
|
|
216
|
+
} else if (obj.include_dependencies !== undefined || obj.include_source !== undefined ||
|
|
217
|
+
obj.source_start_line !== undefined || obj.source_line_limit !== undefined) {
|
|
218
|
+
obj.action = "context";
|
|
219
|
+
} else {
|
|
220
|
+
obj.action = "locate";
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (!obj.query && !obj.symbol && typeof obj.symbol_ref === "object" && obj.symbol_ref !== null) {
|
|
225
|
+
obj.query = (obj.symbol_ref as Record<string, unknown>).name;
|
|
226
|
+
obj.symbol = obj.query;
|
|
227
|
+
}
|
|
228
|
+
if (obj.action === "inspect") obj.action = "context";
|
|
229
|
+
return obj;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export const SymbolToolSchema = z.preprocess(
|
|
233
|
+
normalizeSymbolToolArgs,
|
|
234
|
+
z.object({
|
|
235
|
+
action: z.enum(["locate", "inspect", "impact", "context"]).optional().default("locate"),
|
|
236
|
+
query: z.string().optional(),
|
|
237
|
+
symbol: z.string().optional(),
|
|
238
|
+
domain: z.string().optional(),
|
|
239
|
+
symbol_ref: SymbolReferenceSchema.optional(),
|
|
240
|
+
include_dependencies: z.boolean().optional().default(true),
|
|
241
|
+
limit: z.number().int().positive().optional(),
|
|
242
|
+
workspace_path: z.string().optional(),
|
|
243
|
+
file_path: z.string().min(1).optional(),
|
|
244
|
+
include_source: z.boolean().optional(),
|
|
245
|
+
source_start_line: z.number().int().positive().optional(),
|
|
246
|
+
source_line_limit: z.number().int().positive().max(200).optional(),
|
|
247
|
+
semantic_depth: z.number().int().min(1).max(2).optional(),
|
|
248
|
+
context_mode: z.enum(["deep", "source"]).optional(),
|
|
249
|
+
budget_bytes: z.number().int().min(2048).max(2 * 1024 * 1024).optional(),
|
|
250
|
+
max_depth: z.number().int().min(1).max(4).optional(),
|
|
251
|
+
continuation: z.string().min(1).max(4096).optional(),
|
|
252
|
+
format: z.enum(["json", "text"]).optional().default("text"),
|
|
253
|
+
}).superRefine((args, ctx) => {
|
|
254
|
+
if (args.symbol_ref && args.action !== "locate" && args.action !== "inspect" && args.action !== "impact" && args.action !== "context") {
|
|
255
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["symbol_ref"], message: "symbol_ref is supported only for locate, inspect, impact, and context." });
|
|
256
|
+
}
|
|
257
|
+
if (args.action !== "context" && (args.budget_bytes !== undefined || args.continuation !== undefined || args.max_depth !== undefined)) {
|
|
258
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["action"], message: "budget_bytes, max_depth, and continuation are supported only for context." });
|
|
259
|
+
}
|
|
260
|
+
if (args.context_mode !== undefined && args.action !== "context") {
|
|
261
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["context_mode"], message: "context_mode requires action='context' or its inspect alias." });
|
|
262
|
+
}
|
|
263
|
+
if (args.context_mode === "deep" && (args.include_source !== undefined || args.source_start_line !== undefined || args.source_line_limit !== undefined)) {
|
|
264
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["context_mode"], message: "Deep context does not accept bounded source options." });
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
);
|
|
268
|
+
export type SymbolToolArgs = z.infer<typeof SymbolToolSchema>;
|