ai-first-cli 1.2.3 → 1.3.1
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/.github/workflows/publish.yml +4 -1
- 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/test-ai-context-understanding.sh +21 -0
- package/test_adapters.mjs +11 -11
- 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/BUGS.md +0 -455
- package/PLAN_MEJORAS.md +0 -216
- package/STATUS_ADAPTADORES +0 -126
- 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,216 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
aiContextGenerator,
|
|
4
|
+
flowGenerator,
|
|
5
|
+
architectureGenerator,
|
|
6
|
+
} from "../src/core/generation/index.js";
|
|
7
|
+
|
|
8
|
+
describe("AI Context Generator", () => {
|
|
9
|
+
it("should generate enriched context", () => {
|
|
10
|
+
const analysis = {
|
|
11
|
+
architecture: {
|
|
12
|
+
primary: {
|
|
13
|
+
name: "Layered Architecture",
|
|
14
|
+
confidence: 0.85,
|
|
15
|
+
evidence: ["Found 3 layers", "Clear separation of concerns"],
|
|
16
|
+
},
|
|
17
|
+
secondary: [],
|
|
18
|
+
layers: [
|
|
19
|
+
{
|
|
20
|
+
name: "API",
|
|
21
|
+
symbols: ["src/controller.ts#UserController"],
|
|
22
|
+
files: ["src/controller.ts"],
|
|
23
|
+
responsibility: "Handle HTTP requests",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "Service",
|
|
27
|
+
symbols: ["src/service.ts#UserService"],
|
|
28
|
+
files: ["src/service.ts"],
|
|
29
|
+
responsibility: "Business logic",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
entryPoints: ["src/main.ts#main"],
|
|
33
|
+
},
|
|
34
|
+
symbols: [
|
|
35
|
+
{ id: "src/controller.ts#UserController", name: "UserController", type: "class", file: "src/controller.ts" },
|
|
36
|
+
{ id: "src/service.ts#UserService", name: "UserService", type: "class", file: "src/service.ts" },
|
|
37
|
+
{ id: "src/main.ts#main", name: "main", type: "function", file: "src/main.ts" },
|
|
38
|
+
],
|
|
39
|
+
dependencies: {
|
|
40
|
+
totalDependencies: 10,
|
|
41
|
+
dependencies: [
|
|
42
|
+
{ source: "src/controller.ts", target: "src/service.ts", type: "import" },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
projectName: "TestApp",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const context = aiContextGenerator.generate(analysis);
|
|
49
|
+
|
|
50
|
+
expect(context).toContain("# AI Context: TestApp");
|
|
51
|
+
expect(context).toContain("Layered Architecture");
|
|
52
|
+
expect(context).toContain("85%");
|
|
53
|
+
expect(context).toContain("API");
|
|
54
|
+
expect(context).toContain("Service");
|
|
55
|
+
expect(context).toContain("main");
|
|
56
|
+
expect(context).toContain("Total Files");
|
|
57
|
+
expect(context).toContain("Total Symbols");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should detect project type", () => {
|
|
61
|
+
const analysis = {
|
|
62
|
+
architecture: {
|
|
63
|
+
primary: null,
|
|
64
|
+
secondary: [],
|
|
65
|
+
layers: [],
|
|
66
|
+
entryPoints: [],
|
|
67
|
+
},
|
|
68
|
+
symbols: [
|
|
69
|
+
{ id: "src/controller.ts#Test", name: "Test", type: "class", file: "src/controller.ts" },
|
|
70
|
+
],
|
|
71
|
+
dependencies: { totalDependencies: 0, dependencies: [] },
|
|
72
|
+
projectName: "Test",
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const context = aiContextGenerator.generate(analysis);
|
|
76
|
+
|
|
77
|
+
expect(context).toContain("MVC Web Application");
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("Flow Generator", () => {
|
|
82
|
+
it("should generate enriched flows", () => {
|
|
83
|
+
const entryPoints = ["src/auth.ts#login"];
|
|
84
|
+
const symbols = [
|
|
85
|
+
{ id: "src/auth.ts#login", name: "login", type: "function", file: "src/auth.ts" },
|
|
86
|
+
{ id: "src/service.ts#validate", name: "validate", type: "function", file: "src/service.ts" },
|
|
87
|
+
];
|
|
88
|
+
const dependencyGraph = {
|
|
89
|
+
edges: [{ from: "src/auth.ts#login", to: "src/service.ts#validate", type: "import" }],
|
|
90
|
+
};
|
|
91
|
+
const callGraph = {
|
|
92
|
+
edges: [{ caller: "src/auth.ts#login", callee: "src/service.ts#validate" }],
|
|
93
|
+
};
|
|
94
|
+
const inheritanceGraph = { edges: [] };
|
|
95
|
+
|
|
96
|
+
const flows = flowGenerator.generateFlows(
|
|
97
|
+
entryPoints,
|
|
98
|
+
symbols,
|
|
99
|
+
dependencyGraph,
|
|
100
|
+
callGraph,
|
|
101
|
+
inheritanceGraph
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect(flows).toHaveLength(1);
|
|
105
|
+
expect(flows[0].name).toBe("login");
|
|
106
|
+
expect(flows[0].type).toBe("API Endpoint");
|
|
107
|
+
expect(flows[0].files).toHaveLength(2);
|
|
108
|
+
expect(flows[0].dependencies.calls).toContain("src/service.ts#validate");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should detect layers in flow", () => {
|
|
112
|
+
const entryPoints = ["src/controller.ts#getUser"];
|
|
113
|
+
const symbols = [
|
|
114
|
+
{ id: "src/controller.ts#getUser", name: "getUser", type: "function", file: "src/controller.ts" },
|
|
115
|
+
{ id: "src/service.ts#findUser", name: "findUser", type: "function", file: "src/service.ts" },
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
const callGraph = {
|
|
119
|
+
edges: [{ caller: "src/controller.ts#getUser", callee: "src/service.ts#findUser" }],
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const flows = flowGenerator.generateFlows(
|
|
123
|
+
entryPoints,
|
|
124
|
+
symbols,
|
|
125
|
+
{ edges: [] },
|
|
126
|
+
callGraph,
|
|
127
|
+
{ edges: [] }
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
expect(flows[0].layers).toContain("api");
|
|
131
|
+
expect(flows[0].layers).toContain("service");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("should calculate complexity", () => {
|
|
135
|
+
const entryPoints = ["src/simple.ts#simple"];
|
|
136
|
+
const symbols = [{ id: "src/simple.ts#simple", name: "simple", type: "function", file: "src/simple.ts" }];
|
|
137
|
+
|
|
138
|
+
const flows = flowGenerator.generateFlows(
|
|
139
|
+
entryPoints,
|
|
140
|
+
symbols,
|
|
141
|
+
{ edges: [] },
|
|
142
|
+
{ edges: [] },
|
|
143
|
+
{ edges: [] }
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
expect(flows[0].complexity).toBe("low");
|
|
147
|
+
expect(flows[0].depth).toBe(1);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe("Architecture Generator", () => {
|
|
152
|
+
it("should generate architecture markdown", () => {
|
|
153
|
+
const analysis = {
|
|
154
|
+
primary: {
|
|
155
|
+
name: "MVC",
|
|
156
|
+
confidence: 0.9,
|
|
157
|
+
evidence: ["Found controllers", "Found models"],
|
|
158
|
+
},
|
|
159
|
+
secondary: [],
|
|
160
|
+
layers: [
|
|
161
|
+
{ name: "Controller", symbols: ["ctrl1", "ctrl2"], files: ["ctrl.ts"], responsibility: "Handle requests" },
|
|
162
|
+
{ name: "Model", symbols: ["model1"], files: ["model.ts"], responsibility: "Data" },
|
|
163
|
+
],
|
|
164
|
+
entryPoints: ["main"],
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const dependencyGraph = {
|
|
168
|
+
nodes: ["ctrl1", "model1"],
|
|
169
|
+
edges: [{ from: "ctrl1", to: "model1", type: "import" }],
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const markdown = architectureGenerator.generate(analysis, dependencyGraph);
|
|
173
|
+
|
|
174
|
+
expect(markdown).toContain("# Architecture");
|
|
175
|
+
expect(markdown).toContain("MVC");
|
|
176
|
+
expect(markdown).toContain("90%");
|
|
177
|
+
expect(markdown).toContain("Controller");
|
|
178
|
+
expect(markdown).toContain("Model");
|
|
179
|
+
expect(markdown).toContain("Architecture Diagram");
|
|
180
|
+
expect(markdown).toContain("mermaid");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("should generate mermaid diagram", () => {
|
|
184
|
+
const analysis = {
|
|
185
|
+
primary: { name: "Layered", confidence: 0.8, evidence: [] },
|
|
186
|
+
secondary: [],
|
|
187
|
+
layers: [{ name: "API", symbols: ["api1"], files: ["api.ts"], responsibility: "" }],
|
|
188
|
+
entryPoints: [],
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const dependencyGraph = {
|
|
192
|
+
nodes: ["api1", "svc1"],
|
|
193
|
+
edges: [{ from: "api1", to: "svc1", type: "import" }],
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const markdown = architectureGenerator.generate(analysis, dependencyGraph);
|
|
197
|
+
|
|
198
|
+
expect(markdown).toContain("graph TD");
|
|
199
|
+
expect(markdown).toContain("api1");
|
|
200
|
+
expect(markdown).toContain("svc1");
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("should handle unknown patterns", () => {
|
|
204
|
+
const analysis = {
|
|
205
|
+
primary: null,
|
|
206
|
+
secondary: [],
|
|
207
|
+
layers: [],
|
|
208
|
+
entryPoints: [],
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const markdown = architectureGenerator.generate(analysis, { nodes: [], edges: [] });
|
|
212
|
+
|
|
213
|
+
expect(markdown).toContain("Unknown");
|
|
214
|
+
expect(markdown).toContain("No strong pattern detected");
|
|
215
|
+
});
|
|
216
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { parserRegistry, createSymbolFromParsed } from "../src/core/parsers/index.js";
|
|
3
|
+
|
|
4
|
+
describe("Parser Registry", () => {
|
|
5
|
+
it("should return TypeScript parser for .ts files", () => {
|
|
6
|
+
const parser = parserRegistry.getParser(".ts");
|
|
7
|
+
expect(parser).toBeDefined();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should return TypeScript parser for .tsx files", () => {
|
|
11
|
+
const parser = parserRegistry.getParser(".tsx");
|
|
12
|
+
expect(parser).toBeDefined();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should return TypeScript parser for .js files", () => {
|
|
16
|
+
const parser = parserRegistry.getParser(".js");
|
|
17
|
+
expect(parser).toBeDefined();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should return Python parser for .py files", () => {
|
|
21
|
+
const parser = parserRegistry.getParser(".py");
|
|
22
|
+
expect(parser).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should return undefined for unsupported extensions", () => {
|
|
26
|
+
const parser = parserRegistry.getParser(".unknown");
|
|
27
|
+
expect(parser).toBeUndefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should be case insensitive", () => {
|
|
31
|
+
const parserLower = parserRegistry.getParser(".ts");
|
|
32
|
+
const parserUpper = parserRegistry.getParser(".TS");
|
|
33
|
+
expect(parserLower).toBe(parserUpper);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should check if parser exists", () => {
|
|
37
|
+
expect(parserRegistry.hasParser(".ts")).toBe(true);
|
|
38
|
+
expect(parserRegistry.hasParser(".py")).toBe(true);
|
|
39
|
+
expect(parserRegistry.hasParser(".unknown")).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should return list of supported extensions", () => {
|
|
43
|
+
const extensions = parserRegistry.getSupportedExtensions();
|
|
44
|
+
expect(extensions).toContain(".ts");
|
|
45
|
+
expect(extensions).toContain(".tsx");
|
|
46
|
+
expect(extensions).toContain(".js");
|
|
47
|
+
expect(extensions).toContain(".py");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should parse TypeScript file", () => {
|
|
51
|
+
const source = `
|
|
52
|
+
export class UserService {
|
|
53
|
+
async findById(id: string) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const result = parserRegistry.parse("test.ts", source);
|
|
60
|
+
expect(result).toBeDefined();
|
|
61
|
+
expect(result?.symbols).toHaveLength(1);
|
|
62
|
+
expect(result?.symbols[0].name).toBe("UserService");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should parse Python file", () => {
|
|
66
|
+
const source = `
|
|
67
|
+
class UserService:
|
|
68
|
+
def find_by_id(self, id):
|
|
69
|
+
return None
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
const result = parserRegistry.parse("test.py", source);
|
|
73
|
+
expect(result).toBeDefined();
|
|
74
|
+
expect(result?.symbols).toHaveLength(1);
|
|
75
|
+
expect(result?.symbols[0].name).toBe("UserService");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should return null for unsupported files", () => {
|
|
79
|
+
const result = parserRegistry.parse("test.unknown", "content");
|
|
80
|
+
expect(result).toBeNull();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should create symbols from parsed TypeScript", () => {
|
|
84
|
+
const source = `
|
|
85
|
+
export class UserService {
|
|
86
|
+
async findById(id: string): Promise<User | null> {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface User {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
|
|
97
|
+
const parsed = parserRegistry.parse("test.ts", source);
|
|
98
|
+
expect(parsed).toBeDefined();
|
|
99
|
+
|
|
100
|
+
const symbols = createSymbolFromParsed(parsed!, "test.ts");
|
|
101
|
+
|
|
102
|
+
expect(symbols.length).toBeGreaterThanOrEqual(2);
|
|
103
|
+
|
|
104
|
+
const userService = symbols.find(s => s.name === "UserService");
|
|
105
|
+
expect(userService).toBeDefined();
|
|
106
|
+
expect(userService?.type).toBe("class");
|
|
107
|
+
expect(userService?.export).toBe(true);
|
|
108
|
+
|
|
109
|
+
const userInterface = symbols.find(s => s.name === "User");
|
|
110
|
+
expect(userInterface).toBeDefined();
|
|
111
|
+
expect(userInterface?.type).toBe("interface");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("should create symbols from parsed Python", () => {
|
|
115
|
+
const source = `
|
|
116
|
+
class UserService:
|
|
117
|
+
def find_by_id(self, id: str):
|
|
118
|
+
return None
|
|
119
|
+
|
|
120
|
+
def helper_function():
|
|
121
|
+
pass
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
const parsed = parserRegistry.parse("test.py", source);
|
|
125
|
+
expect(parsed).toBeDefined();
|
|
126
|
+
|
|
127
|
+
const symbols = createSymbolFromParsed(parsed!, "test.py");
|
|
128
|
+
|
|
129
|
+
expect(symbols.length).toBeGreaterThanOrEqual(2);
|
|
130
|
+
|
|
131
|
+
const userService = symbols.find(s => s.name === "UserService");
|
|
132
|
+
expect(userService).toBeDefined();
|
|
133
|
+
expect(userService?.type).toBe("class");
|
|
134
|
+
|
|
135
|
+
const helperFunc = symbols.find(s => s.name === "helper_function");
|
|
136
|
+
expect(helperFunc).toBeDefined();
|
|
137
|
+
expect(helperFunc?.type).toBe("function");
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
+
import { AnalysisPipeline } from "../src/core/pipeline";
|
|
3
|
+
import type { FileInfo } from "../src/core/repoScanner";
|
|
4
|
+
|
|
5
|
+
describe("AnalysisPipeline Integration", () => {
|
|
6
|
+
let pipeline: AnalysisPipeline;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
pipeline = new AnalysisPipeline();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should analyze TypeScript files with AST parser", async () => {
|
|
13
|
+
const files: FileInfo[] = [
|
|
14
|
+
{
|
|
15
|
+
path: "/project/src/user.ts",
|
|
16
|
+
relativePath: "src/user.ts",
|
|
17
|
+
name: "user.ts",
|
|
18
|
+
extension: "ts",
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const content = `
|
|
23
|
+
export class User {
|
|
24
|
+
name: string;
|
|
25
|
+
constructor(name: string) {
|
|
26
|
+
this.name = name;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createUser(name: string): User {
|
|
31
|
+
return new User(name);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IUser {
|
|
35
|
+
name: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type UserId = string;
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const fs = await import("node:fs");
|
|
42
|
+
const tempFile = "/tmp/test-user.ts";
|
|
43
|
+
fs.writeFileSync(tempFile, content);
|
|
44
|
+
|
|
45
|
+
files[0].path = tempFile;
|
|
46
|
+
|
|
47
|
+
const result = await pipeline.run(files, "TestProject");
|
|
48
|
+
|
|
49
|
+
expect(result.symbols.symbols.length).toBeGreaterThan(0);
|
|
50
|
+
expect(result.symbols.symbols.some(s => s.name === "User" && s.type === "class")).toBe(true);
|
|
51
|
+
expect(result.symbols.symbols.some(s => s.name === "createUser" && s.type === "function")).toBe(true);
|
|
52
|
+
expect(result.symbols.symbols.some(s => s.name === "IUser" && s.type === "interface")).toBe(true);
|
|
53
|
+
expect(result.symbols.symbols.some(s => s.name === "UserId" && s.type === "type")).toBe(true);
|
|
54
|
+
|
|
55
|
+
expect(result.metrics.duration).toBeGreaterThan(0);
|
|
56
|
+
expect(result.metrics.filesProcessed).toBe(1);
|
|
57
|
+
|
|
58
|
+
fs.unlinkSync(tempFile);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should detect architecture pattern", async () => {
|
|
62
|
+
const files: FileInfo[] = [
|
|
63
|
+
{
|
|
64
|
+
path: "/project/src/controllers/userController.ts",
|
|
65
|
+
relativePath: "src/controllers/userController.ts",
|
|
66
|
+
name: "userController.ts",
|
|
67
|
+
extension: "ts",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
path: "/project/src/services/userService.ts",
|
|
71
|
+
relativePath: "src/services/userService.ts",
|
|
72
|
+
name: "userService.ts",
|
|
73
|
+
extension: "ts",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
path: "/project/src/repositories/userRepository.ts",
|
|
77
|
+
relativePath: "src/repositories/userRepository.ts",
|
|
78
|
+
name: "userRepository.ts",
|
|
79
|
+
extension: "ts",
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const controllerContent = `
|
|
84
|
+
export class UserController {
|
|
85
|
+
constructor(private userService: UserService) {}
|
|
86
|
+
async getUser(id: string) {
|
|
87
|
+
return this.userService.findById(id);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
const serviceContent = `
|
|
93
|
+
export class UserService {
|
|
94
|
+
constructor(private userRepo: UserRepository) {}
|
|
95
|
+
async findById(id: string) {
|
|
96
|
+
return this.userRepo.findOne(id);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
const repoContent = `
|
|
102
|
+
export class UserRepository {
|
|
103
|
+
async findOne(id: string) {
|
|
104
|
+
return { id, name: "Test" };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
const fs = await import("node:fs");
|
|
110
|
+
const filesWithContent = [
|
|
111
|
+
{ path: "/tmp/test-controller.ts", content: controllerContent },
|
|
112
|
+
{ path: "/tmp/test-service.ts", content: serviceContent },
|
|
113
|
+
{ path: "/tmp/test-repo.ts", content: repoContent },
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
filesWithContent.forEach(({ path, content }) => {
|
|
117
|
+
fs.writeFileSync(path, content);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
files[0].path = "/tmp/test-controller.ts";
|
|
121
|
+
files[1].path = "/tmp/test-service.ts";
|
|
122
|
+
files[2].path = "/tmp/test-repo.ts";
|
|
123
|
+
|
|
124
|
+
const result = await pipeline.run(files, "TestProject");
|
|
125
|
+
|
|
126
|
+
expect(result.architecture.primary !== null || result.architecture.secondary.length > 0).toBe(true);
|
|
127
|
+
expect(result.architecture.layers.length).toBeGreaterThan(0);
|
|
128
|
+
expect(result.metrics.filesProcessed).toBe(3);
|
|
129
|
+
|
|
130
|
+
filesWithContent.forEach(({ path }) => {
|
|
131
|
+
fs.unlinkSync(path);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("should generate AI context", async () => {
|
|
136
|
+
const files: FileInfo[] = [
|
|
137
|
+
{
|
|
138
|
+
path: "/project/src/auth.ts",
|
|
139
|
+
relativePath: "src/auth.ts",
|
|
140
|
+
name: "auth.ts",
|
|
141
|
+
extension: "ts",
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
const content = `
|
|
146
|
+
export function authenticate(token: string): boolean {
|
|
147
|
+
return token.length > 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export class AuthMiddleware {
|
|
151
|
+
handle(req: any, res: any, next: any) {
|
|
152
|
+
next();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
|
|
157
|
+
const fs = await import("node:fs");
|
|
158
|
+
fs.writeFileSync("/tmp/test-auth.ts", content);
|
|
159
|
+
files[0].path = "/tmp/test-auth.ts";
|
|
160
|
+
|
|
161
|
+
const result = await pipeline.run(files, "AuthService");
|
|
162
|
+
|
|
163
|
+
expect(result.aiContext).toContain("AuthService");
|
|
164
|
+
expect(result.aiContext.length).toBeGreaterThan(100);
|
|
165
|
+
expect(result.architectureDoc.length).toBeGreaterThan(0);
|
|
166
|
+
|
|
167
|
+
fs.unlinkSync("/tmp/test-auth.ts");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("should cache and clear cache correctly", async () => {
|
|
171
|
+
const pipeline = new AnalysisPipeline();
|
|
172
|
+
|
|
173
|
+
expect(pipeline.getMetrics().cacheSize).toBe(0);
|
|
174
|
+
|
|
175
|
+
pipeline.clearCache();
|
|
176
|
+
expect(pipeline.getMetrics().cacheSize).toBe(0);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("should handle empty file list", async () => {
|
|
180
|
+
const result = await pipeline.run([], "EmptyProject");
|
|
181
|
+
|
|
182
|
+
expect(result.symbols.symbols).toEqual([]);
|
|
183
|
+
expect(result.metrics.filesProcessed).toBe(0);
|
|
184
|
+
expect(result.metrics.duration).toBeGreaterThanOrEqual(0);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("should handle unsupported file types gracefully", async () => {
|
|
188
|
+
const files: FileInfo[] = [
|
|
189
|
+
{
|
|
190
|
+
path: "/project/readme.md",
|
|
191
|
+
relativePath: "readme.md",
|
|
192
|
+
name: "readme.md",
|
|
193
|
+
extension: "md",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
path: "/project/config.yaml",
|
|
197
|
+
relativePath: "config.yaml",
|
|
198
|
+
name: "config.yaml",
|
|
199
|
+
extension: "yaml",
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
|
|
203
|
+
const result = await pipeline.run(files, "MixedProject");
|
|
204
|
+
|
|
205
|
+
expect(result.metrics.filesProcessed).toBe(2);
|
|
206
|
+
expect(result.symbols.symbols.length).toBe(0);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("should generate dependency graph", async () => {
|
|
210
|
+
const files: FileInfo[] = [
|
|
211
|
+
{
|
|
212
|
+
path: "/project/src/app.ts",
|
|
213
|
+
relativePath: "src/app.ts",
|
|
214
|
+
name: "app.ts",
|
|
215
|
+
extension: "ts",
|
|
216
|
+
},
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
const content = `
|
|
220
|
+
import { UserService } from './services/userService';
|
|
221
|
+
import { Config } from './config';
|
|
222
|
+
|
|
223
|
+
export class App {
|
|
224
|
+
constructor(private userService: UserService) {}
|
|
225
|
+
start() {
|
|
226
|
+
console.log('Starting...');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export const app = new App();
|
|
231
|
+
`;
|
|
232
|
+
|
|
233
|
+
const fs = await import("node:fs");
|
|
234
|
+
fs.writeFileSync("/tmp/test-app.ts", content);
|
|
235
|
+
files[0].path = "/tmp/test-app.ts";
|
|
236
|
+
|
|
237
|
+
const result = await pipeline.run(files, "TestApp");
|
|
238
|
+
|
|
239
|
+
expect(result.dependencyGraph).toBeDefined();
|
|
240
|
+
expect(result.dependencyGraph.edges).toBeDefined();
|
|
241
|
+
expect(result.dependencyGraph.nodes).toBeDefined();
|
|
242
|
+
|
|
243
|
+
fs.unlinkSync("/tmp/test-app.ts");
|
|
244
|
+
});
|
|
245
|
+
});
|