@dimassetoid/septum-mcp 0.2.1 → 0.3.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 (106) hide show
  1. package/README.md +46 -28
  2. package/package.json +4 -4
  3. package/src/cli/commands/check.ts +27 -16
  4. package/src/cli/commands/hook.ts +38 -101
  5. package/src/cli/commands/init.ts +26 -9
  6. package/src/cli/commands/sync.ts +4 -6
  7. package/src/cli/hook-payload.ts +43 -0
  8. package/src/cli/index.ts +9 -52
  9. package/src/cli/scaffold/harness-config.ts +48 -8
  10. package/src/cli/templates/hooks.ts +49 -14
  11. package/src/cli/templates/rules.ts +34 -49
  12. package/src/cli/templates/skill.ts +39 -35
  13. package/src/core/boundary/evaluator.ts +67 -83
  14. package/src/core/boundary/staged-auditor.ts +102 -40
  15. package/src/core/config/domain-ownership.ts +45 -0
  16. package/src/core/config/loader.ts +81 -29
  17. package/src/core/config/schema.ts +0 -10
  18. package/src/core/database/repositories/dependency.repository.ts +169 -148
  19. package/src/core/database/repositories/domain.repository.ts +46 -3
  20. package/src/core/database/repositories/symbol.repository.ts +226 -87
  21. package/src/core/database/repository.ts +73 -18
  22. package/src/core/database/schema.ts +2 -33
  23. package/src/core/discovery/navigation.ts +105 -0
  24. package/src/core/discovery/topology-detector.ts +60 -2
  25. package/src/core/ingestion/pipeline.ts +96 -129
  26. package/src/core/parser/behavioral-analyzer.ts +26 -22
  27. package/src/core/parser/boundary-tracker.ts +15 -0
  28. package/src/core/parser/extractors/base.ts +7 -3
  29. package/src/core/parser/extractors/csharp.ts +7 -3
  30. package/src/core/parser/extractors/django-semantic.ts +4 -36
  31. package/src/core/parser/extractors/elysia-semantic.ts +3 -24
  32. package/src/core/parser/extractors/express-semantic.ts +3 -18
  33. package/src/core/parser/extractors/fastapi-semantic.ts +19 -53
  34. package/src/core/parser/extractors/fastify-semantic.ts +3 -18
  35. package/src/core/parser/extractors/flask-semantic.ts +22 -55
  36. package/src/core/parser/extractors/go-semantic.ts +92 -33
  37. package/src/core/parser/extractors/hono-semantic.ts +3 -24
  38. package/src/core/parser/extractors/java.ts +5 -3
  39. package/src/core/parser/extractors/laravel-semantic.ts +44 -16
  40. package/src/core/parser/extractors/mcp-cli-semantic.ts +6 -7
  41. package/src/core/parser/extractors/nestjs-semantic.ts +3 -19
  42. package/src/core/parser/extractors/php.ts +16 -0
  43. package/src/core/parser/extractors/python.ts +9 -4
  44. package/src/core/parser/extractors/registry.ts +26 -5
  45. package/src/core/parser/extractors/ruby.ts +8 -5
  46. package/src/core/parser/extractors/rust.ts +31 -13
  47. package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
  48. package/src/core/parser/extractors/symfony-semantic.ts +4 -37
  49. package/src/core/parser/extractors/typescript.ts +14 -1
  50. package/src/core/parser/implementation-fingerprint.ts +97 -0
  51. package/src/core/parser/language-capabilities.ts +23 -7
  52. package/src/core/parser/schema/providers/laravel-migration-provider.ts +73 -50
  53. package/src/core/parser/schema/schema-provider-registry.ts +1 -3
  54. package/src/core/parser/schema/schema-provider.interface.ts +2 -1
  55. package/src/core/parser/semantic-revision.ts +3 -0
  56. package/src/core/parser/static-string.ts +51 -0
  57. package/src/core/resolver/call-graph-tracer.ts +337 -28
  58. package/src/core/resolver/import-resolver.ts +107 -179
  59. package/src/core/resolver/interpretation-inputs.ts +7 -0
  60. package/src/core/resolver/languages/go.ts +103 -0
  61. package/src/core/resolver/languages/managed.ts +200 -0
  62. package/src/core/resolver/languages/python.ts +115 -0
  63. package/src/core/resolver/languages/ruby.ts +40 -0
  64. package/src/core/resolver/languages/rust.ts +127 -0
  65. package/src/core/resolver/languages/shared.ts +71 -0
  66. package/src/core/resolver/module-resolver.ts +8 -4
  67. package/src/core/resolver/slice-catalog.ts +79 -0
  68. package/src/core/resolver/slice-format.ts +9 -0
  69. package/src/core/resolver/symbol-impact.ts +381 -0
  70. package/src/core/resolver/vertical-slice-tracer.ts +93 -115
  71. package/src/core/resources/ignore.ts +22 -1
  72. package/src/core/resources/source-files.ts +143 -20
  73. package/src/core/resources/source-inventory.ts +55 -0
  74. package/src/core/retrieval/context-page.ts +109 -0
  75. package/src/core/retrieval/context.ts +320 -0
  76. package/src/core/retrieval/resolution-warnings.ts +21 -0
  77. package/src/core/retrieval/symbol-evidence.ts +97 -0
  78. package/src/core/retrieval/typescript-references.ts +262 -0
  79. package/src/core/telemetry/telemetry.ts +54 -9
  80. package/src/index.ts +0 -3
  81. package/src/mcp/schemas.ts +61 -420
  82. package/src/mcp/server.ts +116 -290
  83. package/src/mcp/tools/boundary.ts +2 -2
  84. package/src/mcp/tools/check-boundary.ts +55 -60
  85. package/src/mcp/tools/get-domain-catalog.ts +32 -219
  86. package/src/mcp/tools/get-symbol-impact.ts +45 -5
  87. package/src/mcp/tools/get-symbol.ts +227 -3
  88. package/src/mcp/tools/locate-symbol.ts +54 -14
  89. package/src/mcp/tools/{domain.ts → map.ts} +4 -18
  90. package/src/mcp/tools/register-domain.ts +41 -3
  91. package/src/mcp/tools/symbol.ts +23 -21
  92. package/src/mcp/tools/trace-vertical-slice.ts +36 -10
  93. package/src/mcp/workspace-manager.ts +15 -4
  94. package/src/mcp/workspace-watcher.ts +8 -8
  95. package/src/types/index.ts +35 -53
  96. package/src/cli/commands/topology.ts +0 -161
  97. package/src/core/database/repositories/environment.repository.ts +0 -207
  98. package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
  99. package/src/core/session/session-manager.ts +0 -107
  100. package/src/core/topology/environment-detector.ts +0 -973
  101. package/src/core/topology/types.ts +0 -83
  102. package/src/mcp/tools/feature.ts +0 -67
  103. package/src/mcp/tools/get-environment-topology.ts +0 -138
  104. package/src/mcp/tools/get-feature-context.ts +0 -224
  105. package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
  106. package/src/mcp/tools/register-feature.ts +0 -110
@@ -38,51 +38,13 @@ export function extractSingleStringFallback(
38
38
  return raw;
39
39
  }
40
40
 
41
- export function normalizeFeatureContextArgs(raw: unknown): unknown {
42
- const coerced = extractSingleStringFallback(raw, "feature_key");
43
- if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
44
- const obj = { ...(coerced as Record<string, unknown>) };
45
-
46
- const aliases: Record<string, string> = {
47
- feature: "feature_key",
48
- featureKey: "feature_key",
49
- feature_name: "feature_key",
50
- featureName: "feature_key",
51
- feat: "feature_key",
52
- name: "feature_key",
53
- key: "feature_key",
54
- task: "feature_key",
55
- task_name: "feature_key",
56
- target: "feature_key",
57
- context: "feature_key",
58
- slug: "feature_key",
59
- workspace: "workspace_path",
60
- workspacePath: "workspace_path",
61
- project_root: "workspace_path",
62
- projectRoot: "workspace_path",
63
- };
64
-
65
- for (const [alias, target] of Object.entries(aliases)) {
66
- if (obj[alias] !== undefined && obj[target] === undefined) {
67
- obj[target] = obj[alias];
68
- }
69
- }
70
-
71
- // Populate feature as backward-compatible alias
72
- if (obj.feature_key !== undefined && obj.feature === undefined) {
73
- obj.feature = obj.feature_key;
74
- } else if (obj.feature !== undefined && obj.feature_key === undefined) {
75
- obj.feature_key = obj.feature;
76
- }
77
-
78
- return obj;
79
- }
80
-
81
41
  export function normalizeBoundaryArgs(raw: unknown): unknown {
82
42
  if (Array.isArray(raw) && raw.length > 1 && raw.every((item) => typeof item === "string")) {
83
43
  raw = { file_paths: raw };
84
44
  }
85
45
  const coerced = extractSingleStringFallback(raw, "file_path", [
46
+ "action",
47
+ "plan_ref",
86
48
  "workspace_path",
87
49
  "workspacePath",
88
50
  "workspace",
@@ -128,6 +90,7 @@ export function normalizeBoundaryArgs(raw: unknown): unknown {
128
90
  project_root: "workspace_path",
129
91
  projectRoot: "workspace_path",
130
92
  };
93
+ obj.proposed_imports_supplied ??= ["proposed_imports", "proposedImports", "imports", "to_file", "toFile"].some(key => Object.prototype.hasOwnProperty.call(obj, key));
131
94
  for (const [alias, target] of Object.entries(aliases)) {
132
95
  if (obj[alias] !== undefined && obj[target] === undefined) {
133
96
  obj[target] = obj[alias];
@@ -235,28 +198,15 @@ export const GetDomainCatalogSchema = z.preprocess(
235
198
  archetype: z.string().optional(),
236
199
  detail_level: z.enum(["compact", "full"]).optional().default("compact"),
237
200
  file_filter: z.string().optional(),
201
+ file_offset: z.number().int().nonnegative().optional(),
202
+ file_limit: z.number().int().min(1).max(100).optional(),
203
+ include_evidence: z.boolean().optional(),
204
+ include_capabilities: z.boolean().optional(),
238
205
  workspace_path: z.string().optional(),
239
206
  })
240
207
  );
241
208
  export type GetDomainCatalogArgs = z.infer<typeof GetDomainCatalogSchema>;
242
209
 
243
- export const GetFeatureContextSchema = z.preprocess(
244
- normalizeFeatureContextArgs,
245
- z.object({
246
- feature_key: z.string().optional(),
247
- feature: z.string().optional(),
248
- workspace_path: z.string().optional(),
249
- })
250
- );
251
- export type GetFeatureContextArgs = z.infer<typeof GetFeatureContextSchema>;
252
-
253
- export const ClearFeatureContextSchema = z
254
- .object({
255
- workspace_path: z.string().optional(),
256
- })
257
- .passthrough();
258
- export type ClearFeatureContextArgs = z.infer<typeof ClearFeatureContextSchema>;
259
-
260
210
  export function normalizeLocateSymbolArgs(raw: unknown): unknown {
261
211
  const coerced = extractSingleStringFallback(raw, "query", [
262
212
  "workspace_path",
@@ -269,6 +219,8 @@ export function normalizeLocateSymbolArgs(raw: unknown): unknown {
269
219
  "domain",
270
220
  "domain_name",
271
221
  "domainName",
222
+ "file_path",
223
+ "filePath",
272
224
  ]);
273
225
  if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
274
226
  const obj = withAliases(coerced, {
@@ -329,6 +281,8 @@ export function normalizeGetSymbolArgs(raw: unknown): unknown {
329
281
  "domain",
330
282
  "domain_name",
331
283
  "domainName",
284
+ "file_path",
285
+ "filePath",
332
286
  ]);
333
287
  if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
334
288
  const obj = withAliases(coerced, {
@@ -416,7 +370,9 @@ export const GetSymbolImpactSchema = z.preprocess(
416
370
  export type GetSymbolImpactArgs = z.infer<typeof GetSymbolImpactSchema>;
417
371
 
418
372
  export function normalizeTraceVerticalSliceArgs(raw: unknown): unknown {
419
- const coerced = extractSingleStringFallback(raw, "query");
373
+ const coerced = extractSingleStringFallback(raw, "query", [
374
+ "workspace_path", "workspacePath", "workspace", "project_root", "projectRoot", "controller_file",
375
+ ]);
420
376
  if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
421
377
  const obj = withAliases(coerced, {
422
378
  route: "query",
@@ -457,6 +413,7 @@ export const TraceVerticalSliceSchema = z.preprocess(
457
413
  z.object({
458
414
  query: z.string().min(1, "query is required"),
459
415
  symbol: z.string().optional(),
416
+ controller_file: z.string().min(1).optional(),
460
417
  max_depth: z.number().int().min(1).max(8).optional().default(5),
461
418
  workspace_path: z.string().optional(),
462
419
  })
@@ -469,7 +426,7 @@ export const CheckBoundarySchema = z.preprocess(
469
426
  file_path: z.string().trim().min(1, "file_path cannot be blank").optional(),
470
427
  file_paths: z.array(z.string().trim().min(1, "file_paths cannot contain blank paths")).optional(),
471
428
  proposed_imports: z.array(z.string()).optional().default([]),
472
- feature_key: z.string().optional(),
429
+ proposed_imports_supplied: z.boolean().optional().default(false),
473
430
  scope: z.enum(["file", "all", "staged", "domain"]).optional(),
474
431
  domain: z.string().trim().min(1, "domain cannot be blank").optional(),
475
432
  staged: z.boolean().optional(),
@@ -503,34 +460,6 @@ export const CheckBoundarySchema = z.preprocess(
503
460
  );
504
461
  export type CheckBoundaryArgs = z.infer<typeof CheckBoundarySchema>;
505
462
 
506
- export const GetSymbolHotspotsSchema = z.preprocess(
507
- (args) =>
508
- withAliases(args, {
509
- domain_name: "domain",
510
- domainName: "domain",
511
- max: "limit",
512
- nesting: "min_nesting",
513
- minNesting: "min_nesting",
514
- lines: "min_lines",
515
- minLines: "min_lines",
516
- sortBy: "sort_by",
517
- workspace: "workspace_path",
518
- workspacePath: "workspace_path",
519
- project_root: "workspace_path",
520
- projectRoot: "workspace_path",
521
- }),
522
- z.object({
523
- min_lines: z.number().int().nonnegative().optional(),
524
- min_nesting: z.number().int().positive().optional(),
525
- kind: z.string().optional(),
526
- domain: z.string().optional(),
527
- limit: z.number().int().positive().optional().default(30),
528
- sort_by: z.enum(["lines", "nesting", "risk_score"]).optional(),
529
- workspace_path: z.string().optional(),
530
- })
531
- );
532
- export type GetSymbolHotspotsArgs = z.infer<typeof GetSymbolHotspotsSchema>;
533
-
534
463
  export function normalizeRegisterDomainArgs(raw: unknown): unknown {
535
464
  const coerced = extractSingleStringFallback(raw, "domain", [
536
465
  "root",
@@ -587,167 +516,12 @@ export const RegisterDomainSchema = z.preprocess(
587
516
  );
588
517
  export type RegisterDomainArgs = z.infer<typeof RegisterDomainSchema>;
589
518
 
590
- export function normalizeRegisterFeatureArgs(raw: unknown): unknown {
591
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
592
- const obj = { ...(raw as Record<string, unknown>) };
593
-
594
- const aliases: Record<string, string> = {
595
- feature: "feature_key",
596
- featureKey: "feature_key",
597
- feature_name: "feature_key",
598
- featureName: "feature_key",
599
- feat: "feature_key",
600
- name: "feature_key",
601
- key: "feature_key",
602
- domain_name: "domain",
603
- domainName: "domain",
604
- touchpoints: "allowed_touchpoints",
605
- allowedTouchpoints: "allowed_touchpoints",
606
- touchpoint: "allowed_touchpoints",
607
- files: "allowed_touchpoints",
608
- allowed_files: "allowed_touchpoints",
609
- reuseSymbols: "reuse_symbols",
610
- reuse: "reuse_symbols",
611
- symbols: "reuse_symbols",
612
- inputContract: "input_contract",
613
- outputContract: "output_contract",
614
- workspace: "workspace_path",
615
- workspacePath: "workspace_path",
616
- project_root: "workspace_path",
617
- projectRoot: "workspace_path",
618
- };
619
-
620
- for (const [alias, target] of Object.entries(aliases)) {
621
- if (obj[alias] !== undefined && obj[target] === undefined) {
622
- obj[target] = obj[alias];
623
- }
624
- }
625
-
626
- // Symmetrical contract: feature_key <-> feature
627
- if (obj.feature_key !== undefined && obj.feature === undefined) {
628
- obj.feature = obj.feature_key;
629
- } else if (obj.feature !== undefined && obj.feature_key === undefined) {
630
- obj.feature_key = obj.feature;
631
- }
632
-
633
- // Symmetrical contract: domain <-> domain_name
634
- if (obj.domain !== undefined && obj.domain_name === undefined) {
635
- obj.domain_name = obj.domain;
636
- } else if (obj.domain_name !== undefined && obj.domain === undefined) {
637
- obj.domain = obj.domain_name;
638
- }
639
-
640
- // Array coercion for allowed_touchpoints
641
- if (typeof obj.allowed_touchpoints === "string") {
642
- obj.allowed_touchpoints = [obj.allowed_touchpoints];
643
- } else if (!Array.isArray(obj.allowed_touchpoints) && obj.allowed_touchpoints !== undefined) {
644
- obj.allowed_touchpoints = [];
645
- }
646
-
647
- // Array coercion for reuse_symbols
648
- if (typeof obj.reuse_symbols === "string") {
649
- obj.reuse_symbols = [obj.reuse_symbols];
650
- }
651
-
652
- return obj;
653
- }
654
-
655
- export const RegisterFeatureSchema = z.preprocess(
656
- normalizeRegisterFeatureArgs,
657
- z.object({
658
- feature_key: z.string().min(1, "Feature key is required"),
659
- feature: z.string().optional(),
660
- domain: z.string().min(1, "Domain name is required"),
661
- domain_name: z.string().optional(),
662
- description: z.string().optional(),
663
- allowed_touchpoints: z.array(z.string()).default([]),
664
- reuse_symbols: z.array(z.string()).optional(),
665
- input_contract: z.record(z.unknown()).optional(),
666
- output_contract: z.record(z.unknown()).optional(),
667
- workspace_path: z.string().optional(),
668
- })
669
- );
670
- export type RegisterFeatureArgs = z.infer<typeof RegisterFeatureSchema>;
671
-
672
- function normalizeTopologyArgs(raw: unknown): unknown {
673
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
674
- const obj = withAliases(raw, {
675
- workspace: "workspace_path",
676
- workspacePath: "workspace_path",
677
- project_root: "workspace_path",
678
- projectRoot: "workspace_path",
679
- }) as Record<string, unknown>;
680
- if (obj.resolve_node !== undefined && obj.resolveNode === undefined) {
681
- obj.resolveNode = obj.resolve_node;
682
- }
683
- if (obj.resolve_layer !== undefined && obj.resolve === undefined) {
684
- obj.resolve = obj.resolve_layer;
685
- }
686
- if (obj.resolveLayer !== undefined && obj.resolve === undefined) {
687
- obj.resolve = obj.resolveLayer;
688
- }
689
- if (typeof obj.resolveNode === "object" && obj.resolveNode !== null) {
690
- obj.resolveNode = withAliases(obj.resolveNode, {
691
- canonicalTag: "canonical_tag",
692
- domainOrIp: "domain_or_ip",
693
- connectedTo: "connected_to",
694
- nodeId: "id",
695
- node_id: "id",
696
- nodeName: "name",
697
- node_name: "name",
698
- });
699
- }
700
- return obj;
701
- }
702
-
703
- export const GetEnvironmentTopologySchema = z.preprocess(
704
- (args) => normalizeTopologyArgs(args),
705
- z.object({
706
- resolve: z
707
- .object({
708
- layer: z.enum(["edge", "gateway", "host", "runtime", "storage", "telemetry"]),
709
- platform: z.string().min(1, "platform name cannot be empty"),
710
- constraints: z.array(z.string()).optional(),
711
- })
712
- .optional(),
713
- resolveNode: z
714
- .object({
715
- id: z.string().min(1, "Node id cannot be empty"),
716
- layer: z.enum(["edge", "gateway", "host", "runtime", "storage", "telemetry"]),
717
- name: z.string().min(1, "Node name cannot be empty"),
718
- platform: z.string().min(1, "Platform cannot be empty"),
719
- canonical_tag: z
720
- .enum([
721
- "shared_hosting",
722
- "vps",
723
- "docker",
724
- "serverless",
725
- "kubernetes",
726
- "managed_db",
727
- "cdn_edge",
728
- "paas",
729
- "static_cdn",
730
- "unspecified",
731
- ])
732
- .optional(),
733
- domain_or_ip: z.string().optional(),
734
- role: z.string().optional(),
735
- constraints: z.array(z.string()).optional(),
736
- connected_to: z.array(z.string()).optional(),
737
- })
738
- .optional(),
739
- refresh: z.boolean().optional().default(false),
740
- workspace_path: z.string().optional(),
741
- })
742
- );
743
- export type GetEnvironmentTopologyArgs = z.infer<typeof GetEnvironmentTopologySchema>;
744
-
745
519
  // =========================================================================
746
- // 5 UNIFIED TOOLS SCHEMAS & NORMALIZERS (Refactored Clean-Break MCP Engine)
520
+ // 4 UNIFIED TOOLS SCHEMAS & NORMALIZERS
747
521
  // =========================================================================
748
522
 
749
- // 1. septum_domain
750
- export function normalizeDomainToolArgs(raw: unknown): unknown {
523
+ // 1. septum_map
524
+ export function normalizeMapToolArgs(raw: unknown): unknown {
751
525
  const coerced = extractSingleStringFallback(raw, "domain", [
752
526
  "workspace_path",
753
527
  "workspacePath",
@@ -792,9 +566,6 @@ export function normalizeDomainToolArgs(raw: unknown): unknown {
792
566
  forbidden: "forbidden_dependencies",
793
567
  archetypes: "archetypes",
794
568
  ingestNow: "ingest_now",
795
- resolveLayer: "resolve",
796
- resolve_layer: "resolve",
797
- resolveNode: "resolve_node",
798
569
  workspace: "workspace_path",
799
570
  workspacePath: "workspace_path",
800
571
  project_root: "workspace_path",
@@ -817,23 +588,9 @@ export function normalizeDomainToolArgs(raw: unknown): unknown {
817
588
  obj.detail_level = "full";
818
589
  }
819
590
 
820
- if (typeof obj.resolve_node === "object" && obj.resolve_node !== null) {
821
- obj.resolve_node = withAliases(obj.resolve_node, {
822
- canonicalTag: "canonical_tag",
823
- domainOrIp: "domain_or_ip",
824
- connectedTo: "connected_to",
825
- nodeId: "id",
826
- node_id: "id",
827
- nodeName: "name",
828
- node_name: "name",
829
- });
830
- }
831
-
832
591
  if (!obj.action) {
833
592
  if (obj.root !== undefined || obj.ingest_now !== undefined) {
834
593
  obj.action = "register";
835
- } else if (obj.resolve !== undefined || obj.resolve_node !== undefined || obj.resolveNode !== undefined || obj.refresh !== undefined) {
836
- obj.action = "topology";
837
594
  } else {
838
595
  obj.action = "catalog";
839
596
  }
@@ -842,61 +599,30 @@ export function normalizeDomainToolArgs(raw: unknown): unknown {
842
599
  return obj;
843
600
  }
844
601
 
845
- export const DomainToolSchema = z.preprocess(
846
- normalizeDomainToolArgs,
602
+ export const MapToolSchema = z.preprocess(
603
+ normalizeMapToolArgs,
847
604
  z.object({
848
- action: z.enum(["catalog", "register", "topology"]).optional().default("catalog"),
605
+ action: z.enum(["catalog", "register"]).optional().default("catalog"),
849
606
  domain: z.string().optional(),
850
607
  name: z.string().optional(),
851
608
  detail_level: z.enum(["compact", "full"]).optional().default("compact"),
852
609
  archetype_filter: z.string().optional(),
853
610
  archetype: z.string().optional(),
854
611
  file_filter: z.string().optional(),
612
+ file_offset: z.number().int().nonnegative().optional(),
613
+ file_limit: z.number().int().min(1).max(100).optional(),
614
+ include_evidence: z.boolean().optional(),
615
+ include_capabilities: z.boolean().optional(),
855
616
  root: z.string().optional(),
856
617
  description: z.string().optional(),
857
618
  allowed_dependencies: z.array(z.string()).optional(),
858
619
  forbidden_dependencies: z.array(z.string()).optional(),
859
620
  archetypes: z.record(z.string()).optional(),
860
621
  ingest_now: z.boolean().optional().default(false),
861
- resolve: z
862
- .object({
863
- layer: z.enum(["edge", "gateway", "host", "runtime", "storage", "telemetry"]),
864
- platform: z.string().min(1, "platform name cannot be empty"),
865
- constraints: z.array(z.string()).optional(),
866
- })
867
- .optional(),
868
- resolve_node: z
869
- .object({
870
- id: z.string().min(1, "Node id cannot be empty"),
871
- layer: z.enum(["edge", "gateway", "host", "runtime", "storage", "telemetry"]),
872
- name: z.string().min(1, "Node name cannot be empty"),
873
- platform: z.string().min(1, "Platform cannot be empty"),
874
- canonical_tag: z
875
- .enum([
876
- "shared_hosting",
877
- "vps",
878
- "docker",
879
- "serverless",
880
- "kubernetes",
881
- "managed_db",
882
- "cdn_edge",
883
- "paas",
884
- "static_cdn",
885
- "unspecified",
886
- ])
887
- .optional(),
888
- domain_or_ip: z.string().optional(),
889
- role: z.string().optional(),
890
- constraints: z.array(z.string()).optional(),
891
- connected_to: z.array(z.string()).optional(),
892
- })
893
- .optional(),
894
- resolveNode: z.any().optional(),
895
- refresh: z.boolean().optional().default(false),
896
622
  workspace_path: z.string().optional(),
897
623
  })
898
624
  );
899
- export type DomainToolArgs = z.infer<typeof DomainToolSchema>;
625
+ export type MapToolArgs = z.infer<typeof MapToolSchema>;
900
626
 
901
627
  // 2. septum_symbol
902
628
  export function normalizeSymbolToolArgs(raw: unknown): unknown {
@@ -910,9 +636,8 @@ export function normalizeSymbolToolArgs(raw: unknown): unknown {
910
636
  "domain",
911
637
  "domain_name",
912
638
  "domainName",
913
- "min_lines",
914
- "min_nesting",
915
- "sort_by",
639
+ "file_path",
640
+ "filePath",
916
641
  "limit",
917
642
  ]);
918
643
  if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
@@ -930,11 +655,6 @@ export function normalizeSymbolToolArgs(raw: unknown): unknown {
930
655
  dependencies: "include_dependencies",
931
656
  deps: "include_dependencies",
932
657
  max: "limit",
933
- nesting: "min_nesting",
934
- minNesting: "min_nesting",
935
- lines: "min_lines",
936
- minLines: "min_lines",
937
- sortBy: "sort_by",
938
658
  workspace: "workspace_path",
939
659
  workspacePath: "workspace_path",
940
660
  project_root: "workspace_path",
@@ -942,6 +662,7 @@ export function normalizeSymbolToolArgs(raw: unknown): unknown {
942
662
  filePath: "file_path",
943
663
  sourceStartLine: "source_start_line",
944
664
  sourceLineLimit: "source_line_limit",
665
+ semanticDepth: "semantic_depth",
945
666
  }) as Record<string, unknown>;
946
667
 
947
668
  if (obj.query !== undefined && obj.symbol === undefined) {
@@ -951,10 +672,11 @@ export function normalizeSymbolToolArgs(raw: unknown): unknown {
951
672
  }
952
673
 
953
674
  if (!obj.action) {
954
- if (obj.min_lines !== undefined || obj.min_nesting !== undefined || obj.kind !== undefined || (obj.sort_by && !obj.query)) {
955
- obj.action = "hotspots";
956
- } else if (obj.include_dependencies !== undefined) {
957
- obj.action = "inspect";
675
+ if (obj.budget_bytes !== undefined || obj.continuation !== undefined || obj.context_mode !== undefined) {
676
+ obj.action = "context";
677
+ } else if (obj.include_dependencies !== undefined || obj.include_source !== undefined ||
678
+ obj.source_start_line !== undefined || obj.source_line_limit !== undefined) {
679
+ obj.action = "context";
958
680
  } else {
959
681
  obj.action = "locate";
960
682
  }
@@ -964,31 +686,41 @@ export function normalizeSymbolToolArgs(raw: unknown): unknown {
964
686
  obj.query = (obj.symbol_ref as Record<string, unknown>).name;
965
687
  obj.symbol = obj.query;
966
688
  }
689
+ if (obj.action === "inspect") obj.action = "context";
967
690
  return obj;
968
691
  }
969
692
 
970
693
  export const SymbolToolSchema = z.preprocess(
971
694
  normalizeSymbolToolArgs,
972
695
  z.object({
973
- action: z.enum(["locate", "inspect", "impact", "hotspots"]).optional().default("locate"),
696
+ action: z.enum(["locate", "inspect", "impact", "context"]).optional().default("locate"),
974
697
  query: z.string().optional(),
975
698
  symbol: z.string().optional(),
976
699
  domain: z.string().optional(),
977
700
  symbol_ref: SymbolReferenceSchema.optional(),
978
701
  include_dependencies: z.boolean().optional().default(true),
979
702
  limit: z.number().int().positive().optional(),
980
- min_lines: z.number().int().nonnegative().optional(),
981
- min_nesting: z.number().int().positive().optional(),
982
- kind: z.string().optional(),
983
- sort_by: z.enum(["lines", "nesting", "risk_score", "line_count"]).optional(),
984
703
  workspace_path: z.string().optional(),
985
704
  file_path: z.string().min(1).optional(),
986
- include_source: z.boolean().optional().default(false),
705
+ include_source: z.boolean().optional(),
987
706
  source_start_line: z.number().int().positive().optional(),
988
- source_line_limit: z.number().int().positive().max(200).optional().default(120),
707
+ source_line_limit: z.number().int().positive().max(200).optional(),
708
+ semantic_depth: z.number().int().min(1).max(2).optional(),
709
+ context_mode: z.enum(["deep", "source"]).optional(),
710
+ budget_bytes: z.number().int().min(2048).max(2 * 1024 * 1024).optional(),
711
+ continuation: z.string().min(1).max(4096).optional(),
989
712
  }).superRefine((args, ctx) => {
990
- if (args.symbol_ref && args.action !== "locate" && args.action !== "inspect" && args.action !== "impact") {
991
- ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["symbol_ref"], message: "symbol_ref is supported only for locate, inspect, and impact." });
713
+ if (args.symbol_ref && args.action !== "locate" && args.action !== "inspect" && args.action !== "impact" && args.action !== "context") {
714
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["symbol_ref"], message: "symbol_ref is supported only for locate, inspect, impact, and context." });
715
+ }
716
+ if (args.action !== "context" && (args.budget_bytes !== undefined || args.continuation !== undefined)) {
717
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["action"], message: "budget_bytes and continuation are supported only for context." });
718
+ }
719
+ if (args.context_mode !== undefined && args.action !== "context") {
720
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["context_mode"], message: "context_mode requires action='context' or its inspect alias." });
721
+ }
722
+ if (args.context_mode === "deep" && (args.include_source !== undefined || args.source_start_line !== undefined || args.source_line_limit !== undefined)) {
723
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["context_mode"], message: "Deep context does not accept bounded source options." });
992
724
  }
993
725
  })
994
726
  );
@@ -1002,104 +734,13 @@ export type SliceToolArgs = TraceVerticalSliceArgs;
1002
734
  export const BoundaryToolSchema = CheckBoundarySchema;
1003
735
  export type BoundaryToolArgs = CheckBoundaryArgs;
1004
736
 
1005
- // 5. septum_feature
1006
- export function normalizeFeatureToolArgs(raw: unknown): unknown {
1007
- const coerced = extractSingleStringFallback(raw, "feature_key", [
1008
- "workspace_path",
1009
- "workspacePath",
1010
- "workspace",
1011
- "project_root",
1012
- "projectRoot",
1013
- "action",
1014
- "domain",
1015
- "domain_name",
1016
- "domainName",
1017
- "force",
1018
- ]);
1019
- if (typeof coerced !== "object" || coerced === null || Array.isArray(coerced)) return coerced;
1020
- const obj = { ...(coerced as Record<string, unknown>) };
1021
-
1022
- const aliases: Record<string, string> = {
1023
- feature: "feature_key",
1024
- featureKey: "feature_key",
1025
- feature_name: "feature_key",
1026
- featureName: "feature_key",
1027
- feat: "feature_key",
1028
- name: "feature_key",
1029
- key: "feature_key",
1030
- domain_name: "domain",
1031
- domainName: "domain",
1032
- touchpoints: "allowed_touchpoints",
1033
- allowedTouchpoints: "allowed_touchpoints",
1034
- touchpoint: "allowed_touchpoints",
1035
- files: "allowed_touchpoints",
1036
- allowed_files: "allowed_touchpoints",
1037
- reuseSymbols: "reuse_symbols",
1038
- reuse: "reuse_symbols",
1039
- symbols: "reuse_symbols",
1040
- inputContract: "input_contract",
1041
- outputContract: "output_contract",
1042
- workspace: "workspace_path",
1043
- workspacePath: "workspace_path",
1044
- project_root: "workspace_path",
1045
- projectRoot: "workspace_path",
1046
- };
1047
-
1048
- for (const [alias, target] of Object.entries(aliases)) {
1049
- if (obj[alias] !== undefined && obj[target] === undefined) {
1050
- obj[target] = obj[alias];
1051
- }
1052
- }
1053
-
1054
- if (obj.feature_key !== undefined && obj.feature === undefined) {
1055
- obj.feature = obj.feature_key;
1056
- } else if (obj.feature !== undefined && obj.feature_key === undefined) {
1057
- obj.feature_key = obj.feature;
1058
- }
1059
-
1060
- if (obj.domain !== undefined && obj.domain_name === undefined) {
1061
- obj.domain_name = obj.domain;
1062
- } else if (obj.domain_name !== undefined && obj.domain === undefined) {
1063
- obj.domain = obj.domain_name;
1064
- }
1065
-
1066
- if (typeof obj.allowed_touchpoints === "string") {
1067
- obj.allowed_touchpoints = [obj.allowed_touchpoints];
1068
- } else if (!Array.isArray(obj.allowed_touchpoints) && obj.allowed_touchpoints !== undefined) {
1069
- obj.allowed_touchpoints = [];
1070
- }
1071
-
1072
- if (typeof obj.reuse_symbols === "string") {
1073
- obj.reuse_symbols = [obj.reuse_symbols];
1074
- }
1075
-
1076
- if (!obj.action) {
1077
- if (obj.allowed_touchpoints !== undefined || obj.domain !== undefined || obj.reuse_symbols !== undefined) {
1078
- obj.action = "lock";
1079
- } else {
1080
- obj.action = "get";
1081
- }
737
+ export function parseToolRequest(name: string, args: unknown) {
738
+ switch (name) {
739
+ case "septum_map": return { name, args: MapToolSchema.parse(args ?? {}) } as const;
740
+ case "septum_symbol": return { name, args: SymbolToolSchema.parse(args ?? {}) } as const;
741
+ case "septum_slice": return { name, args: SliceToolSchema.parse(args ?? {}) } as const;
742
+ case "septum_boundary": return { name, args: BoundaryToolSchema.parse(args ?? {}) } as const;
743
+ default: throw new Error(`Unknown tool: '${name}'`);
1082
744
  }
1083
-
1084
- return obj;
1085
745
  }
1086
746
 
1087
- export const FeatureToolSchema = z.preprocess(
1088
- normalizeFeatureToolArgs,
1089
- z.object({
1090
- action: z.enum(["get", "lock", "release"]).optional().default("get"),
1091
- feature_key: z.string().optional(),
1092
- feature: z.string().optional(),
1093
- domain: z.string().optional(),
1094
- domain_name: z.string().optional(),
1095
- description: z.string().optional(),
1096
- allowed_touchpoints: z.array(z.string()).optional(),
1097
- reuse_symbols: z.array(z.string()).optional(),
1098
- input_contract: z.record(z.unknown()).optional(),
1099
- output_contract: z.record(z.unknown()).optional(),
1100
- force: z.boolean().optional().default(false),
1101
- workspace_path: z.string().optional(),
1102
- })
1103
- );
1104
- export type FeatureToolArgs = z.infer<typeof FeatureToolSchema>;
1105
-