Implement Project Analysis Service for Automatic Config Generation#27
Merged
Conversation
- Analyze package.json and detect 50+ frameworks - Detect architecture patterns from directory structure - Parse TypeScript, ESLint, Prettier config files - Sample and categorize source code files - NestJS service integrating all analyzers - Comprehensive test coverage Enables automatic config generation from project analysis. close #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement Project Analysis Service for Automatic Config Generation
📋 Summary
Implements a comprehensive project analysis service that automatically extracts project information (tech stack, architecture patterns, config files, code samples) to enable automatic CodingBuddy configuration generation. This eliminates the need for manual config file creation.
Closes #21
🎯 Problem
Manual Configuration is Tedious
When developers apply CodingBuddy to a new project, they must manually write
codingbuddy.config.jsfrom scratch. This is time-consuming and error-prone, especially when:package.jsonInformation Already Exists
Projects contain rich information that can be automatically extracted:
package.jsonlists frameworks, libraries, toolsWhy manually recreate what already exists?
✨ Solution
Project Analysis Service
A comprehensive analysis engine that automatically collects and structures project information:
1. Package Analyzer (
package.analyzer.ts)Features:
package.json(name, version, description, type, scripts)PackageInfowith detected frameworks and versionsKey Functions:
analyzePackage(projectRoot): Loads and analyzes package.jsonparsePackageJson(content): Parses JSON contentdetectFrameworks(deps, devDeps): Detects frameworks from dependencies2. Directory Analyzer (
directory.analyzer.ts)Features:
ignore.parserfrom config module)app/,components/,lib/,public/)pages/,components/,styles/)src/modules/,src/common/,src/config/)src/features/,src/entities/,src/shared/)src/components/,src/hooks/,src/utils/)packages/,apps/,libs/)src/models/,src/views/,src/controllers/)src/domain/,src/application/,src/infrastructure/)Key Functions:
analyzeDirectory(projectRoot, ignorePatterns): Scans directory structuredetectArchitecturePatterns(directories): Detects patterns with confidencecategorizeDirectory(dirName): Categorizes directory by name3. Config Analyzer (
config.analyzer.ts)Features:
tsconfig.json,tsconfig.*.json.eslintrc.*,eslint.config.*.prettierrc.*,prettier.config.*jest.config.*,vitest.config.*,playwright.config.*vite.config.*,webpack.config.*,rollup.config.*.eslintrc.json) and flat format (eslint.config.js)Key Functions:
analyzeConfigs(projectRoot, rootFiles): Analyzes config filesparseTsConfig(content, filePath): Parses TypeScript configparseEslintConfig(content, filePath, format): Parses ESLint configparsePrettierConfig(content, filePath): Parses Prettier configdetectConfigFiles(files): Detects config files from file list4. Code Sampler (
code.sampler.ts)Features:
component: React/Vue componentspage: Next.js pages, routeshook: React hooks (useXxx)util: Utility functionsapi: API routes, endpointsservice: Service classesmodel: Data models, entitiestest: Test files (excluded from samples)config: Configuration filesKey Functions:
sampleCode(projectRoot, files, maxSamples): Samples code filescategorizeFile(filePath): Categorizes file by pathdetectLanguage(filePath): Detects programming languageselectSampleFiles(files, maxSamples): Selects diverse samples5. Analyzer Service (
analyzer.service.ts)Features:
ProjectAnalysisinterface:packageInfo: Package.json analysisdirectoryStructure: Directory analysisconfigFiles: Config file summariescodeSamples: Sampled code filesdetectedPatterns: High-level patterns (e.g., "TypeScript", "NestJS Backend")quickAnalyze) for package.json onlyKey Methods:
analyzeProject(projectRoot, options): Complete project analysisquickAnalyze(projectRoot): Package.json only (fast)inferPatterns(packageInfo, dirAnalysis): Infers high-level patterns🧪 Testing
Test Coverage
Total: 70+ analyzer tests, all passing ✅
Test Scenarios
Package Analyzer:
Directory Analyzer:
Config Analyzer:
Code Sampler:
Analyzer Service:
🎯 Benefits
1. Time Savings
No need to manually write config files. Analysis takes seconds, config generation is automatic.
2. Accuracy
Configuration reflects actual project state, not assumptions or outdated information.
3. Discovery
Identifies project characteristics developers might not be aware of (e.g., architecture patterns).
4. Standardization
Consistent analysis result format enables reliable config generation.
5. Extensibility
Easy to add new framework detections, architecture patterns, or config parsers.
📖 Usage Example
📝 Design Decisions
Why Separate Analyzers?
Why Pattern Detection?
Why Code Sampling?
Why NestJS Service?
✅ Acceptance Criteria