ai-first-cli 1.2.3 → 1.3.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/CHANGELOG.md +292 -6
- package/README.md +24 -4
- package/dist/analyzers/symbols.d.ts.map +1 -1
- package/dist/analyzers/symbols.js +9 -7
- package/dist/analyzers/symbols.js.map +1 -1
- package/dist/analyzers/techStack.d.ts.map +1 -1
- package/dist/analyzers/techStack.js +198 -3
- package/dist/analyzers/techStack.js.map +1 -1
- package/dist/commands/ai-first.d.ts.map +1 -1
- package/dist/commands/ai-first.js +14 -13
- package/dist/commands/ai-first.js.map +1 -1
- package/dist/core/analysis/architectureDetector.d.ts +37 -0
- package/dist/core/analysis/architectureDetector.d.ts.map +1 -0
- package/dist/core/analysis/architectureDetector.js +316 -0
- package/dist/core/analysis/architectureDetector.js.map +1 -0
- package/dist/core/analysis/callGraphBuilder.d.ts +37 -0
- package/dist/core/analysis/callGraphBuilder.d.ts.map +1 -0
- package/dist/core/analysis/callGraphBuilder.js +101 -0
- package/dist/core/analysis/callGraphBuilder.js.map +1 -0
- package/dist/core/analysis/dependencyAnalyzer.d.ts +45 -0
- package/dist/core/analysis/dependencyAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/dependencyAnalyzer.js +98 -0
- package/dist/core/analysis/dependencyAnalyzer.js.map +1 -0
- package/dist/core/analysis/index.d.ts +5 -0
- package/dist/core/analysis/index.d.ts.map +1 -0
- package/dist/core/analysis/index.js +5 -0
- package/dist/core/analysis/index.js.map +1 -0
- package/dist/core/analysis/inheritanceAnalyzer.d.ts +35 -0
- package/dist/core/analysis/inheritanceAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/inheritanceAnalyzer.js +115 -0
- package/dist/core/analysis/inheritanceAnalyzer.js.map +1 -0
- package/dist/core/ccp.d.ts.map +1 -1
- package/dist/core/ccp.js +3 -2
- package/dist/core/ccp.js.map +1 -1
- package/dist/core/generation/aiContextGenerator.d.ts +71 -0
- package/dist/core/generation/aiContextGenerator.d.ts.map +1 -0
- package/dist/core/generation/aiContextGenerator.js +217 -0
- package/dist/core/generation/aiContextGenerator.js.map +1 -0
- package/dist/core/generation/architectureGenerator.d.ts +17 -0
- package/dist/core/generation/architectureGenerator.d.ts.map +1 -0
- package/dist/core/generation/architectureGenerator.js +160 -0
- package/dist/core/generation/architectureGenerator.js.map +1 -0
- package/dist/core/generation/flowGenerator.d.ts +52 -0
- package/dist/core/generation/flowGenerator.d.ts.map +1 -0
- package/dist/core/generation/flowGenerator.js +164 -0
- package/dist/core/generation/flowGenerator.js.map +1 -0
- package/dist/core/generation/index.d.ts +4 -0
- package/dist/core/generation/index.d.ts.map +1 -0
- package/dist/core/generation/index.js +4 -0
- package/dist/core/generation/index.js.map +1 -0
- package/dist/core/hierarchyGenerator.d.ts.map +1 -1
- package/dist/core/hierarchyGenerator.js +3 -2
- package/dist/core/hierarchyGenerator.js.map +1 -1
- package/dist/core/parsers/index.d.ts +20 -0
- package/dist/core/parsers/index.d.ts.map +1 -0
- package/dist/core/parsers/index.js +76 -0
- package/dist/core/parsers/index.js.map +1 -0
- package/dist/core/parsers/pythonParser.d.ts +37 -0
- package/dist/core/parsers/pythonParser.d.ts.map +1 -0
- package/dist/core/parsers/pythonParser.js +229 -0
- package/dist/core/parsers/pythonParser.js.map +1 -0
- package/dist/core/parsers/typescriptParser.d.ts +54 -0
- package/dist/core/parsers/typescriptParser.d.ts.map +1 -0
- package/dist/core/parsers/typescriptParser.js +291 -0
- package/dist/core/parsers/typescriptParser.js.map +1 -0
- package/dist/core/pipeline.d.ts +42 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +172 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/semanticContexts.js +1 -1
- package/dist/core/semanticContexts.js.map +1 -1
- package/dist/utils/constants.d.ts +46 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +67 -0
- package/dist/utils/constants.js.map +1 -0
- package/package.json +1 -1
- package/run-all-tests.sh +184 -0
- package/src/analyzers/symbols.ts +12 -7
- package/src/analyzers/techStack.ts +203 -3
- package/src/commands/ai-first.ts +14 -13
- package/src/core/analysis/architectureDetector.ts +487 -0
- package/src/core/analysis/callGraphBuilder.ts +158 -0
- package/src/core/analysis/dependencyAnalyzer.ts +167 -0
- package/src/core/analysis/index.ts +28 -0
- package/src/core/analysis/inheritanceAnalyzer.ts +169 -0
- package/src/core/ccp.ts +3 -2
- package/src/core/generation/aiContextGenerator.ts +335 -0
- package/src/core/generation/architectureGenerator.ts +200 -0
- package/src/core/generation/flowGenerator.ts +238 -0
- package/src/core/generation/index.ts +16 -0
- package/src/core/hierarchyGenerator.ts +3 -2
- package/src/core/parsers/index.ts +99 -0
- package/src/core/parsers/pythonParser.ts +302 -0
- package/src/core/parsers/typescriptParser.ts +445 -0
- package/src/core/pipeline.ts +241 -0
- package/src/core/semanticContexts.ts +1 -1
- package/src/utils/constants.ts +78 -0
- package/tests/analysis.test.ts +283 -0
- package/tests/architectureDetector.test.ts +137 -0
- package/tests/generation.test.ts +216 -0
- package/tests/parserRegistry.test.ts +139 -0
- package/tests/pipeline.integration.test.ts +245 -0
- package/tests/pythonParser.test.ts +210 -0
- package/tests/typescriptParser.test.ts +197 -0
- package/.ai-dev/index.db +0 -0
- package/ANALISIS_COMPLETO.md +0 -424
- package/ANALISIS_MEJORAS.md +0 -327
- package/BUGS.md +0 -455
- package/PLAN_MEJORAS.md +0 -216
- package/STATUS_ADAPTADORES +0 -126
- package/TEST_RESULTS.md +0 -198
- package/TEST_RESULTS_COMPARATIVE.md +0 -159
- package/TEST_RESULTS_COMPLETE.md +0 -127
- package/TEST_RESULTS_COMPREHENSIVE.md +0 -208
- package/TEST_RESULTS_PHASE1.md +0 -420
- package/ai/dependencies.json +0 -15
- package/ai/graph/knowledge-graph.json +0 -12
- package/ai-context/ai_context.md +0 -130
- package/ai-context/ai_rules.md +0 -54
- package/ai-context/architecture.md +0 -136
- package/ai-context/cache.json +0 -2349
- package/ai-context/ccp/jira-123/context.json +0 -7
- package/ai-context/context/features/commands.json +0 -18
- package/ai-context/context/features/src.json +0 -61
- package/ai-context/context/features/test-projects.json +0 -69
- package/ai-context/context/flows/account.json +0 -9
- package/ai-context/context/flows/ai-first.json +0 -9
- package/ai-context/context/flows/api.json +0 -9
- package/ai-context/context/flows/auth.json +0 -13
- package/ai-context/context/flows/category.json +0 -12
- package/ai-context/context/flows/comment.json +0 -16
- package/ai-context/context/flows/dashboard.json +0 -9
- package/ai-context/context/flows/doctor.json +0 -9
- package/ai-context/context/flows/explore.json +0 -9
- package/ai-context/context/flows/login.json +0 -9
- package/ai-context/context/flows/opportunity.json +0 -9
- package/ai-context/context/flows/post.json +0 -18
- package/ai-context/context/flows/routes.json +0 -19
- package/ai-context/context/flows/user.json +0 -20
- package/ai-context/context/flows/users.json +0 -9
- package/ai-context/context/flows/views.json +0 -14
- package/ai-context/context/repo.json +0 -56
- package/ai-context/context/utils.json +0 -7
- package/ai-context/conventions.md +0 -53
- package/ai-context/dependencies.json +0 -2978
- package/ai-context/embeddings.json +0 -23828
- package/ai-context/entrypoints.md +0 -42
- package/ai-context/files.json +0 -2944
- package/ai-context/git/commit-activity.json +0 -8646
- package/ai-context/git/recent-features.json +0 -1
- package/ai-context/git/recent-files.json +0 -52
- package/ai-context/git/recent-flows.json +0 -1
- package/ai-context/graph/knowledge-graph.json +0 -44129
- package/ai-context/graph/module-graph.json +0 -866
- package/ai-context/graph/symbol-graph.json +0 -200622
- package/ai-context/graph/symbol-references.json +0 -6778
- package/ai-context/hierarchy.json +0 -20
- package/ai-context/index-state.json +0 -4487
- package/ai-context/index.db +0 -0
- package/ai-context/modules.json +0 -933
- package/ai-context/project.json +0 -30
- package/ai-context/repo_map.json +0 -9116
- package/ai-context/repo_map.md +0 -2061
- package/ai-context/schema.json +0 -5
- package/ai-context/summary.md +0 -47
- package/ai-context/symbols.json +0 -65351
- package/ai-context/tech_stack.md +0 -47
- package/ai-context/tools.json +0 -10
- package/test-projects/django-app/.ai-dev/index.db +0 -0
- package/test-projects/django-app/ai-context/ai_context.md +0 -92
- package/test-projects/django-app/ai-context/ai_rules.md +0 -47
- package/test-projects/django-app/ai-context/architecture.md +0 -57
- package/test-projects/django-app/ai-context/cache.json +0 -169
- package/test-projects/django-app/ai-context/context/flows/views.json +0 -10
- package/test-projects/django-app/ai-context/conventions.md +0 -51
- package/test-projects/django-app/ai-context/dependencies.json +0 -312
- package/test-projects/django-app/ai-context/entrypoints.md +0 -4
- package/test-projects/django-app/ai-context/files.json +0 -209
- package/test-projects/django-app/ai-context/graph/knowledge-graph.json +0 -36
- package/test-projects/django-app/ai-context/graph/module-graph.json +0 -145
- package/test-projects/django-app/ai-context/graph/symbol-graph.json +0 -1488
- package/test-projects/django-app/ai-context/graph/symbol-references.json +0 -1
- package/test-projects/django-app/ai-context/index-state.json +0 -294
- package/test-projects/django-app/ai-context/index.db +0 -0
- package/test-projects/django-app/ai-context/modules.json +0 -35
- package/test-projects/django-app/ai-context/project.json +0 -11
- package/test-projects/django-app/ai-context/repo_map.json +0 -412
- package/test-projects/django-app/ai-context/repo_map.md +0 -105
- package/test-projects/django-app/ai-context/schema.json +0 -5
- package/test-projects/django-app/ai-context/summary.md +0 -15
- package/test-projects/django-app/ai-context/symbols.json +0 -1
- package/test-projects/django-app/ai-context/tech_stack.md +0 -32
- package/test-projects/django-app/ai-context/tools.json +0 -10
- package/test-projects/express-api/ai-context/ai_context.md +0 -112
- package/test-projects/express-api/ai-context/ai_rules.md +0 -50
- package/test-projects/express-api/ai-context/architecture.md +0 -62
- package/test-projects/express-api/ai-context/context/features/controllers.json +0 -13
- package/test-projects/express-api/ai-context/context/features/services.json +0 -13
- package/test-projects/express-api/ai-context/context/flows/auth.json +0 -12
- package/test-projects/express-api/ai-context/context/flows/user.json +0 -13
- package/test-projects/express-api/ai-context/conventions.md +0 -51
- package/test-projects/express-api/ai-context/dependencies.json +0 -54
- package/test-projects/express-api/ai-context/entrypoints.md +0 -17
- package/test-projects/express-api/ai-context/modules.json +0 -30
- package/test-projects/express-api/ai-context/project.json +0 -15
- package/test-projects/express-api/ai-context/repo_map.json +0 -100
- package/test-projects/express-api/ai-context/repo_map.md +0 -36
- package/test-projects/express-api/ai-context/schema.json +0 -5
- package/test-projects/express-api/ai-context/summary.md +0 -14
- package/test-projects/express-api/ai-context/symbols.json +0 -7
- package/test-projects/express-api/ai-context/tech_stack.md +0 -38
- package/test-projects/express-api/ai-context/tools.json +0 -10
- package/test-projects/fastapi-app/.ai-dev/index.db +0 -0
- package/test-projects/fastapi-app/ai-context/ai_context.md +0 -89
- package/test-projects/fastapi-app/ai-context/ai_rules.md +0 -47
- package/test-projects/fastapi-app/ai-context/architecture.md +0 -39
- package/test-projects/fastapi-app/ai-context/cache.json +0 -125
- package/test-projects/fastapi-app/ai-context/conventions.md +0 -51
- package/test-projects/fastapi-app/ai-context/dependencies.json +0 -244
- package/test-projects/fastapi-app/ai-context/entrypoints.md +0 -4
- package/test-projects/fastapi-app/ai-context/files.json +0 -154
- package/test-projects/fastapi-app/ai-context/graph/knowledge-graph.json +0 -15
- package/test-projects/fastapi-app/ai-context/graph/module-graph.json +0 -78
- package/test-projects/fastapi-app/ai-context/graph/symbol-graph.json +0 -1724
- package/test-projects/fastapi-app/ai-context/graph/symbol-references.json +0 -51
- package/test-projects/fastapi-app/ai-context/index-state.json +0 -217
- package/test-projects/fastapi-app/ai-context/index.db +0 -0
- package/test-projects/fastapi-app/ai-context/modules.json +0 -16
- package/test-projects/fastapi-app/ai-context/project.json +0 -9
- package/test-projects/fastapi-app/ai-context/repo_map.json +0 -298
- package/test-projects/fastapi-app/ai-context/repo_map.md +0 -74
- package/test-projects/fastapi-app/ai-context/schema.json +0 -5
- package/test-projects/fastapi-app/ai-context/summary.md +0 -12
- package/test-projects/fastapi-app/ai-context/symbols.json +0 -1
- package/test-projects/fastapi-app/ai-context/tech_stack.md +0 -32
- package/test-projects/fastapi-app/ai-context/tools.json +0 -10
- package/test-projects/flask-app/.ai-dev/index.db +0 -0
- package/test-projects/flask-app/ai-context/ai_context.md +0 -94
- package/test-projects/flask-app/ai-context/ai_rules.md +0 -47
- package/test-projects/flask-app/ai-context/architecture.md +0 -49
- package/test-projects/flask-app/ai-context/cache.json +0 -157
- package/test-projects/flask-app/ai-context/context/features/app.json +0 -25
- package/test-projects/flask-app/ai-context/context/flows/routes.json +0 -14
- package/test-projects/flask-app/ai-context/conventions.md +0 -51
- package/test-projects/flask-app/ai-context/dependencies.json +0 -298
- package/test-projects/flask-app/ai-context/entrypoints.md +0 -4
- package/test-projects/flask-app/ai-context/files.json +0 -194
- package/test-projects/flask-app/ai-context/graph/knowledge-graph.json +0 -60
- package/test-projects/flask-app/ai-context/graph/module-graph.json +0 -95
- package/test-projects/flask-app/ai-context/graph/symbol-graph.json +0 -1448
- package/test-projects/flask-app/ai-context/graph/symbol-references.json +0 -45
- package/test-projects/flask-app/ai-context/index-state.json +0 -273
- package/test-projects/flask-app/ai-context/index.db +0 -0
- package/test-projects/flask-app/ai-context/modules.json +0 -21
- package/test-projects/flask-app/ai-context/project.json +0 -13
- package/test-projects/flask-app/ai-context/repo_map.json +0 -400
- package/test-projects/flask-app/ai-context/repo_map.md +0 -98
- package/test-projects/flask-app/ai-context/schema.json +0 -5
- package/test-projects/flask-app/ai-context/summary.md +0 -13
- package/test-projects/flask-app/ai-context/symbols.json +0 -1
- package/test-projects/flask-app/ai-context/tech_stack.md +0 -32
- package/test-projects/flask-app/ai-context/tools.json +0 -10
- package/test-projects/laravel-app/.ai-dev/index.db +0 -0
- package/test-projects/laravel-app/ai-context/ai_context.md +0 -97
- package/test-projects/laravel-app/ai-context/ai_rules.md +0 -47
- package/test-projects/laravel-app/ai-context/architecture.md +0 -60
- package/test-projects/laravel-app/ai-context/cache.json +0 -161
- package/test-projects/laravel-app/ai-context/context/features/app.json +0 -21
- package/test-projects/laravel-app/ai-context/context/flows/.json +0 -9
- package/test-projects/laravel-app/ai-context/context/flows/category.json +0 -12
- package/test-projects/laravel-app/ai-context/context/flows/comment.json +0 -12
- package/test-projects/laravel-app/ai-context/context/flows/post.json +0 -12
- package/test-projects/laravel-app/ai-context/context/flows/unnamed.json +0 -9
- package/test-projects/laravel-app/ai-context/conventions.md +0 -51
- package/test-projects/laravel-app/ai-context/dependencies.json +0 -6
- package/test-projects/laravel-app/ai-context/entrypoints.md +0 -4
- package/test-projects/laravel-app/ai-context/files.json +0 -199
- package/test-projects/laravel-app/ai-context/graph/knowledge-graph.json +0 -98
- package/test-projects/laravel-app/ai-context/graph/module-graph.json +0 -30
- package/test-projects/laravel-app/ai-context/graph/symbol-graph.json +0 -5
- package/test-projects/laravel-app/ai-context/graph/symbol-references.json +0 -1
- package/test-projects/laravel-app/ai-context/index-state.json +0 -280
- package/test-projects/laravel-app/ai-context/index.db +0 -0
- package/test-projects/laravel-app/ai-context/modules.json +0 -29
- package/test-projects/laravel-app/ai-context/project.json +0 -17
- package/test-projects/laravel-app/ai-context/repo_map.json +0 -419
- package/test-projects/laravel-app/ai-context/repo_map.md +0 -106
- package/test-projects/laravel-app/ai-context/schema.json +0 -5
- package/test-projects/laravel-app/ai-context/summary.md +0 -15
- package/test-projects/laravel-app/ai-context/symbols.json +0 -1
- package/test-projects/laravel-app/ai-context/tech_stack.md +0 -34
- package/test-projects/laravel-app/ai-context/tools.json +0 -10
- package/test-projects/nestjs-backend/.ai-dev/index.db +0 -0
- package/test-projects/nestjs-backend/ai-context/ai_context.md +0 -111
- package/test-projects/nestjs-backend/ai-context/ai_rules.md +0 -52
- package/test-projects/nestjs-backend/ai-context/architecture.md +0 -49
- package/test-projects/nestjs-backend/ai-context/cache.json +0 -169
- package/test-projects/nestjs-backend/ai-context/context/features/src.json +0 -23
- package/test-projects/nestjs-backend/ai-context/context/flows/auth.controller.json +0 -14
- package/test-projects/nestjs-backend/ai-context/context/flows/auth.json +0 -10
- package/test-projects/nestjs-backend/ai-context/context/flows/users..json +0 -10
- package/test-projects/nestjs-backend/ai-context/context/flows/users.controller.json +0 -14
- package/test-projects/nestjs-backend/ai-context/context/flows/users.json +0 -10
- package/test-projects/nestjs-backend/ai-context/conventions.md +0 -52
- package/test-projects/nestjs-backend/ai-context/dependencies.json +0 -152
- package/test-projects/nestjs-backend/ai-context/entrypoints.md +0 -18
- package/test-projects/nestjs-backend/ai-context/files.json +0 -209
- package/test-projects/nestjs-backend/ai-context/graph/knowledge-graph.json +0 -132
- package/test-projects/nestjs-backend/ai-context/graph/module-graph.json +0 -29
- package/test-projects/nestjs-backend/ai-context/graph/symbol-graph.json +0 -304
- package/test-projects/nestjs-backend/ai-context/graph/symbol-references.json +0 -5
- package/test-projects/nestjs-backend/ai-context/index-state.json +0 -294
- package/test-projects/nestjs-backend/ai-context/index.db +0 -0
- package/test-projects/nestjs-backend/ai-context/modules.json +0 -19
- package/test-projects/nestjs-backend/ai-context/project.json +0 -18
- package/test-projects/nestjs-backend/ai-context/repo_map.json +0 -427
- package/test-projects/nestjs-backend/ai-context/repo_map.md +0 -104
- package/test-projects/nestjs-backend/ai-context/schema.json +0 -5
- package/test-projects/nestjs-backend/ai-context/summary.md +0 -13
- package/test-projects/nestjs-backend/ai-context/symbols.json +0 -1
- package/test-projects/nestjs-backend/ai-context/tech_stack.md +0 -38
- package/test-projects/nestjs-backend/ai-context/tools.json +0 -10
- package/test-projects/python-cli/.ai-dev/index.db +0 -0
- package/test-projects/python-cli/ai-context/ai_context.md +0 -95
- package/test-projects/python-cli/ai-context/ai_rules.md +0 -47
- package/test-projects/python-cli/ai-context/architecture.md +0 -55
- package/test-projects/python-cli/ai-context/cache.json +0 -149
- package/test-projects/python-cli/ai-context/context/features/cli.json +0 -16
- package/test-projects/python-cli/ai-context/context/flows/list_.json +0 -9
- package/test-projects/python-cli/ai-context/context/flows/remove_.json +0 -9
- package/test-projects/python-cli/ai-context/conventions.md +0 -51
- package/test-projects/python-cli/ai-context/dependencies.json +0 -66
- package/test-projects/python-cli/ai-context/entrypoints.md +0 -4
- package/test-projects/python-cli/ai-context/files.json +0 -184
- package/test-projects/python-cli/ai-context/graph/knowledge-graph.json +0 -83
- package/test-projects/python-cli/ai-context/graph/module-graph.json +0 -31
- package/test-projects/python-cli/ai-context/graph/symbol-graph.json +0 -358
- package/test-projects/python-cli/ai-context/graph/symbol-references.json +0 -11
- package/test-projects/python-cli/ai-context/index-state.json +0 -259
- package/test-projects/python-cli/ai-context/index.db +0 -0
- package/test-projects/python-cli/ai-context/modules.json +0 -21
- package/test-projects/python-cli/ai-context/project.json +0 -15
- package/test-projects/python-cli/ai-context/repo_map.json +0 -367
- package/test-projects/python-cli/ai-context/repo_map.md +0 -93
- package/test-projects/python-cli/ai-context/schema.json +0 -5
- package/test-projects/python-cli/ai-context/summary.md +0 -14
- package/test-projects/python-cli/ai-context/symbols.json +0 -1
- package/test-projects/python-cli/ai-context/tech_stack.md +0 -32
- package/test-projects/python-cli/ai-context/tools.json +0 -10
- package/test-projects/rails-app/.ai-dev/index.db +0 -0
- package/test-projects/rails-app/ai-context/ai_context.md +0 -94
- package/test-projects/rails-app/ai-context/ai_rules.md +0 -47
- package/test-projects/rails-app/ai-context/architecture.md +0 -49
- package/test-projects/rails-app/ai-context/cache.json +0 -193
- package/test-projects/rails-app/ai-context/context/features/app.json +0 -24
- package/test-projects/rails-app/ai-context/context/features/config.json +0 -13
- package/test-projects/rails-app/ai-context/context/flows/application.json +0 -9
- package/test-projects/rails-app/ai-context/context/flows/application_.json +0 -9
- package/test-projects/rails-app/ai-context/context/flows/comments.json +0 -11
- package/test-projects/rails-app/ai-context/context/flows/comments_.json +0 -11
- package/test-projects/rails-app/ai-context/context/flows/posts.json +0 -11
- package/test-projects/rails-app/ai-context/context/flows/posts_.json +0 -11
- package/test-projects/rails-app/ai-context/context/flows/routes.json +0 -9
- package/test-projects/rails-app/ai-context/context/flows/users.json +0 -11
- package/test-projects/rails-app/ai-context/context/flows/users_.json +0 -11
- package/test-projects/rails-app/ai-context/conventions.md +0 -51
- package/test-projects/rails-app/ai-context/dependencies.json +0 -6
- package/test-projects/rails-app/ai-context/entrypoints.md +0 -4
- package/test-projects/rails-app/ai-context/files.json +0 -239
- package/test-projects/rails-app/ai-context/graph/knowledge-graph.json +0 -130
- package/test-projects/rails-app/ai-context/graph/module-graph.json +0 -27
- package/test-projects/rails-app/ai-context/graph/symbol-graph.json +0 -5
- package/test-projects/rails-app/ai-context/graph/symbol-references.json +0 -1
- package/test-projects/rails-app/ai-context/index-state.json +0 -336
- package/test-projects/rails-app/ai-context/index.db +0 -0
- package/test-projects/rails-app/ai-context/modules.json +0 -26
- package/test-projects/rails-app/ai-context/project.json +0 -22
- package/test-projects/rails-app/ai-context/repo_map.json +0 -486
- package/test-projects/rails-app/ai-context/repo_map.md +0 -117
- package/test-projects/rails-app/ai-context/schema.json +0 -5
- package/test-projects/rails-app/ai-context/summary.md +0 -13
- package/test-projects/rails-app/ai-context/symbols.json +0 -1
- package/test-projects/rails-app/ai-context/tech_stack.md +0 -32
- package/test-projects/rails-app/ai-context/tools.json +0 -10
- package/test-projects/react-app/.ai-dev/index.db +0 -0
- package/test-projects/react-app/ai-context/ai_context.md +0 -96
- package/test-projects/react-app/ai-context/ai_rules.md +0 -49
- package/test-projects/react-app/ai-context/architecture.md +0 -39
- package/test-projects/react-app/ai-context/cache.json +0 -153
- package/test-projects/react-app/ai-context/context/features/src.json +0 -18
- package/test-projects/react-app/ai-context/context/flows/UsersPage.json +0 -14
- package/test-projects/react-app/ai-context/context/flows/dashboard.json +0 -9
- package/test-projects/react-app/ai-context/context/flows/login.json +0 -9
- package/test-projects/react-app/ai-context/context/flows/users.json +0 -9
- package/test-projects/react-app/ai-context/conventions.md +0 -52
- package/test-projects/react-app/ai-context/dependencies.json +0 -128
- package/test-projects/react-app/ai-context/entrypoints.md +0 -4
- package/test-projects/react-app/ai-context/files.json +0 -189
- package/test-projects/react-app/ai-context/graph/knowledge-graph.json +0 -112
- package/test-projects/react-app/ai-context/graph/module-graph.json +0 -31
- package/test-projects/react-app/ai-context/graph/symbol-graph.json +0 -868
- package/test-projects/react-app/ai-context/graph/symbol-references.json +0 -31
- package/test-projects/react-app/ai-context/index-state.json +0 -266
- package/test-projects/react-app/ai-context/index.db +0 -0
- package/test-projects/react-app/ai-context/modules.json +0 -17
- package/test-projects/react-app/ai-context/project.json +0 -16
- package/test-projects/react-app/ai-context/repo_map.json +0 -391
- package/test-projects/react-app/ai-context/repo_map.md +0 -94
- package/test-projects/react-app/ai-context/schema.json +0 -5
- package/test-projects/react-app/ai-context/summary.md +0 -13
- package/test-projects/react-app/ai-context/symbols.json +0 -1
- package/test-projects/react-app/ai-context/tech_stack.md +0 -39
- package/test-projects/react-app/ai-context/tools.json +0 -10
- package/test-projects/salesforce-cli/.ai-dev/index.db +0 -0
- package/test-projects/salesforce-cli/ai-context/ai_context.md +0 -89
- package/test-projects/salesforce-cli/ai-context/ai_rules.md +0 -47
- package/test-projects/salesforce-cli/ai-context/architecture.md +0 -39
- package/test-projects/salesforce-cli/ai-context/cache.json +0 -125
- package/test-projects/salesforce-cli/ai-context/context/features/force-app.json +0 -14
- package/test-projects/salesforce-cli/ai-context/context/flows/account.json +0 -9
- package/test-projects/salesforce-cli/ai-context/context/flows/opportunity.json +0 -9
- package/test-projects/salesforce-cli/ai-context/conventions.md +0 -51
- package/test-projects/salesforce-cli/ai-context/dependencies.json +0 -6
- package/test-projects/salesforce-cli/ai-context/entrypoints.md +0 -4
- package/test-projects/salesforce-cli/ai-context/files.json +0 -154
- package/test-projects/salesforce-cli/ai-context/graph/knowledge-graph.json +0 -64
- package/test-projects/salesforce-cli/ai-context/graph/module-graph.json +0 -13
- package/test-projects/salesforce-cli/ai-context/graph/symbol-graph.json +0 -148
- package/test-projects/salesforce-cli/ai-context/graph/symbol-references.json +0 -1
- package/test-projects/salesforce-cli/ai-context/index-state.json +0 -217
- package/test-projects/salesforce-cli/ai-context/index.db +0 -0
- package/test-projects/salesforce-cli/ai-context/modules.json +0 -12
- package/test-projects/salesforce-cli/ai-context/project.json +0 -14
- package/test-projects/salesforce-cli/ai-context/repo_map.json +0 -328
- package/test-projects/salesforce-cli/ai-context/repo_map.md +0 -80
- package/test-projects/salesforce-cli/ai-context/schema.json +0 -5
- package/test-projects/salesforce-cli/ai-context/summary.md +0 -13
- package/test-projects/salesforce-cli/ai-context/symbols.json +0 -1
- package/test-projects/salesforce-cli/ai-context/tech_stack.md +0 -31
- package/test-projects/salesforce-cli/ai-context/tools.json +0 -10
- package/test-projects/spring-boot-app/.ai-dev/index.db +0 -0
- package/test-projects/spring-boot-app/ai-context/ai_context.md +0 -91
- package/test-projects/spring-boot-app/ai-context/ai_rules.md +0 -48
- package/test-projects/spring-boot-app/ai-context/architecture.md +0 -39
- package/test-projects/spring-boot-app/ai-context/cache.json +0 -173
- package/test-projects/spring-boot-app/ai-context/context/features/src.json +0 -26
- package/test-projects/spring-boot-app/ai-context/context/flows/PostController.json +0 -19
- package/test-projects/spring-boot-app/ai-context/context/flows/UserController.json +0 -19
- package/test-projects/spring-boot-app/ai-context/context/flows/comment.json +0 -11
- package/test-projects/spring-boot-app/ai-context/context/flows/post.json +0 -14
- package/test-projects/spring-boot-app/ai-context/context/flows/user.json +0 -14
- package/test-projects/spring-boot-app/ai-context/conventions.md +0 -52
- package/test-projects/spring-boot-app/ai-context/dependencies.json +0 -326
- package/test-projects/spring-boot-app/ai-context/entrypoints.md +0 -4
- package/test-projects/spring-boot-app/ai-context/files.json +0 -214
- package/test-projects/spring-boot-app/ai-context/graph/knowledge-graph.json +0 -231
- package/test-projects/spring-boot-app/ai-context/graph/module-graph.json +0 -22
- package/test-projects/spring-boot-app/ai-context/graph/symbol-graph.json +0 -794
- package/test-projects/spring-boot-app/ai-context/graph/symbol-references.json +0 -70
- package/test-projects/spring-boot-app/ai-context/index-state.json +0 -301
- package/test-projects/spring-boot-app/ai-context/index.db +0 -0
- package/test-projects/spring-boot-app/ai-context/modules.json +0 -21
- package/test-projects/spring-boot-app/ai-context/project.json +0 -17
- package/test-projects/spring-boot-app/ai-context/repo_map.json +0 -461
- package/test-projects/spring-boot-app/ai-context/repo_map.md +0 -109
- package/test-projects/spring-boot-app/ai-context/schema.json +0 -5
- package/test-projects/spring-boot-app/ai-context/summary.md +0 -12
- package/test-projects/spring-boot-app/ai-context/symbols.json +0 -1
- package/test-projects/spring-boot-app/ai-context/tech_stack.md +0 -32
- package/test-projects/spring-boot-app/ai-context/tools.json +0 -10
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export interface ParsedSymbol {
|
|
4
|
+
name: string;
|
|
5
|
+
type: "class" | "interface" | "function" | "method" | "property" | "enum" | "type" | "const" | "variable";
|
|
6
|
+
line: number;
|
|
7
|
+
character: number;
|
|
8
|
+
isExported: boolean;
|
|
9
|
+
modifiers?: string[];
|
|
10
|
+
heritage?: {
|
|
11
|
+
extends?: string[];
|
|
12
|
+
implements?: string[];
|
|
13
|
+
};
|
|
14
|
+
members?: ParsedSymbol[];
|
|
15
|
+
parameters?: {
|
|
16
|
+
name: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
optional?: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
returnType?: string;
|
|
21
|
+
jsDoc?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ParsedFile {
|
|
25
|
+
filePath: string;
|
|
26
|
+
symbols: ParsedSymbol[];
|
|
27
|
+
imports: {
|
|
28
|
+
name: string;
|
|
29
|
+
module: string;
|
|
30
|
+
isDefault?: boolean;
|
|
31
|
+
isNamespace?: boolean;
|
|
32
|
+
}[];
|
|
33
|
+
exports: string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class TypeScriptParser {
|
|
37
|
+
private program: ts.Program | null = null;
|
|
38
|
+
|
|
39
|
+
parseFile(filePath: string, sourceText: string): ParsedFile {
|
|
40
|
+
const sourceFile = ts.createSourceFile(
|
|
41
|
+
filePath,
|
|
42
|
+
sourceText,
|
|
43
|
+
ts.ScriptTarget.Latest,
|
|
44
|
+
true,
|
|
45
|
+
ts.ScriptKind.TS
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const symbols: ParsedSymbol[] = [];
|
|
49
|
+
const imports: ParsedFile["imports"] = [];
|
|
50
|
+
const exports: string[] = [];
|
|
51
|
+
|
|
52
|
+
this.visitNode(sourceFile, sourceFile, symbols, imports, exports);
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
filePath,
|
|
56
|
+
symbols,
|
|
57
|
+
imports,
|
|
58
|
+
exports,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private visitNode(
|
|
63
|
+
node: ts.Node,
|
|
64
|
+
sourceFile: ts.SourceFile,
|
|
65
|
+
symbols: ParsedSymbol[],
|
|
66
|
+
imports: ParsedFile["imports"],
|
|
67
|
+
exports: string[]
|
|
68
|
+
): void {
|
|
69
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
70
|
+
|
|
71
|
+
switch (node.kind) {
|
|
72
|
+
case ts.SyntaxKind.ClassDeclaration:
|
|
73
|
+
this.handleClassDeclaration(node as ts.ClassDeclaration, line, character, sourceFile, symbols);
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case ts.SyntaxKind.InterfaceDeclaration:
|
|
77
|
+
this.handleInterfaceDeclaration(node as ts.InterfaceDeclaration, line, character, sourceFile, symbols);
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case ts.SyntaxKind.FunctionDeclaration:
|
|
81
|
+
this.handleFunctionDeclaration(node as ts.FunctionDeclaration, line, character, sourceFile, symbols, exports);
|
|
82
|
+
break;
|
|
83
|
+
|
|
84
|
+
case ts.SyntaxKind.EnumDeclaration:
|
|
85
|
+
this.handleEnumDeclaration(node as ts.EnumDeclaration, line, character, sourceFile, symbols);
|
|
86
|
+
break;
|
|
87
|
+
|
|
88
|
+
case ts.SyntaxKind.TypeAliasDeclaration:
|
|
89
|
+
this.handleTypeAliasDeclaration(node as ts.TypeAliasDeclaration, line, character, sourceFile, symbols);
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case ts.SyntaxKind.VariableStatement:
|
|
93
|
+
this.handleVariableStatement(node as ts.VariableStatement, line, character, sourceFile, symbols, exports);
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case ts.SyntaxKind.ImportDeclaration:
|
|
97
|
+
this.handleImportDeclaration(node as ts.ImportDeclaration, sourceFile, imports);
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case ts.SyntaxKind.ExportAssignment:
|
|
101
|
+
case ts.SyntaxKind.ExportDeclaration:
|
|
102
|
+
this.handleExport(node, sourceFile, exports);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
ts.forEachChild(node, (child) =>
|
|
107
|
+
this.visitNode(child, sourceFile, symbols, imports, exports)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private handleClassDeclaration(
|
|
112
|
+
node: ts.ClassDeclaration,
|
|
113
|
+
line: number,
|
|
114
|
+
character: number,
|
|
115
|
+
sourceFile: ts.SourceFile,
|
|
116
|
+
symbols: ParsedSymbol[]
|
|
117
|
+
): void {
|
|
118
|
+
if (!node.name) return;
|
|
119
|
+
|
|
120
|
+
const symbol: ParsedSymbol = {
|
|
121
|
+
name: node.name.text,
|
|
122
|
+
type: "class",
|
|
123
|
+
line: line + 1,
|
|
124
|
+
character: character + 1,
|
|
125
|
+
isExported: this.hasExportModifier(node),
|
|
126
|
+
modifiers: this.getModifiers(node),
|
|
127
|
+
heritage: this.getHeritage(node),
|
|
128
|
+
members: [],
|
|
129
|
+
jsDoc: this.getJsDoc(node, sourceFile),
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
node.members.forEach((member) => {
|
|
133
|
+
const memberSymbol = this.extractClassMember(member, sourceFile);
|
|
134
|
+
if (memberSymbol) {
|
|
135
|
+
symbol.members!.push(memberSymbol);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
symbols.push(symbol);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private handleInterfaceDeclaration(
|
|
143
|
+
node: ts.InterfaceDeclaration,
|
|
144
|
+
line: number,
|
|
145
|
+
character: number,
|
|
146
|
+
sourceFile: ts.SourceFile,
|
|
147
|
+
symbols: ParsedSymbol[]
|
|
148
|
+
): void {
|
|
149
|
+
const symbol: ParsedSymbol = {
|
|
150
|
+
name: node.name.text,
|
|
151
|
+
type: "interface",
|
|
152
|
+
line: line + 1,
|
|
153
|
+
character: character + 1,
|
|
154
|
+
isExported: this.hasExportModifier(node),
|
|
155
|
+
modifiers: this.getModifiers(node),
|
|
156
|
+
heritage: { extends: node.heritageClauses?.flatMap((h) =>
|
|
157
|
+
h.types.map((t) => t.getText(sourceFile))
|
|
158
|
+
) },
|
|
159
|
+
members: [],
|
|
160
|
+
jsDoc: this.getJsDoc(node, sourceFile),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
node.members.forEach((member) => {
|
|
164
|
+
const memberSymbol = this.extractInterfaceMember(member, sourceFile);
|
|
165
|
+
if (memberSymbol) {
|
|
166
|
+
symbol.members!.push(memberSymbol);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
symbols.push(symbol);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private handleFunctionDeclaration(
|
|
174
|
+
node: ts.FunctionDeclaration,
|
|
175
|
+
line: number,
|
|
176
|
+
character: number,
|
|
177
|
+
sourceFile: ts.SourceFile,
|
|
178
|
+
symbols: ParsedSymbol[],
|
|
179
|
+
exports: string[]
|
|
180
|
+
): void {
|
|
181
|
+
if (!node.name) return;
|
|
182
|
+
|
|
183
|
+
const symbol: ParsedSymbol = {
|
|
184
|
+
name: node.name.text,
|
|
185
|
+
type: "function",
|
|
186
|
+
line: line + 1,
|
|
187
|
+
character: character + 1,
|
|
188
|
+
isExported: this.hasExportModifier(node),
|
|
189
|
+
modifiers: this.getModifiers(node),
|
|
190
|
+
parameters: this.getParameters(node.parameters, sourceFile),
|
|
191
|
+
returnType: node.type?.getText(sourceFile),
|
|
192
|
+
jsDoc: this.getJsDoc(node, sourceFile),
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
symbols.push(symbol);
|
|
196
|
+
|
|
197
|
+
if (symbol.isExported) {
|
|
198
|
+
exports.push(symbol.name);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private handleEnumDeclaration(
|
|
203
|
+
node: ts.EnumDeclaration,
|
|
204
|
+
line: number,
|
|
205
|
+
character: number,
|
|
206
|
+
sourceFile: ts.SourceFile,
|
|
207
|
+
symbols: ParsedSymbol[]
|
|
208
|
+
): void {
|
|
209
|
+
const symbol: ParsedSymbol = {
|
|
210
|
+
name: node.name.text,
|
|
211
|
+
type: "enum",
|
|
212
|
+
line: line + 1,
|
|
213
|
+
character: character + 1,
|
|
214
|
+
isExported: this.hasExportModifier(node),
|
|
215
|
+
modifiers: this.getModifiers(node),
|
|
216
|
+
jsDoc: this.getJsDoc(node, sourceFile),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
symbols.push(symbol);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private handleTypeAliasDeclaration(
|
|
223
|
+
node: ts.TypeAliasDeclaration,
|
|
224
|
+
line: number,
|
|
225
|
+
character: number,
|
|
226
|
+
sourceFile: ts.SourceFile,
|
|
227
|
+
symbols: ParsedSymbol[]
|
|
228
|
+
): void {
|
|
229
|
+
const symbol: ParsedSymbol = {
|
|
230
|
+
name: node.name.text,
|
|
231
|
+
type: "type",
|
|
232
|
+
line: line + 1,
|
|
233
|
+
character: character + 1,
|
|
234
|
+
isExported: this.hasExportModifier(node),
|
|
235
|
+
modifiers: this.getModifiers(node),
|
|
236
|
+
jsDoc: this.getJsDoc(node, sourceFile),
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
symbols.push(symbol);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private handleVariableStatement(
|
|
243
|
+
node: ts.VariableStatement,
|
|
244
|
+
line: number,
|
|
245
|
+
character: number,
|
|
246
|
+
sourceFile: ts.SourceFile,
|
|
247
|
+
symbols: ParsedSymbol[],
|
|
248
|
+
exports: string[]
|
|
249
|
+
): void {
|
|
250
|
+
const isExported = this.hasExportModifier(node);
|
|
251
|
+
|
|
252
|
+
node.declarationList.declarations.forEach((decl) => {
|
|
253
|
+
if (ts.isIdentifier(decl.name)) {
|
|
254
|
+
const symbol: ParsedSymbol = {
|
|
255
|
+
name: decl.name.text,
|
|
256
|
+
type: this.isConst(node) ? "const" : "variable",
|
|
257
|
+
line: line + 1,
|
|
258
|
+
character: character + 1,
|
|
259
|
+
isExported,
|
|
260
|
+
modifiers: this.getModifiers(node),
|
|
261
|
+
jsDoc: this.getJsDoc(node, sourceFile),
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
symbols.push(symbol);
|
|
265
|
+
|
|
266
|
+
if (isExported) {
|
|
267
|
+
exports.push(symbol.name);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private handleImportDeclaration(
|
|
274
|
+
node: ts.ImportDeclaration,
|
|
275
|
+
sourceFile: ts.SourceFile,
|
|
276
|
+
imports: ParsedFile["imports"]
|
|
277
|
+
): void {
|
|
278
|
+
const moduleSpecifier = (node.moduleSpecifier as ts.StringLiteral).text;
|
|
279
|
+
|
|
280
|
+
if (node.importClause) {
|
|
281
|
+
if (node.importClause.name) {
|
|
282
|
+
imports.push({
|
|
283
|
+
name: node.importClause.name.text,
|
|
284
|
+
module: moduleSpecifier,
|
|
285
|
+
isDefault: true,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (node.importClause.namedBindings) {
|
|
290
|
+
if (ts.isNamedImports(node.importClause.namedBindings)) {
|
|
291
|
+
node.importClause.namedBindings.elements.forEach((element) => {
|
|
292
|
+
imports.push({
|
|
293
|
+
name: element.name.text,
|
|
294
|
+
module: moduleSpecifier,
|
|
295
|
+
isDefault: false,
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
} else if (ts.isNamespaceImport(node.importClause.namedBindings)) {
|
|
299
|
+
imports.push({
|
|
300
|
+
name: node.importClause.namedBindings.name.text,
|
|
301
|
+
module: moduleSpecifier,
|
|
302
|
+
isNamespace: true,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private handleExport(
|
|
310
|
+
node: ts.Node,
|
|
311
|
+
sourceFile: ts.SourceFile,
|
|
312
|
+
exports: string[]
|
|
313
|
+
): void {
|
|
314
|
+
if (ts.isExportAssignment(node)) {
|
|
315
|
+
if (ts.isIdentifier(node.expression)) {
|
|
316
|
+
exports.push(node.expression.text);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private extractClassMember(
|
|
322
|
+
member: ts.ClassElement,
|
|
323
|
+
sourceFile: ts.SourceFile
|
|
324
|
+
): ParsedSymbol | null {
|
|
325
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(member.getStart());
|
|
326
|
+
|
|
327
|
+
if (ts.isMethodDeclaration(member) && member.name) {
|
|
328
|
+
return {
|
|
329
|
+
name: member.name.getText(sourceFile),
|
|
330
|
+
type: "method",
|
|
331
|
+
line: line + 1,
|
|
332
|
+
character: character + 1,
|
|
333
|
+
isExported: false,
|
|
334
|
+
modifiers: this.getModifiers(member),
|
|
335
|
+
parameters: this.getParameters(member.parameters, sourceFile),
|
|
336
|
+
returnType: member.type?.getText(sourceFile),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (ts.isPropertyDeclaration(member) && member.name) {
|
|
341
|
+
return {
|
|
342
|
+
name: member.name.getText(sourceFile),
|
|
343
|
+
type: "property",
|
|
344
|
+
line: line + 1,
|
|
345
|
+
character: character + 1,
|
|
346
|
+
isExported: false,
|
|
347
|
+
modifiers: this.getModifiers(member),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private extractInterfaceMember(
|
|
355
|
+
member: ts.TypeElement,
|
|
356
|
+
sourceFile: ts.SourceFile
|
|
357
|
+
): ParsedSymbol | null {
|
|
358
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(member.getStart());
|
|
359
|
+
|
|
360
|
+
if (ts.isMethodSignature(member) && member.name) {
|
|
361
|
+
return {
|
|
362
|
+
name: member.name.getText(sourceFile),
|
|
363
|
+
type: "method",
|
|
364
|
+
line: line + 1,
|
|
365
|
+
character: character + 1,
|
|
366
|
+
isExported: false,
|
|
367
|
+
parameters: this.getParameters(member.parameters, sourceFile),
|
|
368
|
+
returnType: member.type?.getText(sourceFile),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (ts.isPropertySignature(member) && member.name) {
|
|
373
|
+
return {
|
|
374
|
+
name: member.name.getText(sourceFile),
|
|
375
|
+
type: "property",
|
|
376
|
+
line: line + 1,
|
|
377
|
+
character: character + 1,
|
|
378
|
+
isExported: false,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
private getModifiers(node: ts.Node): string[] {
|
|
386
|
+
const modifiers: string[] = [];
|
|
387
|
+
if (ts.canHaveModifiers(node)) {
|
|
388
|
+
const nodeModifiers = ts.getModifiers(node);
|
|
389
|
+
nodeModifiers?.forEach((mod) => {
|
|
390
|
+
modifiers.push(ts.SyntaxKind[mod.kind].toLowerCase().replace("keyword", ""));
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return modifiers;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private hasExportModifier(node: ts.Node): boolean {
|
|
397
|
+
if (ts.canHaveModifiers(node)) {
|
|
398
|
+
const modifiers = ts.getModifiers(node);
|
|
399
|
+
return modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
400
|
+
}
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
private isConst(node: ts.VariableStatement): boolean {
|
|
405
|
+
return (node.declarationList.flags & ts.NodeFlags.Const) !== 0;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
private getHeritage(node: ts.ClassDeclaration): { extends?: string[]; implements?: string[] } {
|
|
409
|
+
const heritage: { extends?: string[]; implements?: string[] } = {};
|
|
410
|
+
|
|
411
|
+
if (node.heritageClauses) {
|
|
412
|
+
node.heritageClauses.forEach((clause) => {
|
|
413
|
+
const types = clause.types.map((t) => t.getText());
|
|
414
|
+
if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
|
|
415
|
+
heritage.extends = types;
|
|
416
|
+
} else if (clause.token === ts.SyntaxKind.ImplementsKeyword) {
|
|
417
|
+
heritage.implements = types;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return heritage;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
private getParameters(
|
|
426
|
+
params: ts.NodeArray<ts.ParameterDeclaration>,
|
|
427
|
+
sourceFile: ts.SourceFile
|
|
428
|
+
): { name: string; type?: string; optional?: boolean }[] {
|
|
429
|
+
return params.map((param) => ({
|
|
430
|
+
name: param.name.getText(sourceFile),
|
|
431
|
+
type: param.type?.getText(sourceFile),
|
|
432
|
+
optional: !!param.questionToken,
|
|
433
|
+
}));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
private getJsDoc(node: ts.Node, sourceFile: ts.SourceFile): string | undefined {
|
|
437
|
+
const jsDoc = ts.getJSDocCommentsAndTags(node);
|
|
438
|
+
if (jsDoc && jsDoc.length > 0) {
|
|
439
|
+
return jsDoc[0].getText(sourceFile);
|
|
440
|
+
}
|
|
441
|
+
return undefined;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export const typescriptParser = new TypeScriptParser();
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { FileInfo } from "./repoScanner.js";
|
|
2
|
+
import { extractSymbols, type SymbolsAnalysis, type Symbol as CodeSymbol } from "../analyzers/symbols.js";
|
|
3
|
+
import { parserRegistry, createSymbolFromParsed } from "./parsers/index.js";
|
|
4
|
+
import { architectureDetector, type ArchitectureAnalysis } from "./analysis/architectureDetector.js";
|
|
5
|
+
import { dependencyAnalyzer, type DependencyGraph } from "./analysis/dependencyAnalyzer.js";
|
|
6
|
+
import { aiContextGenerator } from "./generation/aiContextGenerator.js";
|
|
7
|
+
import { flowGenerator } from "./generation/flowGenerator.js";
|
|
8
|
+
import { architectureGenerator } from "./generation/architectureGenerator.js";
|
|
9
|
+
import { readFile } from "../utils/fileUtils.js";
|
|
10
|
+
|
|
11
|
+
export interface AnalysisResult {
|
|
12
|
+
symbols: SymbolsAnalysis;
|
|
13
|
+
architecture: ArchitectureAnalysis;
|
|
14
|
+
dependencyGraph: DependencyGraph;
|
|
15
|
+
aiContext: string;
|
|
16
|
+
architectureDoc: string;
|
|
17
|
+
flows: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
files: string[];
|
|
21
|
+
layers: string[];
|
|
22
|
+
}>;
|
|
23
|
+
metrics: {
|
|
24
|
+
duration: number;
|
|
25
|
+
filesProcessed: number;
|
|
26
|
+
symbolsExtracted: number;
|
|
27
|
+
cacheHitRate: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface CacheEntry {
|
|
32
|
+
symbols: CodeSymbol[];
|
|
33
|
+
mtime: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class AnalysisPipeline {
|
|
37
|
+
private cache: Map<string, CacheEntry> = new Map();
|
|
38
|
+
private stats = { cacheHits: 0, cacheMisses: 0 };
|
|
39
|
+
|
|
40
|
+
async run(files: FileInfo[], projectName: string): Promise<AnalysisResult> {
|
|
41
|
+
const startTime = Date.now();
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const symbols = this.extractSymbolsWithAST(files);
|
|
45
|
+
|
|
46
|
+
const cacheHitRate = this.stats.cacheHits + this.stats.cacheMisses > 0
|
|
47
|
+
? Math.round((this.stats.cacheHits / (this.stats.cacheHits + this.stats.cacheMisses)) * 100)
|
|
48
|
+
: 0;
|
|
49
|
+
|
|
50
|
+
const dependencyGraph = this.buildDependencyGraph(symbols);
|
|
51
|
+
|
|
52
|
+
const architecture = architectureDetector.detect(
|
|
53
|
+
symbols.symbols,
|
|
54
|
+
{ edges: dependencyGraph.edges }
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const flows = flowGenerator.generateFlows(
|
|
58
|
+
architecture.entryPoints,
|
|
59
|
+
symbols.symbols,
|
|
60
|
+
{ edges: dependencyGraph.edges },
|
|
61
|
+
{ edges: [] },
|
|
62
|
+
{ edges: [] }
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const aiContext = aiContextGenerator.generate({
|
|
66
|
+
architecture,
|
|
67
|
+
symbols: symbols.symbols,
|
|
68
|
+
dependencies: {
|
|
69
|
+
totalDependencies: dependencyGraph.edges.length,
|
|
70
|
+
dependencies: dependencyGraph.edges.map((e) => ({
|
|
71
|
+
source: e.from,
|
|
72
|
+
target: e.to,
|
|
73
|
+
type: e.type,
|
|
74
|
+
})),
|
|
75
|
+
},
|
|
76
|
+
projectName,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const architectureDoc = architectureGenerator.generate(architecture, dependencyGraph);
|
|
80
|
+
|
|
81
|
+
const duration = Date.now() - startTime;
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
symbols,
|
|
85
|
+
architecture,
|
|
86
|
+
dependencyGraph,
|
|
87
|
+
aiContext,
|
|
88
|
+
architectureDoc,
|
|
89
|
+
flows: flows.map((f) => ({
|
|
90
|
+
name: f.name,
|
|
91
|
+
type: f.type,
|
|
92
|
+
files: f.files.map((fi) => fi.path),
|
|
93
|
+
layers: f.layers,
|
|
94
|
+
})),
|
|
95
|
+
metrics: {
|
|
96
|
+
duration,
|
|
97
|
+
filesProcessed: files.length,
|
|
98
|
+
symbolsExtracted: symbols.symbols.length,
|
|
99
|
+
cacheHitRate,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error("Analysis pipeline failed:", error);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private extractSymbolsWithAST(files: FileInfo[]): SymbolsAnalysis {
|
|
109
|
+
const allSymbols: SymbolsAnalysis["symbols"] = [];
|
|
110
|
+
const byFile: Record<string, SymbolsAnalysis["symbols"]> = {};
|
|
111
|
+
|
|
112
|
+
const BATCH_SIZE = 50;
|
|
113
|
+
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
114
|
+
const batch = files.slice(i, i + BATCH_SIZE);
|
|
115
|
+
|
|
116
|
+
const batchResults = batch.map(file => {
|
|
117
|
+
const cached = this.getCachedSymbols(file);
|
|
118
|
+
if (cached) {
|
|
119
|
+
return { filePath: file.relativePath, symbols: cached };
|
|
120
|
+
}
|
|
121
|
+
return this.processFile(file);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
for (const result of batchResults) {
|
|
125
|
+
if (result && result.symbols.length > 0) {
|
|
126
|
+
allSymbols.push(...result.symbols);
|
|
127
|
+
byFile[result.filePath] = result.symbols;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const byId: Record<string, (typeof allSymbols)[0]> = {};
|
|
133
|
+
for (const sym of allSymbols) {
|
|
134
|
+
byId[sym.id] = sym;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const byType: Record<string, typeof allSymbols> = {};
|
|
138
|
+
for (const sym of allSymbols) {
|
|
139
|
+
if (!byType[sym.type]) byType[sym.type] = [];
|
|
140
|
+
byType[sym.type].push(sym);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
symbols: allSymbols,
|
|
145
|
+
byId,
|
|
146
|
+
byFile,
|
|
147
|
+
byType,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private getCachedSymbols(file: FileInfo): CodeSymbol[] | null {
|
|
152
|
+
const cached = this.cache.get(file.path);
|
|
153
|
+
if (cached) {
|
|
154
|
+
this.stats.cacheHits++;
|
|
155
|
+
return cached.symbols;
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private processFile(file: FileInfo): { filePath: string; symbols: CodeSymbol[] } | null {
|
|
161
|
+
this.stats.cacheMisses++;
|
|
162
|
+
const ext = "." + file.extension;
|
|
163
|
+
let symbols: CodeSymbol[] = [];
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
if (parserRegistry.hasParser(ext)) {
|
|
167
|
+
const content = readFile(file.path);
|
|
168
|
+
const parsed = parserRegistry.parse(file.relativePath, content, ext);
|
|
169
|
+
|
|
170
|
+
if (parsed) {
|
|
171
|
+
symbols = createSymbolFromParsed(parsed, file.relativePath);
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
const existing = extractSymbols([file]);
|
|
175
|
+
symbols = existing.symbols;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.cache.set(file.path, { symbols, mtime: Date.now() });
|
|
179
|
+
|
|
180
|
+
if (this.cache.size > 1000) {
|
|
181
|
+
const firstKey = this.cache.keys().next().value;
|
|
182
|
+
if (firstKey !== undefined) {
|
|
183
|
+
this.cache.delete(firstKey);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return { filePath: file.relativePath, symbols };
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.warn(`Failed to process ${file.path}:`, error);
|
|
190
|
+
const fallbackSymbols = this.fallbackToRegex(file);
|
|
191
|
+
return { filePath: file.relativePath, symbols: fallbackSymbols };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private fallbackToRegex(file: FileInfo): CodeSymbol[] {
|
|
196
|
+
const existing = extractSymbols([file]);
|
|
197
|
+
return existing.symbols;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private buildDependencyGraph(symbols: SymbolsAnalysis): DependencyGraph {
|
|
201
|
+
const files: Array<{ filePath: string; imports: Array<{ name: string; module: string; isDefault?: boolean }>; exports: string[] }> = [];
|
|
202
|
+
|
|
203
|
+
for (const [filePath, fileSymbols] of Object.entries(symbols.byFile)) {
|
|
204
|
+
const imports: Array<{ name: string; module: string; isDefault?: boolean }> = [];
|
|
205
|
+
const exports: string[] = [];
|
|
206
|
+
|
|
207
|
+
for (const sym of fileSymbols) {
|
|
208
|
+
if (sym.export) {
|
|
209
|
+
exports.push(sym.name);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
files.push({ filePath, imports, exports });
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return dependencyAnalyzer.buildDependencyGraph(files);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
clearCache(): void {
|
|
220
|
+
this.cache.clear();
|
|
221
|
+
this.stats = { cacheHits: 0, cacheMisses: 0 };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
getMetrics(): {
|
|
225
|
+
cacheSize: number;
|
|
226
|
+
cacheHits: number;
|
|
227
|
+
cacheMisses: number;
|
|
228
|
+
cacheHitRate: number;
|
|
229
|
+
} {
|
|
230
|
+
const total = this.stats.cacheHits + this.stats.cacheMisses;
|
|
231
|
+
const cacheHitRate = total > 0 ? Math.round((this.stats.cacheHits / total) * 100) : 0;
|
|
232
|
+
return {
|
|
233
|
+
cacheSize: this.cache.size,
|
|
234
|
+
cacheHits: this.stats.cacheHits,
|
|
235
|
+
cacheMisses: this.stats.cacheMisses,
|
|
236
|
+
cacheHitRate,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export const analysisPipeline = new AnalysisPipeline();
|
|
@@ -100,7 +100,7 @@ function getLayer(filePath: string): string {
|
|
|
100
100
|
);
|
|
101
101
|
|
|
102
102
|
for (const [layer, patterns] of Object.entries(LAYER_PATTERNS)) {
|
|
103
|
-
if (parts.some(s => patterns.includes(
|
|
103
|
+
if (parts.some(s => patterns.some(p => s.includes(p)))) {
|
|
104
104
|
return layer;
|
|
105
105
|
}
|
|
106
106
|
}
|