@veewo/gitnexus 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +234 -0
- package/dist/benchmark/agent-context/evaluators.d.ts +9 -0
- package/dist/benchmark/agent-context/evaluators.js +196 -0
- package/dist/benchmark/agent-context/evaluators.test.d.ts +1 -0
- package/dist/benchmark/agent-context/evaluators.test.js +39 -0
- package/dist/benchmark/agent-context/io.d.ts +2 -0
- package/dist/benchmark/agent-context/io.js +23 -0
- package/dist/benchmark/agent-context/io.test.d.ts +1 -0
- package/dist/benchmark/agent-context/io.test.js +19 -0
- package/dist/benchmark/agent-context/report.d.ts +2 -0
- package/dist/benchmark/agent-context/report.js +59 -0
- package/dist/benchmark/agent-context/report.test.d.ts +1 -0
- package/dist/benchmark/agent-context/report.test.js +85 -0
- package/dist/benchmark/agent-context/runner.d.ts +46 -0
- package/dist/benchmark/agent-context/runner.js +111 -0
- package/dist/benchmark/agent-context/runner.test.d.ts +1 -0
- package/dist/benchmark/agent-context/runner.test.js +79 -0
- package/dist/benchmark/agent-context/tool-runner.d.ts +7 -0
- package/dist/benchmark/agent-context/tool-runner.js +18 -0
- package/dist/benchmark/agent-context/tool-runner.test.d.ts +1 -0
- package/dist/benchmark/agent-context/tool-runner.test.js +11 -0
- package/dist/benchmark/agent-context/types.d.ts +40 -0
- package/dist/benchmark/agent-context/types.js +1 -0
- package/dist/benchmark/analyze-runner.d.ts +16 -0
- package/dist/benchmark/analyze-runner.js +51 -0
- package/dist/benchmark/analyze-runner.test.d.ts +1 -0
- package/dist/benchmark/analyze-runner.test.js +37 -0
- package/dist/benchmark/evaluators.d.ts +6 -0
- package/dist/benchmark/evaluators.js +10 -0
- package/dist/benchmark/evaluators.test.d.ts +1 -0
- package/dist/benchmark/evaluators.test.js +12 -0
- package/dist/benchmark/io.d.ts +7 -0
- package/dist/benchmark/io.js +25 -0
- package/dist/benchmark/io.test.d.ts +1 -0
- package/dist/benchmark/io.test.js +35 -0
- package/dist/benchmark/neonspark-candidates.d.ts +19 -0
- package/dist/benchmark/neonspark-candidates.js +94 -0
- package/dist/benchmark/neonspark-candidates.test.d.ts +1 -0
- package/dist/benchmark/neonspark-candidates.test.js +43 -0
- package/dist/benchmark/neonspark-materialize.d.ts +19 -0
- package/dist/benchmark/neonspark-materialize.js +111 -0
- package/dist/benchmark/neonspark-materialize.test.d.ts +1 -0
- package/dist/benchmark/neonspark-materialize.test.js +124 -0
- package/dist/benchmark/neonspark-sync.d.ts +3 -0
- package/dist/benchmark/neonspark-sync.js +53 -0
- package/dist/benchmark/neonspark-sync.test.d.ts +1 -0
- package/dist/benchmark/neonspark-sync.test.js +20 -0
- package/dist/benchmark/report.d.ts +1 -0
- package/dist/benchmark/report.js +7 -0
- package/dist/benchmark/runner.d.ts +48 -0
- package/dist/benchmark/runner.js +302 -0
- package/dist/benchmark/runner.test.d.ts +1 -0
- package/dist/benchmark/runner.test.js +50 -0
- package/dist/benchmark/scoring.d.ts +16 -0
- package/dist/benchmark/scoring.js +27 -0
- package/dist/benchmark/scoring.test.d.ts +1 -0
- package/dist/benchmark/scoring.test.js +24 -0
- package/dist/benchmark/tool-runner.d.ts +6 -0
- package/dist/benchmark/tool-runner.js +17 -0
- package/dist/benchmark/types.d.ts +36 -0
- package/dist/benchmark/types.js +1 -0
- package/dist/cli/ai-context.d.ts +22 -0
- package/dist/cli/ai-context.js +184 -0
- package/dist/cli/ai-context.test.d.ts +1 -0
- package/dist/cli/ai-context.test.js +30 -0
- package/dist/cli/analyze-multi-scope-regression.test.d.ts +1 -0
- package/dist/cli/analyze-multi-scope-regression.test.js +22 -0
- package/dist/cli/analyze-options.d.ts +7 -0
- package/dist/cli/analyze-options.js +56 -0
- package/dist/cli/analyze-options.test.d.ts +1 -0
- package/dist/cli/analyze-options.test.js +36 -0
- package/dist/cli/analyze.d.ts +14 -0
- package/dist/cli/analyze.js +384 -0
- package/dist/cli/augment.d.ts +13 -0
- package/dist/cli/augment.js +33 -0
- package/dist/cli/benchmark-agent-context.d.ts +29 -0
- package/dist/cli/benchmark-agent-context.js +61 -0
- package/dist/cli/benchmark-agent-context.test.d.ts +1 -0
- package/dist/cli/benchmark-agent-context.test.js +80 -0
- package/dist/cli/benchmark-unity.d.ts +15 -0
- package/dist/cli/benchmark-unity.js +31 -0
- package/dist/cli/benchmark-unity.test.d.ts +1 -0
- package/dist/cli/benchmark-unity.test.js +18 -0
- package/dist/cli/claude-hooks.d.ts +22 -0
- package/dist/cli/claude-hooks.js +97 -0
- package/dist/cli/clean.d.ts +10 -0
- package/dist/cli/clean.js +60 -0
- package/dist/cli/eval-server.d.ts +30 -0
- package/dist/cli/eval-server.js +372 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +182 -0
- package/dist/cli/list.d.ts +6 -0
- package/dist/cli/list.js +33 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +34 -0
- package/dist/cli/repo-manager-alias.test.d.ts +1 -0
- package/dist/cli/repo-manager-alias.test.js +40 -0
- package/dist/cli/scope-filter.test.d.ts +1 -0
- package/dist/cli/scope-filter.test.js +49 -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 +311 -0
- package/dist/cli/setup.test.d.ts +1 -0
- package/dist/cli/setup.test.js +31 -0
- package/dist/cli/status.d.ts +6 -0
- package/dist/cli/status.js +27 -0
- package/dist/cli/tool.d.ts +40 -0
- package/dist/cli/tool.js +94 -0
- package/dist/cli/version.test.d.ts +1 -0
- package/dist/cli/version.test.js +19 -0
- package/dist/cli/wiki.d.ts +15 -0
- package/dist/cli/wiki.js +361 -0
- package/dist/config/ignore-service.d.ts +1 -0
- package/dist/config/ignore-service.js +210 -0
- package/dist/config/supported-languages.d.ts +12 -0
- package/dist/config/supported-languages.js +15 -0
- package/dist/core/augmentation/engine.d.ts +26 -0
- package/dist/core/augmentation/engine.js +213 -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 +329 -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 +61 -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 +34 -0
- package/dist/core/ingestion/call-processor.d.ts +15 -0
- package/dist/core/ingestion/call-processor.js +327 -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/entry-point-scoring.d.ts +39 -0
- package/dist/core/ingestion/entry-point-scoring.js +260 -0
- package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
- package/dist/core/ingestion/filesystem-walker.js +80 -0
- package/dist/core/ingestion/framework-detection.d.ts +39 -0
- package/dist/core/ingestion/framework-detection.js +235 -0
- package/dist/core/ingestion/heritage-processor.d.ts +20 -0
- package/dist/core/ingestion/heritage-processor.js +197 -0
- package/dist/core/ingestion/import-processor.d.ts +38 -0
- package/dist/core/ingestion/import-processor.js +778 -0
- package/dist/core/ingestion/parsing-processor.d.ts +15 -0
- package/dist/core/ingestion/parsing-processor.js +291 -0
- package/dist/core/ingestion/pipeline.d.ts +5 -0
- package/dist/core/ingestion/pipeline.js +323 -0
- package/dist/core/ingestion/process-processor.d.ts +51 -0
- package/dist/core/ingestion/process-processor.js +309 -0
- package/dist/core/ingestion/scope-filter.d.ts +25 -0
- package/dist/core/ingestion/scope-filter.js +100 -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 +33 -0
- package/dist/core/ingestion/symbol-table.js +38 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +12 -0
- package/dist/core/ingestion/tree-sitter-queries.js +398 -0
- package/dist/core/ingestion/utils.d.ts +10 -0
- package/dist/core/ingestion/utils.js +50 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +59 -0
- package/dist/core/ingestion/workers/parse-worker.js +672 -0
- package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
- package/dist/core/ingestion/workers/worker-pool.js +120 -0
- package/dist/core/kuzu/csv-generator.d.ts +29 -0
- package/dist/core/kuzu/csv-generator.js +336 -0
- package/dist/core/kuzu/kuzu-adapter.d.ts +101 -0
- package/dist/core/kuzu/kuzu-adapter.js +753 -0
- package/dist/core/kuzu/schema.d.ts +53 -0
- package/dist/core/kuzu/schema.js +407 -0
- package/dist/core/search/bm25-index.d.ts +23 -0
- package/dist/core/search/bm25-index.js +95 -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 +4 -0
- package/dist/core/tree-sitter/parser-loader.js +44 -0
- package/dist/core/wiki/generator.d.ts +110 -0
- package/dist/core/wiki/generator.js +786 -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 +40 -0
- package/dist/core/wiki/llm-client.js +162 -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/core/embedder.d.ts +27 -0
- package/dist/mcp/core/embedder.js +108 -0
- package/dist/mcp/core/kuzu-adapter.d.ts +34 -0
- package/dist/mcp/core/kuzu-adapter.js +231 -0
- package/dist/mcp/local/local-backend.d.ts +160 -0
- package/dist/mcp/local/local-backend.js +1646 -0
- package/dist/mcp/resources.d.ts +31 -0
- package/dist/mcp/resources.js +407 -0
- package/dist/mcp/server.d.ts +23 -0
- package/dist/mcp/server.js +251 -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 +195 -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 +32 -0
- package/dist/storage/repo-manager.d.ts +125 -0
- package/dist/storage/repo-manager.js +257 -0
- package/dist/types/pipeline.d.ts +34 -0
- package/dist/types/pipeline.js +18 -0
- package/hooks/claude/gitnexus-hook.cjs +135 -0
- package/hooks/claude/pre-tool-use.sh +78 -0
- package/hooks/claude/session-start.sh +42 -0
- package/package.json +92 -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-refactoring.md +121 -0
- package/vendor/leiden/index.cjs +355 -0
- package/vendor/leiden/utils.cjs +392 -0
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
// ============================================================================
|
|
14
|
+
// NAME PATTERNS - All 9 supported languages
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Common entry point naming patterns by language
|
|
18
|
+
* These patterns indicate functions that are likely feature entry points
|
|
19
|
+
*/
|
|
20
|
+
const ENTRY_POINT_PATTERNS = {
|
|
21
|
+
// Universal patterns (apply to all languages)
|
|
22
|
+
'*': [
|
|
23
|
+
/^(main|init|bootstrap|start|run|setup|configure)$/i,
|
|
24
|
+
/^handle[A-Z]/, // handleLogin, handleSubmit
|
|
25
|
+
/^on[A-Z]/, // onClick, onSubmit
|
|
26
|
+
/Handler$/, // RequestHandler
|
|
27
|
+
/Controller$/, // UserController
|
|
28
|
+
/^process[A-Z]/, // processPayment
|
|
29
|
+
/^execute[A-Z]/, // executeQuery
|
|
30
|
+
/^perform[A-Z]/, // performAction
|
|
31
|
+
/^dispatch[A-Z]/, // dispatchEvent
|
|
32
|
+
/^trigger[A-Z]/, // triggerAction
|
|
33
|
+
/^fire[A-Z]/, // fireEvent
|
|
34
|
+
/^emit[A-Z]/, // emitEvent
|
|
35
|
+
],
|
|
36
|
+
// JavaScript/TypeScript
|
|
37
|
+
'javascript': [
|
|
38
|
+
/^use[A-Z]/, // React hooks (useEffect, etc.)
|
|
39
|
+
],
|
|
40
|
+
'typescript': [
|
|
41
|
+
/^use[A-Z]/, // React hooks
|
|
42
|
+
],
|
|
43
|
+
// Python
|
|
44
|
+
'python': [
|
|
45
|
+
/^app$/, // Flask/FastAPI app
|
|
46
|
+
/^(get|post|put|delete|patch)_/i, // REST conventions
|
|
47
|
+
/^api_/, // API functions
|
|
48
|
+
/^view_/, // Django views
|
|
49
|
+
],
|
|
50
|
+
// Java
|
|
51
|
+
'java': [
|
|
52
|
+
/^do[A-Z]/, // doGet, doPost (Servlets)
|
|
53
|
+
/^create[A-Z]/, // Factory patterns
|
|
54
|
+
/^build[A-Z]/, // Builder patterns
|
|
55
|
+
/Service$/, // UserService
|
|
56
|
+
],
|
|
57
|
+
// C#
|
|
58
|
+
'csharp': [
|
|
59
|
+
/^(Get|Post|Put|Delete)/, // ASP.NET conventions
|
|
60
|
+
/Action$/, // MVC actions
|
|
61
|
+
/^On[A-Z]/, // Event handlers
|
|
62
|
+
/Async$/, // Async entry points
|
|
63
|
+
],
|
|
64
|
+
// Go
|
|
65
|
+
'go': [
|
|
66
|
+
/Handler$/, // http.Handler pattern
|
|
67
|
+
/^Serve/, // ServeHTTP
|
|
68
|
+
/^New[A-Z]/, // Constructor pattern (returns new instance)
|
|
69
|
+
/^Make[A-Z]/, // Make functions
|
|
70
|
+
],
|
|
71
|
+
// Rust
|
|
72
|
+
'rust': [
|
|
73
|
+
/^(get|post|put|delete)_handler$/i,
|
|
74
|
+
/^handle_/, // handle_request
|
|
75
|
+
/^new$/, // Constructor pattern
|
|
76
|
+
/^run$/, // run entry point
|
|
77
|
+
/^spawn/, // Async spawn
|
|
78
|
+
],
|
|
79
|
+
// C - explicit main() boost (critical for C programs)
|
|
80
|
+
'c': [
|
|
81
|
+
/^main$/, // THE entry point
|
|
82
|
+
/^init_/, // Initialization functions
|
|
83
|
+
/^start_/, // Start functions
|
|
84
|
+
/^run_/, // Run functions
|
|
85
|
+
],
|
|
86
|
+
// C++ - same as C plus class patterns
|
|
87
|
+
'cpp': [
|
|
88
|
+
/^main$/, // THE entry point
|
|
89
|
+
/^init_/,
|
|
90
|
+
/^Create[A-Z]/, // Factory patterns
|
|
91
|
+
/^Run$/, // Run methods
|
|
92
|
+
/^Start$/, // Start methods
|
|
93
|
+
],
|
|
94
|
+
// PHP / Laravel
|
|
95
|
+
'php': [
|
|
96
|
+
/Controller$/, // UserController (class name convention)
|
|
97
|
+
/^handle$/, // Job::handle(), Listener::handle()
|
|
98
|
+
/^execute$/, // Command::execute()
|
|
99
|
+
/^boot$/, // ServiceProvider::boot()
|
|
100
|
+
/^register$/, // ServiceProvider::register()
|
|
101
|
+
/^__invoke$/, // Invokable controllers/actions
|
|
102
|
+
/^(index|show|store|update|destroy|create|edit)$/, // RESTful resource methods
|
|
103
|
+
/^(get|post|put|delete|patch)[A-Z]/, // Explicit HTTP method actions
|
|
104
|
+
/^run$/, // Command/Job run()
|
|
105
|
+
/^fire$/, // Event fire()
|
|
106
|
+
/^dispatch$/, // Dispatchable jobs
|
|
107
|
+
/Service$/, // UserService (Service layer)
|
|
108
|
+
/Repository$/, // UserRepository (Repository pattern)
|
|
109
|
+
/^find$/, // Repository::find()
|
|
110
|
+
/^findAll$/, // Repository::findAll()
|
|
111
|
+
/^save$/, // Repository::save()
|
|
112
|
+
/^delete$/, // Repository::delete()
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// UTILITY PATTERNS - Functions that should be penalized
|
|
117
|
+
// ============================================================================
|
|
118
|
+
/**
|
|
119
|
+
* Patterns that indicate utility/helper functions (NOT entry points)
|
|
120
|
+
* These get penalized in scoring
|
|
121
|
+
*/
|
|
122
|
+
const UTILITY_PATTERNS = [
|
|
123
|
+
/^(get|set|is|has|can|should|will|did)[A-Z]/, // Accessors/predicates
|
|
124
|
+
/^_/, // Private by convention
|
|
125
|
+
/^(format|parse|validate|convert|transform)/i, // Transformation utilities
|
|
126
|
+
/^(log|debug|error|warn|info)$/i, // Logging
|
|
127
|
+
/^(to|from)[A-Z]/, // Conversions
|
|
128
|
+
/^(encode|decode)/i, // Encoding utilities
|
|
129
|
+
/^(serialize|deserialize)/i, // Serialization
|
|
130
|
+
/^(clone|copy|deep)/i, // Cloning utilities
|
|
131
|
+
/^(merge|extend|assign)/i, // Object utilities
|
|
132
|
+
/^(filter|map|reduce|sort|find)/i, // Collection utilities (standalone)
|
|
133
|
+
/Helper$/,
|
|
134
|
+
/Util$/,
|
|
135
|
+
/Utils$/,
|
|
136
|
+
/^utils?$/i,
|
|
137
|
+
/^helpers?$/i,
|
|
138
|
+
];
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// MAIN SCORING FUNCTION
|
|
141
|
+
// ============================================================================
|
|
142
|
+
/**
|
|
143
|
+
* Calculate an entry point score for a function/method
|
|
144
|
+
*
|
|
145
|
+
* Higher scores indicate better entry point candidates.
|
|
146
|
+
* Score = baseScore × exportMultiplier × nameMultiplier
|
|
147
|
+
*
|
|
148
|
+
* @param name - Function/method name
|
|
149
|
+
* @param language - Programming language
|
|
150
|
+
* @param isExported - Whether the function is exported/public
|
|
151
|
+
* @param callerCount - Number of functions that call this function
|
|
152
|
+
* @param calleeCount - Number of functions this function calls
|
|
153
|
+
* @returns Score and array of reasons explaining the score
|
|
154
|
+
*/
|
|
155
|
+
export function calculateEntryPointScore(name, language, isExported, callerCount, calleeCount, filePath = '' // Optional for backwards compatibility
|
|
156
|
+
) {
|
|
157
|
+
const reasons = [];
|
|
158
|
+
// Must have outgoing calls to be an entry point (we need to trace forward)
|
|
159
|
+
if (calleeCount === 0) {
|
|
160
|
+
return { score: 0, reasons: ['no-outgoing-calls'] };
|
|
161
|
+
}
|
|
162
|
+
// Base score: call ratio (existing algorithm)
|
|
163
|
+
// High ratio = calls many, called by few = likely entry point
|
|
164
|
+
const baseScore = calleeCount / (callerCount + 1);
|
|
165
|
+
reasons.push(`base:${baseScore.toFixed(2)}`);
|
|
166
|
+
// Export bonus: exported/public functions are more likely entry points
|
|
167
|
+
const exportMultiplier = isExported ? 2.0 : 1.0;
|
|
168
|
+
if (isExported) {
|
|
169
|
+
reasons.push('exported');
|
|
170
|
+
}
|
|
171
|
+
// Name pattern scoring
|
|
172
|
+
let nameMultiplier = 1.0;
|
|
173
|
+
// Check negative patterns first (utilities get penalized)
|
|
174
|
+
if (UTILITY_PATTERNS.some(p => p.test(name))) {
|
|
175
|
+
nameMultiplier = 0.3; // Significant penalty
|
|
176
|
+
reasons.push('utility-pattern');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// Check positive patterns
|
|
180
|
+
const universalPatterns = ENTRY_POINT_PATTERNS['*'] || [];
|
|
181
|
+
const langPatterns = ENTRY_POINT_PATTERNS[language] || [];
|
|
182
|
+
const allPatterns = [...universalPatterns, ...langPatterns];
|
|
183
|
+
if (allPatterns.some(p => p.test(name))) {
|
|
184
|
+
nameMultiplier = 1.5; // Bonus for matching entry point pattern
|
|
185
|
+
reasons.push('entry-pattern');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Framework detection bonus (Phase 2)
|
|
189
|
+
let frameworkMultiplier = 1.0;
|
|
190
|
+
if (filePath) {
|
|
191
|
+
const frameworkHint = detectFrameworkFromPath(filePath);
|
|
192
|
+
if (frameworkHint) {
|
|
193
|
+
frameworkMultiplier = frameworkHint.entryPointMultiplier;
|
|
194
|
+
reasons.push(`framework:${frameworkHint.reason}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Calculate final score
|
|
198
|
+
const finalScore = baseScore * exportMultiplier * nameMultiplier * frameworkMultiplier;
|
|
199
|
+
return {
|
|
200
|
+
score: finalScore,
|
|
201
|
+
reasons,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// ============================================================================
|
|
205
|
+
// HELPER FUNCTIONS
|
|
206
|
+
// ============================================================================
|
|
207
|
+
/**
|
|
208
|
+
* Check if a file path is a test file (should be excluded from entry points)
|
|
209
|
+
* Covers common test file patterns across all supported languages
|
|
210
|
+
*/
|
|
211
|
+
export function isTestFile(filePath) {
|
|
212
|
+
const p = filePath.toLowerCase().replace(/\\/g, '/');
|
|
213
|
+
return (
|
|
214
|
+
// JavaScript/TypeScript test patterns
|
|
215
|
+
p.includes('.test.') ||
|
|
216
|
+
p.includes('.spec.') ||
|
|
217
|
+
p.includes('__tests__/') ||
|
|
218
|
+
p.includes('__mocks__/') ||
|
|
219
|
+
// Generic test folders
|
|
220
|
+
p.includes('/test/') ||
|
|
221
|
+
p.includes('/tests/') ||
|
|
222
|
+
p.includes('/testing/') ||
|
|
223
|
+
// Python test patterns
|
|
224
|
+
p.endsWith('_test.py') ||
|
|
225
|
+
p.includes('/test_') ||
|
|
226
|
+
// Go test patterns
|
|
227
|
+
p.endsWith('_test.go') ||
|
|
228
|
+
// Java test patterns
|
|
229
|
+
p.includes('/src/test/') ||
|
|
230
|
+
// Rust test patterns (inline tests are different, but test files)
|
|
231
|
+
p.includes('/tests/') ||
|
|
232
|
+
// C# test patterns
|
|
233
|
+
p.includes('.tests/') ||
|
|
234
|
+
p.includes('tests.cs') ||
|
|
235
|
+
// PHP/Laravel test patterns
|
|
236
|
+
p.endsWith('test.php') ||
|
|
237
|
+
p.endsWith('spec.php') ||
|
|
238
|
+
p.includes('/tests/feature/') ||
|
|
239
|
+
p.includes('/tests/unit/'));
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Check if a file path is likely a utility/helper file
|
|
243
|
+
* These might still have entry points but should be lower priority
|
|
244
|
+
*/
|
|
245
|
+
export function isUtilityFile(filePath) {
|
|
246
|
+
const p = filePath.toLowerCase().replace(/\\/g, '/');
|
|
247
|
+
return (p.includes('/utils/') ||
|
|
248
|
+
p.includes('/util/') ||
|
|
249
|
+
p.includes('/helpers/') ||
|
|
250
|
+
p.includes('/helper/') ||
|
|
251
|
+
p.includes('/common/') ||
|
|
252
|
+
p.includes('/shared/') ||
|
|
253
|
+
p.includes('/lib/') ||
|
|
254
|
+
p.endsWith('/utils.ts') ||
|
|
255
|
+
p.endsWith('/utils.js') ||
|
|
256
|
+
p.endsWith('/helpers.ts') ||
|
|
257
|
+
p.endsWith('/helpers.js') ||
|
|
258
|
+
p.endsWith('_utils.py') ||
|
|
259
|
+
p.endsWith('_helpers.py'));
|
|
260
|
+
}
|
|
@@ -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[]>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
import { shouldIgnorePath } from '../../config/ignore-service.js';
|
|
5
|
+
const READ_CONCURRENCY = 32;
|
|
6
|
+
/** Skip files larger than 512KB — they're usually generated/vendored and crash tree-sitter */
|
|
7
|
+
const MAX_FILE_SIZE = 512 * 1024;
|
|
8
|
+
/**
|
|
9
|
+
* Phase 1: Scan repository — stat files to get paths + sizes, no content loaded.
|
|
10
|
+
* Memory: ~10MB for 100K files vs ~1GB+ with content.
|
|
11
|
+
*/
|
|
12
|
+
export const walkRepositoryPaths = async (repoPath, onProgress) => {
|
|
13
|
+
const files = await glob('**/*', {
|
|
14
|
+
cwd: repoPath,
|
|
15
|
+
nodir: true,
|
|
16
|
+
dot: false,
|
|
17
|
+
});
|
|
18
|
+
const filtered = files.filter(file => !shouldIgnorePath(file));
|
|
19
|
+
const entries = [];
|
|
20
|
+
let processed = 0;
|
|
21
|
+
let skippedLarge = 0;
|
|
22
|
+
for (let start = 0; start < filtered.length; start += READ_CONCURRENCY) {
|
|
23
|
+
const batch = filtered.slice(start, start + READ_CONCURRENCY);
|
|
24
|
+
const results = await Promise.allSettled(batch.map(async (relativePath) => {
|
|
25
|
+
const fullPath = path.join(repoPath, relativePath);
|
|
26
|
+
const stat = await fs.stat(fullPath);
|
|
27
|
+
if (stat.size > MAX_FILE_SIZE) {
|
|
28
|
+
skippedLarge++;
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return { path: relativePath.replace(/\\/g, '/'), size: stat.size };
|
|
32
|
+
}));
|
|
33
|
+
for (const result of results) {
|
|
34
|
+
processed++;
|
|
35
|
+
if (result.status === 'fulfilled' && result.value !== null) {
|
|
36
|
+
entries.push(result.value);
|
|
37
|
+
onProgress?.(processed, filtered.length, result.value.path);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
onProgress?.(processed, filtered.length, batch[results.indexOf(result)]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (skippedLarge > 0) {
|
|
45
|
+
console.warn(` Skipped ${skippedLarge} large files (>${MAX_FILE_SIZE / 1024}KB, likely generated/vendored)`);
|
|
46
|
+
}
|
|
47
|
+
return entries;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Phase 2: Read file contents for a specific set of relative paths.
|
|
51
|
+
* Returns a Map for O(1) lookup. Silently skips files that fail to read.
|
|
52
|
+
*/
|
|
53
|
+
export const readFileContents = async (repoPath, relativePaths) => {
|
|
54
|
+
const contents = new Map();
|
|
55
|
+
for (let start = 0; start < relativePaths.length; start += READ_CONCURRENCY) {
|
|
56
|
+
const batch = relativePaths.slice(start, start + READ_CONCURRENCY);
|
|
57
|
+
const results = await Promise.allSettled(batch.map(async (relativePath) => {
|
|
58
|
+
const fullPath = path.join(repoPath, relativePath);
|
|
59
|
+
const content = await fs.readFile(fullPath, 'utf-8');
|
|
60
|
+
return { path: relativePath, content };
|
|
61
|
+
}));
|
|
62
|
+
for (const result of results) {
|
|
63
|
+
if (result.status === 'fulfilled') {
|
|
64
|
+
contents.set(result.value.path, result.value.content);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return contents;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Legacy API — scans and reads everything into memory.
|
|
72
|
+
* Used by sequential fallback path only.
|
|
73
|
+
*/
|
|
74
|
+
export const walkRepository = async (repoPath, onProgress) => {
|
|
75
|
+
const scanned = await walkRepositoryPaths(repoPath, onProgress);
|
|
76
|
+
const contents = await readFileContents(repoPath, scanned.map(f => f.path));
|
|
77
|
+
return scanned
|
|
78
|
+
.filter(f => contents.has(f.path))
|
|
79
|
+
.map(f => ({ path: f.path, content: contents.get(f.path) }));
|
|
80
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework Detection
|
|
3
|
+
*
|
|
4
|
+
* Detects frameworks from file path patterns and provides entry point multipliers.
|
|
5
|
+
* This enables framework-aware entry point scoring.
|
|
6
|
+
*
|
|
7
|
+
* DESIGN: Returns null for unknown frameworks, which causes a 1.0 multiplier
|
|
8
|
+
* (no bonus, no penalty) - same behavior as before this feature.
|
|
9
|
+
*/
|
|
10
|
+
export interface FrameworkHint {
|
|
11
|
+
framework: string;
|
|
12
|
+
entryPointMultiplier: number;
|
|
13
|
+
reason: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Detect framework from file path patterns
|
|
17
|
+
*
|
|
18
|
+
* This provides entry point multipliers based on well-known framework conventions.
|
|
19
|
+
* Returns null if no framework pattern is detected (falls back to 1.0 multiplier).
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectFrameworkFromPath(filePath: string): FrameworkHint | null;
|
|
22
|
+
/**
|
|
23
|
+
* Patterns that indicate entry points within code (for future AST-based detection)
|
|
24
|
+
* These would require parsing decorators/annotations in the code itself.
|
|
25
|
+
*/
|
|
26
|
+
export declare const FRAMEWORK_AST_PATTERNS: {
|
|
27
|
+
nestjs: string[];
|
|
28
|
+
express: string[];
|
|
29
|
+
fastapi: string[];
|
|
30
|
+
flask: string[];
|
|
31
|
+
spring: string[];
|
|
32
|
+
jaxrs: string[];
|
|
33
|
+
aspnet: string[];
|
|
34
|
+
'go-http': string[];
|
|
35
|
+
laravel: string[];
|
|
36
|
+
actix: string[];
|
|
37
|
+
axum: string[];
|
|
38
|
+
rocket: string[];
|
|
39
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework Detection
|
|
3
|
+
*
|
|
4
|
+
* Detects frameworks from file path patterns and provides entry point multipliers.
|
|
5
|
+
* This enables framework-aware entry point scoring.
|
|
6
|
+
*
|
|
7
|
+
* DESIGN: Returns null for unknown frameworks, which causes a 1.0 multiplier
|
|
8
|
+
* (no bonus, no penalty) - same behavior as before this feature.
|
|
9
|
+
*/
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// PATH-BASED FRAMEWORK DETECTION
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Detect framework from file path patterns
|
|
15
|
+
*
|
|
16
|
+
* This provides entry point multipliers based on well-known framework conventions.
|
|
17
|
+
* Returns null if no framework pattern is detected (falls back to 1.0 multiplier).
|
|
18
|
+
*/
|
|
19
|
+
export function detectFrameworkFromPath(filePath) {
|
|
20
|
+
// Normalize path separators and ensure leading slash for consistent matching
|
|
21
|
+
let p = filePath.toLowerCase().replace(/\\/g, '/');
|
|
22
|
+
if (!p.startsWith('/')) {
|
|
23
|
+
p = '/' + p; // Add leading slash so patterns like '/app/' match 'app/...'
|
|
24
|
+
}
|
|
25
|
+
// ========== JAVASCRIPT / TYPESCRIPT FRAMEWORKS ==========
|
|
26
|
+
// Next.js - Pages Router (high confidence)
|
|
27
|
+
if (p.includes('/pages/') && !p.includes('/_') && !p.includes('/api/')) {
|
|
28
|
+
if (p.endsWith('.tsx') || p.endsWith('.ts') || p.endsWith('.jsx') || p.endsWith('.js')) {
|
|
29
|
+
return { framework: 'nextjs-pages', entryPointMultiplier: 3.0, reason: 'nextjs-page' };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Next.js - App Router (page.tsx files)
|
|
33
|
+
if (p.includes('/app/') && (p.endsWith('page.tsx') || p.endsWith('page.ts') ||
|
|
34
|
+
p.endsWith('page.jsx') || p.endsWith('page.js'))) {
|
|
35
|
+
return { framework: 'nextjs-app', entryPointMultiplier: 3.0, reason: 'nextjs-app-page' };
|
|
36
|
+
}
|
|
37
|
+
// Next.js - API Routes
|
|
38
|
+
if (p.includes('/pages/api/') || (p.includes('/app/') && p.includes('/api/') && p.endsWith('route.ts'))) {
|
|
39
|
+
return { framework: 'nextjs-api', entryPointMultiplier: 3.0, reason: 'nextjs-api-route' };
|
|
40
|
+
}
|
|
41
|
+
// Next.js - Layout files (moderate - they're entry-ish but not the main entry)
|
|
42
|
+
if (p.includes('/app/') && (p.endsWith('layout.tsx') || p.endsWith('layout.ts'))) {
|
|
43
|
+
return { framework: 'nextjs-app', entryPointMultiplier: 2.0, reason: 'nextjs-layout' };
|
|
44
|
+
}
|
|
45
|
+
// Express / Node.js routes
|
|
46
|
+
if (p.includes('/routes/') && (p.endsWith('.ts') || p.endsWith('.js'))) {
|
|
47
|
+
return { framework: 'express', entryPointMultiplier: 2.5, reason: 'routes-folder' };
|
|
48
|
+
}
|
|
49
|
+
// Generic controllers (MVC pattern)
|
|
50
|
+
if (p.includes('/controllers/') && (p.endsWith('.ts') || p.endsWith('.js'))) {
|
|
51
|
+
return { framework: 'mvc', entryPointMultiplier: 2.5, reason: 'controllers-folder' };
|
|
52
|
+
}
|
|
53
|
+
// Generic handlers
|
|
54
|
+
if (p.includes('/handlers/') && (p.endsWith('.ts') || p.endsWith('.js'))) {
|
|
55
|
+
return { framework: 'handlers', entryPointMultiplier: 2.5, reason: 'handlers-folder' };
|
|
56
|
+
}
|
|
57
|
+
// React components (lower priority - not all are entry points)
|
|
58
|
+
if ((p.includes('/components/') || p.includes('/views/')) &&
|
|
59
|
+
(p.endsWith('.tsx') || p.endsWith('.jsx'))) {
|
|
60
|
+
// Only boost if PascalCase filename (likely a component, not util)
|
|
61
|
+
const fileName = p.split('/').pop() || '';
|
|
62
|
+
if (/^[A-Z]/.test(fileName)) {
|
|
63
|
+
return { framework: 'react', entryPointMultiplier: 1.5, reason: 'react-component' };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// ========== PYTHON FRAMEWORKS ==========
|
|
67
|
+
// Django views (high confidence)
|
|
68
|
+
if (p.endsWith('views.py')) {
|
|
69
|
+
return { framework: 'django', entryPointMultiplier: 3.0, reason: 'django-views' };
|
|
70
|
+
}
|
|
71
|
+
// Django URL configs
|
|
72
|
+
if (p.endsWith('urls.py')) {
|
|
73
|
+
return { framework: 'django', entryPointMultiplier: 2.0, reason: 'django-urls' };
|
|
74
|
+
}
|
|
75
|
+
// FastAPI / Flask routers
|
|
76
|
+
if ((p.includes('/routers/') || p.includes('/endpoints/') || p.includes('/routes/')) &&
|
|
77
|
+
p.endsWith('.py')) {
|
|
78
|
+
return { framework: 'fastapi', entryPointMultiplier: 2.5, reason: 'api-routers' };
|
|
79
|
+
}
|
|
80
|
+
// Python API folder
|
|
81
|
+
if (p.includes('/api/') && p.endsWith('.py') && !p.endsWith('__init__.py')) {
|
|
82
|
+
return { framework: 'python-api', entryPointMultiplier: 2.0, reason: 'api-folder' };
|
|
83
|
+
}
|
|
84
|
+
// ========== JAVA FRAMEWORKS ==========
|
|
85
|
+
// Spring Boot controllers
|
|
86
|
+
if ((p.includes('/controller/') || p.includes('/controllers/')) && p.endsWith('.java')) {
|
|
87
|
+
return { framework: 'spring', entryPointMultiplier: 3.0, reason: 'spring-controller' };
|
|
88
|
+
}
|
|
89
|
+
// Spring Boot - files ending in Controller.java
|
|
90
|
+
if (p.endsWith('controller.java')) {
|
|
91
|
+
return { framework: 'spring', entryPointMultiplier: 3.0, reason: 'spring-controller-file' };
|
|
92
|
+
}
|
|
93
|
+
// Java service layer (often entry points for business logic)
|
|
94
|
+
if ((p.includes('/service/') || p.includes('/services/')) && p.endsWith('.java')) {
|
|
95
|
+
return { framework: 'java-service', entryPointMultiplier: 1.8, reason: 'java-service' };
|
|
96
|
+
}
|
|
97
|
+
// ========== C# / .NET FRAMEWORKS ==========
|
|
98
|
+
// ASP.NET Controllers
|
|
99
|
+
if (p.includes('/controllers/') && p.endsWith('.cs')) {
|
|
100
|
+
return { framework: 'aspnet', entryPointMultiplier: 3.0, reason: 'aspnet-controller' };
|
|
101
|
+
}
|
|
102
|
+
// ASP.NET - files ending in Controller.cs
|
|
103
|
+
if (p.endsWith('controller.cs')) {
|
|
104
|
+
return { framework: 'aspnet', entryPointMultiplier: 3.0, reason: 'aspnet-controller-file' };
|
|
105
|
+
}
|
|
106
|
+
// Blazor pages
|
|
107
|
+
if (p.includes('/pages/') && p.endsWith('.razor')) {
|
|
108
|
+
return { framework: 'blazor', entryPointMultiplier: 2.5, reason: 'blazor-page' };
|
|
109
|
+
}
|
|
110
|
+
// ========== GO FRAMEWORKS ==========
|
|
111
|
+
// Go handlers
|
|
112
|
+
if ((p.includes('/handlers/') || p.includes('/handler/')) && p.endsWith('.go')) {
|
|
113
|
+
return { framework: 'go-http', entryPointMultiplier: 2.5, reason: 'go-handlers' };
|
|
114
|
+
}
|
|
115
|
+
// Go routes
|
|
116
|
+
if (p.includes('/routes/') && p.endsWith('.go')) {
|
|
117
|
+
return { framework: 'go-http', entryPointMultiplier: 2.5, reason: 'go-routes' };
|
|
118
|
+
}
|
|
119
|
+
// Go controllers
|
|
120
|
+
if (p.includes('/controllers/') && p.endsWith('.go')) {
|
|
121
|
+
return { framework: 'go-mvc', entryPointMultiplier: 2.5, reason: 'go-controller' };
|
|
122
|
+
}
|
|
123
|
+
// Go main.go files (THE entry point)
|
|
124
|
+
if (p.endsWith('/main.go') || p.endsWith('/cmd/') && p.endsWith('.go')) {
|
|
125
|
+
return { framework: 'go', entryPointMultiplier: 3.0, reason: 'go-main' };
|
|
126
|
+
}
|
|
127
|
+
// ========== RUST FRAMEWORKS ==========
|
|
128
|
+
// Rust handlers/routes
|
|
129
|
+
if ((p.includes('/handlers/') || p.includes('/routes/')) && p.endsWith('.rs')) {
|
|
130
|
+
return { framework: 'rust-web', entryPointMultiplier: 2.5, reason: 'rust-handlers' };
|
|
131
|
+
}
|
|
132
|
+
// Rust main.rs (THE entry point)
|
|
133
|
+
if (p.endsWith('/main.rs')) {
|
|
134
|
+
return { framework: 'rust', entryPointMultiplier: 3.0, reason: 'rust-main' };
|
|
135
|
+
}
|
|
136
|
+
// Rust bin folder (executables)
|
|
137
|
+
if (p.includes('/bin/') && p.endsWith('.rs')) {
|
|
138
|
+
return { framework: 'rust', entryPointMultiplier: 2.5, reason: 'rust-bin' };
|
|
139
|
+
}
|
|
140
|
+
// ========== C / C++ ==========
|
|
141
|
+
// C/C++ main files
|
|
142
|
+
if (p.endsWith('/main.c') || p.endsWith('/main.cpp') || p.endsWith('/main.cc')) {
|
|
143
|
+
return { framework: 'c-cpp', entryPointMultiplier: 3.0, reason: 'c-main' };
|
|
144
|
+
}
|
|
145
|
+
// C/C++ src folder entry points (if named specifically)
|
|
146
|
+
if ((p.includes('/src/') && (p.endsWith('/app.c') || p.endsWith('/app.cpp')))) {
|
|
147
|
+
return { framework: 'c-cpp', entryPointMultiplier: 2.5, reason: 'c-app' };
|
|
148
|
+
}
|
|
149
|
+
// ========== PHP / LARAVEL FRAMEWORKS ==========
|
|
150
|
+
// Laravel routes (highest - these ARE the entry point definitions)
|
|
151
|
+
if (p.includes('/routes/') && p.endsWith('.php')) {
|
|
152
|
+
return { framework: 'laravel', entryPointMultiplier: 3.0, reason: 'laravel-routes' };
|
|
153
|
+
}
|
|
154
|
+
// Laravel controllers (very high - receive HTTP requests)
|
|
155
|
+
if ((p.includes('/http/controllers/') || p.includes('/controllers/')) && p.endsWith('.php')) {
|
|
156
|
+
return { framework: 'laravel', entryPointMultiplier: 3.0, reason: 'laravel-controller' };
|
|
157
|
+
}
|
|
158
|
+
// Laravel controller by file name convention
|
|
159
|
+
if (p.endsWith('controller.php')) {
|
|
160
|
+
return { framework: 'laravel', entryPointMultiplier: 3.0, reason: 'laravel-controller-file' };
|
|
161
|
+
}
|
|
162
|
+
// Laravel console commands
|
|
163
|
+
if ((p.includes('/console/commands/') || p.includes('/commands/')) && p.endsWith('.php')) {
|
|
164
|
+
return { framework: 'laravel', entryPointMultiplier: 2.5, reason: 'laravel-command' };
|
|
165
|
+
}
|
|
166
|
+
// Laravel jobs (queue entry points)
|
|
167
|
+
if (p.includes('/jobs/') && p.endsWith('.php')) {
|
|
168
|
+
return { framework: 'laravel', entryPointMultiplier: 2.5, reason: 'laravel-job' };
|
|
169
|
+
}
|
|
170
|
+
// Laravel listeners (event-driven entry points)
|
|
171
|
+
if (p.includes('/listeners/') && p.endsWith('.php')) {
|
|
172
|
+
return { framework: 'laravel', entryPointMultiplier: 2.5, reason: 'laravel-listener' };
|
|
173
|
+
}
|
|
174
|
+
// Laravel middleware
|
|
175
|
+
if (p.includes('/http/middleware/') && p.endsWith('.php')) {
|
|
176
|
+
return { framework: 'laravel', entryPointMultiplier: 2.5, reason: 'laravel-middleware' };
|
|
177
|
+
}
|
|
178
|
+
// Laravel service providers
|
|
179
|
+
if (p.includes('/providers/') && p.endsWith('.php')) {
|
|
180
|
+
return { framework: 'laravel', entryPointMultiplier: 1.8, reason: 'laravel-provider' };
|
|
181
|
+
}
|
|
182
|
+
// Laravel policies
|
|
183
|
+
if (p.includes('/policies/') && p.endsWith('.php')) {
|
|
184
|
+
return { framework: 'laravel', entryPointMultiplier: 2.0, reason: 'laravel-policy' };
|
|
185
|
+
}
|
|
186
|
+
// Laravel models (important but not entry points per se)
|
|
187
|
+
if (p.includes('/models/') && p.endsWith('.php')) {
|
|
188
|
+
return { framework: 'laravel', entryPointMultiplier: 1.5, reason: 'laravel-model' };
|
|
189
|
+
}
|
|
190
|
+
// Laravel services (Service Repository pattern)
|
|
191
|
+
if (p.includes('/services/') && p.endsWith('.php')) {
|
|
192
|
+
return { framework: 'laravel', entryPointMultiplier: 1.8, reason: 'laravel-service' };
|
|
193
|
+
}
|
|
194
|
+
// Laravel repositories (Service Repository pattern)
|
|
195
|
+
if (p.includes('/repositories/') && p.endsWith('.php')) {
|
|
196
|
+
return { framework: 'laravel', entryPointMultiplier: 1.5, reason: 'laravel-repository' };
|
|
197
|
+
}
|
|
198
|
+
// ========== GENERIC PATTERNS ==========
|
|
199
|
+
// Any language: index files in API folders
|
|
200
|
+
if (p.includes('/api/') && (p.endsWith('/index.ts') || p.endsWith('/index.js') ||
|
|
201
|
+
p.endsWith('/__init__.py'))) {
|
|
202
|
+
return { framework: 'api', entryPointMultiplier: 1.8, reason: 'api-index' };
|
|
203
|
+
}
|
|
204
|
+
// No framework detected - return null for graceful fallback (1.0 multiplier)
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
// ============================================================================
|
|
208
|
+
// FUTURE: AST-BASED PATTERNS (for Phase 3)
|
|
209
|
+
// ============================================================================
|
|
210
|
+
/**
|
|
211
|
+
* Patterns that indicate entry points within code (for future AST-based detection)
|
|
212
|
+
* These would require parsing decorators/annotations in the code itself.
|
|
213
|
+
*/
|
|
214
|
+
export const FRAMEWORK_AST_PATTERNS = {
|
|
215
|
+
// JavaScript/TypeScript decorators
|
|
216
|
+
'nestjs': ['@Controller', '@Get', '@Post', '@Put', '@Delete', '@Patch'],
|
|
217
|
+
'express': ['app.get', 'app.post', 'app.put', 'app.delete', 'router.get', 'router.post'],
|
|
218
|
+
// Python decorators
|
|
219
|
+
'fastapi': ['@app.get', '@app.post', '@app.put', '@app.delete', '@router.get'],
|
|
220
|
+
'flask': ['@app.route', '@blueprint.route'],
|
|
221
|
+
// Java annotations
|
|
222
|
+
'spring': ['@RestController', '@Controller', '@GetMapping', '@PostMapping', '@RequestMapping'],
|
|
223
|
+
'jaxrs': ['@Path', '@GET', '@POST', '@PUT', '@DELETE'],
|
|
224
|
+
// C# attributes
|
|
225
|
+
'aspnet': ['[ApiController]', '[HttpGet]', '[HttpPost]', '[Route]'],
|
|
226
|
+
// Go patterns (function signatures)
|
|
227
|
+
'go-http': ['http.Handler', 'http.HandlerFunc', 'ServeHTTP'],
|
|
228
|
+
// PHP/Laravel
|
|
229
|
+
'laravel': ['Route::get', 'Route::post', 'Route::put', 'Route::delete',
|
|
230
|
+
'Route::resource', 'Route::apiResource', '#[Route('],
|
|
231
|
+
// Rust macros
|
|
232
|
+
'actix': ['#[get', '#[post', '#[put', '#[delete'],
|
|
233
|
+
'axum': ['Router::new'],
|
|
234
|
+
'rocket': ['#[get', '#[post'],
|
|
235
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heritage Processor
|
|
3
|
+
*
|
|
4
|
+
* Extracts class inheritance relationships:
|
|
5
|
+
* - EXTENDS: Class extends another Class (TS, JS, Python)
|
|
6
|
+
* - IMPLEMENTS: Class implements an Interface (TS only)
|
|
7
|
+
*/
|
|
8
|
+
import { KnowledgeGraph } from '../graph/types.js';
|
|
9
|
+
import { ASTCache } from './ast-cache.js';
|
|
10
|
+
import { SymbolTable } from './symbol-table.js';
|
|
11
|
+
import type { ExtractedHeritage } from './workers/parse-worker.js';
|
|
12
|
+
export declare const processHeritage: (graph: KnowledgeGraph, files: {
|
|
13
|
+
path: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}[], astCache: ASTCache, symbolTable: SymbolTable, onProgress?: (current: number, total: number) => void) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Fast path: resolve pre-extracted heritage from workers.
|
|
18
|
+
* No AST parsing — workers already extracted className + parentName + kind.
|
|
19
|
+
*/
|
|
20
|
+
export declare const processHeritageFromExtracted: (graph: KnowledgeGraph, extractedHeritage: ExtractedHeritage[], symbolTable: SymbolTable, onProgress?: (current: number, total: number) => void) => Promise<void>;
|