codebeacon 0.1.2__py3-none-any.whl

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 (59) hide show
  1. codebeacon/__init__.py +1 -0
  2. codebeacon/__main__.py +3 -0
  3. codebeacon/cache.py +136 -0
  4. codebeacon/cli.py +391 -0
  5. codebeacon/common/__init__.py +0 -0
  6. codebeacon/common/filters.py +170 -0
  7. codebeacon/common/symbols.py +121 -0
  8. codebeacon/common/types.py +98 -0
  9. codebeacon/config.py +144 -0
  10. codebeacon/contextmap/__init__.py +0 -0
  11. codebeacon/contextmap/generator.py +602 -0
  12. codebeacon/discover/__init__.py +0 -0
  13. codebeacon/discover/detector.py +388 -0
  14. codebeacon/discover/scanner.py +192 -0
  15. codebeacon/export/__init__.py +0 -0
  16. codebeacon/export/mcp.py +515 -0
  17. codebeacon/export/obsidian.py +812 -0
  18. codebeacon/extract/__init__.py +22 -0
  19. codebeacon/extract/base.py +372 -0
  20. codebeacon/extract/components.py +357 -0
  21. codebeacon/extract/dependencies.py +140 -0
  22. codebeacon/extract/entities.py +575 -0
  23. codebeacon/extract/queries/README.md +116 -0
  24. codebeacon/extract/queries/actix.scm +115 -0
  25. codebeacon/extract/queries/angular.scm +155 -0
  26. codebeacon/extract/queries/aspnet.scm +159 -0
  27. codebeacon/extract/queries/django.scm +122 -0
  28. codebeacon/extract/queries/express.scm +124 -0
  29. codebeacon/extract/queries/fastapi.scm +152 -0
  30. codebeacon/extract/queries/flask.scm +120 -0
  31. codebeacon/extract/queries/gin.scm +142 -0
  32. codebeacon/extract/queries/ktor.scm +144 -0
  33. codebeacon/extract/queries/laravel.scm +172 -0
  34. codebeacon/extract/queries/nestjs.scm +183 -0
  35. codebeacon/extract/queries/rails.scm +114 -0
  36. codebeacon/extract/queries/react.scm +111 -0
  37. codebeacon/extract/queries/spring_boot.scm +204 -0
  38. codebeacon/extract/queries/svelte.scm +73 -0
  39. codebeacon/extract/queries/vapor.scm +130 -0
  40. codebeacon/extract/queries/vue.scm +123 -0
  41. codebeacon/extract/routes.py +910 -0
  42. codebeacon/extract/semantic.py +280 -0
  43. codebeacon/extract/services.py +597 -0
  44. codebeacon/graph/__init__.py +1 -0
  45. codebeacon/graph/analyze.py +281 -0
  46. codebeacon/graph/build.py +320 -0
  47. codebeacon/graph/cluster.py +160 -0
  48. codebeacon/graph/enrich.py +206 -0
  49. codebeacon/skill/SKILL.md +127 -0
  50. codebeacon/wave.py +292 -0
  51. codebeacon/wiki/__init__.py +0 -0
  52. codebeacon/wiki/generator.py +376 -0
  53. codebeacon/wiki/index.py +95 -0
  54. codebeacon/wiki/templates.py +467 -0
  55. codebeacon-0.1.2.dist-info/METADATA +319 -0
  56. codebeacon-0.1.2.dist-info/RECORD +59 -0
  57. codebeacon-0.1.2.dist-info/WHEEL +4 -0
  58. codebeacon-0.1.2.dist-info/entry_points.txt +2 -0
  59. codebeacon-0.1.2.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,204 @@
1
+ ; ── Spring Boot (Java) tree-sitter queries ──────────────────────────────────
2
+ ; Grammar: tree-sitter-java
3
+ ;
4
+ ; Java grammar note:
5
+ ; - marker_annotation: @Override, @RestController (no arguments)
6
+ ; - annotation: @RequestMapping("/path") (with arguments)
7
+ ; Both appear as children of `modifiers`.
8
+ ;
9
+ ; Captures used by routes.py / services.py / entities.py:
10
+ ; @route.class_annotation - @RequestMapping on class
11
+ ; @route.method_annotation - @GetMapping/@PostMapping/etc on method
12
+ ; @route.class_name - controller class name
13
+ ; @route.method_name - handler method name
14
+ ; @route.path_value - path string literal
15
+ ; @service.annotation - @Service/@Component etc. name
16
+ ; @service.class_name - service class name
17
+ ; @service.interface - implemented interface name
18
+ ; @entity.class_name - entity class name
19
+ ; @entity.table_name - @Table(name="...") value
20
+ ; @di.field_type - @Autowired field type
21
+ ; @di.field_name - @Autowired field name
22
+ ; @di.ctor_param_type - constructor injection param type
23
+ ; @di.ctor_param_name - constructor injection param name
24
+ ; @import.path - import path
25
+
26
+ ; ── Controller class ─────────────────────────────────────────────────────────
27
+
28
+ (class_declaration
29
+ (modifiers
30
+ [
31
+ (annotation name: (identifier) @route.class_annotation)
32
+ (marker_annotation name: (identifier) @route.class_annotation)
33
+ ]
34
+ (#match? @route.class_annotation "^(RestController|Controller)$")
35
+ )
36
+ name: (identifier) @route.class_name
37
+ ) @route.controller_class
38
+
39
+ ; Class-level @RequestMapping path
40
+ (class_declaration
41
+ (modifiers
42
+ (annotation
43
+ name: (identifier) @_rm
44
+ (#eq? @_rm "RequestMapping")
45
+ arguments: (annotation_argument_list
46
+ [
47
+ (string_literal) @route.class_path
48
+ (element_value_pair
49
+ key: (identifier) @_key
50
+ (#match? @_key "^(value|path)$")
51
+ value: [
52
+ (string_literal) @route.class_path
53
+ (array_initializer (string_literal) @route.class_path)
54
+ ]
55
+ )
56
+ ]
57
+ )
58
+ )
59
+ )
60
+ ) @route.class_mapping
61
+
62
+ ; ── Method-level route annotations ───────────────────────────────────────────
63
+
64
+ ; With arguments (annotation)
65
+ (method_declaration
66
+ (modifiers
67
+ (annotation
68
+ name: (identifier) @route.method_annotation
69
+ (#match? @route.method_annotation "^(GetMapping|PostMapping|PutMapping|DeleteMapping|PatchMapping|RequestMapping)$")
70
+ )
71
+ )
72
+ name: (identifier) @route.method_name
73
+ ) @route.handler_method
74
+
75
+ ; Without arguments (marker_annotation) — e.g. @GetMapping with no path
76
+ (method_declaration
77
+ (modifiers
78
+ (marker_annotation
79
+ name: (identifier) @route.method_annotation
80
+ (#match? @route.method_annotation "^(GetMapping|PostMapping|PutMapping|DeleteMapping|PatchMapping|RequestMapping)$")
81
+ )
82
+ )
83
+ name: (identifier) @route.method_name
84
+ ) @route.handler_method
85
+
86
+ ; Method annotation WITH path value
87
+ (method_declaration
88
+ (modifiers
89
+ (annotation
90
+ name: (identifier) @_ann
91
+ (#match? @_ann "^(GetMapping|PostMapping|PutMapping|DeleteMapping|PatchMapping|RequestMapping)$")
92
+ arguments: (annotation_argument_list
93
+ [
94
+ (string_literal) @route.path_value
95
+ (element_value_pair
96
+ key: (identifier) @_key
97
+ (#match? @_key "^(value|path)$")
98
+ value: [
99
+ (string_literal) @route.path_value
100
+ (array_initializer (string_literal) @route.path_value)
101
+ ]
102
+ )
103
+ ]
104
+ )
105
+ )
106
+ )
107
+ name: (identifier) @route.method_name_with_path
108
+ ) @route.method_with_path
109
+
110
+ ; ── Service / Component / Repository ─────────────────────────────────────────
111
+
112
+ (class_declaration
113
+ (modifiers
114
+ [
115
+ (annotation name: (identifier) @service.annotation)
116
+ (marker_annotation name: (identifier) @service.annotation)
117
+ ]
118
+ (#match? @service.annotation "^(Service|Component|Repository|RestController|Controller)$")
119
+ )
120
+ name: (identifier) @service.class_name
121
+ ) @service.class
122
+
123
+ ; Implemented interfaces
124
+ (class_declaration
125
+ name: (identifier) @service.class_name
126
+ (super_interfaces
127
+ (type_list
128
+ (type_identifier) @service.interface
129
+ )
130
+ )
131
+ ) @service.with_interface
132
+
133
+ ; ── Entity ────────────────────────────────────────────────────────────────────
134
+
135
+ (class_declaration
136
+ (modifiers
137
+ (marker_annotation
138
+ name: (identifier) @entity.annotation
139
+ (#eq? @entity.annotation "Entity")
140
+ )
141
+ )
142
+ name: (identifier) @entity.class_name
143
+ ) @entity.class
144
+
145
+ ; @Table(name = "...") — separate query (not inside class_declaration to avoid nesting issues)
146
+ (annotation
147
+ name: (identifier) @_tbl
148
+ (#eq? @_tbl "Table")
149
+ arguments: (annotation_argument_list
150
+ (element_value_pair
151
+ key: (identifier) @_name_key
152
+ (#eq? @_name_key "name")
153
+ value: (string_literal) @entity.table_name
154
+ )
155
+ )
156
+ ) @entity.table_annotation
157
+
158
+ ; ── DI — @Autowired field injection ──────────────────────────────────────────
159
+
160
+ (field_declaration
161
+ (modifiers
162
+ [
163
+ (annotation name: (identifier) @_aw (#eq? @_aw "Autowired"))
164
+ (marker_annotation name: (identifier) @_aw (#eq? @_aw "Autowired"))
165
+ ]
166
+ )
167
+ type: (type_identifier) @di.field_type
168
+ (variable_declarator
169
+ name: (identifier) @di.field_name
170
+ )
171
+ ) @di.autowired_field
172
+
173
+ ; ── DI — Constructor injection ───────────────────────────────────────────────
174
+
175
+ (constructor_declaration
176
+ parameters: (formal_parameters
177
+ (formal_parameter
178
+ type: (type_identifier) @di.ctor_param_type
179
+ name: (identifier) @di.ctor_param_name
180
+ )
181
+ )
182
+ ) @di.constructor
183
+
184
+ ; ── Entity fields ─────────────────────────────────────────────────────────────
185
+
186
+ (field_declaration
187
+ (modifiers
188
+ [
189
+ (annotation name: (identifier) @entity.field_annotation)
190
+ (marker_annotation name: (identifier) @entity.field_annotation)
191
+ ]
192
+ (#match? @entity.field_annotation "^(Id|Column|ManyToOne|OneToMany|ManyToMany|OneToOne|JoinColumn|GeneratedValue)$")
193
+ )
194
+ type: _ @entity.field_type
195
+ (variable_declarator
196
+ name: (identifier) @entity.field_name
197
+ )
198
+ ) @entity.field
199
+
200
+ ; ── Imports ───────────────────────────────────────────────────────────────────
201
+
202
+ (import_declaration
203
+ (scoped_identifier) @import.path
204
+ ) @import.decl
@@ -0,0 +1,73 @@
1
+ ; ── Svelte / SvelteKit (script section only) ──────────────────────────────────
2
+ ; Grammar: tree-sitter-typescript (applied to extracted <script> section)
3
+ ;
4
+ ; Usage note:
5
+ ; .svelte files use SFC section extraction (same as Vue).
6
+ ; This .scm file applies to the extracted <script> section.
7
+ ;
8
+ ; Svelte 5 runes: $state(), $derived(), $effect() — captured as call_expression
9
+ ; Svelte 4: export let prop — explicit prop declarations
10
+ ; SvelteKit routes: file-system (src/routes/**/+page.svelte) → detector.py
11
+ ; SvelteKit load: +page.ts export function load() { } — separate file
12
+ ;
13
+ ; Captures:
14
+ ; @component.name - component name (derived from filename in routes.py)
15
+ ; @prop.name - export let propName (Svelte 4)
16
+ ; @store.name - writable/readable/derived store
17
+ ; @rune.name - Svelte 5: $state/$derived/$effect call
18
+ ; @load.func - SvelteKit load function name
19
+ ; @import.path - import source
20
+
21
+ ; ── export let prop (Svelte 4 props) ─────────────────────────────────────────
22
+
23
+ (export_statement
24
+ (lexical_declaration
25
+ (variable_declarator
26
+ name: (identifier) @prop.name
27
+ )
28
+ )
29
+ ) @prop.exported_let
30
+
31
+ ; ── Svelte 5 runes ────────────────────────────────────────────────────────────
32
+
33
+ (variable_declarator
34
+ name: (identifier) @_var
35
+ value: (call_expression
36
+ function: (identifier) @rune.name
37
+ (#match? @rune.name "^\\$(state|derived|effect|props|bindable|inspect|host)$")
38
+ )
39
+ ) @rune.usage
40
+
41
+ ; ── Svelte stores ─────────────────────────────────────────────────────────────
42
+
43
+ (variable_declarator
44
+ name: (identifier) @store.name
45
+ value: (call_expression
46
+ function: (identifier) @_store_fn
47
+ (#match? @_store_fn "^(writable|readable|derived|get)$")
48
+ )
49
+ ) @store.decl
50
+
51
+ ; ── SvelteKit load function ───────────────────────────────────────────────────
52
+
53
+ (export_statement
54
+ (function_declaration
55
+ name: (identifier) @load.func
56
+ (#match? @load.func "^(load|GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|fallback)$")
57
+ )
58
+ ) @load.export
59
+
60
+ ; ── Component function / class (less common in Svelte but possible) ──────────
61
+
62
+ (export_statement
63
+ (function_declaration
64
+ name: (identifier) @component.name
65
+ (#match? @component.name "^[A-Z]")
66
+ )
67
+ ) @component.func
68
+
69
+ ; ── imports ───────────────────────────────────────────────────────────────────
70
+
71
+ (import_statement
72
+ source: (string) @import.path
73
+ ) @import.decl
@@ -0,0 +1,130 @@
1
+ ; ── Vapor (Swift) ────────────────────────────────────────────────────────────
2
+ ; Grammar: tree-sitter-swift
3
+ ;
4
+ ; Swift grammar note:
5
+ ; - call_expression + navigation_expression: app.get("path") { ... }
6
+ ; - navigation_suffix with simple_identifier: method name
7
+ ; - call_suffix + value_arguments: route path arguments
8
+ ; - line_string_literal: Swift double-quoted string
9
+ ; - line_str_text: string content
10
+ ; - property_declaration: let x = app.grouped("prefix")
11
+ ; - attribute: @ID, @Field property wrappers
12
+ ;
13
+ ; Note: Swift paths can be multiple string arguments: app.get("users", ":id")
14
+ ; extract/routes.py joins them with "/"
15
+ ;
16
+ ; Captures:
17
+ ; @route.object - app / group variable
18
+ ; @route.method - get/post/put/patch/delete/on
19
+ ; @route.path_segment - path string segment(s)
20
+ ; @route.grouped_name - grouped variable name
21
+ ; @route.grouped_prefix - grouped path string
22
+ ; @entity.class_name - Fluent Model class
23
+ ; @entity.field_name - @Field property name
24
+ ; @entity.field_key - @Field(key: "column") value
25
+ ; @entity.id_name - @ID property name
26
+ ; @service.func_name - routes configuration function
27
+ ; @import.name - import module name
28
+
29
+ ; ── app.get("path") { ... } ──────────────────────────────────────────────────
30
+
31
+ (call_expression
32
+ (navigation_expression
33
+ (simple_identifier) @route.object
34
+ (navigation_suffix
35
+ (simple_identifier) @route.method
36
+ (#match? @route.method "^(get|post|put|patch|delete|on|grouped)$")
37
+ )
38
+ )
39
+ (call_suffix
40
+ (value_arguments
41
+ (value_argument
42
+ (line_string_literal
43
+ (line_str_text) @route.path_segment
44
+ )
45
+ )
46
+ )
47
+ (lambda_literal)?
48
+ )
49
+ ) @route.call
50
+
51
+ ; ── let users = app.grouped("users") ─────────────────────────────────────────
52
+
53
+ (property_declaration
54
+ (pattern
55
+ (simple_identifier) @route.grouped_name
56
+ )
57
+ (call_expression
58
+ (navigation_expression
59
+ (simple_identifier) @_app
60
+ (navigation_suffix
61
+ (simple_identifier) @_grouped
62
+ (#eq? @_grouped "grouped")
63
+ )
64
+ )
65
+ (call_suffix
66
+ (value_arguments
67
+ (value_argument
68
+ (line_string_literal
69
+ (line_str_text) @route.grouped_prefix
70
+ )
71
+ )
72
+ )
73
+ )
74
+ )
75
+ ) @route.grouped_decl
76
+
77
+ ; ── Fluent Model class ────────────────────────────────────────────────────────
78
+
79
+ (class_declaration
80
+ (type_modifiers (attribute (user_type (type_identifier) @_final (#eq? @_final "final"))))?
81
+ (simple_identifier) @entity.class_name
82
+ (type_inheritance_clause
83
+ (inheritance_specifier
84
+ (user_type
85
+ (type_identifier) @_base
86
+ (#match? @_base "^(Model|Content|Authenticatable)$")
87
+ )
88
+ )
89
+ )
90
+ ) @entity.model
91
+
92
+ ; @Field(key: "column_name") var fieldName: Type
93
+ (property_declaration
94
+ (modifiers
95
+ (attribute
96
+ (user_type (type_identifier) @_attr (#eq? @_attr "Field"))
97
+ (attribute_argument_clause
98
+ (value_argument
99
+ (simple_identifier) @_key (#eq? @_key "key")
100
+ (line_string_literal (line_str_text) @entity.field_key)
101
+ )
102
+ )
103
+ )
104
+ )
105
+ (pattern (simple_identifier) @entity.field_name)
106
+ ) @entity.field
107
+
108
+ ; @ID(key: .id) var id
109
+ (property_declaration
110
+ (modifiers
111
+ (attribute
112
+ (user_type (type_identifier) @_id (#eq? @_id "ID"))
113
+ )
114
+ )
115
+ (pattern (simple_identifier) @entity.id_name)
116
+ ) @entity.id_field
117
+
118
+ ; ── Routes function ───────────────────────────────────────────────────────────
119
+
120
+ (function_declaration
121
+ (simple_identifier) @service.func_name
122
+ ) @service.func
123
+
124
+ ; ── imports ───────────────────────────────────────────────────────────────────
125
+
126
+ (import_declaration
127
+ (identifier
128
+ (simple_identifier) @import.name
129
+ )
130
+ ) @import.decl
@@ -0,0 +1,123 @@
1
+ ; ── Vue / Nuxt (script section only) ──────────────────────────────────────────
2
+ ; Grammar: tree-sitter-typescript (applied to extracted <script> section)
3
+ ;
4
+ ; Usage note:
5
+ ; .vue SFC files are NOT parsed directly. extract/base.py extracts the
6
+ ; <script> section text and parses it with TypeScript grammar.
7
+ ; This .scm file describes queries for that extracted script section.
8
+ ;
9
+ ; Vue 3 Composition API patterns:
10
+ ; - defineComponent({ name, setup, components, props })
11
+ ; - <script setup> — top-level statements are component options
12
+ ; - defineProps<{ name: string }>() / defineProps({ name: String })
13
+ ; - defineEmits
14
+ ; - const router = useRouter() / const route = useRoute()
15
+ ;
16
+ ; Vue Router: const routes = [{ path: "/users", component: UserList }]
17
+ ; Nuxt: file-system routing handled in detector.py
18
+ ;
19
+ ; Captures:
20
+ ; @component.name - defineComponent({ name: "..." }) value
21
+ ; @component.class_name - export default class ComponentName
22
+ ; @component.setup_name - <script setup> — use filename as component name
23
+ ; @route.path - Vue Router route path string
24
+ ; @route.component - Vue Router component identifier
25
+ ; @prop.name - defineProps({ name: ... }) key
26
+ ; @composable.name - used composable (useX function calls)
27
+ ; @import.path - import source
28
+
29
+ ; ── defineComponent({ name: "ComponentName", ... }) ─────────────────────────
30
+
31
+ (call_expression
32
+ function: (identifier) @_dc
33
+ (#eq? @_dc "defineComponent")
34
+ arguments: (arguments
35
+ (object
36
+ (pair
37
+ key: (property_identifier) @_name_key
38
+ (#eq? @_name_key "name")
39
+ value: (string
40
+ (string_fragment) @component.name
41
+ )
42
+ )
43
+ )
44
+ )
45
+ ) @component.define
46
+
47
+ ; ── export default class ComponentName ───────────────────────────────────────
48
+
49
+ (export_statement
50
+ "default"
51
+ (class_declaration
52
+ name: (type_identifier) @component.class_name
53
+ )
54
+ ) @component.class
55
+
56
+ (export_statement
57
+ "default"
58
+ (call_expression
59
+ function: (identifier) @_dc2
60
+ (#eq? @_dc2 "defineComponent")
61
+ )
62
+ ) @component.define_anon
63
+
64
+ ; ── defineProps({ ... }) / defineProps<T>() ──────────────────────────────────
65
+
66
+ (call_expression
67
+ function: (identifier) @_dp
68
+ (#eq? @_dp "defineProps")
69
+ arguments: (arguments
70
+ (object
71
+ (pair
72
+ key: (property_identifier) @prop.name
73
+ )
74
+ )
75
+ )
76
+ ) @component.props_object
77
+
78
+ ; ── Vue Router routes array ───────────────────────────────────────────────────
79
+
80
+ (variable_declarator
81
+ name: (identifier) @_routes
82
+ (#eq? @_routes "routes")
83
+ value: (array
84
+ (object
85
+ (pair
86
+ key: (property_identifier) @_path_key
87
+ (#eq? @_path_key "path")
88
+ value: (string
89
+ (string_fragment) @route.path
90
+ )
91
+ )
92
+ )
93
+ )
94
+ ) @route.routes_array
95
+
96
+ ; Route component reference
97
+ (object
98
+ (pair
99
+ key: (property_identifier) @_path_key2
100
+ (#eq? @_path_key2 "path")
101
+ value: (string
102
+ (string_fragment) @route.path
103
+ )
104
+ )
105
+ (pair
106
+ key: (property_identifier) @_comp_key
107
+ (#match? @_comp_key "^(component|components)$")
108
+ value: (identifier) @route.component
109
+ )
110
+ ) @route.route_entry
111
+
112
+ ; ── Composable usage (useX) ───────────────────────────────────────────────────
113
+
114
+ (call_expression
115
+ function: (identifier) @composable.name
116
+ (#match? @composable.name "^use[A-Z]")
117
+ ) @composable.call
118
+
119
+ ; ── imports ───────────────────────────────────────────────────────────────────
120
+
121
+ (import_statement
122
+ source: (string) @import.path
123
+ ) @import.decl