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,56 +1,56 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import type { ActiveFeatureSession } from "../../types/index.ts";
|
|
4
|
-
|
|
5
|
-
export class SessionManager {
|
|
6
|
-
private static readonly SESSION_FILE = ".septum/session.json";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Save the active feature session to .septum/session.json
|
|
10
|
-
*/
|
|
11
|
-
public static saveActiveSession(workspaceRoot: string, session: ActiveFeatureSession): void {
|
|
12
|
-
const septumDir = join(workspaceRoot, ".septum");
|
|
13
|
-
if (!existsSync(septumDir)) {
|
|
14
|
-
mkdirSync(septumDir, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
17
|
-
writeFileSync(sessionPath, JSON.stringify(session, null, 2), "utf-8");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get the active feature session, or null if no session exists or file is invalid
|
|
22
|
-
*/
|
|
23
|
-
public static getActiveSession(workspaceRoot: string): ActiveFeatureSession | null {
|
|
24
|
-
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
25
|
-
if (!existsSync(sessionPath)) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const raw = readFileSync(sessionPath, "utf-8");
|
|
31
|
-
const parsed = JSON.parse(raw) as ActiveFeatureSession;
|
|
32
|
-
if (parsed && typeof parsed.feature_key === "string" && Array.isArray(parsed.touchpoints)) {
|
|
33
|
-
return parsed;
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
} catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Clear the active feature session
|
|
43
|
-
*/
|
|
44
|
-
public static clearActiveSession(workspaceRoot: string): boolean {
|
|
45
|
-
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
46
|
-
if (existsSync(sessionPath)) {
|
|
47
|
-
try {
|
|
48
|
-
rmSync(sessionPath, { force: true });
|
|
49
|
-
return true;
|
|
50
|
-
} catch {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import type { ActiveFeatureSession } from "../../types/index.ts";
|
|
4
|
+
|
|
5
|
+
export class SessionManager {
|
|
6
|
+
private static readonly SESSION_FILE = ".septum/session.json";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Save the active feature session to .septum/session.json
|
|
10
|
+
*/
|
|
11
|
+
public static saveActiveSession(workspaceRoot: string, session: ActiveFeatureSession): void {
|
|
12
|
+
const septumDir = join(workspaceRoot, ".septum");
|
|
13
|
+
if (!existsSync(septumDir)) {
|
|
14
|
+
mkdirSync(septumDir, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
17
|
+
writeFileSync(sessionPath, JSON.stringify(session, null, 2), "utf-8");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the active feature session, or null if no session exists or file is invalid
|
|
22
|
+
*/
|
|
23
|
+
public static getActiveSession(workspaceRoot: string): ActiveFeatureSession | null {
|
|
24
|
+
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
25
|
+
if (!existsSync(sessionPath)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const raw = readFileSync(sessionPath, "utf-8");
|
|
31
|
+
const parsed = JSON.parse(raw) as ActiveFeatureSession;
|
|
32
|
+
if (parsed && typeof parsed.feature_key === "string" && Array.isArray(parsed.touchpoints)) {
|
|
33
|
+
return parsed;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Clear the active feature session
|
|
43
|
+
*/
|
|
44
|
+
public static clearActiveSession(workspaceRoot: string): boolean {
|
|
45
|
+
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
46
|
+
if (existsSync(sessionPath)) {
|
|
47
|
+
try {
|
|
48
|
+
rmSync(sessionPath, { force: true });
|
|
49
|
+
return true;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { appendFileSync, existsSync, mkdirSync, renameSync, statSync } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
|
|
4
|
-
export interface SeptumToolCallEvent {
|
|
5
|
-
timestamp?: string;
|
|
6
|
-
event: "tool_call_completed" | "tool_call_failed";
|
|
7
|
-
tool: string;
|
|
8
|
-
duration_ms: number;
|
|
9
|
-
input: Record<string, any>;
|
|
10
|
-
metrics?: {
|
|
11
|
-
bytes_out?: number;
|
|
12
|
-
lines_out?: number;
|
|
13
|
-
nodes_returned?: number;
|
|
14
|
-
};
|
|
15
|
-
session?: {
|
|
16
|
-
feature_key?: string | null;
|
|
17
|
-
domain?: string | null;
|
|
18
|
-
} | null;
|
|
19
|
-
status: "success" | "error";
|
|
20
|
-
error?: {
|
|
21
|
-
code?: string;
|
|
22
|
-
message: string;
|
|
23
|
-
stack?: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class SeptumTelemetry {
|
|
28
|
-
private static readonly MAX_LOG_SIZE_BYTES = 2 * 1024 * 1024; // 2MB
|
|
29
|
-
private static readonly SLOW_EXECUTION_THRESHOLD_MS = 250;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Resolves the log file path inside the active workspace's .septum directory.
|
|
33
|
-
*/
|
|
34
|
-
public static getLogPath(workspaceRoot: string = process.cwd()): string {
|
|
35
|
-
return join(workspaceRoot, ".septum", "septum.log");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Records a tool call event to both stderr (dual-sink) and .septum/septum.log.
|
|
40
|
-
*/
|
|
41
|
-
public static recordToolCall(
|
|
42
|
-
event: SeptumToolCallEvent,
|
|
43
|
-
workspaceRoot: string = process.cwd()
|
|
44
|
-
): void {
|
|
45
|
-
const payload: SeptumToolCallEvent = {
|
|
46
|
-
timestamp: event.timestamp || new Date().toISOString(),
|
|
47
|
-
...event,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const jsonLine = JSON.stringify(payload);
|
|
51
|
-
|
|
52
|
-
// Sink 1: Live stderr stream for operator monitoring (slow queries & failures)
|
|
53
|
-
if (payload.status === "error") {
|
|
54
|
-
console.error(`[Septum Telemetry ERROR] ${jsonLine}`);
|
|
55
|
-
} else if (payload.duration_ms >= this.SLOW_EXECUTION_THRESHOLD_MS) {
|
|
56
|
-
console.error(`[Septum Telemetry SLOW_WARN] ${jsonLine}`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Sink 2: Append-only persistent file recorder in .septum/septum.log
|
|
60
|
-
try {
|
|
61
|
-
const logPath = this.getLogPath(workspaceRoot);
|
|
62
|
-
const logDir = dirname(logPath);
|
|
63
|
-
|
|
64
|
-
if (!existsSync(logDir)) {
|
|
65
|
-
mkdirSync(logDir, { recursive: true });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Check for rotation if file exceeds 2MB
|
|
69
|
-
if (existsSync(logPath)) {
|
|
70
|
-
try {
|
|
71
|
-
const stats = statSync(logPath);
|
|
72
|
-
if (stats.size >= this.MAX_LOG_SIZE_BYTES) {
|
|
73
|
-
const rotatedPath = `${logPath}.1`;
|
|
74
|
-
renameSync(logPath, rotatedPath);
|
|
75
|
-
}
|
|
76
|
-
} catch {
|
|
77
|
-
// If stat/rotation fails, proceed to append without crashing
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
appendFileSync(logPath, `${jsonLine}\n`, "utf8");
|
|
82
|
-
} catch {
|
|
83
|
-
// Telemetry file writes must never crash the main application process
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, renameSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
export interface SeptumToolCallEvent {
|
|
5
|
+
timestamp?: string;
|
|
6
|
+
event: "tool_call_completed" | "tool_call_failed";
|
|
7
|
+
tool: string;
|
|
8
|
+
duration_ms: number;
|
|
9
|
+
input: Record<string, any>;
|
|
10
|
+
metrics?: {
|
|
11
|
+
bytes_out?: number;
|
|
12
|
+
lines_out?: number;
|
|
13
|
+
nodes_returned?: number;
|
|
14
|
+
};
|
|
15
|
+
session?: {
|
|
16
|
+
feature_key?: string | null;
|
|
17
|
+
domain?: string | null;
|
|
18
|
+
} | null;
|
|
19
|
+
status: "success" | "error";
|
|
20
|
+
error?: {
|
|
21
|
+
code?: string;
|
|
22
|
+
message: string;
|
|
23
|
+
stack?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class SeptumTelemetry {
|
|
28
|
+
private static readonly MAX_LOG_SIZE_BYTES = 2 * 1024 * 1024; // 2MB
|
|
29
|
+
private static readonly SLOW_EXECUTION_THRESHOLD_MS = 250;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the log file path inside the active workspace's .septum directory.
|
|
33
|
+
*/
|
|
34
|
+
public static getLogPath(workspaceRoot: string = process.cwd()): string {
|
|
35
|
+
return join(workspaceRoot, ".septum", "septum.log");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Records a tool call event to both stderr (dual-sink) and .septum/septum.log.
|
|
40
|
+
*/
|
|
41
|
+
public static recordToolCall(
|
|
42
|
+
event: SeptumToolCallEvent,
|
|
43
|
+
workspaceRoot: string = process.cwd()
|
|
44
|
+
): void {
|
|
45
|
+
const payload: SeptumToolCallEvent = {
|
|
46
|
+
timestamp: event.timestamp || new Date().toISOString(),
|
|
47
|
+
...event,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const jsonLine = JSON.stringify(payload);
|
|
51
|
+
|
|
52
|
+
// Sink 1: Live stderr stream for operator monitoring (slow queries & failures)
|
|
53
|
+
if (payload.status === "error") {
|
|
54
|
+
console.error(`[Septum Telemetry ERROR] ${jsonLine}`);
|
|
55
|
+
} else if (payload.duration_ms >= this.SLOW_EXECUTION_THRESHOLD_MS) {
|
|
56
|
+
console.error(`[Septum Telemetry SLOW_WARN] ${jsonLine}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Sink 2: Append-only persistent file recorder in .septum/septum.log
|
|
60
|
+
try {
|
|
61
|
+
const logPath = this.getLogPath(workspaceRoot);
|
|
62
|
+
const logDir = dirname(logPath);
|
|
63
|
+
|
|
64
|
+
if (!existsSync(logDir)) {
|
|
65
|
+
mkdirSync(logDir, { recursive: true });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Check for rotation if file exceeds 2MB
|
|
69
|
+
if (existsSync(logPath)) {
|
|
70
|
+
try {
|
|
71
|
+
const stats = statSync(logPath);
|
|
72
|
+
if (stats.size >= this.MAX_LOG_SIZE_BYTES) {
|
|
73
|
+
const rotatedPath = `${logPath}.1`;
|
|
74
|
+
renameSync(logPath, rotatedPath);
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
// If stat/rotation fails, proceed to append without crashing
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
appendFileSync(logPath, `${jsonLine}\n`, "utf8");
|
|
82
|
+
} catch {
|
|
83
|
+
// Telemetry file writes must never crash the main application process
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export * from "./types/index.ts";
|
|
2
|
-
export * from "./core/config/schema.ts";
|
|
3
|
-
export * from "./core/config/loader.ts";
|
|
4
|
-
export * from "./core/database/client.ts";
|
|
5
|
-
export * from "./core/database/repository.ts";
|
|
6
|
-
export * from "./core/parser/extractors/base.ts";
|
|
7
|
-
export * from "./core/parser/tree-sitter.ts";
|
|
8
|
-
export * from "./core/ingestion/pipeline.ts";
|
|
9
|
-
export * from "./core/boundary/evaluator.ts";
|
|
10
|
-
export * from "./core/resolver/call-graph-tracer.ts";
|
|
11
|
-
export * from "./core/resolver/vertical-slice-tracer.ts";
|
|
12
|
-
export * from "./core/topology/types.ts";
|
|
13
|
-
export * from "./core/topology/environment-detector.ts";
|
|
14
|
-
export * from "./mcp/tools/get-environment-topology.ts";
|
|
15
|
-
export * from "./mcp/server.ts";
|
|
16
|
-
export * from "./cli/index.ts";
|
|
17
|
-
|
|
18
|
-
import { runCLI } from "./cli/index.ts";
|
|
19
|
-
if (import.meta.main) {
|
|
20
|
-
runCLI(process.argv);
|
|
21
|
-
}
|
|
1
|
+
export * from "./types/index.ts";
|
|
2
|
+
export * from "./core/config/schema.ts";
|
|
3
|
+
export * from "./core/config/loader.ts";
|
|
4
|
+
export * from "./core/database/client.ts";
|
|
5
|
+
export * from "./core/database/repository.ts";
|
|
6
|
+
export * from "./core/parser/extractors/base.ts";
|
|
7
|
+
export * from "./core/parser/tree-sitter.ts";
|
|
8
|
+
export * from "./core/ingestion/pipeline.ts";
|
|
9
|
+
export * from "./core/boundary/evaluator.ts";
|
|
10
|
+
export * from "./core/resolver/call-graph-tracer.ts";
|
|
11
|
+
export * from "./core/resolver/vertical-slice-tracer.ts";
|
|
12
|
+
export * from "./core/topology/types.ts";
|
|
13
|
+
export * from "./core/topology/environment-detector.ts";
|
|
14
|
+
export * from "./mcp/tools/get-environment-topology.ts";
|
|
15
|
+
export * from "./mcp/server.ts";
|
|
16
|
+
export * from "./cli/index.ts";
|
|
17
|
+
|
|
18
|
+
import { runCLI } from "./cli/index.ts";
|
|
19
|
+
if (import.meta.main) {
|
|
20
|
+
runCLI(process.argv);
|
|
21
|
+
}
|