septum 0.1.3 → 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.
Files changed (74) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +105 -102
  3. package/bin/septum.ts +4 -4
  4. package/package.json +63 -63
  5. package/src/cli/commands/check.ts +161 -161
  6. package/src/cli/commands/hook.ts +188 -188
  7. package/src/cli/commands/ingest.ts +29 -29
  8. package/src/cli/commands/init.ts +211 -211
  9. package/src/cli/commands/locate.ts +61 -61
  10. package/src/cli/commands/query.ts +64 -64
  11. package/src/cli/commands/serve.ts +5 -5
  12. package/src/cli/commands/slice.ts +48 -90
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/commands/topology.ts +119 -0
  15. package/src/cli/index.ts +210 -199
  16. package/src/cli/templates/hooks.ts +75 -75
  17. package/src/cli/templates/rules.ts +38 -38
  18. package/src/cli/templates/skill.ts +69 -69
  19. package/src/core/boundary/evaluator.ts +232 -210
  20. package/src/core/config/loader.ts +97 -97
  21. package/src/core/config/schema.ts +39 -39
  22. package/src/core/database/client.ts +44 -44
  23. package/src/core/database/repositories/dependency.repository.ts +366 -349
  24. package/src/core/database/repositories/domain.repository.ts +218 -198
  25. package/src/core/database/repositories/environment.repository.ts +207 -0
  26. package/src/core/database/repositories/file.repository.ts +116 -106
  27. package/src/core/database/repositories/meta.repository.ts +33 -33
  28. package/src/core/database/repositories/symbol.repository.ts +443 -424
  29. package/src/core/database/repository.ts +264 -255
  30. package/src/core/database/schema.ts +34 -1
  31. package/src/core/discovery/topology-detector.ts +486 -486
  32. package/src/core/ingestion/hasher.ts +5 -5
  33. package/src/core/ingestion/pipeline.ts +584 -535
  34. package/src/core/parser/behavioral-analyzer.ts +119 -0
  35. package/src/core/parser/boundary-tracker.ts +288 -128
  36. package/src/core/parser/extractors/base.ts +62 -61
  37. package/src/core/parser/extractors/frontend.ts +194 -194
  38. package/src/core/parser/extractors/go.ts +229 -176
  39. package/src/core/parser/extractors/laravel-semantic.ts +1039 -585
  40. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
  41. package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
  42. package/src/core/parser/extractors/php.ts +153 -149
  43. package/src/core/parser/extractors/python.ts +228 -226
  44. package/src/core/parser/extractors/registry.ts +70 -70
  45. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  46. package/src/core/parser/extractors/typescript.ts +181 -177
  47. package/src/core/parser/schema/providers/laravel-migration-provider.ts +215 -0
  48. package/src/core/parser/schema/providers/prisma-schema-provider.ts +89 -0
  49. package/src/core/parser/schema/schema-provider-registry.ts +43 -0
  50. package/src/core/parser/schema/schema-provider.interface.ts +33 -0
  51. package/src/core/parser/tree-sitter.ts +41 -41
  52. package/src/core/resolver/call-graph-tracer.ts +666 -668
  53. package/src/core/resolver/module-resolver.ts +408 -342
  54. package/src/core/resolver/symbol-locator.ts +543 -543
  55. package/src/core/resolver/vertical-slice-tracer.ts +301 -252
  56. package/src/core/session/session-manager.ts +56 -56
  57. package/src/core/telemetry/telemetry.ts +86 -86
  58. package/src/core/topology/environment-detector.ts +860 -0
  59. package/src/core/topology/types.ts +83 -0
  60. package/src/index.ts +21 -18
  61. package/src/mcp/schemas.ts +578 -238
  62. package/src/mcp/server.ts +875 -656
  63. package/src/mcp/tools/check-boundary.ts +171 -152
  64. package/src/mcp/tools/get-domain-catalog.ts +145 -121
  65. package/src/mcp/tools/get-environment-topology.ts +141 -0
  66. package/src/mcp/tools/get-feature-context.ts +212 -116
  67. package/src/mcp/tools/get-symbol-hotspots.ts +60 -49
  68. package/src/mcp/tools/get-symbol-impact.ts +28 -26
  69. package/src/mcp/tools/get-symbol.ts +65 -63
  70. package/src/mcp/tools/locate-symbol.ts +171 -190
  71. package/src/mcp/tools/register-domain.ts +68 -64
  72. package/src/mcp/tools/register-feature.ts +100 -0
  73. package/src/mcp/tools/trace-vertical-slice.ts +74 -103
  74. package/src/types/index.ts +335 -299
@@ -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
+ }