gitnexus 1.6.0 → 1.6.2-rc.1
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/README.md +73 -0
- package/dist/cli/analyze.js +50 -3
- package/dist/core/group/extractors/fs-utils.d.ts +10 -0
- package/dist/core/group/extractors/fs-utils.js +24 -0
- package/dist/core/group/extractors/grpc-extractor.d.ts +17 -8
- package/dist/core/group/extractors/grpc-extractor.js +328 -191
- package/dist/core/group/extractors/grpc-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/go.js +97 -0
- package/dist/core/group/extractors/grpc-patterns/index.d.ts +19 -0
- package/dist/core/group/extractors/grpc-patterns/index.js +46 -0
- package/dist/core/group/extractors/grpc-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/java.js +173 -0
- package/dist/core/group/extractors/grpc-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/grpc-patterns/node.js +290 -0
- package/dist/core/group/extractors/grpc-patterns/proto.d.ts +9 -0
- package/dist/core/group/extractors/grpc-patterns/proto.js +134 -0
- package/dist/core/group/extractors/grpc-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/python.js +67 -0
- package/dist/core/group/extractors/grpc-patterns/types.d.ts +50 -0
- package/dist/core/group/extractors/grpc-patterns/types.js +1 -0
- package/dist/core/group/extractors/http-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/go.js +215 -0
- package/dist/core/group/extractors/http-patterns/index.d.ts +17 -0
- package/dist/core/group/extractors/http-patterns/index.js +44 -0
- package/dist/core/group/extractors/http-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/java.js +253 -0
- package/dist/core/group/extractors/http-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/http-patterns/node.js +354 -0
- package/dist/core/group/extractors/http-patterns/php.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/php.js +70 -0
- package/dist/core/group/extractors/http-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/python.js +133 -0
- package/dist/core/group/extractors/http-patterns/types.d.ts +61 -0
- package/dist/core/group/extractors/http-patterns/types.js +1 -0
- package/dist/core/group/extractors/http-route-extractor.d.ts +10 -13
- package/dist/core/group/extractors/http-route-extractor.js +231 -238
- package/dist/core/group/extractors/manifest-extractor.d.ts +54 -0
- package/dist/core/group/extractors/manifest-extractor.js +277 -0
- package/dist/core/group/extractors/topic-extractor.d.ts +0 -1
- package/dist/core/group/extractors/topic-extractor.js +55 -192
- package/dist/core/group/extractors/topic-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/go.js +120 -0
- package/dist/core/group/extractors/topic-patterns/index.d.ts +14 -0
- package/dist/core/group/extractors/topic-patterns/index.js +38 -0
- package/dist/core/group/extractors/topic-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/java.js +80 -0
- package/dist/core/group/extractors/topic-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/topic-patterns/node.js +155 -0
- package/dist/core/group/extractors/topic-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/python.js +116 -0
- package/dist/core/group/extractors/topic-patterns/types.d.ts +25 -0
- package/dist/core/group/extractors/topic-patterns/types.js +10 -0
- package/dist/core/group/extractors/tree-sitter-scanner.d.ts +113 -0
- package/dist/core/group/extractors/tree-sitter-scanner.js +94 -0
- package/dist/core/ingestion/binding-accumulator.d.ts +22 -17
- package/dist/core/ingestion/binding-accumulator.js +29 -25
- package/dist/core/ingestion/cobol-processor.d.ts +1 -1
- package/dist/core/ingestion/import-processor.js +1 -1
- package/dist/core/ingestion/language-config.js +1 -1
- package/dist/core/ingestion/language-provider.d.ts +32 -5
- package/dist/core/ingestion/languages/c-cpp.js +2 -2
- package/dist/core/ingestion/languages/dart.d.ts +1 -1
- package/dist/core/ingestion/languages/dart.js +2 -2
- package/dist/core/ingestion/languages/go.d.ts +1 -1
- package/dist/core/ingestion/languages/go.js +2 -2
- package/dist/core/ingestion/languages/ruby.js +16 -1
- package/dist/core/ingestion/languages/swift.d.ts +1 -1
- package/dist/core/ingestion/languages/swift.js +2 -2
- package/dist/core/ingestion/markdown-processor.d.ts +1 -1
- package/dist/core/ingestion/method-extractors/configs/jvm.js +1 -0
- package/dist/core/ingestion/method-extractors/configs/ruby.js +1 -0
- package/dist/core/ingestion/method-extractors/generic.d.ts +6 -0
- package/dist/core/ingestion/method-extractors/generic.js +48 -4
- package/dist/core/ingestion/method-types.d.ts +4 -0
- package/dist/core/ingestion/model/resolve.js +103 -48
- package/dist/core/ingestion/model/semantic-model.d.ts +1 -1
- package/dist/core/ingestion/model/semantic-model.js +1 -1
- package/dist/core/ingestion/model/symbol-table.d.ts +7 -7
- package/dist/core/ingestion/model/symbol-table.js +7 -7
- package/dist/core/ingestion/mro-processor.d.ts +1 -1
- package/dist/core/ingestion/mro-processor.js +1 -1
- package/dist/core/ingestion/parsing-processor.js +54 -42
- package/dist/core/ingestion/pipeline-phases/cobol.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/cobol.js +45 -0
- package/dist/core/ingestion/pipeline-phases/communities.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/communities.js +62 -0
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +17 -0
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +156 -0
- package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +37 -0
- package/dist/core/ingestion/pipeline-phases/cross-file.js +63 -0
- package/dist/core/ingestion/pipeline-phases/index.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/index.js +22 -0
- package/dist/core/ingestion/pipeline-phases/markdown.d.ts +17 -0
- package/dist/core/ingestion/pipeline-phases/markdown.js +33 -0
- package/dist/core/ingestion/pipeline-phases/mro.d.ts +18 -0
- package/dist/core/ingestion/pipeline-phases/mro.js +36 -0
- package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +22 -0
- package/dist/core/ingestion/pipeline-phases/orm-extraction.js +92 -0
- package/dist/core/ingestion/pipeline-phases/orm.d.ts +15 -0
- package/dist/core/ingestion/pipeline-phases/orm.js +74 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +47 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +437 -0
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +49 -0
- package/dist/core/ingestion/pipeline-phases/parse.js +33 -0
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/processes.js +143 -0
- package/dist/core/ingestion/pipeline-phases/routes.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/routes.js +243 -0
- package/dist/core/ingestion/pipeline-phases/runner.d.ts +22 -0
- package/dist/core/ingestion/pipeline-phases/runner.js +203 -0
- package/dist/core/ingestion/pipeline-phases/scan.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/scan.js +46 -0
- package/dist/core/ingestion/pipeline-phases/structure.d.ts +27 -0
- package/dist/core/ingestion/pipeline-phases/structure.js +35 -0
- package/dist/core/ingestion/pipeline-phases/tools.d.ts +20 -0
- package/dist/core/ingestion/pipeline-phases/tools.js +79 -0
- package/dist/core/ingestion/pipeline-phases/types.d.ts +79 -0
- package/dist/core/ingestion/pipeline-phases/types.js +37 -0
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +70 -0
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +312 -0
- package/dist/core/ingestion/pipeline.d.ts +16 -10
- package/dist/core/ingestion/pipeline.js +66 -1534
- package/dist/core/ingestion/process-processor.js +1 -1
- package/dist/core/ingestion/tree-sitter-queries.d.ts +2 -2
- package/dist/core/ingestion/tree-sitter-queries.js +69 -0
- package/dist/core/ingestion/utils/ast-helpers.d.ts +1 -3
- package/dist/core/ingestion/utils/ast-helpers.js +48 -21
- package/dist/core/ingestion/utils/env.d.ts +10 -0
- package/dist/core/ingestion/utils/env.js +10 -0
- package/dist/core/ingestion/utils/graph-sort.d.ts +58 -0
- package/dist/core/ingestion/utils/graph-sort.js +100 -0
- package/dist/core/ingestion/workers/parse-worker.js +12 -8
- package/dist/core/lbug/lbug-adapter.d.ts +28 -0
- package/dist/core/lbug/lbug-adapter.js +162 -57
- package/package.json +3 -3
- package/vendor/tree-sitter-proto/binding.gyp +30 -0
- package/vendor/tree-sitter-proto/bindings/node/binding.cc +20 -0
- package/vendor/tree-sitter-proto/bindings/node/index.d.ts +28 -0
- package/vendor/tree-sitter-proto/bindings/node/index.js +7 -0
- package/vendor/tree-sitter-proto/package.json +18 -0
- package/vendor/tree-sitter-proto/src/node-types.json +1145 -0
- package/vendor/tree-sitter-proto/src/parser.c +10149 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/alloc.h +54 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/array.h +291 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/parser.h +266 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import Go from 'tree-sitter-go';
|
|
2
|
+
import { compilePatterns } from '../tree-sitter-scanner.js';
|
|
3
|
+
/**
|
|
4
|
+
* Go topic extraction patterns.
|
|
5
|
+
*
|
|
6
|
+
* Detects Sarama, segmentio/kafka-go and nats.go producer/consumer APIs:
|
|
7
|
+
* - `X.ConsumePartition("topic", ...)`
|
|
8
|
+
* - `sarama.ProducerMessage{Topic: "xxx"}`
|
|
9
|
+
* - `kafka.Writer{Topic: "xxx"}` / `kafka.WriterConfig{Topic: ...}`
|
|
10
|
+
* - `kafka.Reader{Topic: "xxx"}` / `kafka.ReaderConfig{Topic: ...}`
|
|
11
|
+
* - `nc.Subscribe("topic", ...)` / `js.Subscribe("topic", ...)`
|
|
12
|
+
* - `nc.Publish("topic", ...)` / `js.Publish("topic", ...)`
|
|
13
|
+
*
|
|
14
|
+
* Every query MUST bind `@value` to the topic literal node.
|
|
15
|
+
*/
|
|
16
|
+
const GO_TOPIC_SPEC = {
|
|
17
|
+
name: 'go-topic',
|
|
18
|
+
language: Go,
|
|
19
|
+
patterns: [
|
|
20
|
+
{
|
|
21
|
+
meta: {
|
|
22
|
+
role: 'consumer',
|
|
23
|
+
broker: 'kafka',
|
|
24
|
+
confidence: 0.7,
|
|
25
|
+
symbolName: 'ConsumePartition',
|
|
26
|
+
},
|
|
27
|
+
query: `
|
|
28
|
+
(call_expression
|
|
29
|
+
function: (selector_expression
|
|
30
|
+
field: (field_identifier) @method (#eq? @method "ConsumePartition"))
|
|
31
|
+
arguments: (argument_list . (interpreted_string_literal) @value))
|
|
32
|
+
`,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
meta: {
|
|
36
|
+
role: 'provider',
|
|
37
|
+
broker: 'kafka',
|
|
38
|
+
confidence: 0.75,
|
|
39
|
+
symbolName: 'sarama.ProducerMessage',
|
|
40
|
+
},
|
|
41
|
+
query: `
|
|
42
|
+
(composite_literal
|
|
43
|
+
type: (qualified_type
|
|
44
|
+
package: (package_identifier) @pkg (#eq? @pkg "sarama")
|
|
45
|
+
name: (type_identifier) @ty (#eq? @ty "ProducerMessage"))
|
|
46
|
+
body: (literal_value
|
|
47
|
+
(keyed_element
|
|
48
|
+
(literal_element (identifier) @field (#eq? @field "Topic"))
|
|
49
|
+
(literal_element (interpreted_string_literal) @value))))
|
|
50
|
+
`,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
meta: {
|
|
54
|
+
role: 'provider',
|
|
55
|
+
broker: 'kafka',
|
|
56
|
+
confidence: 0.75,
|
|
57
|
+
symbolName: 'kafka.Writer',
|
|
58
|
+
},
|
|
59
|
+
query: `
|
|
60
|
+
(composite_literal
|
|
61
|
+
type: (qualified_type
|
|
62
|
+
package: (package_identifier) @pkg (#eq? @pkg "kafka")
|
|
63
|
+
name: (type_identifier) @ty (#match? @ty "^(Writer|WriterConfig)$"))
|
|
64
|
+
body: (literal_value
|
|
65
|
+
(keyed_element
|
|
66
|
+
(literal_element (identifier) @field (#eq? @field "Topic"))
|
|
67
|
+
(literal_element (interpreted_string_literal) @value))))
|
|
68
|
+
`,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
meta: {
|
|
72
|
+
role: 'consumer',
|
|
73
|
+
broker: 'kafka',
|
|
74
|
+
confidence: 0.75,
|
|
75
|
+
symbolName: 'kafka.Reader',
|
|
76
|
+
},
|
|
77
|
+
query: `
|
|
78
|
+
(composite_literal
|
|
79
|
+
type: (qualified_type
|
|
80
|
+
package: (package_identifier) @pkg (#eq? @pkg "kafka")
|
|
81
|
+
name: (type_identifier) @ty (#match? @ty "^(Reader|ReaderConfig)$"))
|
|
82
|
+
body: (literal_value
|
|
83
|
+
(keyed_element
|
|
84
|
+
(literal_element (identifier) @field (#eq? @field "Topic"))
|
|
85
|
+
(literal_element (interpreted_string_literal) @value))))
|
|
86
|
+
`,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
meta: {
|
|
90
|
+
role: 'consumer',
|
|
91
|
+
broker: 'nats',
|
|
92
|
+
confidence: 0.8,
|
|
93
|
+
symbolName: 'nc.Subscribe',
|
|
94
|
+
},
|
|
95
|
+
query: `
|
|
96
|
+
(call_expression
|
|
97
|
+
function: (selector_expression
|
|
98
|
+
operand: (identifier) @obj (#match? @obj "^(nc|js)$")
|
|
99
|
+
field: (field_identifier) @method (#match? @method "^[Ss]ubscribe$"))
|
|
100
|
+
arguments: (argument_list . (interpreted_string_literal) @value))
|
|
101
|
+
`,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
meta: {
|
|
105
|
+
role: 'provider',
|
|
106
|
+
broker: 'nats',
|
|
107
|
+
confidence: 0.8,
|
|
108
|
+
symbolName: 'nc.Publish',
|
|
109
|
+
},
|
|
110
|
+
query: `
|
|
111
|
+
(call_expression
|
|
112
|
+
function: (selector_expression
|
|
113
|
+
operand: (identifier) @obj (#match? @obj "^(nc|js)$")
|
|
114
|
+
field: (field_identifier) @method (#match? @method "^[Pp]ublish$"))
|
|
115
|
+
arguments: (argument_list . (interpreted_string_literal) @value))
|
|
116
|
+
`,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
};
|
|
120
|
+
export const GO_TOPIC_PROVIDER = compilePatterns(GO_TOPIC_SPEC);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CompiledPatterns } from '../tree-sitter-scanner.js';
|
|
2
|
+
import type { TopicMeta } from './types.js';
|
|
3
|
+
export type { TopicMeta, Broker } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Glob pattern for files worth scanning. Kept here so adding a new
|
|
6
|
+
* language to the registry also widens the glob automatically via a
|
|
7
|
+
* single edit.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TOPIC_SCAN_GLOB = "**/*.{ts,tsx,js,jsx,java,go,py}";
|
|
10
|
+
/**
|
|
11
|
+
* Return the compiled provider registered for the given file's
|
|
12
|
+
* extension, or `undefined` if the extension is not registered.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getProviderForFile(rel: string): CompiledPatterns<TopicMeta> | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { JAVA_TOPIC_PROVIDER } from './java.js';
|
|
3
|
+
import { GO_TOPIC_PROVIDER } from './go.js';
|
|
4
|
+
import { PYTHON_TOPIC_PROVIDER } from './python.js';
|
|
5
|
+
import { JAVASCRIPT_TOPIC_PROVIDER, TYPESCRIPT_TOPIC_PROVIDER, TSX_TOPIC_PROVIDER, } from './node.js';
|
|
6
|
+
/**
|
|
7
|
+
* File-extension → compiled-plugin registry for topic extraction. The
|
|
8
|
+
* top-level orchestrator (`topic-extractor.ts`) looks up the plugin for
|
|
9
|
+
* each file it visits and delegates the scanning to `tree-sitter-scanner`.
|
|
10
|
+
*
|
|
11
|
+
* Keys are lowercase extensions including the leading dot. To add a new
|
|
12
|
+
* language, drop a `topic-patterns/<lang>.ts` that exports a compiled
|
|
13
|
+
* provider, import it here and register the extension(s). No edits to
|
|
14
|
+
* `topic-extractor.ts` are required.
|
|
15
|
+
*/
|
|
16
|
+
const REGISTRY = {
|
|
17
|
+
'.java': JAVA_TOPIC_PROVIDER,
|
|
18
|
+
'.go': GO_TOPIC_PROVIDER,
|
|
19
|
+
'.py': PYTHON_TOPIC_PROVIDER,
|
|
20
|
+
'.js': JAVASCRIPT_TOPIC_PROVIDER,
|
|
21
|
+
'.jsx': JAVASCRIPT_TOPIC_PROVIDER,
|
|
22
|
+
'.ts': TYPESCRIPT_TOPIC_PROVIDER,
|
|
23
|
+
'.tsx': TSX_TOPIC_PROVIDER,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Glob pattern for files worth scanning. Kept here so adding a new
|
|
27
|
+
* language to the registry also widens the glob automatically via a
|
|
28
|
+
* single edit.
|
|
29
|
+
*/
|
|
30
|
+
export const TOPIC_SCAN_GLOB = '**/*.{ts,tsx,js,jsx,java,go,py}';
|
|
31
|
+
/**
|
|
32
|
+
* Return the compiled provider registered for the given file's
|
|
33
|
+
* extension, or `undefined` if the extension is not registered.
|
|
34
|
+
*/
|
|
35
|
+
export function getProviderForFile(rel) {
|
|
36
|
+
const ext = path.extname(rel).toLowerCase();
|
|
37
|
+
return REGISTRY[ext];
|
|
38
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import Java from 'tree-sitter-java';
|
|
2
|
+
import { compilePatterns } from '../tree-sitter-scanner.js';
|
|
3
|
+
/**
|
|
4
|
+
* Java topic extraction patterns.
|
|
5
|
+
*
|
|
6
|
+
* Detects Kafka and RabbitMQ (Spring conventions) producer/consumer APIs:
|
|
7
|
+
* - `@KafkaListener(topics = "xxx")`
|
|
8
|
+
* - `@RabbitListener(queues = "xxx")`
|
|
9
|
+
* - `kafkaTemplate.send("xxx", ...)`
|
|
10
|
+
* - `rabbitTemplate.convertAndSend("xxx", ...)`
|
|
11
|
+
*
|
|
12
|
+
* Every query MUST bind `@value` to the topic literal node.
|
|
13
|
+
*/
|
|
14
|
+
const JAVA_TOPIC_SPEC = {
|
|
15
|
+
name: 'java-topic',
|
|
16
|
+
language: Java,
|
|
17
|
+
patterns: [
|
|
18
|
+
{
|
|
19
|
+
meta: {
|
|
20
|
+
role: 'consumer',
|
|
21
|
+
broker: 'kafka',
|
|
22
|
+
confidence: 0.8,
|
|
23
|
+
symbolName: 'kafkaListener',
|
|
24
|
+
},
|
|
25
|
+
query: `
|
|
26
|
+
(annotation
|
|
27
|
+
name: (identifier) @name (#eq? @name "KafkaListener")
|
|
28
|
+
arguments: (annotation_argument_list
|
|
29
|
+
(element_value_pair
|
|
30
|
+
key: (identifier) @key (#eq? @key "topics")
|
|
31
|
+
value: (string_literal) @value)))
|
|
32
|
+
`,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
meta: {
|
|
36
|
+
role: 'consumer',
|
|
37
|
+
broker: 'rabbitmq',
|
|
38
|
+
confidence: 0.8,
|
|
39
|
+
symbolName: 'rabbitListener',
|
|
40
|
+
},
|
|
41
|
+
query: `
|
|
42
|
+
(annotation
|
|
43
|
+
name: (identifier) @name (#eq? @name "RabbitListener")
|
|
44
|
+
arguments: (annotation_argument_list
|
|
45
|
+
(element_value_pair
|
|
46
|
+
key: (identifier) @key (#eq? @key "queues")
|
|
47
|
+
value: (string_literal) @value)))
|
|
48
|
+
`,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
meta: {
|
|
52
|
+
role: 'provider',
|
|
53
|
+
broker: 'kafka',
|
|
54
|
+
confidence: 0.8,
|
|
55
|
+
symbolName: 'kafkaTemplate.send',
|
|
56
|
+
},
|
|
57
|
+
query: `
|
|
58
|
+
(method_invocation
|
|
59
|
+
object: (identifier) @obj (#eq? @obj "kafkaTemplate")
|
|
60
|
+
name: (identifier) @method (#eq? @method "send")
|
|
61
|
+
arguments: (argument_list . (string_literal) @value))
|
|
62
|
+
`,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
meta: {
|
|
66
|
+
role: 'provider',
|
|
67
|
+
broker: 'rabbitmq',
|
|
68
|
+
confidence: 0.8,
|
|
69
|
+
symbolName: 'rabbitTemplate.convertAndSend',
|
|
70
|
+
},
|
|
71
|
+
query: `
|
|
72
|
+
(method_invocation
|
|
73
|
+
object: (identifier) @obj (#eq? @obj "rabbitTemplate")
|
|
74
|
+
name: (identifier) @method (#eq? @method "convertAndSend")
|
|
75
|
+
arguments: (argument_list . (string_literal) @value))
|
|
76
|
+
`,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
export const JAVA_TOPIC_PROVIDER = compilePatterns(JAVA_TOPIC_SPEC);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TopicMeta } from './types.js';
|
|
2
|
+
export declare const JAVASCRIPT_TOPIC_PROVIDER: import("../tree-sitter-scanner.js").CompiledPatterns<TopicMeta>;
|
|
3
|
+
export declare const TYPESCRIPT_TOPIC_PROVIDER: import("../tree-sitter-scanner.js").CompiledPatterns<TopicMeta>;
|
|
4
|
+
export declare const TSX_TOPIC_PROVIDER: import("../tree-sitter-scanner.js").CompiledPatterns<TopicMeta>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import JavaScript from 'tree-sitter-javascript';
|
|
2
|
+
import TypeScript from 'tree-sitter-typescript';
|
|
3
|
+
import { compilePatterns, } from '../tree-sitter-scanner.js';
|
|
4
|
+
/**
|
|
5
|
+
* Node.js / TypeScript topic extraction patterns.
|
|
6
|
+
*
|
|
7
|
+
* Detects kafkajs, amqplib (RabbitMQ), and nats.js producer/consumer APIs:
|
|
8
|
+
* - `producer.send({ topic: 'xxx', ... })` (kafkajs)
|
|
9
|
+
* - `consumer.subscribe({ topic: 'xxx', ... })` (kafkajs)
|
|
10
|
+
* - `channel.consume("queue", ...)` / `channel.publish(...)` / `channel.sendToQueue(...)`
|
|
11
|
+
* - `nc.subscribe("topic")` / `js.subscribe("topic")`
|
|
12
|
+
* - `nc.publish("topic", ...)` / `js.publish("topic", ...)`
|
|
13
|
+
*
|
|
14
|
+
* The JavaScript and TypeScript tree-sitter grammars share node type
|
|
15
|
+
* names for every construct we query here, so the pattern sources are
|
|
16
|
+
* defined once and compiled against each grammar variant. We export three
|
|
17
|
+
* providers because Parser.Query objects are NOT portable across grammar
|
|
18
|
+
* instances — `.js` files use the JavaScript grammar, `.ts` uses
|
|
19
|
+
* TypeScript.typescript, and `.tsx` uses TypeScript.tsx.
|
|
20
|
+
*
|
|
21
|
+
* Every query MUST bind `@value` to the topic literal node.
|
|
22
|
+
*/
|
|
23
|
+
const NODE_TOPIC_PATTERNS = [
|
|
24
|
+
{
|
|
25
|
+
meta: {
|
|
26
|
+
role: 'provider',
|
|
27
|
+
broker: 'kafka',
|
|
28
|
+
confidence: 0.8,
|
|
29
|
+
symbolName: 'producer.send',
|
|
30
|
+
},
|
|
31
|
+
query: `
|
|
32
|
+
(call_expression
|
|
33
|
+
function: (member_expression
|
|
34
|
+
object: (identifier) @obj (#eq? @obj "producer")
|
|
35
|
+
property: (property_identifier) @prop (#eq? @prop "send"))
|
|
36
|
+
arguments: (arguments
|
|
37
|
+
(object
|
|
38
|
+
(pair
|
|
39
|
+
key: (property_identifier) @key (#eq? @key "topic")
|
|
40
|
+
value: [(string) (template_string)] @value))))
|
|
41
|
+
`,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
meta: {
|
|
45
|
+
role: 'consumer',
|
|
46
|
+
broker: 'kafka',
|
|
47
|
+
confidence: 0.8,
|
|
48
|
+
symbolName: 'consumer.subscribe',
|
|
49
|
+
},
|
|
50
|
+
query: `
|
|
51
|
+
(call_expression
|
|
52
|
+
function: (member_expression
|
|
53
|
+
object: (identifier) @obj (#eq? @obj "consumer")
|
|
54
|
+
property: (property_identifier) @prop (#eq? @prop "subscribe"))
|
|
55
|
+
arguments: (arguments
|
|
56
|
+
(object
|
|
57
|
+
(pair
|
|
58
|
+
key: (property_identifier) @key (#eq? @key "topic")
|
|
59
|
+
value: [(string) (template_string)] @value))))
|
|
60
|
+
`,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
meta: {
|
|
64
|
+
role: 'consumer',
|
|
65
|
+
broker: 'rabbitmq',
|
|
66
|
+
confidence: 0.8,
|
|
67
|
+
symbolName: 'channel.consume',
|
|
68
|
+
},
|
|
69
|
+
query: `
|
|
70
|
+
(call_expression
|
|
71
|
+
function: (member_expression
|
|
72
|
+
object: (identifier) @obj (#eq? @obj "channel")
|
|
73
|
+
property: (property_identifier) @prop (#eq? @prop "consume"))
|
|
74
|
+
arguments: (arguments . [(string) (template_string)] @value))
|
|
75
|
+
`,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
meta: {
|
|
79
|
+
role: 'provider',
|
|
80
|
+
broker: 'rabbitmq',
|
|
81
|
+
confidence: 0.8,
|
|
82
|
+
symbolName: 'channel.publish',
|
|
83
|
+
},
|
|
84
|
+
query: `
|
|
85
|
+
(call_expression
|
|
86
|
+
function: (member_expression
|
|
87
|
+
object: (identifier) @obj (#eq? @obj "channel")
|
|
88
|
+
property: (property_identifier) @prop (#eq? @prop "publish"))
|
|
89
|
+
arguments: (arguments . [(string) (template_string)] @value))
|
|
90
|
+
`,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
meta: {
|
|
94
|
+
role: 'provider',
|
|
95
|
+
broker: 'rabbitmq',
|
|
96
|
+
confidence: 0.8,
|
|
97
|
+
symbolName: 'channel.sendToQueue',
|
|
98
|
+
},
|
|
99
|
+
query: `
|
|
100
|
+
(call_expression
|
|
101
|
+
function: (member_expression
|
|
102
|
+
object: (identifier) @obj (#eq? @obj "channel")
|
|
103
|
+
property: (property_identifier) @prop (#eq? @prop "sendToQueue"))
|
|
104
|
+
arguments: (arguments . [(string) (template_string)] @value))
|
|
105
|
+
`,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
meta: {
|
|
109
|
+
role: 'consumer',
|
|
110
|
+
broker: 'nats',
|
|
111
|
+
confidence: 0.8,
|
|
112
|
+
symbolName: 'nc.subscribe',
|
|
113
|
+
},
|
|
114
|
+
query: `
|
|
115
|
+
(call_expression
|
|
116
|
+
function: (member_expression
|
|
117
|
+
object: (identifier) @obj (#match? @obj "^(nc|js)$")
|
|
118
|
+
property: (property_identifier) @prop (#match? @prop "^[Ss]ubscribe$"))
|
|
119
|
+
arguments: (arguments . [(string) (template_string)] @value))
|
|
120
|
+
`,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
meta: {
|
|
124
|
+
role: 'provider',
|
|
125
|
+
broker: 'nats',
|
|
126
|
+
confidence: 0.8,
|
|
127
|
+
symbolName: 'nc.publish',
|
|
128
|
+
},
|
|
129
|
+
query: `
|
|
130
|
+
(call_expression
|
|
131
|
+
function: (member_expression
|
|
132
|
+
object: (identifier) @obj (#match? @obj "^(nc|js)$")
|
|
133
|
+
property: (property_identifier) @prop (#match? @prop "^[Pp]ublish$"))
|
|
134
|
+
arguments: (arguments . [(string) (template_string)] @value))
|
|
135
|
+
`,
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
const JAVASCRIPT_TOPIC_SPEC = {
|
|
139
|
+
name: 'javascript-topic',
|
|
140
|
+
language: JavaScript,
|
|
141
|
+
patterns: NODE_TOPIC_PATTERNS,
|
|
142
|
+
};
|
|
143
|
+
const TYPESCRIPT_TOPIC_SPEC = {
|
|
144
|
+
name: 'typescript-topic',
|
|
145
|
+
language: TypeScript.typescript,
|
|
146
|
+
patterns: NODE_TOPIC_PATTERNS,
|
|
147
|
+
};
|
|
148
|
+
const TSX_TOPIC_SPEC = {
|
|
149
|
+
name: 'tsx-topic',
|
|
150
|
+
language: TypeScript.tsx,
|
|
151
|
+
patterns: NODE_TOPIC_PATTERNS,
|
|
152
|
+
};
|
|
153
|
+
export const JAVASCRIPT_TOPIC_PROVIDER = compilePatterns(JAVASCRIPT_TOPIC_SPEC);
|
|
154
|
+
export const TYPESCRIPT_TOPIC_PROVIDER = compilePatterns(TYPESCRIPT_TOPIC_SPEC);
|
|
155
|
+
export const TSX_TOPIC_PROVIDER = compilePatterns(TSX_TOPIC_SPEC);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Python from 'tree-sitter-python';
|
|
2
|
+
import { compilePatterns } from '../tree-sitter-scanner.js';
|
|
3
|
+
/**
|
|
4
|
+
* Python topic extraction patterns.
|
|
5
|
+
*
|
|
6
|
+
* Detects kafka-python, pika (RabbitMQ), and nats-py producer/consumer APIs:
|
|
7
|
+
* - `KafkaConsumer('topic', ...)`
|
|
8
|
+
* - `producer.send('topic', ...)` / `producer.produce('topic', ...)`
|
|
9
|
+
* - `channel.basic_consume(queue='xxx', ...)`
|
|
10
|
+
* - `channel.basic_publish(exchange='xxx', ...)`
|
|
11
|
+
* - `await nc.subscribe('topic')`
|
|
12
|
+
* - `await nc.publish('topic', ...)`
|
|
13
|
+
*
|
|
14
|
+
* Every query MUST bind `@value` to the topic literal node.
|
|
15
|
+
*/
|
|
16
|
+
const PYTHON_TOPIC_SPEC = {
|
|
17
|
+
name: 'python-topic',
|
|
18
|
+
language: Python,
|
|
19
|
+
patterns: [
|
|
20
|
+
{
|
|
21
|
+
meta: {
|
|
22
|
+
role: 'consumer',
|
|
23
|
+
broker: 'kafka',
|
|
24
|
+
confidence: 0.7,
|
|
25
|
+
symbolName: 'KafkaConsumer',
|
|
26
|
+
},
|
|
27
|
+
query: `
|
|
28
|
+
(call
|
|
29
|
+
function: (identifier) @func (#eq? @func "KafkaConsumer")
|
|
30
|
+
arguments: (argument_list . (string) @value))
|
|
31
|
+
`,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
meta: {
|
|
35
|
+
role: 'provider',
|
|
36
|
+
broker: 'kafka',
|
|
37
|
+
confidence: 0.7,
|
|
38
|
+
symbolName: 'producer.send',
|
|
39
|
+
},
|
|
40
|
+
query: `
|
|
41
|
+
(call
|
|
42
|
+
function: (attribute
|
|
43
|
+
object: (identifier) @obj (#eq? @obj "producer")
|
|
44
|
+
attribute: (identifier) @method (#match? @method "^(send|produce)$"))
|
|
45
|
+
arguments: (argument_list . (string) @value))
|
|
46
|
+
`,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
meta: {
|
|
50
|
+
role: 'consumer',
|
|
51
|
+
broker: 'rabbitmq',
|
|
52
|
+
confidence: 0.7,
|
|
53
|
+
symbolName: 'basic_consume',
|
|
54
|
+
},
|
|
55
|
+
query: `
|
|
56
|
+
(call
|
|
57
|
+
function: (attribute
|
|
58
|
+
object: (identifier) @obj (#eq? @obj "channel")
|
|
59
|
+
attribute: (identifier) @method (#eq? @method "basic_consume"))
|
|
60
|
+
arguments: (argument_list
|
|
61
|
+
(keyword_argument
|
|
62
|
+
name: (identifier) @kw (#eq? @kw "queue")
|
|
63
|
+
value: (string) @value)))
|
|
64
|
+
`,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
meta: {
|
|
68
|
+
role: 'provider',
|
|
69
|
+
broker: 'rabbitmq',
|
|
70
|
+
confidence: 0.7,
|
|
71
|
+
symbolName: 'basic_publish',
|
|
72
|
+
},
|
|
73
|
+
query: `
|
|
74
|
+
(call
|
|
75
|
+
function: (attribute
|
|
76
|
+
object: (identifier) @obj (#eq? @obj "channel")
|
|
77
|
+
attribute: (identifier) @method (#eq? @method "basic_publish"))
|
|
78
|
+
arguments: (argument_list
|
|
79
|
+
(keyword_argument
|
|
80
|
+
name: (identifier) @kw (#eq? @kw "exchange")
|
|
81
|
+
value: (string) @value)))
|
|
82
|
+
`,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
meta: {
|
|
86
|
+
role: 'consumer',
|
|
87
|
+
broker: 'nats',
|
|
88
|
+
confidence: 0.75,
|
|
89
|
+
symbolName: 'nc.subscribe',
|
|
90
|
+
},
|
|
91
|
+
query: `
|
|
92
|
+
(call
|
|
93
|
+
function: (attribute
|
|
94
|
+
object: (identifier) @obj (#eq? @obj "nc")
|
|
95
|
+
attribute: (identifier) @method (#eq? @method "subscribe"))
|
|
96
|
+
arguments: (argument_list . (string) @value))
|
|
97
|
+
`,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
meta: {
|
|
101
|
+
role: 'provider',
|
|
102
|
+
broker: 'nats',
|
|
103
|
+
confidence: 0.75,
|
|
104
|
+
symbolName: 'nc.publish',
|
|
105
|
+
},
|
|
106
|
+
query: `
|
|
107
|
+
(call
|
|
108
|
+
function: (attribute
|
|
109
|
+
object: (identifier) @obj (#eq? @obj "nc")
|
|
110
|
+
attribute: (identifier) @method (#eq? @method "publish"))
|
|
111
|
+
arguments: (argument_list . (string) @value))
|
|
112
|
+
`,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
export const PYTHON_TOPIC_PROVIDER = compilePatterns(PYTHON_TOPIC_SPEC);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the topic-extractor language plugins.
|
|
3
|
+
*
|
|
4
|
+
* Each plugin lives in its own file (java.ts, go.ts, ...) and owns the
|
|
5
|
+
* tree-sitter grammar import + query sources. The top-level
|
|
6
|
+
* `topic-extractor.ts` orchestrator only knows about this type module and
|
|
7
|
+
* the plugin registry (`./index.ts`). It MUST NOT import any grammar or
|
|
8
|
+
* query text directly — that's the whole point of the split.
|
|
9
|
+
*/
|
|
10
|
+
export type Broker = 'kafka' | 'rabbitmq' | 'nats';
|
|
11
|
+
/**
|
|
12
|
+
* Per-pattern payload every topic plugin attaches to its query. Whatever
|
|
13
|
+
* the pattern matches, the orchestrator receives this object verbatim
|
|
14
|
+
* and uses it to build an `ExtractedContract`.
|
|
15
|
+
*
|
|
16
|
+
* Plugins produce one `TopicMeta` per pattern (not per match) because a
|
|
17
|
+
* single query uniquely identifies its broker/role/confidence triple.
|
|
18
|
+
*/
|
|
19
|
+
export interface TopicMeta {
|
|
20
|
+
role: 'provider' | 'consumer';
|
|
21
|
+
broker: Broker;
|
|
22
|
+
confidence: number;
|
|
23
|
+
/** Short human-readable label of the API being detected. */
|
|
24
|
+
symbolName: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the topic-extractor language plugins.
|
|
3
|
+
*
|
|
4
|
+
* Each plugin lives in its own file (java.ts, go.ts, ...) and owns the
|
|
5
|
+
* tree-sitter grammar import + query sources. The top-level
|
|
6
|
+
* `topic-extractor.ts` orchestrator only knows about this type module and
|
|
7
|
+
* the plugin registry (`./index.ts`). It MUST NOT import any grammar or
|
|
8
|
+
* query text directly — that's the whole point of the split.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|