@duytransipher/gitnexus 1.4.6-sipher.0

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 (224) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +261 -0
  3. package/dist/cli/ai-context.d.ts +23 -0
  4. package/dist/cli/ai-context.js +265 -0
  5. package/dist/cli/analyze.d.ts +12 -0
  6. package/dist/cli/analyze.js +345 -0
  7. package/dist/cli/augment.d.ts +13 -0
  8. package/dist/cli/augment.js +33 -0
  9. package/dist/cli/clean.d.ts +10 -0
  10. package/dist/cli/clean.js +60 -0
  11. package/dist/cli/eval-server.d.ts +37 -0
  12. package/dist/cli/eval-server.js +389 -0
  13. package/dist/cli/index.d.ts +2 -0
  14. package/dist/cli/index.js +137 -0
  15. package/dist/cli/lazy-action.d.ts +6 -0
  16. package/dist/cli/lazy-action.js +18 -0
  17. package/dist/cli/list.d.ts +6 -0
  18. package/dist/cli/list.js +30 -0
  19. package/dist/cli/mcp.d.ts +8 -0
  20. package/dist/cli/mcp.js +36 -0
  21. package/dist/cli/serve.d.ts +4 -0
  22. package/dist/cli/serve.js +6 -0
  23. package/dist/cli/setup.d.ts +8 -0
  24. package/dist/cli/setup.js +367 -0
  25. package/dist/cli/sipher-patched.d.ts +2 -0
  26. package/dist/cli/sipher-patched.js +77 -0
  27. package/dist/cli/skill-gen.d.ts +26 -0
  28. package/dist/cli/skill-gen.js +549 -0
  29. package/dist/cli/status.d.ts +6 -0
  30. package/dist/cli/status.js +36 -0
  31. package/dist/cli/tool.d.ts +60 -0
  32. package/dist/cli/tool.js +180 -0
  33. package/dist/cli/wiki.d.ts +15 -0
  34. package/dist/cli/wiki.js +365 -0
  35. package/dist/config/ignore-service.d.ts +26 -0
  36. package/dist/config/ignore-service.js +284 -0
  37. package/dist/config/supported-languages.d.ts +15 -0
  38. package/dist/config/supported-languages.js +16 -0
  39. package/dist/core/augmentation/engine.d.ts +26 -0
  40. package/dist/core/augmentation/engine.js +240 -0
  41. package/dist/core/embeddings/embedder.d.ts +60 -0
  42. package/dist/core/embeddings/embedder.js +251 -0
  43. package/dist/core/embeddings/embedding-pipeline.d.ts +51 -0
  44. package/dist/core/embeddings/embedding-pipeline.js +356 -0
  45. package/dist/core/embeddings/index.d.ts +9 -0
  46. package/dist/core/embeddings/index.js +9 -0
  47. package/dist/core/embeddings/text-generator.d.ts +24 -0
  48. package/dist/core/embeddings/text-generator.js +182 -0
  49. package/dist/core/embeddings/types.d.ts +87 -0
  50. package/dist/core/embeddings/types.js +32 -0
  51. package/dist/core/graph/graph.d.ts +2 -0
  52. package/dist/core/graph/graph.js +66 -0
  53. package/dist/core/graph/types.d.ts +66 -0
  54. package/dist/core/graph/types.js +1 -0
  55. package/dist/core/ingestion/ast-cache.d.ts +11 -0
  56. package/dist/core/ingestion/ast-cache.js +35 -0
  57. package/dist/core/ingestion/call-processor.d.ts +23 -0
  58. package/dist/core/ingestion/call-processor.js +793 -0
  59. package/dist/core/ingestion/call-routing.d.ts +68 -0
  60. package/dist/core/ingestion/call-routing.js +129 -0
  61. package/dist/core/ingestion/cluster-enricher.d.ts +38 -0
  62. package/dist/core/ingestion/cluster-enricher.js +170 -0
  63. package/dist/core/ingestion/community-processor.d.ts +39 -0
  64. package/dist/core/ingestion/community-processor.js +312 -0
  65. package/dist/core/ingestion/constants.d.ts +16 -0
  66. package/dist/core/ingestion/constants.js +16 -0
  67. package/dist/core/ingestion/entry-point-scoring.d.ts +40 -0
  68. package/dist/core/ingestion/entry-point-scoring.js +353 -0
  69. package/dist/core/ingestion/export-detection.d.ts +18 -0
  70. package/dist/core/ingestion/export-detection.js +231 -0
  71. package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
  72. package/dist/core/ingestion/filesystem-walker.js +81 -0
  73. package/dist/core/ingestion/framework-detection.d.ts +54 -0
  74. package/dist/core/ingestion/framework-detection.js +411 -0
  75. package/dist/core/ingestion/heritage-processor.d.ts +28 -0
  76. package/dist/core/ingestion/heritage-processor.js +251 -0
  77. package/dist/core/ingestion/import-processor.d.ts +34 -0
  78. package/dist/core/ingestion/import-processor.js +398 -0
  79. package/dist/core/ingestion/language-config.d.ts +46 -0
  80. package/dist/core/ingestion/language-config.js +167 -0
  81. package/dist/core/ingestion/mro-processor.d.ts +45 -0
  82. package/dist/core/ingestion/mro-processor.js +369 -0
  83. package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
  84. package/dist/core/ingestion/named-binding-extraction.js +363 -0
  85. package/dist/core/ingestion/parsing-processor.d.ts +19 -0
  86. package/dist/core/ingestion/parsing-processor.js +315 -0
  87. package/dist/core/ingestion/pipeline.d.ts +6 -0
  88. package/dist/core/ingestion/pipeline.js +401 -0
  89. package/dist/core/ingestion/process-processor.d.ts +51 -0
  90. package/dist/core/ingestion/process-processor.js +315 -0
  91. package/dist/core/ingestion/resolution-context.d.ts +53 -0
  92. package/dist/core/ingestion/resolution-context.js +132 -0
  93. package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
  94. package/dist/core/ingestion/resolvers/csharp.js +109 -0
  95. package/dist/core/ingestion/resolvers/go.d.ts +19 -0
  96. package/dist/core/ingestion/resolvers/go.js +42 -0
  97. package/dist/core/ingestion/resolvers/index.d.ts +18 -0
  98. package/dist/core/ingestion/resolvers/index.js +13 -0
  99. package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
  100. package/dist/core/ingestion/resolvers/jvm.js +87 -0
  101. package/dist/core/ingestion/resolvers/php.d.ts +15 -0
  102. package/dist/core/ingestion/resolvers/php.js +35 -0
  103. package/dist/core/ingestion/resolvers/python.d.ts +19 -0
  104. package/dist/core/ingestion/resolvers/python.js +52 -0
  105. package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
  106. package/dist/core/ingestion/resolvers/ruby.js +15 -0
  107. package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
  108. package/dist/core/ingestion/resolvers/rust.js +73 -0
  109. package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
  110. package/dist/core/ingestion/resolvers/standard.js +123 -0
  111. package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
  112. package/dist/core/ingestion/resolvers/utils.js +122 -0
  113. package/dist/core/ingestion/structure-processor.d.ts +2 -0
  114. package/dist/core/ingestion/structure-processor.js +36 -0
  115. package/dist/core/ingestion/symbol-table.d.ts +63 -0
  116. package/dist/core/ingestion/symbol-table.js +85 -0
  117. package/dist/core/ingestion/tree-sitter-queries.d.ts +15 -0
  118. package/dist/core/ingestion/tree-sitter-queries.js +888 -0
  119. package/dist/core/ingestion/type-env.d.ts +49 -0
  120. package/dist/core/ingestion/type-env.js +613 -0
  121. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
  122. package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
  123. package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
  124. package/dist/core/ingestion/type-extractors/csharp.js +383 -0
  125. package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
  126. package/dist/core/ingestion/type-extractors/go.js +467 -0
  127. package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
  128. package/dist/core/ingestion/type-extractors/index.js +31 -0
  129. package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
  130. package/dist/core/ingestion/type-extractors/jvm.js +681 -0
  131. package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
  132. package/dist/core/ingestion/type-extractors/php.js +549 -0
  133. package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
  134. package/dist/core/ingestion/type-extractors/python.js +455 -0
  135. package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
  136. package/dist/core/ingestion/type-extractors/ruby.js +389 -0
  137. package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
  138. package/dist/core/ingestion/type-extractors/rust.js +456 -0
  139. package/dist/core/ingestion/type-extractors/shared.d.ts +145 -0
  140. package/dist/core/ingestion/type-extractors/shared.js +810 -0
  141. package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
  142. package/dist/core/ingestion/type-extractors/swift.js +137 -0
  143. package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
  144. package/dist/core/ingestion/type-extractors/types.js +1 -0
  145. package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
  146. package/dist/core/ingestion/type-extractors/typescript.js +494 -0
  147. package/dist/core/ingestion/utils.d.ts +138 -0
  148. package/dist/core/ingestion/utils.js +1290 -0
  149. package/dist/core/ingestion/workers/parse-worker.d.ts +122 -0
  150. package/dist/core/ingestion/workers/parse-worker.js +1126 -0
  151. package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
  152. package/dist/core/ingestion/workers/worker-pool.js +128 -0
  153. package/dist/core/lbug/csv-generator.d.ts +33 -0
  154. package/dist/core/lbug/csv-generator.js +366 -0
  155. package/dist/core/lbug/lbug-adapter.d.ts +103 -0
  156. package/dist/core/lbug/lbug-adapter.js +769 -0
  157. package/dist/core/lbug/schema.d.ts +53 -0
  158. package/dist/core/lbug/schema.js +430 -0
  159. package/dist/core/search/bm25-index.d.ts +23 -0
  160. package/dist/core/search/bm25-index.js +96 -0
  161. package/dist/core/search/hybrid-search.d.ts +49 -0
  162. package/dist/core/search/hybrid-search.js +118 -0
  163. package/dist/core/tree-sitter/parser-loader.d.ts +5 -0
  164. package/dist/core/tree-sitter/parser-loader.js +63 -0
  165. package/dist/core/wiki/generator.d.ts +120 -0
  166. package/dist/core/wiki/generator.js +939 -0
  167. package/dist/core/wiki/graph-queries.d.ts +80 -0
  168. package/dist/core/wiki/graph-queries.js +238 -0
  169. package/dist/core/wiki/html-viewer.d.ts +10 -0
  170. package/dist/core/wiki/html-viewer.js +297 -0
  171. package/dist/core/wiki/llm-client.d.ts +43 -0
  172. package/dist/core/wiki/llm-client.js +186 -0
  173. package/dist/core/wiki/prompts.d.ts +53 -0
  174. package/dist/core/wiki/prompts.js +174 -0
  175. package/dist/lib/utils.d.ts +1 -0
  176. package/dist/lib/utils.js +3 -0
  177. package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
  178. package/dist/mcp/compatible-stdio-transport.js +200 -0
  179. package/dist/mcp/core/embedder.d.ts +27 -0
  180. package/dist/mcp/core/embedder.js +108 -0
  181. package/dist/mcp/core/lbug-adapter.d.ts +57 -0
  182. package/dist/mcp/core/lbug-adapter.js +455 -0
  183. package/dist/mcp/local/local-backend.d.ts +181 -0
  184. package/dist/mcp/local/local-backend.js +1722 -0
  185. package/dist/mcp/resources.d.ts +31 -0
  186. package/dist/mcp/resources.js +411 -0
  187. package/dist/mcp/server.d.ts +23 -0
  188. package/dist/mcp/server.js +296 -0
  189. package/dist/mcp/staleness.d.ts +15 -0
  190. package/dist/mcp/staleness.js +29 -0
  191. package/dist/mcp/tools.d.ts +24 -0
  192. package/dist/mcp/tools.js +292 -0
  193. package/dist/server/api.d.ts +10 -0
  194. package/dist/server/api.js +344 -0
  195. package/dist/server/mcp-http.d.ts +13 -0
  196. package/dist/server/mcp-http.js +100 -0
  197. package/dist/storage/git.d.ts +6 -0
  198. package/dist/storage/git.js +35 -0
  199. package/dist/storage/repo-manager.d.ts +138 -0
  200. package/dist/storage/repo-manager.js +299 -0
  201. package/dist/types/pipeline.d.ts +32 -0
  202. package/dist/types/pipeline.js +18 -0
  203. package/dist/unreal/bridge.d.ts +4 -0
  204. package/dist/unreal/bridge.js +113 -0
  205. package/dist/unreal/config.d.ts +6 -0
  206. package/dist/unreal/config.js +55 -0
  207. package/dist/unreal/types.d.ts +105 -0
  208. package/dist/unreal/types.js +1 -0
  209. package/hooks/claude/gitnexus-hook.cjs +238 -0
  210. package/hooks/claude/pre-tool-use.sh +79 -0
  211. package/hooks/claude/session-start.sh +42 -0
  212. package/package.json +100 -0
  213. package/scripts/ensure-cli-executable.cjs +21 -0
  214. package/scripts/patch-tree-sitter-swift.cjs +74 -0
  215. package/scripts/setup-unreal-gitnexus.ps1 +191 -0
  216. package/skills/gitnexus-cli.md +82 -0
  217. package/skills/gitnexus-debugging.md +89 -0
  218. package/skills/gitnexus-exploring.md +78 -0
  219. package/skills/gitnexus-guide.md +64 -0
  220. package/skills/gitnexus-impact-analysis.md +97 -0
  221. package/skills/gitnexus-pr-review.md +163 -0
  222. package/skills/gitnexus-refactoring.md +121 -0
  223. package/vendor/leiden/index.cjs +355 -0
  224. package/vendor/leiden/utils.cjs +392 -0
@@ -0,0 +1,353 @@
1
+ /**
2
+ * Entry Point Scoring
3
+ *
4
+ * Calculates entry point scores for process detection based on:
5
+ * 1. Call ratio (existing algorithm - callees / (callers + 1))
6
+ * 2. Export status (exported functions get higher priority)
7
+ * 3. Name patterns (functions matching entry point patterns like handle*, on*, *Controller)
8
+ * 4. Framework detection (path-based detection for Next.js, Express, Django, etc.)
9
+ *
10
+ * This module is language-agnostic - language-specific patterns are defined per language.
11
+ */
12
+ import { detectFrameworkFromPath } from './framework-detection.js';
13
+ import { SupportedLanguages } from '../../config/supported-languages.js';
14
+ // ============================================================================
15
+ // NAME PATTERNS - All 11 supported languages
16
+ // ============================================================================
17
+ /**
18
+ * Common entry point naming patterns by language
19
+ * These patterns indicate functions that are likely feature entry points
20
+ */
21
+ const ENTRY_POINT_PATTERNS = {
22
+ // Universal patterns (apply to all languages)
23
+ '*': [
24
+ /^(main|init|bootstrap|start|run|setup|configure)$/i,
25
+ /^handle[A-Z]/, // handleLogin, handleSubmit
26
+ /^on[A-Z]/, // onClick, onSubmit
27
+ /Handler$/, // RequestHandler
28
+ /Controller$/, // UserController
29
+ /^process[A-Z]/, // processPayment
30
+ /^execute[A-Z]/, // executeQuery
31
+ /^perform[A-Z]/, // performAction
32
+ /^dispatch[A-Z]/, // dispatchEvent
33
+ /^trigger[A-Z]/, // triggerAction
34
+ /^fire[A-Z]/, // fireEvent
35
+ /^emit[A-Z]/, // emitEvent
36
+ ],
37
+ // JavaScript/TypeScript
38
+ [SupportedLanguages.JavaScript]: [
39
+ /^use[A-Z]/, // React hooks (useEffect, etc.)
40
+ ],
41
+ [SupportedLanguages.TypeScript]: [
42
+ /^use[A-Z]/, // React hooks
43
+ ],
44
+ // Python
45
+ [SupportedLanguages.Python]: [
46
+ /^app$/, // Flask/FastAPI app
47
+ /^(get|post|put|delete|patch)_/i, // REST conventions
48
+ /^api_/, // API functions
49
+ /^view_/, // Django views
50
+ ],
51
+ // Java
52
+ [SupportedLanguages.Java]: [
53
+ /^do[A-Z]/, // doGet, doPost (Servlets)
54
+ /^create[A-Z]/, // Factory patterns
55
+ /^build[A-Z]/, // Builder patterns
56
+ /Service$/, // UserService
57
+ ],
58
+ // C#
59
+ [SupportedLanguages.CSharp]: [
60
+ /^(Get|Post|Put|Delete|Patch)/, // ASP.NET action methods
61
+ /Action$/, // MVC actions
62
+ /^On[A-Z]/, // Event handlers / Blazor lifecycle
63
+ /Async$/, // Async entry points
64
+ /^Configure$/, // Startup.Configure
65
+ /^ConfigureServices$/, // Startup.ConfigureServices
66
+ /^Handle$/, // MediatR / generic handler
67
+ /^Execute$/, // Command pattern
68
+ /^Invoke$/, // Middleware Invoke
69
+ /^Map[A-Z]/, // Minimal API MapGet, MapPost
70
+ /Service$/, // Service classes
71
+ /^Seed/, // Database seeding
72
+ ],
73
+ // Go
74
+ [SupportedLanguages.Go]: [
75
+ /Handler$/, // http.Handler pattern
76
+ /^Serve/, // ServeHTTP
77
+ /^New[A-Z]/, // Constructor pattern (returns new instance)
78
+ /^Make[A-Z]/, // Make functions
79
+ ],
80
+ // Rust
81
+ [SupportedLanguages.Rust]: [
82
+ /^(get|post|put|delete)_handler$/i,
83
+ /^handle_/, // handle_request
84
+ /^new$/, // Constructor pattern
85
+ /^run$/, // run entry point
86
+ /^spawn/, // Async spawn
87
+ ],
88
+ // C - explicit main() boost plus common C entry point conventions
89
+ [SupportedLanguages.C]: [
90
+ /^main$/, // THE entry point
91
+ /^init_/, // init_server, init_client
92
+ /_init$/, // module_init, server_init
93
+ /^start_/, // start_server
94
+ /_start$/, // thread_start
95
+ /^run_/, // run_loop
96
+ /_run$/, // event_run
97
+ /^stop_/, // stop_server
98
+ /_stop$/, // service_stop
99
+ /^open_/, // open_connection
100
+ /_open$/, // file_open
101
+ /^close_/, // close_connection
102
+ /_close$/, // socket_close
103
+ /^create_/, // create_session
104
+ /_create$/, // object_create
105
+ /^destroy_/, // destroy_session
106
+ /_destroy$/, // object_destroy
107
+ /^handle_/, // handle_request
108
+ /_handler$/, // signal_handler
109
+ /_callback$/, // event_callback
110
+ /^cmd_/, // tmux: cmd_new_window, cmd_attach_session
111
+ /^server_/, // server_start, server_loop
112
+ /^client_/, // client_connect
113
+ /^session_/, // session_create
114
+ /^window_/, // window_resize (tmux)
115
+ /^key_/, // key_press
116
+ /^input_/, // input_parse
117
+ /^output_/, // output_write
118
+ /^notify_/, // notify_client
119
+ /^control_/, // control_start
120
+ ],
121
+ // C++ - same as C plus OOP/template patterns
122
+ [SupportedLanguages.CPlusPlus]: [
123
+ /^main$/, // THE entry point
124
+ /^init_/,
125
+ /_init$/,
126
+ /^Create[A-Z]/, // Factory patterns
127
+ /^create_/,
128
+ /^Run$/, // Run methods
129
+ /^run$/,
130
+ /^Start$/, // Start methods
131
+ /^start$/,
132
+ /^handle_/,
133
+ /_handler$/,
134
+ /_callback$/,
135
+ /^OnEvent/, // Event callbacks
136
+ /^on_/,
137
+ /::Run$/, // Class::Run
138
+ /::Start$/, // Class::Start
139
+ /::Init$/, // Class::Init
140
+ /::Execute$/, // Class::Execute
141
+ ],
142
+ // Swift / iOS
143
+ [SupportedLanguages.Swift]: [
144
+ /^viewDidLoad$/, // UIKit lifecycle
145
+ /^viewWillAppear$/, // UIKit lifecycle
146
+ /^viewDidAppear$/, // UIKit lifecycle
147
+ /^viewWillDisappear$/, // UIKit lifecycle
148
+ /^viewDidDisappear$/, // UIKit lifecycle
149
+ /^application\(/, // AppDelegate methods
150
+ /^scene\(/, // SceneDelegate methods
151
+ /^body$/, // SwiftUI View.body
152
+ /Coordinator$/, // Coordinator pattern
153
+ /^sceneDidBecomeActive$/, // SceneDelegate lifecycle
154
+ /^sceneWillResignActive$/, // SceneDelegate lifecycle
155
+ /^didFinishLaunchingWithOptions$/, // AppDelegate
156
+ /ViewController$/, // ViewController classes
157
+ /^configure[A-Z]/, // Configuration methods
158
+ /^setup[A-Z]/, // Setup methods
159
+ /^makeBody$/, // SwiftUI ViewModifier
160
+ ],
161
+ // PHP / Laravel
162
+ [SupportedLanguages.PHP]: [
163
+ /Controller$/, // UserController (class name convention)
164
+ /^handle$/, // Job::handle(), Listener::handle()
165
+ /^execute$/, // Command::execute()
166
+ /^boot$/, // ServiceProvider::boot()
167
+ /^register$/, // ServiceProvider::register()
168
+ /^__invoke$/, // Invokable controllers/actions
169
+ /^(index|show|store|update|destroy|create|edit)$/, // RESTful resource methods
170
+ /^(get|post|put|delete|patch)[A-Z]/, // Explicit HTTP method actions
171
+ /^run$/, // Command/Job run()
172
+ /^fire$/, // Event fire()
173
+ /^dispatch$/, // Dispatchable jobs
174
+ /Service$/, // UserService (Service layer)
175
+ /Repository$/, // UserRepository (Repository pattern)
176
+ /^find$/, // Repository::find()
177
+ /^findAll$/, // Repository::findAll()
178
+ /^save$/, // Repository::save()
179
+ /^delete$/, // Repository::delete()
180
+ ],
181
+ // Ruby
182
+ [SupportedLanguages.Ruby]: [
183
+ /^call$/, // Service objects (MyService.call)
184
+ /^perform$/, // Background jobs (Sidekiq, ActiveJob)
185
+ /^execute$/, // Command pattern
186
+ ],
187
+ };
188
+ /** Pre-computed merged patterns (universal + language-specific) to avoid per-call array allocation. */
189
+ const MERGED_ENTRY_POINT_PATTERNS = {};
190
+ const UNIVERSAL_PATTERNS = ENTRY_POINT_PATTERNS['*'] || [];
191
+ for (const [lang, patterns] of Object.entries(ENTRY_POINT_PATTERNS)) {
192
+ if (lang === '*')
193
+ continue;
194
+ MERGED_ENTRY_POINT_PATTERNS[lang] = [...UNIVERSAL_PATTERNS, ...patterns];
195
+ }
196
+ // ============================================================================
197
+ // UTILITY PATTERNS - Functions that should be penalized
198
+ // ============================================================================
199
+ /**
200
+ * Patterns that indicate utility/helper functions (NOT entry points)
201
+ * These get penalized in scoring
202
+ */
203
+ const UTILITY_PATTERNS = [
204
+ /^(get|set|is|has|can|should|will|did)[A-Z]/, // Accessors/predicates
205
+ /^_/, // Private by convention
206
+ /^(format|parse|validate|convert|transform)/i, // Transformation utilities
207
+ /^(log|debug|error|warn|info)$/i, // Logging
208
+ /^(to|from)[A-Z]/, // Conversions
209
+ /^(encode|decode)/i, // Encoding utilities
210
+ /^(serialize|deserialize)/i, // Serialization
211
+ /^(clone|copy|deep)/i, // Cloning utilities
212
+ /^(merge|extend|assign)/i, // Object utilities
213
+ /^(filter|map|reduce|sort|find)/i, // Collection utilities (standalone)
214
+ /Helper$/,
215
+ /Util$/,
216
+ /Utils$/,
217
+ /^utils?$/i,
218
+ /^helpers?$/i,
219
+ ];
220
+ // ============================================================================
221
+ // MAIN SCORING FUNCTION
222
+ // ============================================================================
223
+ /**
224
+ * Calculate an entry point score for a function/method
225
+ *
226
+ * Higher scores indicate better entry point candidates.
227
+ * Score = baseScore × exportMultiplier × nameMultiplier
228
+ *
229
+ * @param name - Function/method name
230
+ * @param language - Programming language
231
+ * @param isExported - Whether the function is exported/public
232
+ * @param callerCount - Number of functions that call this function
233
+ * @param calleeCount - Number of functions this function calls
234
+ * @returns Score and array of reasons explaining the score
235
+ */
236
+ export function calculateEntryPointScore(name, language, isExported, callerCount, calleeCount, filePath = '' // Optional for backwards compatibility
237
+ ) {
238
+ const reasons = [];
239
+ // Must have outgoing calls to be an entry point (we need to trace forward)
240
+ if (calleeCount === 0) {
241
+ return { score: 0, reasons: ['no-outgoing-calls'] };
242
+ }
243
+ // Base score: call ratio (existing algorithm)
244
+ // High ratio = calls many, called by few = likely entry point
245
+ const baseScore = calleeCount / (callerCount + 1);
246
+ reasons.push(`base:${baseScore.toFixed(2)}`);
247
+ // Export bonus: exported/public functions are more likely entry points
248
+ const exportMultiplier = isExported ? 2.0 : 1.0;
249
+ if (isExported) {
250
+ reasons.push('exported');
251
+ }
252
+ // Name pattern scoring
253
+ let nameMultiplier = 1.0;
254
+ // Check negative patterns first (utilities get penalized)
255
+ if (UTILITY_PATTERNS.some(p => p.test(name))) {
256
+ nameMultiplier = 0.3; // Significant penalty
257
+ reasons.push('utility-pattern');
258
+ }
259
+ else {
260
+ // Check positive patterns
261
+ const allPatterns = MERGED_ENTRY_POINT_PATTERNS[language] || UNIVERSAL_PATTERNS;
262
+ if (allPatterns.some(p => p.test(name))) {
263
+ nameMultiplier = 1.5; // Bonus for matching entry point pattern
264
+ reasons.push('entry-pattern');
265
+ }
266
+ }
267
+ // Framework detection bonus (Phase 2)
268
+ let frameworkMultiplier = 1.0;
269
+ if (filePath) {
270
+ const frameworkHint = detectFrameworkFromPath(filePath);
271
+ if (frameworkHint) {
272
+ frameworkMultiplier = frameworkHint.entryPointMultiplier;
273
+ reasons.push(`framework:${frameworkHint.reason}`);
274
+ }
275
+ }
276
+ // Calculate final score
277
+ const finalScore = baseScore * exportMultiplier * nameMultiplier * frameworkMultiplier;
278
+ return {
279
+ score: finalScore,
280
+ reasons,
281
+ };
282
+ }
283
+ // ============================================================================
284
+ // HELPER FUNCTIONS
285
+ // ============================================================================
286
+ /**
287
+ * Check if a file path is a test file (should be excluded from entry points)
288
+ * Covers common test file patterns across all supported languages
289
+ */
290
+ export function isTestFile(filePath) {
291
+ const p = filePath.toLowerCase().replace(/\\/g, '/');
292
+ return (
293
+ // JavaScript/TypeScript test patterns
294
+ p.includes('.test.') ||
295
+ p.includes('.spec.') ||
296
+ p.includes('__tests__/') ||
297
+ p.includes('__mocks__/') ||
298
+ // Generic test folders
299
+ p.includes('/test/') ||
300
+ p.includes('/tests/') ||
301
+ p.includes('/testing/') ||
302
+ // Python test patterns
303
+ p.endsWith('_test.py') ||
304
+ p.includes('/test_') ||
305
+ // Go test patterns
306
+ p.endsWith('_test.go') ||
307
+ // Java test patterns
308
+ p.includes('/src/test/') ||
309
+ // Rust test patterns (inline tests are different, but test files)
310
+ p.includes('/tests/') ||
311
+ // Swift/iOS test patterns
312
+ p.endsWith('tests.swift') ||
313
+ p.endsWith('test.swift') ||
314
+ p.includes('uitests/') ||
315
+ // C# test patterns
316
+ p.endsWith('tests.cs') ||
317
+ p.endsWith('test.cs') ||
318
+ p.includes('.tests/') ||
319
+ p.includes('.test/') ||
320
+ p.includes('.integrationtests/') ||
321
+ p.includes('.unittests/') ||
322
+ p.includes('/testproject/') ||
323
+ // PHP/Laravel test patterns
324
+ p.endsWith('test.php') ||
325
+ p.endsWith('spec.php') ||
326
+ p.includes('/tests/feature/') ||
327
+ p.includes('/tests/unit/') ||
328
+ // Ruby test patterns
329
+ p.endsWith('_spec.rb') ||
330
+ p.endsWith('_test.rb') ||
331
+ p.includes('/spec/') ||
332
+ p.includes('/test/fixtures/'));
333
+ }
334
+ /**
335
+ * Check if a file path is likely a utility/helper file
336
+ * These might still have entry points but should be lower priority
337
+ */
338
+ export function isUtilityFile(filePath) {
339
+ const p = filePath.toLowerCase().replace(/\\/g, '/');
340
+ return (p.includes('/utils/') ||
341
+ p.includes('/util/') ||
342
+ p.includes('/helpers/') ||
343
+ p.includes('/helper/') ||
344
+ p.includes('/common/') ||
345
+ p.includes('/shared/') ||
346
+ p.includes('/lib/') ||
347
+ p.endsWith('/utils.ts') ||
348
+ p.endsWith('/utils.js') ||
349
+ p.endsWith('/helpers.ts') ||
350
+ p.endsWith('/helpers.js') ||
351
+ p.endsWith('_utils.py') ||
352
+ p.endsWith('_helpers.py'));
353
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Export Detection
3
+ *
4
+ * Determines whether a symbol (function, class, etc.) is exported/public
5
+ * in its language. This is a pure function — safe for use in worker threads.
6
+ *
7
+ * Shared between parse-worker.ts (worker pool) and parsing-processor.ts (sequential fallback).
8
+ */
9
+ import { SyntaxNode } from './utils.js';
10
+ import { SupportedLanguages } from '../../config/supported-languages.js';
11
+ /**
12
+ * Check if a tree-sitter node is exported/public in its language.
13
+ * @param node - The tree-sitter AST node
14
+ * @param name - The symbol name
15
+ * @param language - The programming language
16
+ * @returns true if the symbol is exported/public
17
+ */
18
+ export declare const isNodeExported: (node: SyntaxNode, name: string, language: SupportedLanguages) => boolean;
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Export Detection
3
+ *
4
+ * Determines whether a symbol (function, class, etc.) is exported/public
5
+ * in its language. This is a pure function — safe for use in worker threads.
6
+ *
7
+ * Shared between parse-worker.ts (worker pool) and parsing-processor.ts (sequential fallback).
8
+ */
9
+ import { findSiblingChild } from './utils.js';
10
+ import { SupportedLanguages } from '../../config/supported-languages.js';
11
+ // ============================================================================
12
+ // Per-language export checkers
13
+ // ============================================================================
14
+ /** JS/TS: walk ancestors looking for export_statement or export_specifier. */
15
+ const tsExportChecker = (node, _name) => {
16
+ let current = node;
17
+ while (current) {
18
+ const type = current.type;
19
+ if (type === 'export_statement' ||
20
+ type === 'export_specifier' ||
21
+ (type === 'lexical_declaration' && current.parent?.type === 'export_statement')) {
22
+ return true;
23
+ }
24
+ // Fallback: check if node text starts with 'export ' for edge cases
25
+ if (current.text?.startsWith('export ')) {
26
+ return true;
27
+ }
28
+ current = current.parent;
29
+ }
30
+ return false;
31
+ };
32
+ /** Python: public if no leading underscore (convention). */
33
+ const pythonExportChecker = (_node, name) => !name.startsWith('_');
34
+ /** Java: check for 'public' modifier — modifiers are siblings of the name node, not parents. */
35
+ const javaExportChecker = (node, _name) => {
36
+ let current = node;
37
+ while (current) {
38
+ if (current.parent) {
39
+ const parent = current.parent;
40
+ for (let i = 0; i < parent.childCount; i++) {
41
+ const child = parent.child(i);
42
+ if (child?.type === 'modifiers' && child.text?.includes('public')) {
43
+ return true;
44
+ }
45
+ }
46
+ if (parent.type === 'method_declaration' || parent.type === 'constructor_declaration') {
47
+ if (parent.text?.trimStart().startsWith('public')) {
48
+ return true;
49
+ }
50
+ }
51
+ }
52
+ current = current.parent;
53
+ }
54
+ return false;
55
+ };
56
+ /** C# declaration node types for sibling modifier scanning. */
57
+ const CSHARP_DECL_TYPES = new Set([
58
+ 'method_declaration', 'local_function_statement', 'constructor_declaration',
59
+ 'class_declaration', 'interface_declaration', 'struct_declaration',
60
+ 'enum_declaration', 'record_declaration', 'record_struct_declaration',
61
+ 'record_class_declaration', 'delegate_declaration',
62
+ 'property_declaration', 'field_declaration', 'event_declaration',
63
+ 'namespace_declaration', 'file_scoped_namespace_declaration',
64
+ ]);
65
+ /**
66
+ * C#: modifier nodes are SIBLINGS of the name node inside the declaration.
67
+ * Walk up to the declaration node, then scan its direct children.
68
+ */
69
+ const csharpExportChecker = (node, _name) => {
70
+ let current = node;
71
+ while (current) {
72
+ if (CSHARP_DECL_TYPES.has(current.type)) {
73
+ for (let i = 0; i < current.childCount; i++) {
74
+ const child = current.child(i);
75
+ if (child?.type === 'modifier' && child.text === 'public')
76
+ return true;
77
+ }
78
+ return false;
79
+ }
80
+ current = current.parent;
81
+ }
82
+ return false;
83
+ };
84
+ /** Go: uppercase first letter = exported. */
85
+ const goExportChecker = (_node, name) => {
86
+ if (name.length === 0)
87
+ return false;
88
+ const first = name[0];
89
+ return first === first.toUpperCase() && first !== first.toLowerCase();
90
+ };
91
+ /** Rust declaration node types for sibling visibility_modifier scanning. */
92
+ const RUST_DECL_TYPES = new Set([
93
+ 'function_item', 'struct_item', 'enum_item', 'trait_item', 'impl_item',
94
+ 'union_item', 'type_item', 'const_item', 'static_item', 'mod_item',
95
+ 'use_declaration', 'associated_type', 'function_signature_item',
96
+ ]);
97
+ /**
98
+ * Rust: visibility_modifier is a SIBLING of the name node within the declaration node
99
+ * (function_item, struct_item, etc.), not a parent. Walk up to the declaration node,
100
+ * then scan its direct children.
101
+ */
102
+ const rustExportChecker = (node, _name) => {
103
+ let current = node;
104
+ while (current) {
105
+ if (RUST_DECL_TYPES.has(current.type)) {
106
+ for (let i = 0; i < current.childCount; i++) {
107
+ const child = current.child(i);
108
+ if (child?.type === 'visibility_modifier' && child.text?.startsWith('pub'))
109
+ return true;
110
+ }
111
+ return false;
112
+ }
113
+ current = current.parent;
114
+ }
115
+ return false;
116
+ };
117
+ /**
118
+ * Kotlin: default visibility is public (unlike Java).
119
+ * visibility_modifier is inside modifiers, a sibling of the name node within the declaration.
120
+ */
121
+ const kotlinExportChecker = (node, _name) => {
122
+ let current = node;
123
+ while (current) {
124
+ if (current.parent) {
125
+ const visMod = findSiblingChild(current.parent, 'modifiers', 'visibility_modifier');
126
+ if (visMod) {
127
+ const text = visMod.text;
128
+ if (text === 'private' || text === 'internal' || text === 'protected')
129
+ return false;
130
+ if (text === 'public')
131
+ return true;
132
+ }
133
+ }
134
+ current = current.parent;
135
+ }
136
+ // No visibility modifier = public (Kotlin default)
137
+ return true;
138
+ };
139
+ /**
140
+ * C/C++: functions without 'static' storage class have external linkage by default,
141
+ * making them globally accessible (equivalent to exported). Only functions explicitly
142
+ * marked 'static' are file-scoped (not exported). C++ anonymous namespaces
143
+ * (namespace { ... }) also give internal linkage.
144
+ */
145
+ const cCppExportChecker = (node, _name) => {
146
+ let cur = node;
147
+ while (cur) {
148
+ if (cur.type === 'function_definition' || cur.type === 'declaration') {
149
+ // Check for 'static' storage class specifier as a direct child node.
150
+ // This avoids reading the full function text (which can be very large).
151
+ for (let i = 0; i < cur.childCount; i++) {
152
+ const child = cur.child(i);
153
+ if (child?.type === 'storage_class_specifier' && child.text === 'static')
154
+ return false;
155
+ }
156
+ }
157
+ // C++ anonymous namespace: namespace_definition with no name child = internal linkage
158
+ if (cur.type === 'namespace_definition') {
159
+ const hasName = cur.childForFieldName?.('name');
160
+ if (!hasName)
161
+ return false;
162
+ }
163
+ cur = cur.parent;
164
+ }
165
+ return true; // Top-level C/C++ functions default to external linkage
166
+ };
167
+ /** PHP: check for visibility modifier or top-level scope. */
168
+ const phpExportChecker = (node, _name) => {
169
+ let current = node;
170
+ while (current) {
171
+ if (current.type === 'class_declaration' ||
172
+ current.type === 'interface_declaration' ||
173
+ current.type === 'trait_declaration' ||
174
+ current.type === 'enum_declaration') {
175
+ return true;
176
+ }
177
+ if (current.type === 'visibility_modifier') {
178
+ return current.text === 'public';
179
+ }
180
+ current = current.parent;
181
+ }
182
+ // Top-level functions are globally accessible
183
+ return true;
184
+ };
185
+ /** Swift: check for 'public' or 'open' access modifiers. */
186
+ const swiftExportChecker = (node, _name) => {
187
+ let current = node;
188
+ while (current) {
189
+ if (current.type === 'modifiers' || current.type === 'visibility_modifier') {
190
+ const text = current.text || '';
191
+ if (text.includes('public') || text.includes('open'))
192
+ return true;
193
+ }
194
+ current = current.parent;
195
+ }
196
+ return false;
197
+ };
198
+ // ============================================================================
199
+ // Exhaustive dispatch table — satisfies enforces all SupportedLanguages are covered
200
+ // ============================================================================
201
+ const exportCheckers = {
202
+ [SupportedLanguages.JavaScript]: tsExportChecker,
203
+ [SupportedLanguages.TypeScript]: tsExportChecker,
204
+ [SupportedLanguages.Python]: pythonExportChecker,
205
+ [SupportedLanguages.Java]: javaExportChecker,
206
+ [SupportedLanguages.CSharp]: csharpExportChecker,
207
+ [SupportedLanguages.Go]: goExportChecker,
208
+ [SupportedLanguages.Rust]: rustExportChecker,
209
+ [SupportedLanguages.Kotlin]: kotlinExportChecker,
210
+ [SupportedLanguages.C]: cCppExportChecker,
211
+ [SupportedLanguages.CPlusPlus]: cCppExportChecker,
212
+ [SupportedLanguages.PHP]: phpExportChecker,
213
+ [SupportedLanguages.Swift]: swiftExportChecker,
214
+ [SupportedLanguages.Ruby]: (_node, _name) => true,
215
+ };
216
+ // ============================================================================
217
+ // Public API
218
+ // ============================================================================
219
+ /**
220
+ * Check if a tree-sitter node is exported/public in its language.
221
+ * @param node - The tree-sitter AST node
222
+ * @param name - The symbol name
223
+ * @param language - The programming language
224
+ * @returns true if the symbol is exported/public
225
+ */
226
+ export const isNodeExported = (node, name, language) => {
227
+ const checker = exportCheckers[language];
228
+ if (!checker)
229
+ return false;
230
+ return checker(node, name);
231
+ };
@@ -0,0 +1,28 @@
1
+ export interface FileEntry {
2
+ path: string;
3
+ content: string;
4
+ }
5
+ /** Lightweight entry — path + size from stat, no content in memory */
6
+ export interface ScannedFile {
7
+ path: string;
8
+ size: number;
9
+ }
10
+ /** Path-only reference (for type signatures) */
11
+ export interface FilePath {
12
+ path: string;
13
+ }
14
+ /**
15
+ * Phase 1: Scan repository — stat files to get paths + sizes, no content loaded.
16
+ * Memory: ~10MB for 100K files vs ~1GB+ with content.
17
+ */
18
+ export declare const walkRepositoryPaths: (repoPath: string, onProgress?: (current: number, total: number, filePath: string) => void) => Promise<ScannedFile[]>;
19
+ /**
20
+ * Phase 2: Read file contents for a specific set of relative paths.
21
+ * Returns a Map for O(1) lookup. Silently skips files that fail to read.
22
+ */
23
+ export declare const readFileContents: (repoPath: string, relativePaths: string[]) => Promise<Map<string, string>>;
24
+ /**
25
+ * Legacy API — scans and reads everything into memory.
26
+ * Used by sequential fallback path only.
27
+ */
28
+ export declare const walkRepository: (repoPath: string, onProgress?: (current: number, total: number, filePath: string) => void) => Promise<FileEntry[]>;