This commit is contained in:
Max Sveshnikov 2024-11-04 20:08:57 +01:00
parent 1fa920625d
commit 12c18ba854
9 changed files with 855 additions and 7 deletions

177
AppStorePublisherAgent.md Normal file
View file

@ -0,0 +1,177 @@
# AppStorePublisherAgent.js Documentation
## Overview
The `AppStorePublisherAgent.js` is a specialized module designed to automate the process of publishing mobile applications to app stores (Google Play Store and Apple App Store). It is part of a comprehensive project management and deployment system, handling the end-to-end app submission process.
## Dependencies
- `fs/promises`: For file system operations
- `path`: For handling file paths
- `node-fetch`: For making HTTP requests
- `child_process`: For executing shell commands
- Custom modules:
- `FileManager`: Manages file-related operations
- `CONFIG`: Configuration settings
- `UserInterface`: Handles user interactions and AI prompts
- `CodeGenerator`: Generates code and description files
## Main Methods
### `run(projectStructure, readme)`
**Description**:
- Primary method to initiate the app store publishing process
- Coordinates the entire app submission workflow
**Parameters**:
- `projectStructure` (Object): Represents the project's directory structure
- `readme` (String): Project's README file content
**Workflow**:
1. Generate app description files
2. Detect mobile platform (Android/iOS)
3. Prepare app for submission
4. Generate metadata
5. Create description files
6. Upload screenshots
7. Submit for review
**Example**:
```javascript
await AppStorePublisherAgent.run(projectStructure, readmeContent);
```
### `detectPlatform(projectStructure)`
**Description**:
- Determines the mobile app's platform based on project structure
**Parameters**:
- `projectStructure` (Object): Project's directory structure
**Returns**:
- `String`: Platform ('android' or 'ios')
- `null`: If platform cannot be detected
### `prepareApp(platform)`
**Description**:
- Builds the app for release based on the detected platform
- Uses platform-specific build commands
**Parameters**:
- `platform` (String): Mobile platform ('android' or 'ios')
### `generateMetadata(platform, readme)`
**Description**:
- Extracts and generates app metadata from README
- Creates metadata files for app stores
**Parameters**:
- `platform` (String): Mobile platform
- `readme` (String): Project's README content
### `extractMetadataFromReadme(readme)`
**Description**:
- Parses README to extract app description, keywords, etc.
**Parameters**:
- `readme` (String): Project's README content
**Returns**:
- `Object`: Containing description, short description, and keywords
### `createDescriptionFiles(platform)`
**Description**:
- Generates app store metadata files
- Uses AI to create comprehensive app description
**Parameters**:
- `platform` (String): Mobile platform
### `uploadScreenshots(platform)`
**Description**:
- Uploads app screenshots to respective app stores
- Reads screenshots from a predefined directory
**Parameters**:
- `platform` (String): Mobile platform
### `submitForReview(platform)`
**Description**:
- Submits the app for review on the respective app store
- Uses platform-specific submission commands
**Parameters**:
- `platform` (String): Mobile platform
## Usage Scenarios
1. Automated App Store Submission
2. Continuous Deployment Workflows
3. Streamlined App Publishing Process
## Error Handling
- Logs error messages
- Graceful exit if platform cannot be detected
- Uses promises for asynchronous operations
## Best Practices
- Modular design
- Platform-agnostic approach
- AI-assisted metadata generation
- Configurable through external configuration
## Potential Improvements
- Enhanced error handling
- Support for more platforms
- More robust metadata extraction
- Advanced screenshot management
## Security Considerations
- Uses secure file handling
- Relies on configuration-based server URLs
- Separates concerns between different agents
## Dependencies on Other Project Files
- Requires `config.js` for server configurations
- Uses `fileManager.js` for file operations
- Integrates with `userInterface.js` for AI interactions
## Recommended Environment
- Node.js 14+
- Access to app store developer accounts
- Fastlane installed
- Configured build environments for Android/iOS

143
BusinessAnalystAgent.md Normal file
View file

@ -0,0 +1,143 @@
# BusinessAnalystAgent.js Documentation
## Overview
`BusinessAnalystAgent.js` is a module designed to perform business analysis and generate insights for a software project. It leverages the Anthropic Claude AI to extract requirements, generate business insights, and suggest feature prioritization. The agent is part of an automated project management and analysis system.
## Dependencies
- `path`: Node.js path manipulation module
- `chalk`: Terminal string styling
- `@anthropic-ai/sdk`: Anthropic AI SDK for generating insights
- `./config.js`: Project configuration
- `./fileManager.js`: File management utilities
- `./userInterface.js`: User interface configuration
## Module Structure
The `BusinessAnalystAgent` is an object with the following key methods:
### `run(projectStructure, readme)`
Orchestrates the entire business analysis process.
**Parameters:**
- `projectStructure` (Object): Detailed project file and folder structure
- `readme` (String): Project README content
**Process:**
1. Extract requirements from README
2. Generate business insights
3. Update project documentation
4. Suggest feature prioritization
**Example:**
```javascript
await BusinessAnalystAgent.run(projectStructure, readmeContent);
```
### `extractRequirements(readme)`
Extracts key business requirements using Anthropic Claude AI.
**Parameters:**
- `readme` (String): Project README content
**Returns:**
- `Promise<String>`: Extracted business requirements
### `generateInsights(requirements, projectStructure)`
Generates comprehensive business insights based on requirements and project structure.
**Parameters:**
- `requirements` (String): Extracted business requirements
- `projectStructure` (Object): Project file and folder structure
**Returns:**
- `Promise<String>`: Business analysis insights
**Insights Include:**
- Potential market opportunities
- Competitive advantages
- Risks and challenges
- Improvement suggestions
### `updateProjectDocumentation(insights)`
Saves business analysis insights to a Markdown file.
**Parameters:**
- `insights` (String): Generated business insights
**Actions:**
- Creates `/docs/business_analysis.md`
- Writes insights with timestamp
### `suggestFeaturePrioritization(insights)`
Generates and saves a prioritized list of features based on business insights.
**Parameters:**
- `insights` (String): Generated business insights
**Actions:**
- Creates `/docs/prioritized_features.md`
- Writes top 5 prioritized features with timestamp
## Configuration
- Uses environment variable `CLAUDE_KEY` for Anthropic API authentication
- Configurable model and temperature via `UserInterface` methods
- Maximum token limit from `CONFIG.maxTokens`
## Project Context
In the given project structure, `BusinessAnalystAgent.js` serves as an AI-powered business analysis tool, complementing other agents like:
- `ProductOwnerAgent.js`
- `ProjectManagerAgent.js`
- `MarketingAgent.js`
It generates documentation in the `/docs` directory, which can be used by other project components.
## Usage Example
```javascript
import BusinessAnalystAgent from "./BusinessAnalystAgent.js";
import fs from "fs";
async function performBusinessAnalysis() {
const projectStructure = {
/* project structure object */
};
const readme = fs.readFileSync("README.md", "utf-8");
await BusinessAnalystAgent.run(projectStructure, readme);
}
```
## Notes
- Requires Anthropic Claude API key
- Generates markdown documentation
- Provides AI-driven business insights
- Part of an automated project management ecosystem
## Best Practices
- Ensure README is comprehensive
- Maintain accurate project structure
- Regularly review and validate AI-generated insights

View file

@ -0,0 +1,135 @@
# InternationalizationAgent.js Documentation
## Overview
The `InternationalizationAgent` is a sophisticated module designed to automate the internationalization (i18n) process for a JavaScript/React project. It discovers and transforms string files, generates language support infrastructure, and updates project documentation with internationalization details.
## Dependencies
- `fs/promises`: For file system operations
- `path`: For handling file paths
- `chalk`: For colorful console logging
- `FileManager`: Custom file management utility
## Main Methods
### `run(projectStructure, readme)`
Primary method to execute the internationalization process.
**Parameters:**
- `projectStructure` (Object): Represents the project's file and directory structure
- `readme` (String): Existing README.md content
**Process:**
1. Retrieve supported languages
2. Find string files in the project
3. Internationalize each string file
4. Generate a language selection component
5. Update README with internationalization information
**Example:**
```javascript
await InternationalizationAgent.run(projectStructure, existingReadmeContent);
```
### `getSupportedLanguages()`
Retrieves supported languages from configuration or uses default languages.
**Returns:**
- Array of language codes (e.g., `["en", "es", "fr", "de", "ja"]`)
**Configuration:**
- Checks for `i18n.config.json` in project root
- Falls back to default languages if config is not found
### `findStringFiles(projectStructure)`
Recursively searches project structure for JavaScript files containing string definitions.
**Parameters:**
- `projectStructure` (Object): Project's file and directory structure
**Returns:**
- Array of file paths containing string definitions
**Detection Criteria:**
- Files ending with `.js`
- Contains `export const strings` or `export default {`
### `internationalizeFile(file, languages)`
Transforms a single file to support multiple languages.
**Parameters:**
- `file` (String): Path to the file
- `languages` (Array): List of language codes
**Process:**
1. Read file content
2. Extract strings
3. Create internationalized string mappings
4. Update file content with i18n implementation
### `createI18nStrings(strings, languages)`
Generates language-specific string mappings.
**Parameters:**
- `strings` (Array): List of original strings
- `languages` (Array): Target languages
**Returns:**
- Object with language-specific string mappings
### `generateLanguageSelectionComponent(languages)`
Creates a React component for language selection.
**Parameters:**
- `languages` (Array): Supported language codes
**Output:**
- Generates `src/components/LanguageSelector.js`
### `updateReadmeWithI18nInfo(readme, languages)`
Appends internationalization information to README.
**Parameters:**
- `readme` (String): Existing README content
- `languages` (Array): Supported language codes
**Process:**
- Adds section describing supported languages
- Provides guidance on translation management
## Project Context
In the given project structure, this agent plays a crucial role in:
- Preparing multilingual support
- Standardizing string management
- Facilitating easy language switching
## Usage Recommendations
1. Create an optional `i18n.config.json` to specify custom languages
2. Ensure string files follow the expected export pattern
3. Use generated `LanguageSelector` component for runtime language changes
## Configuration Example
`i18n.config.json`:
```json
{
"supportedLanguages": ["en", "es", "fr", "de", "ja", "zh"]
}
```
## Potential Improvements
- Add translation service integration
- Implement more sophisticated string extraction
- Support for more complex internationalization scenarios
## Dependencies
- Requires `i18next` for runtime language management
- Depends on `FileManager` for file operations
## Error Handling
- Gracefully handles missing configuration
- Provides fallback to default language set
- Logs informative messages during the process

112
ProductOwnerAgent.md Normal file
View file

@ -0,0 +1,112 @@
# ProductOwnerAgent.js Documentation
## Overview
The `ProductOwnerAgent.js` is a crucial component of an AI-driven project management system that leverages Anthropic's Claude AI to assist in product management tasks. This module acts as an intelligent Product Owner, helping to manage product backlog, prioritize features, and generate sprint plans.
## Dependencies
- `@anthropic-ai/sdk`: Anthropic AI SDK for generating AI-powered recommendations
- `./config.js`: Configuration settings for the application
- `./fileManager.js`: Utility for file read/write operations
- `chalk`: Terminal string styling
- `ora`: Elegant terminal spinner
- `./userInterface.js`: User interface configuration management
## Main Methods
### `run(projectStructure, readme)`
Generates comprehensive product recommendations based on the project structure and README.
#### Parameters:
- `projectStructure` (Object): JSON representation of the project's file and directory structure
- `readme` (String): Contents of the project's README file
#### Functionality:
- Analyzes project structure and README
- Generates feature recommendations
- Saves recommendations to `docs/product_owner_recommendations.md`
- Triggers backlog update and sprint plan generation
#### Example:
```javascript
await ProductOwnerAgent.run(projectStructure, readmeContent);
```
### `updateBacklog(projectStructure, readme)`
Updates the product backlog with AI-generated insights.
#### Parameters:
- `projectStructure` (Object): JSON representation of the project's file and directory structure
- `readme` (String): Contents of the project's README file
#### Functionality:
- Reads existing backlog
- Generates updated backlog with new features, priorities, and notes
- Saves updated backlog to `docs/product_backlog.md`
#### Example:
```javascript
await ProductOwnerAgent.updateBacklog(projectStructure, readmeContent);
```
### `generateSprintPlan(projectStructure, readme)`
Creates a detailed sprint plan based on the current product backlog.
#### Parameters:
- `projectStructure` (Object): JSON representation of the project's file and directory structure
- `readme` (String): Contents of the project's README file
#### Functionality:
- Reads current product backlog
- Generates a sprint plan with:
- Sprint goal
- Selected user stories
- Effort estimates
- Dependencies and risks
- Definition of Done
- Saves sprint plan to `docs/sprint_plan.md`
#### Example:
```javascript
await ProductOwnerAgent.generateSprintPlan(projectStructure, readmeContent);
```
## Configuration and Environment
- Requires `CLAUDE_KEY` environment variable for Anthropic API authentication
- Uses dynamic model and temperature selection via `UserInterface`
- Configurable max tokens via `CONFIG.maxTokens`
## Output Files
1. `docs/product_owner_recommendations.md`
2. `docs/product_backlog.md`
3. `docs/sprint_plan.md`
## Error Handling
- Uses `ora` spinner to provide visual feedback
- Catches and logs errors with detailed error messages
- Provides user-friendly console output using `chalk` for color-coded messaging
## Project Context
In the given project structure, `ProductOwnerAgent.js` is part of a comprehensive AI-assisted project management toolkit. It works alongside other agent modules like `ProjectManagerAgent.js`, `BusinessAnalystAgent.js`, etc., to provide intelligent project management capabilities.
## Best Practices and Recommendations
- Ensure `CLAUDE_KEY` is securely stored
- Regularly review and validate AI-generated recommendations
- Use the generated documents as living documents that can be manually adjusted
- Integrate with version control and project management tools for seamless workflow
## Potential Improvements
- Add more granular error handling
- Implement caching mechanisms for AI-generated content
- Create more sophisticated prompts for more accurate recommendations
- Add support for multiple project types and structures

132
ProjectManagerAgent.md Normal file
View file

@ -0,0 +1,132 @@
# ProjectManagerAgent.js Documentation
## Overview
`ProjectManagerAgent.js` is a comprehensive project management and automation module designed to orchestrate various development, testing, and deployment tasks for a software project. It acts as a central coordination agent that performs multiple critical functions throughout the software development lifecycle.
## Dependencies
- `fs/promises`: File system operations
- `path`: File path handling
- `child_process`: Executing shell commands
- `chalk`: Terminal color styling
- Custom agents and utilities:
- `FileManager`
- `CodeAnalyzer`
- `TesterAgent`
- `DevOpsAgent`
## Main Methods
### `run(projectStructure, readme)`
**Description**:
- Primary entry point for the Project Manager Agent
- Coordinates and executes a series of project management tasks
**Parameters**:
- `projectStructure` (Object): Detailed project file and directory structure
- `readme` (String): Project README content
**Example**:
```javascript
await ProjectManagerAgent.run(projectStructure, readmeContent);
```
### Task Methods
#### `buildApp()`
- Executes the project build process using `npm run build`
- Logs build output and handles potential errors
#### `runTests()`
- Runs project test suite using `npm test`
- Captures and logs test results
#### `performUIChecks()`
- Scans and analyzes UI-related files (HTML, JS, JSX, TS, TSX)
- Checks for potential UI code issues
#### `checkDependencies()`
- Identifies outdated project dependencies
- Provides a report of current vs. latest package versions
#### `optimizeAssets()`
- Optimizes image and SVG assets
- Uses tools like `svgo` and `imagemin`
#### `monitorPerformance()`
- Collects application performance profiling data
- Generates performance analysis report
#### `generateDockerfile()`
- Creates a standardized Dockerfile for containerization
- Configures Node.js application deployment
#### `setupCICD()`
- Configures GitHub Actions workflow
- Sets up continuous integration and deployment pipeline
#### `generateChangeLog()`
- Generates a changelog based on git commit history
- Creates a `CHANGELOG.md` file
#### `setupEnvironmentConfig()`
- Creates `.env.example` file
- Provides template for environment configuration
### Agent Orchestration
#### `orchestrateAgents(projectStructure, readme)`
- Coordinates and triggers other specialized agents
- Calls `TesterAgent` and `DevOpsAgent`
## Project Context
In the provided project structure, `ProjectManagerAgent.js` serves as a central automation script that interacts with various components:
- Manages server-side configurations
- Prepares deployment artifacts
- Ensures code quality
- Sets up development and production environments
## Usage Example
```javascript
import ProjectManagerAgent from './ProjectManagerAgent.js';
import projectStructure from './projectStructure.js';
import readme from './README.md';
async function initializeProject() {
await ProjectManagerAgent.run(projectStructure, readme);
}
initializeProject();
```
## Best Practices and Notes
- Requires Node.js 14+ with npm
- Uses modern ES module syntax
- Provides colorful console logging
- Handles potential errors gracefully
- Generates configuration files and scripts automatically
## Error Handling
Each method includes try-catch blocks to manage potential execution errors, ensuring robust operation and providing detailed error logging.
## Security Considerations
- Generates example environment files with placeholders
- Encourages secure configuration management
- Supports containerization best practices
## Performance Optimization
- Profiles application performance
- Optimizes static assets
- Checks and updates dependencies
## Extensibility
The modular design allows easy addition of new project management tasks or customization of existing workflows.

View file

@ -83,8 +83,3 @@ AutoCode currently supports the following programming languages:
Each language has its own configuration for file extensions, recommended linter, formatter, and package manager.
# TODO
- add sonnet model selector similar to temperature and move both params to settings.json in ~
- claude-3-5-sonnet-20240620
- claude-3-5-sonnet-20241022
- send model name to all functions along with temperature

154
TesterAgent.md Normal file
View file

@ -0,0 +1,154 @@
# TesterAgent.js Documentation
## Overview
`TesterAgent.js` is a critical component of an automated testing system designed to generate, run, and optimize tests for a project. It leverages AI (Anthropic Claude) to automatically create comprehensive integration and unit tests for JavaScript files, focusing on generating high-quality test coverage for server-side routes and modules.
## Dependencies
- `path`: Node.js path utility for file path manipulations
- `@anthropic-ai/sdk`: Anthropic AI SDK for generating test code
- `./config.js`: Configuration settings
- `./fileManager.js`: File system operations
- `./codeGenerator.js`: Code generation and optimization
- `./codeAnalyzer.js`: Code analysis utilities
- `./userInterface.js`: User interaction and model selection
## Class: TesterAgent
### Constructor
```javascript
constructor()
```
- Initializes the test directory path to `"tests"`
### Methods
#### `run(projectStructure, readme)`
Orchestrates the entire test generation and optimization process
**Parameters:**
- `projectStructure` (Object): Detailed representation of the project's file structure
- `readme` (String): Project README content
**Steps:**
1. Generate integration tests
2. Generate unit tests
3. Run generated tests
4. Optimize test files
**Example:**
```javascript
await TesterAgent.run(projectStructure, readmeContent);
```
#### `generateIntegrationTests(projectStructure, readme)`
Generates integration tests for server routes
**Parameters:**
- `projectStructure` (Object): Project file structure
- `readme` (String): Project README content
**Process:**
- Extracts server endpoints
- Generates a test file for each endpoint using AI
#### `extractEndpoints(projectStructure)`
Identifies API routes in server route files
**Returns:**
- Array of endpoint objects with `method`, `route`, and `file` properties
#### `generateTestForEndpoint(endpoint, projectStructure, readme)`
Generates a Jest test file for a specific API endpoint
**Parameters:**
- `endpoint` (Object): Endpoint details
- `projectStructure` (Object): Project structure
- `readme` (String): README content
**Process:**
- Uses Anthropic Claude to generate a comprehensive test
- Writes the test to a file in the `tests` directory
#### `generateUnitTests(projectStructure, readme)`
Generates unit tests for JavaScript files in the project
**Parameters:**
- `projectStructure` (Object): Project file structure
- `readme` (String): Project README content
**Process:**
- Identifies JavaScript files
- Generates unit tests for each file using AI
#### `generateUnitTestForFile(file, projectStructure, readme)`
Generates a Jest test file for a specific module
**Parameters:**
- `file` (String): Path to the file being tested
- `projectStructure` (Object): Project structure
- `readme` (String): README content
**Process:**
- Reads file content
- Uses AI to generate comprehensive unit tests
- Writes test file to `tests` directory
#### `runTests()`
Executes all generated tests using npm test command
**Process:**
- Runs test suite
- Logs stdout and stderr
#### `optimizeTests()`
Refactors and optimizes generated test files
**Process:**
- Identifies test files
- Uses CodeGenerator to optimize each test file
#### `extractCodeSnippet(text)`
Extracts code block from AI-generated response
**Parameters:**
- `text` (String): Full AI response text
**Returns:**
- Extracted code snippet (JavaScript)
## Usage Example
```javascript
import TesterAgent from './TesterAgent.js';
import { projectStructure } from './projectConfig.js';
import { readFileSync } from 'fs';
const readme = readFileSync('README.md', 'utf-8');
await TesterAgent.run(projectStructure, readme);
```
## Best Practices and Considerations
- Requires Anthropic Claude API key set in environment variables
- Generates tests using AI with configurable model and temperature
- Supports various test types: integration and unit tests
- Automatically handles test file creation and organization
- Provides error handling and logging
## Potential Improvements
- Add more sophisticated test case generation
- Implement more granular test optimization
- Support additional testing frameworks
- Enhanced error reporting and recovery mechanisms
## Dependencies and Configuration
Ensure the following are properly configured:
- Anthropic API key
- Jest testing framework
- Appropriate project structure
- Configured `config.js` with token limits

View file

@ -458,7 +458,7 @@
<div class="features">
<div class="feature">
<h3>Automatic Code Generation</h3>
<p>Generate code based on README.md instructions using Claude 3.5 Sonnet API (October update)</p>
<p>Generate code based on README.md instructions using Claude 3.5 Sonnet API (October update). Haiku 3.5 also supported!</p>
</div>
<div class="feature">
<h3>Multi-Language Support</h3>

View file

@ -60,7 +60,7 @@ const UserInterface = {
type: "list",
name: "model",
message: "Select the Claude model to use:",
choices: ["claude-3-5-sonnet-20240620", "claude-3-5-sonnet-20241022"],
choices: ["claude-3-5-sonnet-20240620", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-latest"],
});
},