@dimassetoid/septum-mcp 0.2.1 → 0.5.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 (161) hide show
  1. package/README.md +46 -45
  2. package/package.json +8 -6
  3. package/src/cli/commands/check.ts +41 -26
  4. package/src/cli/commands/hook.ts +77 -105
  5. package/src/cli/commands/init.ts +35 -9
  6. package/src/cli/commands/stats.ts +33 -0
  7. package/src/cli/commands/sync-progress.ts +71 -0
  8. package/src/cli/commands/sync.ts +35 -9
  9. package/src/cli/hook-payload.ts +43 -0
  10. package/src/cli/index.ts +15 -51
  11. package/src/cli/scaffold/harness-config.ts +48 -8
  12. package/src/cli/templates/hooks.ts +51 -27
  13. package/src/cli/templates/rules.ts +34 -49
  14. package/src/cli/templates/skill.ts +46 -35
  15. package/src/core/boundary/audit.ts +383 -0
  16. package/src/core/boundary/evaluator.ts +299 -178
  17. package/src/core/boundary/staged-auditor.ts +188 -34
  18. package/src/core/config/domain-ownership.ts +47 -0
  19. package/src/core/config/domain-registration.ts +141 -0
  20. package/src/core/config/loader.ts +82 -54
  21. package/src/core/config/schema.ts +24 -46
  22. package/src/core/database/client.ts +2 -0
  23. package/src/core/database/repositories/dependency.repository.ts +326 -543
  24. package/src/core/database/repositories/domain.repository.ts +48 -4
  25. package/src/core/database/repositories/file.repository.ts +10 -0
  26. package/src/core/database/repositories/symbol.repository.ts +97 -259
  27. package/src/core/database/repository.ts +138 -24
  28. package/src/core/database/schema.ts +28 -33
  29. package/src/core/discovery/declarative-routes.ts +69 -0
  30. package/src/core/discovery/framework-detector.ts +149 -0
  31. package/src/core/discovery/navigation.ts +269 -0
  32. package/src/core/discovery/topology-detector.ts +153 -170
  33. package/src/core/errors.ts +19 -0
  34. package/src/core/ingestion/pipeline.ts +378 -212
  35. package/src/core/parser/behavioral-analyzer.ts +26 -22
  36. package/src/core/parser/boundary-tracker.ts +15 -0
  37. package/src/core/parser/extractors/base.ts +16 -4
  38. package/src/core/parser/extractors/csharp.ts +9 -5
  39. package/src/core/parser/extractors/django-routing.ts +163 -0
  40. package/src/core/parser/extractors/django-semantic.ts +400 -516
  41. package/src/core/parser/extractors/elysia-semantic.ts +172 -496
  42. package/src/core/parser/extractors/express-semantic.ts +195 -398
  43. package/src/core/parser/extractors/fastapi-semantic.ts +182 -399
  44. package/src/core/parser/extractors/fastify-semantic.ts +216 -732
  45. package/src/core/parser/extractors/flask-semantic.ts +92 -388
  46. package/src/core/parser/extractors/go-routing.ts +344 -0
  47. package/src/core/parser/extractors/go-semantic.ts +210 -508
  48. package/src/core/parser/extractors/go.ts +6 -3
  49. package/src/core/parser/extractors/graphql-entrypoint.ts +146 -0
  50. package/src/core/parser/extractors/hono-semantic.ts +132 -530
  51. package/src/core/parser/extractors/java.ts +7 -5
  52. package/src/core/parser/extractors/laravel-routing.ts +263 -0
  53. package/src/core/parser/extractors/laravel-semantic.ts +169 -333
  54. package/src/core/parser/extractors/manifest-helpers.ts +64 -0
  55. package/src/core/parser/extractors/mcp-cli-dispatch.ts +268 -0
  56. package/src/core/parser/extractors/mcp-cli-semantic.ts +84 -336
  57. package/src/core/parser/extractors/nestjs-semantic.ts +238 -510
  58. package/src/core/parser/extractors/nextjs-semantic.ts +164 -0
  59. package/src/core/parser/extractors/php-ast-helpers.ts +51 -0
  60. package/src/core/parser/extractors/php.ts +17 -1
  61. package/src/core/parser/extractors/python-route-ast.ts +249 -0
  62. package/src/core/parser/extractors/python.ts +9 -8
  63. package/src/core/parser/extractors/registry.ts +28 -5
  64. package/src/core/parser/extractors/route-prefixes.ts +43 -0
  65. package/src/core/parser/extractors/ruby.ts +10 -7
  66. package/src/core/parser/extractors/rust.ts +35 -17
  67. package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
  68. package/src/core/parser/extractors/symfony-routing.ts +114 -0
  69. package/src/core/parser/extractors/symfony-semantic.ts +75 -262
  70. package/src/core/parser/extractors/typescript-bindings.ts +333 -0
  71. package/src/core/parser/extractors/typescript-compiler-fallback.ts +380 -0
  72. package/src/core/parser/extractors/typescript-fallback.ts +207 -0
  73. package/src/core/parser/extractors/typescript-route-context.ts +58 -0
  74. package/src/core/parser/extractors/typescript.ts +36 -216
  75. package/src/core/parser/implementation-fingerprint.ts +97 -0
  76. package/src/core/parser/language-capabilities.ts +23 -7
  77. package/src/core/parser/schema/providers/laravel-migration-provider.ts +77 -51
  78. package/src/core/parser/schema/schema-provider-registry.ts +1 -3
  79. package/src/core/parser/schema/schema-provider.interface.ts +2 -1
  80. package/src/core/parser/semantic-revision.ts +3 -0
  81. package/src/core/parser/static-string.ts +51 -0
  82. package/src/core/parser/wasm-loader.ts +6 -2
  83. package/src/core/resolver/ast-method-tracer.ts +230 -0
  84. package/src/core/resolver/call-graph-helpers.ts +72 -0
  85. package/src/core/resolver/call-graph-tracer.ts +375 -311
  86. package/src/core/resolver/dependency-analysis.ts +593 -0
  87. package/src/core/resolver/import-candidates.ts +120 -0
  88. package/src/core/resolver/import-evidence.ts +88 -0
  89. package/src/core/resolver/import-resolver.ts +162 -181
  90. package/src/core/resolver/interpretation-inputs.ts +65 -0
  91. package/src/core/resolver/languages/go.ts +103 -0
  92. package/src/core/resolver/languages/managed.ts +200 -0
  93. package/src/core/resolver/languages/python.ts +133 -0
  94. package/src/core/resolver/languages/ruby.ts +40 -0
  95. package/src/core/resolver/languages/rust.ts +127 -0
  96. package/src/core/resolver/languages/shared.ts +74 -0
  97. package/src/core/resolver/module-resolver.ts +18 -7
  98. package/src/core/resolver/path-resolver.ts +6 -3
  99. package/src/core/resolver/polyglot-slice-tracer.ts +197 -0
  100. package/src/core/resolver/slice-catalog.ts +94 -0
  101. package/src/core/resolver/slice-format.ts +22 -0
  102. package/src/core/resolver/slice-selection.ts +237 -0
  103. package/src/core/resolver/symbol-impact.ts +477 -0
  104. package/src/core/resolver/symbol-locator.ts +82 -15
  105. package/src/core/resolver/vertical-slice-tracer.ts +57 -278
  106. package/src/core/resources/ignore.ts +21 -1
  107. package/src/core/resources/limits.ts +2 -1
  108. package/src/core/resources/source-files.ts +143 -20
  109. package/src/core/resources/source-inventory.ts +55 -0
  110. package/src/core/resources/work-queue.ts +167 -4
  111. package/src/core/retrieval/context-page.ts +116 -0
  112. package/src/core/retrieval/context.ts +457 -0
  113. package/src/core/retrieval/resolution-warnings.ts +21 -0
  114. package/src/core/retrieval/source-context.ts +448 -0
  115. package/src/core/retrieval/symbol-details.ts +453 -0
  116. package/src/core/retrieval/symbol-evidence.ts +97 -0
  117. package/src/core/retrieval/typescript-references.ts +293 -0
  118. package/src/core/retrieval/universal-context.ts +182 -0
  119. package/src/core/telemetry/summary.ts +114 -0
  120. package/src/core/telemetry/telemetry.ts +225 -37
  121. package/src/index.ts +0 -3
  122. package/src/mcp/formatters/compact-text.ts +439 -0
  123. package/src/mcp/resources-and-prompts.ts +253 -0
  124. package/src/mcp/schemas/boundary.ts +145 -0
  125. package/src/mcp/schemas/map.ts +250 -0
  126. package/src/mcp/schemas/shared.ts +52 -0
  127. package/src/mcp/schemas/slice.ts +60 -0
  128. package/src/mcp/schemas/symbol.ts +268 -0
  129. package/src/mcp/schemas.ts +5 -1105
  130. package/src/mcp/server.ts +263 -597
  131. package/src/mcp/tool-catalog.ts +331 -0
  132. package/src/mcp/tools/boundary.ts +69 -4
  133. package/src/mcp/tools/map.ts +126 -0
  134. package/src/mcp/tools/slice.ts +101 -3
  135. package/src/mcp/tools/symbol.ts +480 -26
  136. package/src/mcp/ui/app-client.ts +899 -0
  137. package/src/mcp/ui/app.html +478 -0
  138. package/src/mcp/workflow-playbooks.ts +181 -0
  139. package/src/mcp/workspace-boundary.ts +50 -0
  140. package/src/mcp/workspace-manager.ts +102 -18
  141. package/src/mcp/workspace-watcher.ts +38 -19
  142. package/src/types/index.ts +47 -53
  143. package/src/cli/commands/topology.ts +0 -161
  144. package/src/core/database/repositories/environment.repository.ts +0 -207
  145. package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
  146. package/src/core/session/session-manager.ts +0 -107
  147. package/src/core/topology/environment-detector.ts +0 -973
  148. package/src/core/topology/types.ts +0 -83
  149. package/src/mcp/tools/check-boundary.ts +0 -387
  150. package/src/mcp/tools/domain.ts +0 -40
  151. package/src/mcp/tools/feature.ts +0 -67
  152. package/src/mcp/tools/get-domain-catalog.ts +0 -226
  153. package/src/mcp/tools/get-environment-topology.ts +0 -138
  154. package/src/mcp/tools/get-feature-context.ts +0 -224
  155. package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
  156. package/src/mcp/tools/get-symbol-impact.ts +0 -64
  157. package/src/mcp/tools/get-symbol.ts +0 -175
  158. package/src/mcp/tools/locate-symbol.ts +0 -196
  159. package/src/mcp/tools/register-domain.ts +0 -75
  160. package/src/mcp/tools/register-feature.ts +0 -110
  161. package/src/mcp/tools/trace-vertical-slice.ts +0 -80
@@ -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>;