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.
Files changed (67) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +105 -105
  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 -48
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/index.ts +210 -210
  15. package/src/cli/templates/hooks.ts +75 -75
  16. package/src/cli/templates/rules.ts +38 -38
  17. package/src/cli/templates/skill.ts +69 -69
  18. package/src/core/boundary/evaluator.ts +232 -210
  19. package/src/core/config/loader.ts +97 -97
  20. package/src/core/config/schema.ts +39 -39
  21. package/src/core/database/client.ts +44 -44
  22. package/src/core/database/repositories/dependency.repository.ts +366 -349
  23. package/src/core/database/repositories/domain.repository.ts +218 -198
  24. package/src/core/database/repositories/file.repository.ts +116 -106
  25. package/src/core/database/repositories/meta.repository.ts +33 -33
  26. package/src/core/database/repositories/symbol.repository.ts +443 -443
  27. package/src/core/database/repository.ts +264 -260
  28. package/src/core/database/schema.ts +153 -153
  29. package/src/core/discovery/topology-detector.ts +486 -486
  30. package/src/core/ingestion/hasher.ts +5 -5
  31. package/src/core/ingestion/pipeline.ts +584 -535
  32. package/src/core/parser/boundary-tracker.ts +288 -288
  33. package/src/core/parser/extractors/base.ts +62 -62
  34. package/src/core/parser/extractors/blade.ts +158 -158
  35. package/src/core/parser/extractors/frontend.ts +194 -194
  36. package/src/core/parser/extractors/go.ts +229 -180
  37. package/src/core/parser/extractors/laravel-semantic.ts +1039 -901
  38. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
  39. package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
  40. package/src/core/parser/extractors/php.ts +153 -153
  41. package/src/core/parser/extractors/python.ts +228 -228
  42. package/src/core/parser/extractors/registry.ts +70 -70
  43. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  44. package/src/core/parser/extractors/typescript.ts +181 -181
  45. package/src/core/parser/tree-sitter.ts +41 -41
  46. package/src/core/resolver/call-graph-tracer.ts +666 -668
  47. package/src/core/resolver/module-resolver.ts +408 -342
  48. package/src/core/resolver/path-resolver.ts +147 -147
  49. package/src/core/resolver/symbol-locator.ts +543 -543
  50. package/src/core/resolver/vertical-slice-tracer.ts +301 -285
  51. package/src/core/session/session-manager.ts +56 -56
  52. package/src/core/telemetry/telemetry.ts +86 -86
  53. package/src/index.ts +21 -21
  54. package/src/mcp/schemas.ts +578 -286
  55. package/src/mcp/server.ts +875 -716
  56. package/src/mcp/tools/check-boundary.ts +171 -152
  57. package/src/mcp/tools/get-domain-catalog.ts +145 -121
  58. package/src/mcp/tools/get-feature-context.ts +212 -116
  59. package/src/mcp/tools/get-symbol-hotspots.ts +60 -59
  60. package/src/mcp/tools/get-symbol-impact.ts +28 -26
  61. package/src/mcp/tools/get-symbol.ts +65 -63
  62. package/src/mcp/tools/locate-symbol.ts +171 -190
  63. package/src/mcp/tools/register-domain.ts +68 -64
  64. package/src/mcp/tools/register-feature.ts +100 -0
  65. package/src/mcp/tools/trace-vertical-slice.ts +74 -48
  66. package/src/types/index.ts +335 -315
  67. package/src/version.ts +3 -3
@@ -1,97 +1,97 @@
1
- import { existsSync } from "node:fs";
2
- import { isAbsolute, join } from "node:path";
3
- import { Database } from "bun:sqlite";
4
- import type { ValidatedSeptumConfig } from "./schema.ts";
5
- import { TopologyDetector } from "../discovery/topology-detector.ts";
6
- import { SeptumDatabase } from "../database/client.ts";
7
- import { SeptumRepository } from "../database/repository.ts";
8
- import { resolveWorkspaceRoot, isAppHostDirectory } from "../resolver/path-resolver.ts";
9
-
10
- export class ConfigLoader {
11
- /**
12
- * Loads configuration with SQLite as the Single Source of Truth (SSOT).
13
- * Automatically executes Zero-Config TopologyDetector if the database has no domains.
14
- */
15
- public static load(
16
- dbPath?: string,
17
- projectRoot?: string
18
- ): ValidatedSeptumConfig {
19
- const root = resolveWorkspaceRoot(projectRoot);
20
- const resolvedDbPath = dbPath
21
- ? (isAbsolute(dbPath) ? dbPath : join(root, dbPath))
22
- : join(root, ".septum", "septum.db");
23
-
24
- // 1. If database exists and has registered domains, load directly from SQLite SSOT
25
- if (existsSync(resolvedDbPath)) {
26
- const dbConfig = ConfigLoader.loadFromDatabaseOrDefaults(resolvedDbPath);
27
- if (Object.keys(dbConfig.domains).length > 0) {
28
- return dbConfig;
29
- }
30
- }
31
-
32
- // 2. Zero-Config Auto-Discovery: Discover project topology and persist to SQLite
33
- // Guard against running auto-discovery inside MCP host / IDE installation folders
34
- if (!isAppHostDirectory(root)) {
35
- const septumDb = new SeptumDatabase(resolvedDbPath);
36
- const repo = new SeptumRepository(septumDb.raw);
37
- TopologyDetector.discoverAndPersist(repo, root);
38
- septumDb.close();
39
- }
40
-
41
- return ConfigLoader.loadFromDatabaseOrDefaults(resolvedDbPath);
42
- }
43
-
44
- public static getDefaultConfig(): ValidatedSeptumConfig {
45
- return {
46
- version: "1.0",
47
- settings: {
48
- enforcement: "warn",
49
- db_path: ".septum/septum.db",
50
- ignore_patterns: [
51
- "node_modules/**",
52
- "vendor/**",
53
- "dist/**",
54
- "build/**",
55
- "tests/**",
56
- ".git/**",
57
- ".septum/**",
58
- ],
59
- },
60
- domains: {},
61
- features: {},
62
- };
63
- }
64
-
65
- public static loadFromDatabaseOrDefaults(dbPath: string = ".septum/septum.db"): ValidatedSeptumConfig {
66
- const config = ConfigLoader.getDefaultConfig();
67
- config.settings.db_path = dbPath;
68
-
69
- if (existsSync(dbPath)) {
70
- try {
71
- const db = new Database(dbPath, { readonly: true });
72
- const tables = db
73
- .query<{ name: string }, [string]>(
74
- "SELECT name FROM sqlite_master WHERE type='table' AND name = ?"
75
- )
76
- .get("domains");
77
-
78
- if (tables) {
79
- const rows = db.query<any, []>("SELECT * FROM domains").all();
80
- for (const r of rows) {
81
- config.domains[r.name] = {
82
- root: r.root_path,
83
- allowed_dependencies: JSON.parse(r.allowed_deps_json || "[]"),
84
- forbidden_dependencies: JSON.parse(r.forbidden_deps_json || "[]"),
85
- archetypes: JSON.parse(r.archetypes_json || "{}"),
86
- };
87
- }
88
- }
89
- db.close();
90
- } catch {
91
- // Fallback gracefully to default config
92
- }
93
- }
94
-
95
- return config;
96
- }
97
- }
1
+ import { existsSync } from "node:fs";
2
+ import { isAbsolute, join } from "node:path";
3
+ import { Database } from "bun:sqlite";
4
+ import type { ValidatedSeptumConfig } from "./schema.ts";
5
+ import { TopologyDetector } from "../discovery/topology-detector.ts";
6
+ import { SeptumDatabase } from "../database/client.ts";
7
+ import { SeptumRepository } from "../database/repository.ts";
8
+ import { resolveWorkspaceRoot, isAppHostDirectory } from "../resolver/path-resolver.ts";
9
+
10
+ export class ConfigLoader {
11
+ /**
12
+ * Loads configuration with SQLite as the Single Source of Truth (SSOT).
13
+ * Automatically executes Zero-Config TopologyDetector if the database has no domains.
14
+ */
15
+ public static load(
16
+ dbPath?: string,
17
+ projectRoot?: string
18
+ ): ValidatedSeptumConfig {
19
+ const root = resolveWorkspaceRoot(projectRoot);
20
+ const resolvedDbPath = dbPath
21
+ ? (isAbsolute(dbPath) ? dbPath : join(root, dbPath))
22
+ : join(root, ".septum", "septum.db");
23
+
24
+ // 1. If database exists and has registered domains, load directly from SQLite SSOT
25
+ if (existsSync(resolvedDbPath)) {
26
+ const dbConfig = ConfigLoader.loadFromDatabaseOrDefaults(resolvedDbPath);
27
+ if (Object.keys(dbConfig.domains).length > 0) {
28
+ return dbConfig;
29
+ }
30
+ }
31
+
32
+ // 2. Zero-Config Auto-Discovery: Discover project topology and persist to SQLite
33
+ // Guard against running auto-discovery inside MCP host / IDE installation folders
34
+ if (!isAppHostDirectory(root)) {
35
+ const septumDb = new SeptumDatabase(resolvedDbPath);
36
+ const repo = new SeptumRepository(septumDb.raw);
37
+ TopologyDetector.discoverAndPersist(repo, root);
38
+ septumDb.close();
39
+ }
40
+
41
+ return ConfigLoader.loadFromDatabaseOrDefaults(resolvedDbPath);
42
+ }
43
+
44
+ public static getDefaultConfig(): ValidatedSeptumConfig {
45
+ return {
46
+ version: "1.0",
47
+ settings: {
48
+ enforcement: "warn",
49
+ db_path: ".septum/septum.db",
50
+ ignore_patterns: [
51
+ "node_modules/**",
52
+ "vendor/**",
53
+ "dist/**",
54
+ "build/**",
55
+ "tests/**",
56
+ ".git/**",
57
+ ".septum/**",
58
+ ],
59
+ },
60
+ domains: {},
61
+ features: {},
62
+ };
63
+ }
64
+
65
+ public static loadFromDatabaseOrDefaults(dbPath: string = ".septum/septum.db"): ValidatedSeptumConfig {
66
+ const config = ConfigLoader.getDefaultConfig();
67
+ config.settings.db_path = dbPath;
68
+
69
+ if (existsSync(dbPath)) {
70
+ try {
71
+ const db = new Database(dbPath, { readonly: true });
72
+ const tables = db
73
+ .query<{ name: string }, [string]>(
74
+ "SELECT name FROM sqlite_master WHERE type='table' AND name = ?"
75
+ )
76
+ .get("domains");
77
+
78
+ if (tables) {
79
+ const rows = db.query<any, []>("SELECT * FROM domains").all();
80
+ for (const r of rows) {
81
+ config.domains[r.name] = {
82
+ root: r.root_path,
83
+ allowed_dependencies: JSON.parse(r.allowed_deps_json || "[]"),
84
+ forbidden_dependencies: JSON.parse(r.forbidden_deps_json || "[]"),
85
+ archetypes: JSON.parse(r.archetypes_json || "{}"),
86
+ };
87
+ }
88
+ }
89
+ db.close();
90
+ } catch {
91
+ // Fallback gracefully to default config
92
+ }
93
+ }
94
+
95
+ return config;
96
+ }
97
+ }
@@ -1,39 +1,39 @@
1
- import { z } from "zod";
2
-
3
- export const DomainConfigSchema = z.object({
4
- root: z.string().min(1, "root path cannot be empty"),
5
- description: z.string().optional(),
6
- allowed_dependencies: z.array(z.string()).default([]),
7
- forbidden_dependencies: z.array(z.string()).default([]),
8
- archetypes: z.record(z.string()).optional().default({}),
9
- });
10
-
11
- export const FeatureConfigSchema = z.object({
12
- domain: z.string().min(1, "domain reference is required"),
13
- description: z.string().optional(),
14
- allowed_touchpoints: z.array(z.string()).min(1, "allowed_touchpoints must contain at least one file/path"),
15
- reuse_symbols: z.array(z.string()).optional().default([]),
16
- input_contract: z.record(z.unknown()).optional().default({}),
17
- output_contract: z.record(z.unknown()).optional().default({}),
18
- });
19
-
20
- export const SeptumConfigSchema = z.object({
21
- version: z.string().default("1.0"),
22
- settings: z
23
- .object({
24
- enforcement: z.enum(["strict", "warn"]).default("strict"),
25
- db_path: z.string().default(".septum/septum.db"),
26
- ignore_patterns: z
27
- .array(z.string())
28
- .default(["node_modules/**", "vendor/**", "dist/**", "build/**", "tests/**", ".git/**"]),
29
- })
30
- .default({
31
- enforcement: "strict",
32
- db_path: ".septum/septum.db",
33
- ignore_patterns: ["node_modules/**", "vendor/**", "dist/**", "build/**", "tests/**", ".git/**"],
34
- }),
35
- domains: z.record(DomainConfigSchema).default({}),
36
- features: z.record(FeatureConfigSchema).optional().default({}),
37
- });
38
-
39
- export type ValidatedSeptumConfig = z.infer<typeof SeptumConfigSchema>;
1
+ import { z } from "zod";
2
+
3
+ export const DomainConfigSchema = z.object({
4
+ root: z.string().min(1, "root path cannot be empty"),
5
+ description: z.string().optional(),
6
+ allowed_dependencies: z.array(z.string()).default([]),
7
+ forbidden_dependencies: z.array(z.string()).default([]),
8
+ archetypes: z.record(z.string()).optional().default({}),
9
+ });
10
+
11
+ export const FeatureConfigSchema = z.object({
12
+ domain: z.string().min(1, "domain reference is required"),
13
+ description: z.string().optional(),
14
+ allowed_touchpoints: z.array(z.string()).min(1, "allowed_touchpoints must contain at least one file/path"),
15
+ reuse_symbols: z.array(z.string()).optional().default([]),
16
+ input_contract: z.record(z.unknown()).optional().default({}),
17
+ output_contract: z.record(z.unknown()).optional().default({}),
18
+ });
19
+
20
+ export const SeptumConfigSchema = z.object({
21
+ version: z.string().default("1.0"),
22
+ settings: z
23
+ .object({
24
+ enforcement: z.enum(["strict", "warn"]).default("strict"),
25
+ db_path: z.string().default(".septum/septum.db"),
26
+ ignore_patterns: z
27
+ .array(z.string())
28
+ .default(["node_modules/**", "vendor/**", "dist/**", "build/**", "tests/**", ".git/**"]),
29
+ })
30
+ .default({
31
+ enforcement: "strict",
32
+ db_path: ".septum/septum.db",
33
+ ignore_patterns: ["node_modules/**", "vendor/**", "dist/**", "build/**", "tests/**", ".git/**"],
34
+ }),
35
+ domains: z.record(DomainConfigSchema).default({}),
36
+ features: z.record(FeatureConfigSchema).optional().default({}),
37
+ });
38
+
39
+ export type ValidatedSeptumConfig = z.infer<typeof SeptumConfigSchema>;
@@ -1,44 +1,44 @@
1
- import { Database } from "bun:sqlite";
2
- import { existsSync, mkdirSync } from "node:fs";
3
- import { dirname } from "node:path";
4
- import { initializeDatabaseSchema } from "./schema.ts";
5
-
6
- export class SeptumDatabase {
7
- private db: Database;
8
- private dbPath: string;
9
-
10
- constructor(dbPath: string = ".septum/septum.db") {
11
- this.dbPath = dbPath;
12
- const dir = dirname(dbPath);
13
- if (!existsSync(dir)) {
14
- mkdirSync(dir, { recursive: true });
15
- }
16
-
17
- this.db = new Database(dbPath, { create: true });
18
- this.configurePragmas();
19
- this.initSchema();
20
- }
21
-
22
- private configurePragmas(): void {
23
- this.db.run("PRAGMA journal_mode = WAL;");
24
- this.db.run("PRAGMA busy_timeout = 5000;");
25
- this.db.run("PRAGMA foreign_keys = ON;");
26
- this.db.run("PRAGMA synchronous = NORMAL;");
27
- }
28
-
29
- private initSchema(): void {
30
- initializeDatabaseSchema(this.db);
31
- }
32
-
33
- public get raw(): Database {
34
- return this.db;
35
- }
36
-
37
- public close(): void {
38
- this.db.close();
39
- }
40
-
41
- public transaction<T>(fn: () => T): T {
42
- return this.db.transaction(fn)();
43
- }
44
- }
1
+ import { Database } from "bun:sqlite";
2
+ import { existsSync, mkdirSync } from "node:fs";
3
+ import { dirname } from "node:path";
4
+ import { initializeDatabaseSchema } from "./schema.ts";
5
+
6
+ export class SeptumDatabase {
7
+ private db: Database;
8
+ private dbPath: string;
9
+
10
+ constructor(dbPath: string = ".septum/septum.db") {
11
+ this.dbPath = dbPath;
12
+ const dir = dirname(dbPath);
13
+ if (!existsSync(dir)) {
14
+ mkdirSync(dir, { recursive: true });
15
+ }
16
+
17
+ this.db = new Database(dbPath, { create: true });
18
+ this.configurePragmas();
19
+ this.initSchema();
20
+ }
21
+
22
+ private configurePragmas(): void {
23
+ this.db.run("PRAGMA journal_mode = WAL;");
24
+ this.db.run("PRAGMA busy_timeout = 5000;");
25
+ this.db.run("PRAGMA foreign_keys = ON;");
26
+ this.db.run("PRAGMA synchronous = NORMAL;");
27
+ }
28
+
29
+ private initSchema(): void {
30
+ initializeDatabaseSchema(this.db);
31
+ }
32
+
33
+ public get raw(): Database {
34
+ return this.db;
35
+ }
36
+
37
+ public close(): void {
38
+ this.db.close();
39
+ }
40
+
41
+ public transaction<T>(fn: () => T): T {
42
+ return this.db.transaction(fn)();
43
+ }
44
+ }