@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.
- package/LICENSE +73 -0
- package/README.md +261 -0
- package/dist/cli/ai-context.d.ts +23 -0
- package/dist/cli/ai-context.js +265 -0
- package/dist/cli/analyze.d.ts +12 -0
- package/dist/cli/analyze.js +345 -0
- package/dist/cli/augment.d.ts +13 -0
- package/dist/cli/augment.js +33 -0
- package/dist/cli/clean.d.ts +10 -0
- package/dist/cli/clean.js +60 -0
- package/dist/cli/eval-server.d.ts +37 -0
- package/dist/cli/eval-server.js +389 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +137 -0
- package/dist/cli/lazy-action.d.ts +6 -0
- package/dist/cli/lazy-action.js +18 -0
- package/dist/cli/list.d.ts +6 -0
- package/dist/cli/list.js +30 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +36 -0
- package/dist/cli/serve.d.ts +4 -0
- package/dist/cli/serve.js +6 -0
- package/dist/cli/setup.d.ts +8 -0
- package/dist/cli/setup.js +367 -0
- package/dist/cli/sipher-patched.d.ts +2 -0
- package/dist/cli/sipher-patched.js +77 -0
- package/dist/cli/skill-gen.d.ts +26 -0
- package/dist/cli/skill-gen.js +549 -0
- package/dist/cli/status.d.ts +6 -0
- package/dist/cli/status.js +36 -0
- package/dist/cli/tool.d.ts +60 -0
- package/dist/cli/tool.js +180 -0
- package/dist/cli/wiki.d.ts +15 -0
- package/dist/cli/wiki.js +365 -0
- package/dist/config/ignore-service.d.ts +26 -0
- package/dist/config/ignore-service.js +284 -0
- package/dist/config/supported-languages.d.ts +15 -0
- package/dist/config/supported-languages.js +16 -0
- package/dist/core/augmentation/engine.d.ts +26 -0
- package/dist/core/augmentation/engine.js +240 -0
- package/dist/core/embeddings/embedder.d.ts +60 -0
- package/dist/core/embeddings/embedder.js +251 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +51 -0
- package/dist/core/embeddings/embedding-pipeline.js +356 -0
- package/dist/core/embeddings/index.d.ts +9 -0
- package/dist/core/embeddings/index.js +9 -0
- package/dist/core/embeddings/text-generator.d.ts +24 -0
- package/dist/core/embeddings/text-generator.js +182 -0
- package/dist/core/embeddings/types.d.ts +87 -0
- package/dist/core/embeddings/types.js +32 -0
- package/dist/core/graph/graph.d.ts +2 -0
- package/dist/core/graph/graph.js +66 -0
- package/dist/core/graph/types.d.ts +66 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/ingestion/ast-cache.d.ts +11 -0
- package/dist/core/ingestion/ast-cache.js +35 -0
- package/dist/core/ingestion/call-processor.d.ts +23 -0
- package/dist/core/ingestion/call-processor.js +793 -0
- package/dist/core/ingestion/call-routing.d.ts +68 -0
- package/dist/core/ingestion/call-routing.js +129 -0
- package/dist/core/ingestion/cluster-enricher.d.ts +38 -0
- package/dist/core/ingestion/cluster-enricher.js +170 -0
- package/dist/core/ingestion/community-processor.d.ts +39 -0
- package/dist/core/ingestion/community-processor.js +312 -0
- package/dist/core/ingestion/constants.d.ts +16 -0
- package/dist/core/ingestion/constants.js +16 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +40 -0
- package/dist/core/ingestion/entry-point-scoring.js +353 -0
- package/dist/core/ingestion/export-detection.d.ts +18 -0
- package/dist/core/ingestion/export-detection.js +231 -0
- package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
- package/dist/core/ingestion/filesystem-walker.js +81 -0
- package/dist/core/ingestion/framework-detection.d.ts +54 -0
- package/dist/core/ingestion/framework-detection.js +411 -0
- package/dist/core/ingestion/heritage-processor.d.ts +28 -0
- package/dist/core/ingestion/heritage-processor.js +251 -0
- package/dist/core/ingestion/import-processor.d.ts +34 -0
- package/dist/core/ingestion/import-processor.js +398 -0
- package/dist/core/ingestion/language-config.d.ts +46 -0
- package/dist/core/ingestion/language-config.js +167 -0
- package/dist/core/ingestion/mro-processor.d.ts +45 -0
- package/dist/core/ingestion/mro-processor.js +369 -0
- package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
- package/dist/core/ingestion/named-binding-extraction.js +363 -0
- package/dist/core/ingestion/parsing-processor.d.ts +19 -0
- package/dist/core/ingestion/parsing-processor.js +315 -0
- package/dist/core/ingestion/pipeline.d.ts +6 -0
- package/dist/core/ingestion/pipeline.js +401 -0
- package/dist/core/ingestion/process-processor.d.ts +51 -0
- package/dist/core/ingestion/process-processor.js +315 -0
- package/dist/core/ingestion/resolution-context.d.ts +53 -0
- package/dist/core/ingestion/resolution-context.js +132 -0
- package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
- package/dist/core/ingestion/resolvers/csharp.js +109 -0
- package/dist/core/ingestion/resolvers/go.d.ts +19 -0
- package/dist/core/ingestion/resolvers/go.js +42 -0
- package/dist/core/ingestion/resolvers/index.d.ts +18 -0
- package/dist/core/ingestion/resolvers/index.js +13 -0
- package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
- package/dist/core/ingestion/resolvers/jvm.js +87 -0
- package/dist/core/ingestion/resolvers/php.d.ts +15 -0
- package/dist/core/ingestion/resolvers/php.js +35 -0
- package/dist/core/ingestion/resolvers/python.d.ts +19 -0
- package/dist/core/ingestion/resolvers/python.js +52 -0
- package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
- package/dist/core/ingestion/resolvers/ruby.js +15 -0
- package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
- package/dist/core/ingestion/resolvers/rust.js +73 -0
- package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
- package/dist/core/ingestion/resolvers/standard.js +123 -0
- package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
- package/dist/core/ingestion/resolvers/utils.js +122 -0
- package/dist/core/ingestion/structure-processor.d.ts +2 -0
- package/dist/core/ingestion/structure-processor.js +36 -0
- package/dist/core/ingestion/symbol-table.d.ts +63 -0
- package/dist/core/ingestion/symbol-table.js +85 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +15 -0
- package/dist/core/ingestion/tree-sitter-queries.js +888 -0
- package/dist/core/ingestion/type-env.d.ts +49 -0
- package/dist/core/ingestion/type-env.js +613 -0
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
- package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/csharp.js +383 -0
- package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/go.js +467 -0
- package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
- package/dist/core/ingestion/type-extractors/index.js +31 -0
- package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
- package/dist/core/ingestion/type-extractors/jvm.js +681 -0
- package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/php.js +549 -0
- package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/python.js +455 -0
- package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/ruby.js +389 -0
- package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/rust.js +456 -0
- package/dist/core/ingestion/type-extractors/shared.d.ts +145 -0
- package/dist/core/ingestion/type-extractors/shared.js +810 -0
- package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/swift.js +137 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
- package/dist/core/ingestion/type-extractors/types.js +1 -0
- package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/typescript.js +494 -0
- package/dist/core/ingestion/utils.d.ts +138 -0
- package/dist/core/ingestion/utils.js +1290 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +122 -0
- package/dist/core/ingestion/workers/parse-worker.js +1126 -0
- package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
- package/dist/core/ingestion/workers/worker-pool.js +128 -0
- package/dist/core/lbug/csv-generator.d.ts +33 -0
- package/dist/core/lbug/csv-generator.js +366 -0
- package/dist/core/lbug/lbug-adapter.d.ts +103 -0
- package/dist/core/lbug/lbug-adapter.js +769 -0
- package/dist/core/lbug/schema.d.ts +53 -0
- package/dist/core/lbug/schema.js +430 -0
- package/dist/core/search/bm25-index.d.ts +23 -0
- package/dist/core/search/bm25-index.js +96 -0
- package/dist/core/search/hybrid-search.d.ts +49 -0
- package/dist/core/search/hybrid-search.js +118 -0
- package/dist/core/tree-sitter/parser-loader.d.ts +5 -0
- package/dist/core/tree-sitter/parser-loader.js +63 -0
- package/dist/core/wiki/generator.d.ts +120 -0
- package/dist/core/wiki/generator.js +939 -0
- package/dist/core/wiki/graph-queries.d.ts +80 -0
- package/dist/core/wiki/graph-queries.js +238 -0
- package/dist/core/wiki/html-viewer.d.ts +10 -0
- package/dist/core/wiki/html-viewer.js +297 -0
- package/dist/core/wiki/llm-client.d.ts +43 -0
- package/dist/core/wiki/llm-client.js +186 -0
- package/dist/core/wiki/prompts.d.ts +53 -0
- package/dist/core/wiki/prompts.js +174 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +3 -0
- package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
- package/dist/mcp/compatible-stdio-transport.js +200 -0
- package/dist/mcp/core/embedder.d.ts +27 -0
- package/dist/mcp/core/embedder.js +108 -0
- package/dist/mcp/core/lbug-adapter.d.ts +57 -0
- package/dist/mcp/core/lbug-adapter.js +455 -0
- package/dist/mcp/local/local-backend.d.ts +181 -0
- package/dist/mcp/local/local-backend.js +1722 -0
- package/dist/mcp/resources.d.ts +31 -0
- package/dist/mcp/resources.js +411 -0
- package/dist/mcp/server.d.ts +23 -0
- package/dist/mcp/server.js +296 -0
- package/dist/mcp/staleness.d.ts +15 -0
- package/dist/mcp/staleness.js +29 -0
- package/dist/mcp/tools.d.ts +24 -0
- package/dist/mcp/tools.js +292 -0
- package/dist/server/api.d.ts +10 -0
- package/dist/server/api.js +344 -0
- package/dist/server/mcp-http.d.ts +13 -0
- package/dist/server/mcp-http.js +100 -0
- package/dist/storage/git.d.ts +6 -0
- package/dist/storage/git.js +35 -0
- package/dist/storage/repo-manager.d.ts +138 -0
- package/dist/storage/repo-manager.js +299 -0
- package/dist/types/pipeline.d.ts +32 -0
- package/dist/types/pipeline.js +18 -0
- package/dist/unreal/bridge.d.ts +4 -0
- package/dist/unreal/bridge.js +113 -0
- package/dist/unreal/config.d.ts +6 -0
- package/dist/unreal/config.js +55 -0
- package/dist/unreal/types.d.ts +105 -0
- package/dist/unreal/types.js +1 -0
- package/hooks/claude/gitnexus-hook.cjs +238 -0
- package/hooks/claude/pre-tool-use.sh +79 -0
- package/hooks/claude/session-start.sh +42 -0
- package/package.json +100 -0
- package/scripts/ensure-cli-executable.cjs +21 -0
- package/scripts/patch-tree-sitter-swift.cjs +74 -0
- package/scripts/setup-unreal-gitnexus.ps1 +191 -0
- package/skills/gitnexus-cli.md +82 -0
- package/skills/gitnexus-debugging.md +89 -0
- package/skills/gitnexus-exploring.md +78 -0
- package/skills/gitnexus-guide.md +64 -0
- package/skills/gitnexus-impact-analysis.md +97 -0
- package/skills/gitnexus-pr-review.md +163 -0
- package/skills/gitnexus-refactoring.md +121 -0
- package/vendor/leiden/index.cjs +355 -0
- 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[]>;
|