septum 0.1.4 → 0.1.5
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/LICENSE +21 -21
- package/README.md +105 -105
- package/bin/septum.ts +4 -4
- package/package.json +63 -63
- package/src/cli/commands/check.ts +161 -161
- package/src/cli/commands/hook.ts +188 -188
- package/src/cli/commands/ingest.ts +29 -29
- package/src/cli/commands/init.ts +211 -211
- package/src/cli/commands/locate.ts +61 -61
- package/src/cli/commands/query.ts +64 -64
- package/src/cli/commands/serve.ts +5 -5
- package/src/cli/commands/slice.ts +48 -48
- package/src/cli/commands/sync.ts +31 -31
- package/src/cli/index.ts +210 -210
- package/src/cli/templates/hooks.ts +75 -75
- package/src/cli/templates/rules.ts +38 -38
- package/src/cli/templates/skill.ts +69 -69
- package/src/core/boundary/evaluator.ts +232 -210
- package/src/core/config/loader.ts +97 -97
- package/src/core/config/schema.ts +39 -39
- package/src/core/database/client.ts +44 -44
- package/src/core/database/repositories/dependency.repository.ts +366 -349
- package/src/core/database/repositories/domain.repository.ts +218 -198
- package/src/core/database/repositories/file.repository.ts +116 -106
- package/src/core/database/repositories/meta.repository.ts +33 -33
- package/src/core/database/repositories/symbol.repository.ts +443 -443
- package/src/core/database/repository.ts +264 -260
- package/src/core/database/schema.ts +153 -153
- package/src/core/discovery/topology-detector.ts +486 -486
- package/src/core/ingestion/hasher.ts +5 -5
- package/src/core/ingestion/pipeline.ts +584 -535
- package/src/core/parser/boundary-tracker.ts +288 -288
- package/src/core/parser/extractors/base.ts +62 -62
- package/src/core/parser/extractors/blade.ts +158 -158
- package/src/core/parser/extractors/frontend.ts +194 -194
- package/src/core/parser/extractors/go.ts +229 -180
- package/src/core/parser/extractors/laravel-semantic.ts +1039 -901
- package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
- package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
- package/src/core/parser/extractors/php.ts +153 -153
- package/src/core/parser/extractors/python.ts +228 -228
- package/src/core/parser/extractors/registry.ts +70 -70
- package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
- package/src/core/parser/extractors/typescript.ts +181 -181
- package/src/core/parser/tree-sitter.ts +41 -41
- package/src/core/resolver/call-graph-tracer.ts +666 -668
- package/src/core/resolver/module-resolver.ts +408 -342
- package/src/core/resolver/path-resolver.ts +147 -147
- package/src/core/resolver/symbol-locator.ts +543 -543
- package/src/core/resolver/vertical-slice-tracer.ts +301 -285
- package/src/core/session/session-manager.ts +56 -56
- package/src/core/telemetry/telemetry.ts +86 -86
- package/src/index.ts +21 -21
- package/src/mcp/schemas.ts +578 -286
- package/src/mcp/server.ts +875 -716
- package/src/mcp/tools/check-boundary.ts +171 -152
- package/src/mcp/tools/get-domain-catalog.ts +145 -121
- package/src/mcp/tools/get-feature-context.ts +212 -116
- package/src/mcp/tools/get-symbol-hotspots.ts +60 -59
- package/src/mcp/tools/get-symbol-impact.ts +28 -26
- package/src/mcp/tools/get-symbol.ts +65 -63
- package/src/mcp/tools/locate-symbol.ts +171 -190
- package/src/mcp/tools/register-domain.ts +68 -64
- package/src/mcp/tools/register-feature.ts +100 -0
- package/src/mcp/tools/trace-vertical-slice.ts +74 -48
- package/src/types/index.ts +335 -315
- package/src/version.ts +3 -3
|
@@ -1,152 +1,171 @@
|
|
|
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
|
-
|
|
5
|
-
export interface CheckBoundaryArgs {
|
|
6
|
-
file_path?: string;
|
|
7
|
-
filePath?: string;
|
|
8
|
-
file?: string;
|
|
9
|
-
path?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
+
|
|
5
|
+
export interface CheckBoundaryArgs {
|
|
6
|
+
file_path?: string;
|
|
7
|
+
filePath?: string;
|
|
8
|
+
file?: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
from_file?: string;
|
|
11
|
+
fromFile?: string;
|
|
12
|
+
to_file?: string | string[];
|
|
13
|
+
toFile?: string | string[];
|
|
14
|
+
file_paths?: string[];
|
|
15
|
+
filePaths?: string[];
|
|
16
|
+
files?: string[];
|
|
17
|
+
paths?: string[];
|
|
18
|
+
proposed_imports?: string[];
|
|
19
|
+
proposedImports?: string[];
|
|
20
|
+
imports?: string[];
|
|
21
|
+
feature_key?: string;
|
|
22
|
+
featureKey?: string;
|
|
23
|
+
feature?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function handleCheckBoundary(
|
|
27
|
+
evaluator: BoundaryEvaluator,
|
|
28
|
+
config: ValidatedSeptumConfig,
|
|
29
|
+
args: CheckBoundaryArgs,
|
|
30
|
+
repo?: SeptumRepository,
|
|
31
|
+
_workspaceRoot?: string
|
|
32
|
+
) {
|
|
33
|
+
const rawToFile = args.to_file ?? args.toFile;
|
|
34
|
+
const toFileImports = rawToFile ? (Array.isArray(rawToFile) ? rawToFile.map(String) : [String(rawToFile)]) : [];
|
|
35
|
+
const rawFilePaths = args.file_paths ?? args.filePaths ?? args.files ?? args.paths;
|
|
36
|
+
const rawFilePath = args.file_path ?? args.filePath ?? args.file ?? args.path ?? args.from_file ?? args.fromFile;
|
|
37
|
+
const proposedImports = [
|
|
38
|
+
...(args.proposed_imports ?? args.proposedImports ?? args.imports ?? []),
|
|
39
|
+
...toFileImports,
|
|
40
|
+
];
|
|
41
|
+
const featureKey = args.feature_key ?? args.featureKey ?? args.feature;
|
|
42
|
+
|
|
43
|
+
const filesToCheck: string[] = [];
|
|
44
|
+
if (rawFilePaths && Array.isArray(rawFilePaths) && rawFilePaths.length > 0) {
|
|
45
|
+
filesToCheck.push(...rawFilePaths);
|
|
46
|
+
} else if (rawFilePath) {
|
|
47
|
+
if (Array.isArray(rawFilePath)) {
|
|
48
|
+
filesToCheck.push(...rawFilePath);
|
|
49
|
+
} else {
|
|
50
|
+
filesToCheck.push(rawFilePath);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error("Missing required argument: specify either 'file_path' or 'file_paths'");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Multi-file batch evaluation
|
|
57
|
+
if (filesToCheck.length > 1) {
|
|
58
|
+
const results = filesToCheck.map((filePath) => {
|
|
59
|
+
const violations = evaluator.evaluate(filePath, proposedImports, featureKey, config);
|
|
60
|
+
const impact = repo?.getFileInboundImpact(filePath);
|
|
61
|
+
return {
|
|
62
|
+
file: filePath,
|
|
63
|
+
status: violations.length > 0 ? "rejected" : "approved",
|
|
64
|
+
violations,
|
|
65
|
+
impact_summary: impact
|
|
66
|
+
? {
|
|
67
|
+
direct_dependents: impact.direct_dependents_count,
|
|
68
|
+
top_consumers: impact.top_consumers,
|
|
69
|
+
symbols_count: impact.symbols_count,
|
|
70
|
+
risk_level: impact.risk_level,
|
|
71
|
+
}
|
|
72
|
+
: undefined,
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const totalViolations = results.reduce((acc, r) => acc + r.violations.length, 0);
|
|
77
|
+
const hasViolations = totalViolations > 0;
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: "text" as const,
|
|
83
|
+
text: JSON.stringify(
|
|
84
|
+
{
|
|
85
|
+
status: hasViolations ? "rejected" : "approved",
|
|
86
|
+
total_checked: filesToCheck.length,
|
|
87
|
+
total_violations: totalViolations,
|
|
88
|
+
results,
|
|
89
|
+
message: hasViolations
|
|
90
|
+
? `${totalViolations} boundary violation(s) detected across ${filesToCheck.length} file(s).`
|
|
91
|
+
: Object.keys(config?.domains || {}).length === 0
|
|
92
|
+
? `All ${filesToCheck.length} file(s) approved. [Septum Notice: Domain catalog is currently unindexed. Run 'septum_register_domain' to initialize bounded contexts.]`
|
|
93
|
+
: `All ${filesToCheck.length} file(s) approved. No boundary violations detected.`,
|
|
94
|
+
},
|
|
95
|
+
null,
|
|
96
|
+
2
|
|
97
|
+
),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Single file evaluation (backward-compatible output)
|
|
104
|
+
const singleFile = filesToCheck[0];
|
|
105
|
+
const violations = evaluator.evaluate(singleFile, proposedImports, featureKey, config);
|
|
106
|
+
const impact = repo?.getFileInboundImpact(singleFile);
|
|
107
|
+
|
|
108
|
+
if (violations.length > 0) {
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: "text" as const,
|
|
113
|
+
text: JSON.stringify(
|
|
114
|
+
{
|
|
115
|
+
status: "rejected",
|
|
116
|
+
file: singleFile,
|
|
117
|
+
violations_count: violations.length,
|
|
118
|
+
violations,
|
|
119
|
+
impact_summary: impact
|
|
120
|
+
? {
|
|
121
|
+
direct_dependents: impact.direct_dependents_count,
|
|
122
|
+
top_consumers: impact.top_consumers,
|
|
123
|
+
symbols_count: impact.symbols_count,
|
|
124
|
+
risk_level: impact.risk_level,
|
|
125
|
+
}
|
|
126
|
+
: undefined,
|
|
127
|
+
message:
|
|
128
|
+
Object.keys(config?.domains || {}).length === 0
|
|
129
|
+
? "Boundary integrity check failed: Domain catalog is currently unindexed. Run 'septum_register_domain' to initialize bounded contexts."
|
|
130
|
+
: violations.some((v) => v.rule === "unmapped_domain")
|
|
131
|
+
? "Boundary integrity check failed: File does not belong to any declared bounded context."
|
|
132
|
+
: "Boundary violation detected. Proposed imports violate bounded context architecture.",
|
|
133
|
+
},
|
|
134
|
+
null,
|
|
135
|
+
2
|
|
136
|
+
),
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
content: [
|
|
144
|
+
{
|
|
145
|
+
type: "text" as const,
|
|
146
|
+
text: JSON.stringify(
|
|
147
|
+
{
|
|
148
|
+
status: "approved",
|
|
149
|
+
file: singleFile,
|
|
150
|
+
impact_summary: impact
|
|
151
|
+
? {
|
|
152
|
+
direct_dependents: impact.direct_dependents_count,
|
|
153
|
+
top_consumers: impact.top_consumers,
|
|
154
|
+
symbols_count: impact.symbols_count,
|
|
155
|
+
risk_level: impact.risk_level,
|
|
156
|
+
}
|
|
157
|
+
: undefined,
|
|
158
|
+
message:
|
|
159
|
+
Object.keys(config?.domains || {}).length === 0
|
|
160
|
+
? "No boundary violations detected. [Septum Notice: Domain catalog is currently unindexed. Run 'septum_register_domain' to initialize bounded contexts.]"
|
|
161
|
+
: impact && impact.direct_dependents_count > 0
|
|
162
|
+
? `No boundary violations detected. Caution: ${impact.direct_dependents_count} dependent file(s) consume this file.`
|
|
163
|
+
: "No boundary violations detected. Proposed imports are permissible.",
|
|
164
|
+
},
|
|
165
|
+
null,
|
|
166
|
+
2
|
|
167
|
+
),
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -1,121 +1,145 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
4
|
-
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
5
|
-
|
|
6
|
-
export interface GetDomainCatalogArgs {
|
|
7
|
-
domain?: string;
|
|
8
|
-
archetype_filter?: string;
|
|
9
|
-
workspace_path?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function handleGetDomainCatalog(
|
|
13
|
-
repo: SeptumRepository,
|
|
14
|
-
config: ValidatedSeptumConfig,
|
|
15
|
-
args: GetDomainCatalogArgs,
|
|
16
|
-
workspaceRoot?: string
|
|
17
|
-
) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
4
|
+
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
5
|
+
|
|
6
|
+
export interface GetDomainCatalogArgs {
|
|
7
|
+
domain?: string;
|
|
8
|
+
archetype_filter?: string;
|
|
9
|
+
workspace_path?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function handleGetDomainCatalog(
|
|
13
|
+
repo: SeptumRepository,
|
|
14
|
+
config: ValidatedSeptumConfig,
|
|
15
|
+
args: GetDomainCatalogArgs,
|
|
16
|
+
workspaceRoot?: string
|
|
17
|
+
) {
|
|
18
|
+
const targetRoot = args.workspace_path || workspaceRoot || (repo as any)?.projectRoot || process.cwd();
|
|
19
|
+
|
|
20
|
+
if (!args.domain) {
|
|
21
|
+
const allDomains = repo.getAllDomains();
|
|
22
|
+
if (allDomains.length === 0) {
|
|
23
|
+
const root = targetRoot;
|
|
24
|
+
const diagnostic = {
|
|
25
|
+
status: "NOT_INDEXED",
|
|
26
|
+
total_domains: 0,
|
|
27
|
+
message: `Workspace '${root}' belum memiliki domain terdaftar dalam Septum catalog.`,
|
|
28
|
+
suggested_action: {
|
|
29
|
+
tool: "septum_register_domain",
|
|
30
|
+
params: {
|
|
31
|
+
name: "core",
|
|
32
|
+
root: "src",
|
|
33
|
+
ingest_now: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
agent_guidance:
|
|
37
|
+
"Panggil tool 'septum_register_domain(name: \"core\", root: \"src\", ingest_now: true)' untuk mendaftarkan dan mengindeks domain utama secara otomatis, atau jalankan 'septum init' di terminal workspace.",
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: "text" as const,
|
|
43
|
+
text: JSON.stringify(diagnostic, null, 2),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
metadata: diagnostic,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const projectType = repo.getMeta("project_type") || "generic";
|
|
51
|
+
const framework = repo.getMeta("framework") || "unknown";
|
|
52
|
+
const archStyle = repo.getMeta("architecture_style") || "modular";
|
|
53
|
+
const totalSlices = repo.getAllVerticalSlices().length;
|
|
54
|
+
|
|
55
|
+
const macroMap = {
|
|
56
|
+
telescope_view: {
|
|
57
|
+
project_type: projectType,
|
|
58
|
+
framework,
|
|
59
|
+
architecture_style: archStyle,
|
|
60
|
+
total_domains: allDomains.length,
|
|
61
|
+
total_vertical_slices: totalSlices,
|
|
62
|
+
},
|
|
63
|
+
domains: allDomains.map((d) => ({
|
|
64
|
+
name: d.name,
|
|
65
|
+
root: d.root_path,
|
|
66
|
+
archetypes: Object.keys(JSON.parse(d.archetypes_json || "{}")),
|
|
67
|
+
allowed_dependencies: JSON.parse(d.allowed_deps_json || "[]"),
|
|
68
|
+
forbidden_dependencies: JSON.parse(d.forbidden_deps_json || "[]"),
|
|
69
|
+
})),
|
|
70
|
+
agent_instruction:
|
|
71
|
+
"Macro semantic map loaded from SQLite SSOT. Use 'septum_get_domain_catalog' with domain='<name>' for granular file/symbol catalogs, or 'septum_trace_vertical_slice' with query='<route|command|intent>' for end-to-end execution flow.",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
content: [
|
|
76
|
+
{
|
|
77
|
+
type: "text" as const,
|
|
78
|
+
text: JSON.stringify(macroMap, null, 2),
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const catalog = repo.getDomainCatalog(args.domain, args.archetype_filter);
|
|
85
|
+
if (!catalog) {
|
|
86
|
+
const available = Object.keys(config.domains || {});
|
|
87
|
+
const suggestions = available.filter((d) =>
|
|
88
|
+
d.toLowerCase().includes(args.domain!.toLowerCase()) ||
|
|
89
|
+
args.domain!.toLowerCase().includes(d.toLowerCase())
|
|
90
|
+
);
|
|
91
|
+
const notFoundPayload = {
|
|
92
|
+
status: "not_found",
|
|
93
|
+
found: false,
|
|
94
|
+
domain: args.domain,
|
|
95
|
+
message: `Domain '${args.domain}' not found in Septum catalog.`,
|
|
96
|
+
available_domains: available,
|
|
97
|
+
suggestions: suggestions.length > 0 ? suggestions : available,
|
|
98
|
+
suggested_action: {
|
|
99
|
+
tool: "septum_register_domain",
|
|
100
|
+
params: { domain: args.domain, root: `src/domains/${args.domain}` },
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
content: [
|
|
105
|
+
{
|
|
106
|
+
type: "text" as const,
|
|
107
|
+
text: JSON.stringify(notFoundPayload, null, 2),
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
metadata: notFoundPayload,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Record access log for Gate 3 (Mandatory Catalog Consultation)
|
|
115
|
+
recordCatalogAccess(args.domain, targetRoot);
|
|
116
|
+
|
|
117
|
+
// Token-efficient serialization: keep payload dense and under 500 tokens
|
|
118
|
+
return {
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
type: "text" as const,
|
|
122
|
+
text: JSON.stringify(catalog, null, 2),
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function recordCatalogAccess(domain: string, projectRoot: string = process.cwd()): void {
|
|
129
|
+
try {
|
|
130
|
+
const septumDir = path.resolve(projectRoot, ".septum");
|
|
131
|
+
if (!fs.existsSync(septumDir)) {
|
|
132
|
+
fs.mkdirSync(septumDir, { recursive: true });
|
|
133
|
+
}
|
|
134
|
+
const logPath = path.join(septumDir, "catalog_access.json");
|
|
135
|
+
let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
|
|
136
|
+
if (fs.existsSync(logPath)) {
|
|
137
|
+
try {
|
|
138
|
+
log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
|
|
139
|
+
} catch {}
|
|
140
|
+
}
|
|
141
|
+
log.domains = log.domains || {};
|
|
142
|
+
log.domains[domain] = new Date().toISOString();
|
|
143
|
+
fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
|
|
144
|
+
} catch {}
|
|
145
|
+
}
|