septum 0.1.0 → 0.1.2

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 (65) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +100 -100
  3. package/bin/septum.ts +4 -4
  4. package/package.json +63 -62
  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 +90 -90
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/index.ts +199 -178
  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 +66 -66
  18. package/src/core/boundary/evaluator.ts +210 -210
  19. package/src/core/config/loader.ts +84 -84
  20. package/src/core/config/schema.ts +39 -39
  21. package/src/core/database/client.ts +44 -132
  22. package/src/core/database/repositories/dependency.repository.ts +279 -279
  23. package/src/core/database/repositories/domain.repository.ts +198 -198
  24. package/src/core/database/repositories/file.repository.ts +99 -99
  25. package/src/core/database/repositories/meta.repository.ts +33 -33
  26. package/src/core/database/repositories/symbol.repository.ts +424 -424
  27. package/src/core/database/repository.ts +242 -242
  28. package/src/core/database/schema.ts +120 -0
  29. package/src/core/discovery/topology-detector.ts +418 -418
  30. package/src/core/ingestion/hasher.ts +5 -5
  31. package/src/core/ingestion/pipeline.ts +438 -438
  32. package/src/core/parser/boundary-tracker.ts +128 -128
  33. package/src/core/parser/extractors/base.ts +60 -60
  34. package/src/core/parser/extractors/frontend.ts +194 -194
  35. package/src/core/parser/extractors/go.ts +176 -176
  36. package/src/core/parser/extractors/laravel-semantic.ts +426 -426
  37. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
  38. package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
  39. package/src/core/parser/extractors/php.ts +149 -149
  40. package/src/core/parser/extractors/python.ts +226 -226
  41. package/src/core/parser/extractors/registry.ts +49 -49
  42. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  43. package/src/core/parser/extractors/typescript.ts +177 -177
  44. package/src/core/parser/tree-sitter.ts +39 -39
  45. package/src/core/resolver/call-graph-tracer.ts +668 -668
  46. package/src/core/resolver/module-resolver.ts +342 -323
  47. package/src/core/resolver/symbol-locator.ts +543 -405
  48. package/src/core/resolver/vertical-slice-tracer.ts +237 -236
  49. package/src/core/session/session-manager.ts +56 -56
  50. package/src/core/telemetry/telemetry.ts +86 -86
  51. package/src/index.ts +18 -18
  52. package/src/mcp/schemas.ts +68 -68
  53. package/src/mcp/server.ts +612 -602
  54. package/src/mcp/tools/check-boundary.ts +102 -102
  55. package/src/mcp/tools/get-domain-catalog.ts +91 -91
  56. package/src/mcp/tools/get-feature-context.ts +116 -116
  57. package/src/mcp/tools/get-symbol-hotspots.ts +49 -49
  58. package/src/mcp/tools/get-symbol-impact.ts +26 -26
  59. package/src/mcp/tools/get-symbol.ts +63 -63
  60. package/src/mcp/tools/locate-symbol.ts +74 -74
  61. package/src/mcp/tools/register-domain.ts +64 -64
  62. package/src/mcp/tools/trace-vertical-slice.ts +102 -102
  63. package/src/types/index.ts +296 -296
  64. package/src/version.ts +3 -0
  65. package/src/core/database/schema.sql +0 -92
@@ -1,64 +1,64 @@
1
- import { ConfigLoader } from "../../core/config/loader.ts";
2
- import { SeptumDatabase } from "../../core/database/client.ts";
3
- import { SeptumRepository } from "../../core/database/repository.ts";
4
-
5
- export async function handleQueryCommand(domainName?: string, archetype?: string, jsonOutput?: boolean): Promise<void> {
6
- const config = ConfigLoader.load();
7
- const db = new SeptumDatabase(config.settings.db_path);
8
- const repo = new SeptumRepository(db.raw);
9
-
10
- if (!domainName) {
11
- const allDomains = repo.getAllDomains();
12
- if (allDomains.length === 0) {
13
- console.log("[Septum] No domains found in database. Run 'septum ingest' first.");
14
- db.close();
15
- return;
16
- }
17
-
18
- console.log("=== Registered Domains in Septum ===");
19
- for (const d of allDomains) {
20
- console.log(`- ${d.name} (root: ${d.root_path})`);
21
- }
22
- db.close();
23
- return;
24
- }
25
-
26
- const catalog = repo.getDomainCatalog(domainName, archetype);
27
- if (!catalog) {
28
- console.error(`[Septum Error] Domain '${domainName}' not found in database. Run 'septum ingest' first.`);
29
- db.close();
30
- process.exit(1);
31
- }
32
-
33
- if (jsonOutput) {
34
- console.log(JSON.stringify(catalog, null, 2));
35
- } else {
36
- console.log(`=================================================`);
37
- console.log(` Domain: ${catalog.domain.toUpperCase()} (Root: ${catalog.root})`);
38
- console.log(`=================================================`);
39
- console.log(` Allowed Dependencies: [${catalog.allowed_dependencies.join(", ")}]`);
40
- console.log(` Forbidden Dependencies: [${catalog.forbidden_dependencies.join(", ")}]`);
41
- console.log(` Total Files Cataloged: ${catalog.files.length}`);
42
- console.log(`-------------------------------------------------`);
43
-
44
- for (const file of catalog.files) {
45
- console.log(`\n File: ${file.path} [archetype: ${file.archetype}]`);
46
- for (const sym of file.symbols) {
47
- console.log(` • ${sym.kind.toUpperCase()} ${sym.name}`);
48
- if (sym.methods && sym.methods.length > 0) {
49
- for (const m of sym.methods) {
50
- console.log(` - ${m}`);
51
- }
52
- }
53
- if (sym.signatures && sym.signatures.length > 0) {
54
- for (const s of sym.signatures) {
55
- console.log(` - ${s}`);
56
- }
57
- }
58
- }
59
- }
60
- console.log(`\n=================================================`);
61
- }
62
-
63
- db.close();
64
- }
1
+ import { ConfigLoader } from "../../core/config/loader.ts";
2
+ import { SeptumDatabase } from "../../core/database/client.ts";
3
+ import { SeptumRepository } from "../../core/database/repository.ts";
4
+
5
+ export async function handleQueryCommand(domainName?: string, archetype?: string, jsonOutput?: boolean): Promise<void> {
6
+ const config = ConfigLoader.load();
7
+ const db = new SeptumDatabase(config.settings.db_path);
8
+ const repo = new SeptumRepository(db.raw);
9
+
10
+ if (!domainName) {
11
+ const allDomains = repo.getAllDomains();
12
+ if (allDomains.length === 0) {
13
+ console.log("[Septum] No domains found in database. Run 'septum ingest' first.");
14
+ db.close();
15
+ return;
16
+ }
17
+
18
+ console.log("=== Registered Domains in Septum ===");
19
+ for (const d of allDomains) {
20
+ console.log(`- ${d.name} (root: ${d.root_path})`);
21
+ }
22
+ db.close();
23
+ return;
24
+ }
25
+
26
+ const catalog = repo.getDomainCatalog(domainName, archetype);
27
+ if (!catalog) {
28
+ console.error(`[Septum Error] Domain '${domainName}' not found in database. Run 'septum ingest' first.`);
29
+ db.close();
30
+ process.exit(1);
31
+ }
32
+
33
+ if (jsonOutput) {
34
+ console.log(JSON.stringify(catalog, null, 2));
35
+ } else {
36
+ console.log(`=================================================`);
37
+ console.log(` Domain: ${catalog.domain.toUpperCase()} (Root: ${catalog.root})`);
38
+ console.log(`=================================================`);
39
+ console.log(` Allowed Dependencies: [${catalog.allowed_dependencies.join(", ")}]`);
40
+ console.log(` Forbidden Dependencies: [${catalog.forbidden_dependencies.join(", ")}]`);
41
+ console.log(` Total Files Cataloged: ${catalog.files.length}`);
42
+ console.log(`-------------------------------------------------`);
43
+
44
+ for (const file of catalog.files) {
45
+ console.log(`\n File: ${file.path} [archetype: ${file.archetype}]`);
46
+ for (const sym of file.symbols) {
47
+ console.log(` • ${sym.kind.toUpperCase()} ${sym.name}`);
48
+ if (sym.methods && sym.methods.length > 0) {
49
+ for (const m of sym.methods) {
50
+ console.log(` - ${m}`);
51
+ }
52
+ }
53
+ if (sym.signatures && sym.signatures.length > 0) {
54
+ for (const s of sym.signatures) {
55
+ console.log(` - ${s}`);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ console.log(`\n=================================================`);
61
+ }
62
+
63
+ db.close();
64
+ }
@@ -1,5 +1,5 @@
1
- import { runMCPServer } from "../../mcp/server.ts";
2
-
3
- export async function handleServeCommand(): Promise<void> {
4
- await runMCPServer();
5
- }
1
+ import { runMCPServer } from "../../mcp/server.ts";
2
+
3
+ export async function handleServeCommand(): Promise<void> {
4
+ await runMCPServer();
5
+ }
@@ -1,90 +1,90 @@
1
- import { ConfigLoader } from "../../core/config/loader.ts";
2
- import { SeptumDatabase } from "../../core/database/client.ts";
3
- import { SeptumRepository } from "../../core/database/repository.ts";
4
- import { VerticalSliceTracer } from "../../core/resolver/vertical-slice-tracer.ts";
5
-
6
- export async function handleSliceCommand(
7
- query: string,
8
- options?: { json?: boolean }
9
- ): Promise<void> {
10
- const config = ConfigLoader.load();
11
- const db = new SeptumDatabase(config.settings.db_path);
12
- const repo = new SeptumRepository(db.raw);
13
-
14
- try {
15
- const tracer = new VerticalSliceTracer(repo);
16
- const result = tracer.trace(query);
17
-
18
- if (options?.json) {
19
- console.log(JSON.stringify(result, null, 2));
20
- return;
21
- }
22
-
23
- if (result.found && result.slice) {
24
- const s = result.slice;
25
- console.log(`\n=================================================`);
26
- console.log(` VERTICAL SLICE: ${s.route.method} ${s.route.uri}`);
27
- console.log(`=================================================`);
28
- if (s.route.name) {
29
- console.log(` • Route Name: ${s.route.name}`);
30
- }
31
-
32
- if (s.request) {
33
- console.log(`\n • Request Validation:`);
34
- console.log(` Class: ${s.request.class} (${s.request.file || "inline"})`);
35
- const rules = Object.keys(s.request.rules);
36
- if (rules.length > 0) {
37
- console.log(` Rules:`);
38
- for (const r of rules) {
39
- console.log(` - ${r}: ${s.request.rules[r]}`);
40
- }
41
- }
42
- }
43
-
44
- console.log(`\n • Controller Action:`);
45
- console.log(` Class: ${s.controller.class}@${s.controller.action}`);
46
- console.log(` Target: ${s.controller.file || "unknown"}:${s.controller.line}`);
47
-
48
- if (s.model) {
49
- console.log(`\n • Model:`);
50
- console.log(` Class: ${s.model.class} (${s.model.file || "unknown"})`);
51
- if (s.model.fillable && s.model.fillable.length > 0) {
52
- console.log(` Fillable: [${s.model.fillable.join(", ")}]`);
53
- }
54
- if (s.model.casts && Object.keys(s.model.casts).length > 0) {
55
- console.log(` Casts: ${JSON.stringify(s.model.casts)}`);
56
- }
57
- }
58
-
59
- if (s.frontend) {
60
- console.log(`\n • Frontend Target:`);
61
- console.log(` Page: ${s.frontend.target}`);
62
- if (s.frontend.props.length > 0) {
63
- console.log(` Props: [${s.frontend.props.join(", ")}]`);
64
- }
65
- }
66
-
67
- if (result.alternatives && result.alternatives.length > 0) {
68
- console.log(`\n • Alternative Matches:`);
69
- for (const alt of result.alternatives) {
70
- console.log(` - ${alt.method} ${alt.uri} -> ${alt.controller}@${alt.action}`);
71
- }
72
- }
73
- console.log(`\n=================================================\n`);
74
- } else {
75
- console.log(`\n❌ Vertical Slice Not Found:`);
76
- console.log(` Query: ${result.query}`);
77
- console.log(` Message: ${result.message}`);
78
-
79
- if (result.alternatives && result.alternatives.length > 0) {
80
- console.log(`\n Available Slices:`);
81
- for (const alt of result.alternatives) {
82
- console.log(` - ${alt.method} ${alt.uri} -> ${alt.controller}@${alt.action}`);
83
- }
84
- }
85
- console.log(``);
86
- }
87
- } finally {
88
- db.close();
89
- }
90
- }
1
+ import { ConfigLoader } from "../../core/config/loader.ts";
2
+ import { SeptumDatabase } from "../../core/database/client.ts";
3
+ import { SeptumRepository } from "../../core/database/repository.ts";
4
+ import { VerticalSliceTracer } from "../../core/resolver/vertical-slice-tracer.ts";
5
+
6
+ export async function handleSliceCommand(
7
+ query: string,
8
+ options?: { json?: boolean }
9
+ ): Promise<void> {
10
+ const config = ConfigLoader.load();
11
+ const db = new SeptumDatabase(config.settings.db_path);
12
+ const repo = new SeptumRepository(db.raw);
13
+
14
+ try {
15
+ const tracer = new VerticalSliceTracer(repo);
16
+ const result = tracer.trace(query);
17
+
18
+ if (options?.json) {
19
+ console.log(JSON.stringify(result, null, 2));
20
+ return;
21
+ }
22
+
23
+ if (result.found && result.slice) {
24
+ const s = result.slice;
25
+ console.log(`\n=================================================`);
26
+ console.log(` VERTICAL SLICE: ${s.route.method} ${s.route.uri}`);
27
+ console.log(`=================================================`);
28
+ if (s.route.name) {
29
+ console.log(` • Route Name: ${s.route.name}`);
30
+ }
31
+
32
+ if (s.request) {
33
+ console.log(`\n • Request Validation:`);
34
+ console.log(` Class: ${s.request.class} (${s.request.file || "inline"})`);
35
+ const rules = Object.keys(s.request.rules);
36
+ if (rules.length > 0) {
37
+ console.log(` Rules:`);
38
+ for (const r of rules) {
39
+ console.log(` - ${r}: ${s.request.rules[r]}`);
40
+ }
41
+ }
42
+ }
43
+
44
+ console.log(`\n • Controller Action:`);
45
+ console.log(` Class: ${s.controller.class}@${s.controller.action}`);
46
+ console.log(` Target: ${s.controller.file || "unknown"}:${s.controller.line}`);
47
+
48
+ if (s.model) {
49
+ console.log(`\n • Model:`);
50
+ console.log(` Class: ${s.model.class} (${s.model.file || "unknown"})`);
51
+ if (s.model.fillable && s.model.fillable.length > 0) {
52
+ console.log(` Fillable: [${s.model.fillable.join(", ")}]`);
53
+ }
54
+ if (s.model.casts && Object.keys(s.model.casts).length > 0) {
55
+ console.log(` Casts: ${JSON.stringify(s.model.casts)}`);
56
+ }
57
+ }
58
+
59
+ if (s.frontend) {
60
+ console.log(`\n • Frontend Target:`);
61
+ console.log(` Page: ${s.frontend.target}`);
62
+ if (s.frontend.props.length > 0) {
63
+ console.log(` Props: [${s.frontend.props.join(", ")}]`);
64
+ }
65
+ }
66
+
67
+ if (result.alternatives && result.alternatives.length > 0) {
68
+ console.log(`\n • Alternative Matches:`);
69
+ for (const alt of result.alternatives) {
70
+ console.log(` - ${alt.method} ${alt.uri} -> ${alt.controller}@${alt.action}`);
71
+ }
72
+ }
73
+ console.log(`\n=================================================\n`);
74
+ } else {
75
+ console.log(`\n❌ Vertical Slice Not Found:`);
76
+ console.log(` Query: ${result.query}`);
77
+ console.log(` Message: ${result.message}`);
78
+
79
+ if (result.alternatives && result.alternatives.length > 0) {
80
+ console.log(`\n Available Slices:`);
81
+ for (const alt of result.alternatives) {
82
+ console.log(` - ${alt.method} ${alt.uri} -> ${alt.controller}@${alt.action}`);
83
+ }
84
+ }
85
+ console.log(``);
86
+ }
87
+ } finally {
88
+ db.close();
89
+ }
90
+ }
@@ -1,31 +1,31 @@
1
- import { ConfigLoader } from "../../core/config/loader.ts";
2
- import { SeptumDatabase } from "../../core/database/client.ts";
3
- import { SeptumRepository } from "../../core/database/repository.ts";
4
- import { IngestionPipeline } from "../../core/ingestion/pipeline.ts";
5
-
6
- export interface SyncCommandOptions {
7
- json?: boolean;
8
- }
9
-
10
- export async function handleSyncCommand(options: SyncCommandOptions = {}): Promise<void> {
11
- const config = ConfigLoader.load();
12
- const db = new SeptumDatabase(config.settings.db_path);
13
- const repo = new SeptumRepository(db.raw);
14
- const pipeline = new IngestionPipeline(repo);
15
-
16
- const metrics = await pipeline.run(config);
17
-
18
- if (options.json) {
19
- console.log(JSON.stringify(metrics, null, 2));
20
- } else {
21
- console.log(
22
- `[Septum Sync] Ingested in ${metrics.duration_ms.toFixed(0)}ms: ` +
23
- `${metrics.files_updated} updated/added, ` +
24
- `${metrics.files_skipped} unchanged, ` +
25
- `${metrics.symbols_indexed} symbols, ` +
26
- `${metrics.dependencies_indexed} deps.`
27
- );
28
- }
29
-
30
- db.close();
31
- }
1
+ import { ConfigLoader } from "../../core/config/loader.ts";
2
+ import { SeptumDatabase } from "../../core/database/client.ts";
3
+ import { SeptumRepository } from "../../core/database/repository.ts";
4
+ import { IngestionPipeline } from "../../core/ingestion/pipeline.ts";
5
+
6
+ export interface SyncCommandOptions {
7
+ json?: boolean;
8
+ }
9
+
10
+ export async function handleSyncCommand(options: SyncCommandOptions = {}): Promise<void> {
11
+ const config = ConfigLoader.load();
12
+ const db = new SeptumDatabase(config.settings.db_path);
13
+ const repo = new SeptumRepository(db.raw);
14
+ const pipeline = new IngestionPipeline(repo);
15
+
16
+ const metrics = await pipeline.run(config);
17
+
18
+ if (options.json) {
19
+ console.log(JSON.stringify(metrics, null, 2));
20
+ } else {
21
+ console.log(
22
+ `[Septum Sync] Ingested in ${metrics.duration_ms.toFixed(0)}ms: ` +
23
+ `${metrics.files_updated} updated/added, ` +
24
+ `${metrics.files_skipped} unchanged, ` +
25
+ `${metrics.symbols_indexed} symbols, ` +
26
+ `${metrics.dependencies_indexed} deps.`
27
+ );
28
+ }
29
+
30
+ db.close();
31
+ }