@dimassetoid/septum-mcp 0.0.0-stage → 0.2.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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -2
  3. package/bin/septum.ts +4 -0
  4. package/package.json +70 -4
  5. package/scripts/postinstall.ts +25 -0
  6. package/src/cli/commands/check.ts +122 -0
  7. package/src/cli/commands/hook.ts +268 -0
  8. package/src/cli/commands/init.ts +553 -0
  9. package/src/cli/commands/serve.ts +5 -0
  10. package/src/cli/commands/sync.ts +41 -0
  11. package/src/cli/commands/topology.ts +161 -0
  12. package/src/cli/index.ts +167 -0
  13. package/src/cli/scaffold/harness-config.ts +621 -0
  14. package/src/cli/templates/hooks.ts +75 -0
  15. package/src/cli/templates/rules.ts +50 -0
  16. package/src/cli/templates/skill.ts +51 -0
  17. package/src/cli/ui/prompts.ts +122 -0
  18. package/src/core/boundary/evaluator.ts +442 -0
  19. package/src/core/boundary/staged-auditor.ts +58 -0
  20. package/src/core/config/loader.ts +122 -0
  21. package/src/core/config/schema.ts +69 -0
  22. package/src/core/database/client.ts +60 -0
  23. package/src/core/database/repositories/dependency.repository.ts +712 -0
  24. package/src/core/database/repositories/domain.repository.ts +330 -0
  25. package/src/core/database/repositories/environment.repository.ts +207 -0
  26. package/src/core/database/repositories/file.repository.ts +117 -0
  27. package/src/core/database/repositories/meta.repository.ts +33 -0
  28. package/src/core/database/repositories/symbol.repository.ts +508 -0
  29. package/src/core/database/repository.ts +303 -0
  30. package/src/core/database/schema.ts +154 -0
  31. package/src/core/discovery/topology-detector.ts +805 -0
  32. package/src/core/ingestion/hasher.ts +5 -0
  33. package/src/core/ingestion/pipeline.ts +623 -0
  34. package/src/core/parser/behavioral-analyzer.ts +119 -0
  35. package/src/core/parser/boundary-tracker.ts +443 -0
  36. package/src/core/parser/extractors/base.ts +67 -0
  37. package/src/core/parser/extractors/blade.ts +159 -0
  38. package/src/core/parser/extractors/csharp.ts +244 -0
  39. package/src/core/parser/extractors/django-semantic.ts +687 -0
  40. package/src/core/parser/extractors/elysia-semantic.ts +538 -0
  41. package/src/core/parser/extractors/express-semantic.ts +444 -0
  42. package/src/core/parser/extractors/fastapi-semantic.ts +736 -0
  43. package/src/core/parser/extractors/fastify-semantic.ts +774 -0
  44. package/src/core/parser/extractors/flask-semantic.ts +515 -0
  45. package/src/core/parser/extractors/frontend.ts +149 -0
  46. package/src/core/parser/extractors/go-semantic.ts +611 -0
  47. package/src/core/parser/extractors/go.ts +491 -0
  48. package/src/core/parser/extractors/hono-semantic.ts +567 -0
  49. package/src/core/parser/extractors/java.ts +225 -0
  50. package/src/core/parser/extractors/laravel-semantic.ts +1122 -0
  51. package/src/core/parser/extractors/mcp-cli-semantic.ts +368 -0
  52. package/src/core/parser/extractors/nestjs-semantic.ts +543 -0
  53. package/src/core/parser/extractors/php.ts +569 -0
  54. package/src/core/parser/extractors/python.ts +498 -0
  55. package/src/core/parser/extractors/registry.ts +78 -0
  56. package/src/core/parser/extractors/ruby.ts +234 -0
  57. package/src/core/parser/extractors/rust.ts +286 -0
  58. package/src/core/parser/extractors/semantic-extractor.interface.ts +22 -0
  59. package/src/core/parser/extractors/symfony-semantic.ts +354 -0
  60. package/src/core/parser/extractors/typescript.ts +826 -0
  61. package/src/core/parser/language-capabilities.ts +71 -0
  62. package/src/core/parser/schema/providers/laravel-migration-provider.ts +216 -0
  63. package/src/core/parser/schema/providers/prisma-schema-provider.ts +90 -0
  64. package/src/core/parser/schema/schema-provider-registry.ts +43 -0
  65. package/src/core/parser/schema/schema-provider.interface.ts +33 -0
  66. package/src/core/parser/tree-sitter.ts +63 -0
  67. package/src/core/parser/wasm-assets.ts +25 -0
  68. package/src/core/parser/wasm-loader.ts +274 -0
  69. package/src/core/resolver/call-graph-tracer.ts +724 -0
  70. package/src/core/resolver/import-resolver.ts +437 -0
  71. package/src/core/resolver/module-resolver.ts +482 -0
  72. package/src/core/resolver/path-resolver.ts +200 -0
  73. package/src/core/resolver/symbol-locator.ts +276 -0
  74. package/src/core/resolver/symbol-reference.ts +53 -0
  75. package/src/core/resolver/vertical-slice-tracer.ts +366 -0
  76. package/src/core/resources/ignore.ts +123 -0
  77. package/src/core/resources/limits.ts +14 -0
  78. package/src/core/resources/source-files.ts +62 -0
  79. package/src/core/resources/work-queue.ts +74 -0
  80. package/src/core/session/session-manager.ts +107 -0
  81. package/src/core/telemetry/telemetry.ts +97 -0
  82. package/src/core/topology/environment-detector.ts +973 -0
  83. package/src/core/topology/types.ts +83 -0
  84. package/src/index.ts +21 -0
  85. package/src/mcp/schemas.ts +1105 -0
  86. package/src/mcp/server.ts +774 -0
  87. package/src/mcp/tools/boundary.ts +17 -0
  88. package/src/mcp/tools/check-boundary.ts +387 -0
  89. package/src/mcp/tools/domain.ts +40 -0
  90. package/src/mcp/tools/feature.ts +67 -0
  91. package/src/mcp/tools/get-domain-catalog.ts +226 -0
  92. package/src/mcp/tools/get-environment-topology.ts +138 -0
  93. package/src/mcp/tools/get-feature-context.ts +224 -0
  94. package/src/mcp/tools/get-symbol-hotspots.ts +54 -0
  95. package/src/mcp/tools/get-symbol-impact.ts +64 -0
  96. package/src/mcp/tools/get-symbol.ts +175 -0
  97. package/src/mcp/tools/locate-symbol.ts +196 -0
  98. package/src/mcp/tools/register-domain.ts +75 -0
  99. package/src/mcp/tools/register-feature.ts +110 -0
  100. package/src/mcp/tools/slice.ts +16 -0
  101. package/src/mcp/tools/symbol.ts +93 -0
  102. package/src/mcp/tools/trace-vertical-slice.ts +80 -0
  103. package/src/mcp/workspace-manager.ts +159 -0
  104. package/src/mcp/workspace-watcher.ts +202 -0
  105. package/src/types/index.ts +456 -0
  106. package/src/types/wasm.d.ts +4 -0
  107. package/src/utils/version-check.ts +209 -0
  108. package/src/version.ts +1 -0
@@ -0,0 +1,17 @@
1
+ import type { BoundaryEvaluator } from "../../core/boundary/evaluator.ts";
2
+ import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
3
+ import type { SeptumRepository } from "../../core/database/repository.ts";
4
+ import type { BoundaryToolArgs } from "../schemas.ts";
5
+ import { handleCheckBoundary } from "./check-boundary.ts";
6
+
7
+ export type { BoundaryToolArgs };
8
+
9
+ export async function handleBoundaryTool(
10
+ evaluator: BoundaryEvaluator,
11
+ config: ValidatedSeptumConfig,
12
+ args: BoundaryToolArgs,
13
+ repo?: SeptumRepository,
14
+ workspaceRoot?: string
15
+ ) {
16
+ return await handleCheckBoundary(evaluator, config, args as any, repo, workspaceRoot);
17
+ }
@@ -0,0 +1,387 @@
1
+ import { assertPathContained } from "../../core/resolver/path-resolver.ts";
2
+ import { readSourceFile } from "../../core/resources/source-files.ts";
3
+ import { computeContentHash } from "../../core/ingestion/hasher.ts";
4
+ import { relative, resolve } from "node:path";
5
+ import { auditStagedFiles } from "../../core/boundary/staged-auditor.ts";
6
+ import type { BoundaryEvaluator } from "../../core/boundary/evaluator.ts";
7
+ import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
8
+ import type { SeptumRepository } from "../../core/database/repository.ts";
9
+ import { SessionManager } from "../../core/session/session-manager.ts";
10
+ import type { BoundaryViolation } from "../../types/index.ts";
11
+ import { CheckBoundarySchema, type CheckBoundaryArgs } from "../schemas.ts";
12
+
13
+ export type { CheckBoundaryArgs } from "../schemas.ts";
14
+
15
+ export async function handleCheckBoundary(
16
+ evaluator: BoundaryEvaluator,
17
+ config: ValidatedSeptumConfig,
18
+ rawArgs: CheckBoundaryArgs & Record<string, unknown>,
19
+ repo?: SeptumRepository,
20
+ workspaceRoot?: string
21
+ ) {
22
+ const args = CheckBoundarySchema.parse(rawArgs ?? {});
23
+ if (args.domain) {
24
+ const domain = Object.keys(config.domains || {}).find(name => name.toLowerCase() === args.domain!.toLowerCase());
25
+ if (!domain) throw new Error(`Unknown boundary domain '${args.domain}'. Choose a registered domain.`);
26
+ args.domain = domain;
27
+ }
28
+ const root = workspaceRoot || args.workspace_path || process.cwd();
29
+ const proposedImports = args.proposed_imports ?? [];
30
+
31
+ const activeSession = SessionManager.getActiveSession(root);
32
+
33
+ let effectiveFeatureKey = args.feature_key;
34
+ if (activeSession) {
35
+ if (args.feature_key && args.feature_key !== activeSession.feature_key) {
36
+ throw new Error(
37
+ `Active feature lock is '${activeSession.feature_key}' (owner: ${activeSession.owner_id}). Cannot check boundaries for different feature '${args.feature_key}' while another feature is locked.`
38
+ );
39
+ }
40
+ effectiveFeatureKey = activeSession.feature_key;
41
+ if (!config.features) config.features = {};
42
+ if (!config.features[activeSession.feature_key]) {
43
+ config.features[activeSession.feature_key] = {
44
+ domain: activeSession.domain,
45
+ description: `Active session: ${activeSession.feature_key}`,
46
+ allowed_touchpoints: activeSession.touchpoints,
47
+ reuse_symbols: [],
48
+ input_contract: {},
49
+ output_contract: {},
50
+ };
51
+ }
52
+ }
53
+
54
+ const syncState = repo?.getMeta("sync_state");
55
+ const syncError = repo?.getMeta("sync_error");
56
+ if (!syncState || syncState === "running" || syncState === "error" || syncState !== "complete" || syncError) {
57
+ return {
58
+ content: [
59
+ {
60
+ type: "text" as const,
61
+ text: JSON.stringify({
62
+ status: "unknown",
63
+ sync_state: syncState || "unindexed",
64
+ sync_error: syncError || undefined,
65
+ message: "Boundary audit is incomplete because workspace synchronization has not completed.",
66
+ }),
67
+ },
68
+ ],
69
+ };
70
+ }
71
+ const skipped = JSON.parse(repo?.getMeta("skipped_files") || "[]") as {path: string; reason: string}[];
72
+ const unsupported = JSON.parse(repo?.getMeta("unsupported_files") || "[]") as string[];
73
+ const requested = [...(Array.isArray(args.file_path) ? args.file_path : args.file_path ? [args.file_path] : []), ...(args.file_paths || [])]
74
+ .map(file => relative(root, resolve(root, file)).replace(/\\/g, "/"));
75
+ const relevantUnsupported = unsupported.filter(file =>
76
+ (!args.domain || evaluator.resolveSourceDomain(file, config) === args.domain) &&
77
+ (requested.length === 0 || requested.includes(file))
78
+ );
79
+ const relevantSkipped = skipped.filter(file =>
80
+ (!args.domain || evaluator.resolveSourceDomain(file.path, config) === args.domain) &&
81
+ (requested.length === 0 || requested.includes(file.path))
82
+ );
83
+ if (relevantSkipped.length > 0 && args.scope !== "staged" && !args.staged) {
84
+ return { content: [{type: "text" as const, text: JSON.stringify({status: "unknown", skipped_files: relevantSkipped, message: "Boundary audit is incomplete because source files exceed resource limits."})}] };
85
+ }
86
+ if (relevantUnsupported.length > 0 && args.scope !== "staged" && !args.staged) {
87
+ return { content: [{ type: "text" as const, text: JSON.stringify({ status: "unknown", unsupported_files: relevantUnsupported, message: "Boundary audit is incomplete because source files have no supported parser." }) }] };
88
+ }
89
+
90
+ if (args.scope !== "staged" && !args.staged && repo) {
91
+ const relevant = (file: string) => (!args.domain || evaluator.resolveSourceDomain(file,config) === args.domain) && (requested.length === 0 || requested.includes(file));
92
+ const staleFiles = repo.getMeta("workspace_root") ? repo.getAllFiles().filter(file => relevant(file.path)).filter(file => {
93
+ try { assertPathContained(file.path,root,"Boundary source"); return computeContentHash(readSourceFile(resolve(root,file.path))) !== file.content_hash; }
94
+ catch { return true; }
95
+ }).map(file => file.path) : [];
96
+ const relationships = repo.getImportRelationships(root).filter(edge => relevant(edge.source.file));
97
+ const incomplete = relationships.filter(edge => edge.index_coverage === "partial" || edge.freshness !== "current" || !["resolved","external"].includes(edge.resolution.status) || edge.resolution.coverage === "conditional" || edge.target_domains.length > 1);
98
+ const proposed = requested.flatMap(file => proposedImports.map(target => evaluator.getResolver().resolveImport(target,file)))
99
+ .filter(result => !["resolved","external"].includes(result.status) || result.coverage === "conditional");
100
+ if (incomplete.length || proposed.length || staleFiles.length) {
101
+ const known = evaluator.auditCodebase(config).filter(violation => relevant(violation.file));
102
+ known.push(...requested.flatMap(file => evaluator.evaluate(file,proposedImports,effectiveFeatureKey,config)));
103
+ return { content: [{ type: "text" as const, text: JSON.stringify({
104
+ status: known.length ? "rejected" : "unknown", violations: known, total_violations: known.length,
105
+ circular_dependencies: known.filter(v => v.rule === "circular_dependency"), circular_dependencies_count: known.filter(v => v.rule === "circular_dependency").length, relationships: incomplete, proposed_resolutions: proposed,
106
+ stale_files: staleFiles,
107
+ message: "Relevant import resolution is incomplete; an empty graph cannot prove boundary approval.",
108
+ }) }] };
109
+ }
110
+ }
111
+
112
+ const filesToCheck: string[] = [];
113
+ if (args.file_paths && Array.isArray(args.file_paths) && args.file_paths.length > 0) {
114
+ filesToCheck.push(...args.file_paths);
115
+ } else if (args.file_path) {
116
+ if (Array.isArray(args.file_path)) {
117
+ filesToCheck.push(...args.file_path);
118
+ } else if (typeof args.file_path === "string" && args.file_path.trim().length > 0) {
119
+ filesToCheck.push(args.file_path.trim());
120
+ }
121
+ }
122
+
123
+ // Repo-wide, domain-scoped, or git-staged boundary audit when neither file_path nor file_paths is provided
124
+ if (filesToCheck.length === 0) {
125
+ const effectiveScope =
126
+ args.scope ?? (args.staged ? "staged" : args.domain ? "domain" : "all");
127
+
128
+ if (effectiveScope === "staged") {
129
+ const { files: stagedFiles, violations: stagedViolations, resolution_issues: resolutionIssues } = await auditStagedFiles(evaluator, config, root, effectiveFeatureKey, repo);
130
+
131
+ if (stagedFiles.length === 0 && stagedViolations.length === 0) {
132
+ return {
133
+ content: [
134
+ {
135
+ type: "text" as const,
136
+ text: JSON.stringify(
137
+ {
138
+ status: "approved",
139
+ scope: "staged",
140
+ total_checked: 0,
141
+ total_violations: 0,
142
+ circular_dependencies: [],
143
+ domain_violation_breakdown: {},
144
+ violations: [],
145
+ message: "No git staged files found. Boundary check passed.",
146
+ },
147
+ null,
148
+ 2
149
+ ),
150
+ },
151
+ ],
152
+ };
153
+ }
154
+
155
+ const filteredViolations = args.domain
156
+ ? stagedViolations.filter(
157
+ (v) =>
158
+ v.source_domain.toLowerCase() === args.domain!.toLowerCase() ||
159
+ v.target_domain.toLowerCase() === args.domain!.toLowerCase()
160
+ )
161
+ : stagedViolations;
162
+
163
+ const circularDependencies = filteredViolations.filter((v) => v.rule === "circular_dependency");
164
+ const domainBreakdown: Record<string, number> = {};
165
+ for (const v of filteredViolations) {
166
+ const pair = `${v.source_domain} -> ${v.target_domain}`;
167
+ domainBreakdown[pair] = (domainBreakdown[pair] || 0) + 1;
168
+ }
169
+
170
+ const hasViolations = filteredViolations.length > 0;
171
+ return {
172
+ content: [
173
+ {
174
+ type: "text" as const,
175
+ text: JSON.stringify(
176
+ {
177
+ status: hasViolations ? "rejected" : resolutionIssues.length ? "unknown" : "approved",
178
+ resolution_issues: resolutionIssues,
179
+ scope: "staged",
180
+ total_checked: stagedFiles.length,
181
+ total_violations: filteredViolations.length,
182
+ circular_dependencies_count: circularDependencies.length,
183
+ circular_dependencies: circularDependencies,
184
+ domain_violation_breakdown: domainBreakdown,
185
+ violations: filteredViolations,
186
+ message: resolutionIssues.length && !hasViolations ? "Staged import resolution is incomplete; approval is unknown." : hasViolations
187
+ ? `${filteredViolations.length} boundary violation(s) detected across ${stagedFiles.length} staged file(s).`
188
+ : `All ${stagedFiles.length} staged file(s) approved. No boundary violations detected.`,
189
+ },
190
+ null,
191
+ 2
192
+ ),
193
+ },
194
+ ],
195
+ };
196
+ }
197
+
198
+ // Scope: "all" or "domain"
199
+ if (args.feature_key) {
200
+ return {
201
+ content: [
202
+ {
203
+ type: "text" as const,
204
+ text: JSON.stringify(
205
+ {
206
+ status: "rejected",
207
+ scope: effectiveScope,
208
+ message: `Scope '${effectiveScope}' is an architectural audit across domains and does not support feature touchpoint validation ('feature_key'). Feature scopes only apply to 'file', 'batch', or 'staged'.`,
209
+ },
210
+ null,
211
+ 2
212
+ ),
213
+ },
214
+ ],
215
+ };
216
+ }
217
+
218
+ let violations = evaluator.auditCodebase(config);
219
+ if (args.domain) {
220
+ const targetDom = args.domain.toLowerCase();
221
+ violations = violations.filter(
222
+ (v) =>
223
+ v.source_domain.toLowerCase() === targetDom ||
224
+ v.target_domain.toLowerCase() === targetDom
225
+ );
226
+ }
227
+
228
+ const circularDependencies = violations.filter((v) => v.rule === "circular_dependency");
229
+ const domainBreakdown: Record<string, number> = {};
230
+ for (const v of violations) {
231
+ const pair = `${v.source_domain} -> ${v.target_domain}`;
232
+ domainBreakdown[pair] = (domainBreakdown[pair] || 0) + 1;
233
+ }
234
+
235
+ const hasViolations = violations.length > 0;
236
+ const domainCount = Object.keys(config?.domains || {}).length;
237
+
238
+ return {
239
+ content: [
240
+ {
241
+ type: "text" as const,
242
+ text: JSON.stringify(
243
+ {
244
+ status: hasViolations ? "rejected" : "approved",
245
+ scope: args.domain ? "domain" : "all",
246
+ ...(args.domain ? { domain: args.domain } : {}),
247
+ total_domains_checked: domainCount,
248
+ total_violations: violations.length,
249
+ circular_dependencies_count: circularDependencies.length,
250
+ circular_dependencies: circularDependencies,
251
+ domain_violation_breakdown: domainBreakdown,
252
+ violations,
253
+ message: hasViolations
254
+ ? `${violations.length} boundary violation(s) (${circularDependencies.length} circular) detected${
255
+ args.domain ? ` in domain '${args.domain}'` : " across codebase"
256
+ }.`
257
+ : domainCount === 0
258
+ ? "No boundary violations detected. [Septum Notice: Domain catalog is currently unindexed. Run 'septum_domain' with action='register' to initialize bounded contexts.]"
259
+ : `All domain boundaries are clean${
260
+ args.domain ? ` for domain '${args.domain}'` : ""
261
+ }. Zero cross-domain leaks or circular dependencies detected.`,
262
+ },
263
+ null,
264
+ 2
265
+ ),
266
+ },
267
+ ],
268
+ };
269
+ }
270
+
271
+ // Multi-file batch evaluation
272
+ if (filesToCheck.length > 1) {
273
+ const results = filesToCheck.map((filePath) => {
274
+ const violations = evaluator.evaluate(filePath, proposedImports, effectiveFeatureKey, config);
275
+ const impact = repo?.getFileInboundImpact(filePath);
276
+ return {
277
+ file: filePath,
278
+ status: violations.length > 0 ? "rejected" : "approved",
279
+ violations,
280
+ impact_summary: impact
281
+ ? {
282
+ direct_dependents: impact.direct_dependents_count,
283
+ top_consumers: impact.top_consumers,
284
+ symbols_count: impact.symbols_count,
285
+ risk_level: impact.risk_level,
286
+ }
287
+ : undefined,
288
+ };
289
+ });
290
+
291
+ const totalViolations = results.reduce((acc, r) => acc + r.violations.length, 0);
292
+ const hasViolations = totalViolations > 0;
293
+
294
+ return {
295
+ content: [
296
+ {
297
+ type: "text" as const,
298
+ text: JSON.stringify(
299
+ {
300
+ status: hasViolations ? "rejected" : "approved",
301
+ total_checked: filesToCheck.length,
302
+ total_violations: totalViolations,
303
+ results,
304
+ message: hasViolations
305
+ ? `${totalViolations} boundary violation(s) detected across ${filesToCheck.length} file(s).`
306
+ : Object.keys(config?.domains || {}).length === 0
307
+ ? `All ${filesToCheck.length} file(s) approved. [Septum Notice: Domain catalog is currently unindexed. Run 'septum_domain' with action='register' to initialize bounded contexts.]`
308
+ : `All ${filesToCheck.length} file(s) approved. No boundary violations detected.`,
309
+ },
310
+ null,
311
+ 2
312
+ ),
313
+ },
314
+ ],
315
+ };
316
+ }
317
+
318
+ // Single file evaluation (backward-compatible output)
319
+ const singleFile = filesToCheck[0];
320
+ const violations = evaluator.evaluate(singleFile, proposedImports, effectiveFeatureKey, config);
321
+ const impact = repo?.getFileInboundImpact(singleFile);
322
+
323
+ if (violations.length > 0) {
324
+ return {
325
+ content: [
326
+ {
327
+ type: "text" as const,
328
+ text: JSON.stringify(
329
+ {
330
+ status: "rejected",
331
+ file: singleFile,
332
+ violations_count: violations.length,
333
+ violations,
334
+ impact_summary: impact
335
+ ? {
336
+ direct_dependents: impact.direct_dependents_count,
337
+ top_consumers: impact.top_consumers,
338
+ symbols_count: impact.symbols_count,
339
+ risk_level: impact.risk_level,
340
+ }
341
+ : undefined,
342
+ message:
343
+ Object.keys(config?.domains || {}).length === 0
344
+ ? "Boundary integrity check failed: Domain catalog is currently unindexed. Run 'septum_domain' with action='register' to initialize bounded contexts."
345
+ : violations.some((v) => v.rule === "unmapped_domain")
346
+ ? "Boundary integrity check failed: File does not belong to any declared bounded context."
347
+ : "Boundary violation detected. Proposed imports violate bounded context architecture.",
348
+ },
349
+ null,
350
+ 2
351
+ ),
352
+ },
353
+ ],
354
+ };
355
+ }
356
+
357
+ return {
358
+ content: [
359
+ {
360
+ type: "text" as const,
361
+ text: JSON.stringify(
362
+ {
363
+ status: "approved",
364
+ file: singleFile,
365
+ impact_summary: impact
366
+ ? {
367
+ direct_dependents: impact.direct_dependents_count,
368
+ top_consumers: impact.top_consumers,
369
+ symbols_count: impact.symbols_count,
370
+ risk_level: impact.risk_level,
371
+ }
372
+ : undefined,
373
+ message:
374
+ Object.keys(config?.domains || {}).length === 0
375
+ ? "No boundary violations detected. [Septum Notice: Domain catalog is currently unindexed. Run 'septum_domain' with action='register' to initialize bounded contexts.]"
376
+ : impact && impact.direct_dependents_count > 0
377
+ ? `No boundary violations detected. Caution: ${impact.direct_dependents_count} dependent file(s) consume this file.`
378
+ : "No boundary violations detected. Proposed imports are permissible.",
379
+ },
380
+ null,
381
+ 2
382
+ ),
383
+ },
384
+ ],
385
+ };
386
+ }
387
+
@@ -0,0 +1,40 @@
1
+ import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
2
+ import type { SeptumRepository } from "../../core/database/repository.ts";
3
+ import type { DomainToolArgs } from "../schemas.ts";
4
+ import { handleGetDomainCatalog } from "./get-domain-catalog.ts";
5
+ import { handleRegisterDomain } from "./register-domain.ts";
6
+ import { handleGetEnvironmentTopology } from "./get-environment-topology.ts";
7
+
8
+ export type { DomainToolArgs };
9
+
10
+ export async function handleDomainTool(
11
+ repo: SeptumRepository,
12
+ config: ValidatedSeptumConfig,
13
+ args: DomainToolArgs,
14
+ workspaceRoot?: string,
15
+ signal?: AbortSignal
16
+ ) {
17
+ const action = args.action || "catalog";
18
+
19
+ switch (action) {
20
+ case "register":
21
+ return await handleRegisterDomain(repo, config, args, workspaceRoot, signal);
22
+
23
+ case "topology":
24
+ return handleGetEnvironmentTopology(
25
+ repo,
26
+ config,
27
+ {
28
+ resolve: args.resolve,
29
+ resolveNode: args.resolve_node,
30
+ refresh: args.refresh,
31
+ workspace_path: args.workspace_path,
32
+ },
33
+ workspaceRoot || args.workspace_path || process.cwd()
34
+ );
35
+
36
+ case "catalog":
37
+ default:
38
+ return handleGetDomainCatalog(repo, config, args, workspaceRoot);
39
+ }
40
+ }
@@ -0,0 +1,67 @@
1
+ import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
2
+ import type { SeptumRepository } from "../../core/database/repository.ts";
3
+ import type { FeatureToolArgs } from "../schemas.ts";
4
+ import { handleGetFeatureContext, handleClearFeatureContext } from "./get-feature-context.ts";
5
+ import { handleRegisterFeature } from "./register-feature.ts";
6
+
7
+ export type { FeatureToolArgs };
8
+
9
+ export async function handleFeatureTool(
10
+ repo: SeptumRepository,
11
+ config: ValidatedSeptumConfig,
12
+ args: FeatureToolArgs,
13
+ workspaceRoot?: string
14
+ ) {
15
+ const action = args.action || "get";
16
+
17
+ switch (action) {
18
+ case "lock":
19
+ return await handleRegisterFeature(
20
+ repo,
21
+ config,
22
+ {
23
+ feature_key: args.feature_key || args.feature || "",
24
+ feature: args.feature || args.feature_key || "",
25
+ domain: args.domain || args.domain_name || "",
26
+ domain_name: args.domain_name || args.domain || "",
27
+ description: args.description,
28
+ allowed_touchpoints: args.allowed_touchpoints,
29
+ reuse_symbols: args.reuse_symbols,
30
+ input_contract: args.input_contract,
31
+ output_contract: args.output_contract,
32
+ workspace_path: args.workspace_path,
33
+ },
34
+ workspaceRoot || args.workspace_path || process.cwd()
35
+ );
36
+
37
+ case "release": {
38
+ const cleared = handleClearFeatureContext(
39
+ workspaceRoot || args.workspace_path || process.cwd(),
40
+ Boolean(args.force)
41
+ );
42
+ return {
43
+ content: [
44
+ {
45
+ type: "text" as const,
46
+ text: cleared
47
+ ? "Active feature session successfully released."
48
+ : "No active feature session found to release.",
49
+ },
50
+ ],
51
+ };
52
+ }
53
+
54
+ case "get":
55
+ default:
56
+ return handleGetFeatureContext(
57
+ repo,
58
+ config,
59
+ {
60
+ feature_key: args.feature_key || args.feature,
61
+ feature: args.feature || args.feature_key,
62
+ workspace_path: args.workspace_path,
63
+ },
64
+ workspaceRoot || args.workspace_path || process.cwd()
65
+ );
66
+ }
67
+ }