Skip to main content

Development

Learn how to set up your development environment and contribute to the 0G AI SDK.

Prerequisites

Before you begin, ensure you have the following installed:
  • Node.js (v18 or higher)
  • npm, yarn, or pnpm
  • TypeScript (v5.0 or higher)

Project Setup

  1. Clone the repository:
  1. Install dependencies:
  1. Build the project:
  1. Run in development mode:

Project Structure

Building

The project uses TypeScript for compilation:

Testing

Run the example files to test functionality:

Code Style

The project follows these conventions:
  • TypeScript: Strict mode enabled
  • Naming: PascalCase for classes, camelCase for functions/variables
  • Exports: Use named exports for better tree-shaking
  • Documentation: JSDoc comments for all public APIs

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests if applicable
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

API Design Principles

When contributing to the SDK, follow these principles:

Consistency

  • Use consistent naming patterns across all modules
  • Maintain similar parameter structures for related functions
  • Follow the established error handling patterns

Simplicity

  • Provide sensible defaults for optional parameters
  • Keep the public API surface minimal and focused
  • Use builder patterns for complex configurations

TypeScript First

  • Provide comprehensive type definitions
  • Use generics where appropriate for type safety
  • Export all necessary types for consumers

Release Process

  1. Update version in package.json
  2. Update CHANGELOG.md with new features and fixes
  3. Run npm run build to ensure everything compiles
  4. Create a git tag: git tag v1.x.x
  5. Push tags: git push --tags
  6. Publish to npm: npm publish

Getting Help