diff --git a/packages/agent/README.md b/packages/agent/README.md index 31fd71f..460ab01 100644 --- a/packages/agent/README.md +++ b/packages/agent/README.md @@ -1,15 +1,18 @@ # MyCoder Agent -Core AI agent system that powers the MyCoder CLI tool. This package provides a modular tool-based architecture that allows AI agents to interact with files, execute commands, make network requests, and spawn sub-agents for parallel task execution. +Core AI agent system that powers the MyCoder CLI tool. This package provides a modular tool-based architecture that allows AI agents to interact with files, execute commands, make network requests, spawn sub-agents for parallel task execution, and automate browser interactions. ## Overview -The MyCoder Agent system is built around a few key concepts: +The MyCoder Agent system is built around these key concepts: - 🛠️ **Extensible Tool System**: Modular architecture with various tool categories - 🔄 **Parallel Execution**: Ability to spawn sub-agents for concurrent task processing -- 🤖 **AI-Powered**: Leverages Anthropic's Claude API for intelligent decision making +- 🔌 **Multi-LLM Support**: Works with Anthropic Claude, OpenAI GPT models, and Ollama +- 🌐 **Web Automation**: Built-in browser automation for web interactions - 🔍 **Smart Logging**: Hierarchical, color-coded logging system for clear output +- 📝 **Advanced Text Editing**: Powerful file manipulation capabilities +- 🔄 **MCP Integration**: Support for the Model Context Protocol Please join the MyCoder.ai discord for support: https://discord.gg/5K6TYrHGHt @@ -21,65 +24,149 @@ npm install mycoder-agent ## API Key Required -Before using MyCoder Agent, you must have an ANTHROPIC_API_KEY specified either: +Before using MyCoder Agent, you must have one of the following API keys: -- As an environment variable, "export ANTHROPIC_API_KEY=[your-api-key]" or -- In a .env file in your project root - -Get an API key from https://www.anthropic.com/api +- **Anthropic**: Set `ANTHROPIC_API_KEY` as an environment variable or in a .env file (Get from https://www.anthropic.com/api) +- **OpenAI**: Set `OPENAI_API_KEY` as an environment variable or in a .env file +- **Ollama**: Use locally running Ollama instance ## Core Components ### Tool System -- Modular tools for specific functionalities -- Categories: Interaction, I/O, System, Data Management -- Parallel execution capability -- Type-safe definitions -- Input token caching to reduce API costs +The tool system is the foundation of the MyCoder agent's capabilities: + +- **Modular Design**: Each tool is a standalone module with clear inputs and outputs +- **Type Safety**: Tools use Zod for schema validation and TypeScript for type safety +- **Token Tracking**: Built-in token usage tracking to optimize API costs +- **Parallel Execution**: Tools can run concurrently for efficiency ### Agent System -- Main agent for orchestration -- Sub-agents for parallel task execution -- Anthropic Claude API integration -- Hierarchical logging +The agent system orchestrates the execution flow: -### Logger System +- **Main Agent**: Primary agent that handles the overall task +- **Sub-Agents**: Specialized agents for parallel task execution +- **Agent State Management**: Tracking agent status and communication +- **LLM Integration**: Supports multiple LLM providers (Anthropic, OpenAI, Ollama) -- Color-coded component output -- Hierarchical indentation -- Multiple log levels (info, verbose, warn, error) -- Structured data logging +### LLM Providers -## Project Structure +The agent supports multiple LLM providers: -``` -src/ -├── core/ # Core agent and executor logic -├── interfaces/ # Type definitions and interfaces -├── tools/ # Tool implementations -│ ├── interaction/ -│ ├── io/ -│ ├── system/ -│ └── record/ -└── utils/ # Utilities including logger -``` +- **Anthropic**: Claude models with full tool use support +- **OpenAI**: GPT-4 and other OpenAI models with function calling +- **Ollama**: Local LLM support for privacy and offline use + +### Model Context Protocol (MCP) + +MyCoder Agent supports the Model Context Protocol: + +- **Resource Loading**: Load context from MCP-compatible servers +- **Server Configuration**: Configure multiple MCP servers +- **Tool Integration**: Use MCP-provided tools ## Available Tools -The agent system provides various tools in different categories: +### File & Text Manipulation +- **textEditor**: View, create, and edit files with persistent state + - Commands: view, create, str_replace, insert, undo_edit + - Line number support and partial file viewing + +### System Interaction +- **shellStart**: Execute shell commands with sync/async modes +- **shellMessage**: Interact with running shell processes +- **shellExecute**: One-shot shell command execution +- **listShells**: List all running shell processes + +### Agent Management +- **agentStart**: Create sub-agents for parallel tasks +- **agentMessage**: Send messages to sub-agents +- **agentDone**: Complete the current agent's execution +- **listAgents**: List all running agents + +### Network & Web +- **fetch**: Make HTTP requests to APIs +- **sessionStart**: Start browser automation sessions +- **sessionMessage**: Control browser sessions (navigation, clicking, typing) +- **listSessions**: List all browser sessions + +### Utility Tools +- **sleep**: Pause execution for a specified duration +- **userPrompt**: Request input from the user -- **Interaction Tools**: User prompts, sub-agent creation -- **I/O Tools**: File reading/writing, HTTP requests -- **System Tools**: Shell command execution, process management -- **Browser Tools**: Web automation and scraping capabilities +## Project Structure + +``` +src/ +├── core/ # Core agent and LLM abstraction +│ ├── llm/ # LLM providers and interfaces +│ │ └── providers/ # Anthropic, OpenAI, Ollama implementations +│ ├── mcp/ # Model Context Protocol integration +│ └── toolAgent/ # Tool agent implementation +├── tools/ # Tool implementations +│ ├── agent/ # Sub-agent tools +│ ├── fetch/ # HTTP request tools +│ ├── interaction/ # User interaction tools +│ ├── session/ # Browser automation tools +│ ├── shell/ # Shell execution tools +│ ├── sleep/ # Execution pause tool +│ └── textEditor/ # File manipulation tools +└── utils/ # Utility functions and logger +``` ## Technical Requirements -- Node.js >= 20.0.0 +- Node.js >= 18.0.0 - pnpm >= 10.2.1 +## Browser Automation + +The agent includes powerful browser automation capabilities using Playwright: + +- **Web Navigation**: Visit websites and follow links +- **Content Extraction**: Extract and filter page content +- **Element Interaction**: Click buttons, fill forms, and interact with UI elements +- **Waiting Strategies**: Smart waiting for page loads and element visibility + +## Usage Example + +```typescript +import { toolAgent } from 'mycoder-agent'; +import { textEditorTool } from 'mycoder-agent'; +import { shellStartTool } from 'mycoder-agent'; +import { Logger, LogLevel } from 'mycoder-agent'; + +// Create a logger +const logger = new Logger({ name: 'MyAgent', logLevel: LogLevel.info }); + +// Define available tools +const tools = [textEditorTool, shellStartTool]; + +// Run the agent +const result = await toolAgent( + "Write a simple Node.js HTTP server and save it to server.js", + tools, + { + getSystemPrompt: () => "You are a helpful coding assistant...", + maxIterations: 10, + }, + { + logger, + provider: 'anthropic', + model: 'claude-3-opus-20240229', + apiKey: process.env.ANTHROPIC_API_KEY, + workingDirectory: process.cwd(), + } +); + +console.log('Agent result:', result); +``` + ## Contributing -We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow and guidelines. +We welcome contributions! Please see our [CONTRIBUTING.md](../CONTRIBUTING.md) for development workflow and guidelines. + +## License + +MIT \ No newline at end of file diff --git a/packages/docs/README.md b/packages/docs/README.md index dac5eed..90c0f34 100644 --- a/packages/docs/README.md +++ b/packages/docs/README.md @@ -1,20 +1,48 @@ # MyCoder Documentation -This package contains the official documentation for MyCoder, an AI-powered coding assistant. The documentation is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. +This package contains the official documentation for MyCoder, an AI-powered coding assistant. The documentation is built using [Docusaurus v3](https://docusaurus.io/), a modern static website generator maintained by Meta. ## What's Inside -- **Product Documentation**: Comprehensive guides on how to use MyCoder -- **Getting Started**: Platform-specific setup instructions for Windows, macOS, and Linux -- **Usage Guides**: Detailed information on features and capabilities -- **Blog**: Updates, tutorials, and insights about MyCoder +### Documentation Structure + +- **Core Documentation** + - **Introduction**: Overview of MyCoder and its capabilities + - **Getting Started**: Platform-specific setup instructions for Windows, macOS, and Linux + - **Usage Guides**: Detailed information on features, configuration, and capabilities + - **Examples**: Practical examples of using MyCoder for different scenarios + - **Providers**: Information about supported AI providers (OpenAI, Anthropic, Ollama, XAI) + +- **Blog**: Updates, tutorials, and insights about MyCoder and AI-assisted development + +### Technical Structure + +- **docs/**: Contains all markdown documentation files organized by topic +- **blog/**: Contains blog posts with release notes and usage tips +- **src/**: Custom React components and CSS for the documentation site + - **components/**: Custom React components for the site + - **css/**: Custom styling + - **pages/**: Custom pages including the home page +- **static/**: Static assets like images and icons +- **.docusaurus/**: Build cache (gitignored) +- **build/**: Output directory for the built documentation site + +## Features + +- **Responsive Design**: Works on desktop and mobile devices +- **Search Functionality**: Built-in search for documentation +- **Versioning Support**: Ability to maintain documentation for different versions +- **Blog with RSS Feed**: Integrated blog with RSS support +- **Analytics Integration**: Google Analytics for tracking site usage +- **Error Tracking**: Sentry integration for monitoring errors +- **Docker Deployment**: Containerized deployment option ## Development ### Prerequisites - Node.js version 18.0 or above -- pnpm (recommended) +- pnpm (recommended package manager) ### Local Development @@ -22,8 +50,13 @@ This package contains the official documentation for MyCoder, an AI-powered codi # Navigate to the docs package cd packages/docs +# Install dependencies +pnpm install + # Start the development server pnpm start +# or +pnpm dev ``` This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. @@ -37,9 +70,47 @@ pnpm build This command generates static content into the `build` directory and can be served using any static contents hosting service. -### Deployment +### Serve Built Site Locally + +```bash +# Serve the built website locally +pnpm serve +``` + +### Other Commands + +```bash +# Clean the build cache +pnpm clean + +# Clean everything including node_modules +pnpm clean:all + +# Type checking +pnpm typecheck + +# Generate translations +pnpm write-translations + +# Generate heading IDs +pnpm write-heading-ids +``` + +## Docker Deployment + +The documentation site can be deployed using Docker: -The documentation site is automatically deployed when changes are pushed to the `docs-release` branch. +```bash +# Build the Docker image +docker build -t mycoder-docs . + +# Run the container +docker run -p 8080:8080 mycoder-docs +``` + +## Continuous Deployment + +The documentation site is automatically deployed when changes are pushed to the `docs-release` branch. The deployment process uses semantic-release for versioning and release management. ## Contributing @@ -47,14 +118,45 @@ We welcome contributions to improve the documentation: 1. Create a feature branch (`git checkout -b feature/amazing-improvement`) 2. Make your changes -3. Commit your changes (`git commit -m 'Add some amazing improvement'`) +3. Commit your changes following [Conventional Commits](https://www.conventionalcommits.org/) format 4. Push to the branch (`git push origin feature/amazing-improvement`) 5. Open a Pull Request +### Adding New Documentation + +1. Create markdown files in the appropriate directory under `docs/` +2. The sidebar is automatically generated based on the file structure +3. Use front matter to customize the page title, description, and other metadata + +### Adding Blog Posts + +Create new markdown files in the `blog/` directory with the following front matter: + +```markdown +--- +slug: your-post-slug +title: Your Post Title +authors: [yourname] +tags: [tag1, tag2] +--- + +Your content here... + + + +More content here (this part won't appear in the blog list preview) +``` + ## License This project is licensed under the MIT License - see the LICENSE file for details. ## Contact -If you have questions or feedback, please join our [Discord community](https://discord.gg/5K6TYrHGHt). +If you have questions or feedback, please join our [Discord community](https://discord.gg/5K6TYrHGHt) or follow us on [X (Twitter)](https://twitter.com/mycoderAI). + +## Links + +- [MyCoder Website](https://mycoder.ai) +- [GitHub Repository](https://github.com/drivecore/mycoder) +- [Documentation Site](https://docs.mycoder.ai) \ No newline at end of file