# Development

The **Development** section provides guidance on setting up your environment for contributing to or extending the AINU framework. This includes running the project locally, testing, and adding new features.

***

## **1. Setting Up the Development Environment**

To start developing with AINU, clone the repository and install the dependencies:

```bash
git clone https://github.com/AINU-Framework/ainu.git
cd ainu
npm install
```

Ensure you have Node.js (v18 or higher) and npm installed on your system.

***

## **2. Project Structure**

The AINU repository is organized into the following key directories:

* `src`: Contains the source code for the framework, including:
  * `agent/`: Core logic for agents.
  * `providers/`: Implementations for supported AI providers (e.g., Anthropic, OpenAI).
  * `tools/`: Tooling system for extending agent functionality.
  * `mcp/`: Model Context Protocol integration.
  * `utils/`: Utility functions and helpers.
* `tests`: Contains unit tests for all major components, organized by feature:
  * `agent/`: Tests for agent functionality.
  * `providers/`: Tests for Anthropic, OpenAI, and XAI providers.
  * `tools/`: Tests for tools and their integration with agents.
  * `mcp/`: Tests for MCP-related functionality.
  * `util/`: Tests for utility functions.
* `dist`: The compiled output directory (generated after running `npm run build`).

***

## **3. Running the Project Locally**

To run the project in development mode, use the following command:

```bash
npm run dev
```

This will start the project using `tsx` with hot-reloading enabled. You can modify files in the src directory, and changes will automatically reflect.

This will automatically run the main `index.ts` file. You can quickly prototype using this file with little friction.

***

## **4. Building the Project**

To compile the TypeScript code into JavaScript, run:

```bash
npm run build
```

This will generate the output in the dist directory.

***

## **5. Testing**

AINU uses Jest for testing. To run all tests, use:

```bash
npm test
```

You can also run tests for specific components:

* **Agents**:

  ```bash
  npm run test:agents
  ```
* **Providers**:

  ```bash
  npm run test:providers
  ```
* **Tools**:

  ```bash
  npm run test:tools
  ```
* **MCP**:

  ```bash
  npm run test:mcp
  ```
* **Utilities**:

  ```bash
  npm run test:utils
  ```

***

## **6. Adding New Features**

To extend AINU, follow these steps:

1. **Create a New Feature**:\
   Add your new feature to the appropriate directory in src. For example:
   * Add a new provider in providers.
   * Add a new tool in tools.
2. **Write Tests**:\
   Add unit tests for your feature in the corresponding directory in tests. For example:
   * Add tests for a new provider in providers.
3. **Run Tests**:\
   Ensure all tests pass before committing your changes.
4. **Build and Verify**:\
   Build the project and verify that your feature works as expected.

***

## **7. Documentation**

AINU uses TypeDoc to generate documentation. To update the documentation, run:

```bash
npm run docs
```

This will generate updated documentation in the docs directory.

***

## **8. Contributing**

If you plan to contribute to AINU, follow these steps:

1. Fork the repository and create a new branch for your feature or bug fix.
2. Make your changes and ensure all existing and new tests pass.
3. Submit a pull request with a detailed description of your changes.

***

With this guide, you’re ready to start developing and contributing to AINU. Let me know if you'd like to expand on any of these sections!
