Previous git clone commands were: git clone https://github.com/YOUR_USERNAME/sdk-v3.git cd sdk-v3 which were not appropriate and are now fixed to: git clone https://github.com/YOUR_USERNAME/composio.git cd composio
7.6 KiB
Contributing to Composio SDK
Thank you for your interest in contributing to Composio SDK! This document provides guidelines and instructions for contributing to the project.
Table of Contents
- Development Setup
- Project Structure
- Coding Standards
- Documentation Requirements
- Pull Request Process
- Creating New Providers
- Testing Guidelines
- Release Process
Development Setup
Prerequisites
Getting Started
-
Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/composio.git cd composio -
Install dependencies:
pnpm install -
Build the project:
pnpm build -
Run tests:
pnpm test
Development Commands
# Lint code
pnpm lint
# Fix linting issues
pnpm lint:fix
# Format code
pnpm format
# Create a new provider
pnpm create:provider <provider-name> [--agentic]
# Create a new example
pnpm create:example <example-name>
# Check peer dependencies
pnpm check:peer-deps
# Update peer dependencies
pnpm update:peer-deps
Project Structure
composio/
├── packages/ # Main packages directory
│ ├── core/ # Core SDK package
│ └── providers/ # Provider implementations
├── examples/ # Example implementations
├── docs/ # Documentation
├── scripts/ # Development and build scripts
└── .github/ # GitHub configuration
Coding Standards
File Headers
Every source file must include a header comment with:
/**
* @file Description of what this file does/contains
* @module path/to/module
* @description Detailed description of the file's purpose
*
* @author Original Author <email@example.com>
* @contributors
* - Contributor Name <email@example.com>
*
* @copyright Composio 2024
* @license ISC
*
* @see {@link https://related.documentation.link}
* @see {@link https://another.related.link}
*/
Function Documentation
Every user-facing function must include:
- TSDoc documentation
- Example usage
- Parameter and return type descriptions
- Error cases
Example:
/**
* Executes a tool with the given parameters.
*
* @description
* This function executes a tool with the provided parameters and returns the result.
* It handles authentication, parameter validation, and error cases automatically.
*
* @example
* ```typescript
* const result = await executeTool('GMAIL_SEND_EMAIL', {
* userId: 'user123',
* arguments: {
* to: 'recipient@example.com',
* subject: 'Hello',
* body: 'Message content'
* }
* });
* ```
*
* @param {string} toolId - The unique identifier of the tool to execute
* @param {ExecuteToolOptions} options - Tool execution options
* @returns {Promise<ExecuteToolResult>} The result of the tool execution
*
* @throws {ToolNotFoundError} When the specified tool doesn't exist
* @throws {ValidationError} When required parameters are missing
* @throws {AuthenticationError} When authentication fails
*
* @see {@link https://docs.composio.dev/api/tools#execute}
*/
export async function executeTool(
toolId: string,
options: ExecuteToolOptions
): Promise<ExecuteToolResult> {
// Implementation
}
Code Style
- Use TypeScript for all new code
- Follow the existing code style in the repository
- Use ESLint and Prettier for code formatting
- Use meaningful variable and function names
- Keep functions small and focused
- Write unit tests for all new code
- Use async/await instead of Promises
- Use named exports instead of default exports
- Use const assertions for constants
- Use type assertions sparingly
Error Handling
- Use custom error classes
- Include meaningful error messages
- Document error cases in TSDoc
- Include error codes for API errors
- Log errors appropriately
Example:
/**
* Custom error for tool execution failures.
*/
export class ToolExecutionError extends ComposioError {
constructor(
message: string,
public readonly toolId: string,
public readonly cause?: Error
) {
super(message, 'TOOL_EXECUTION_ERROR');
this.name = 'ToolExecutionError';
}
}
Documentation Requirements
Package Documentation
Each package must include:
-
README.md with:
- Package description
- Installation instructions
- Usage examples
- API reference
- Environment variables
- Contributing guidelines
-
API documentation:
- TSDoc for all public APIs
- Example code snippets
- Error handling documentation
- Type definitions
-
Example implementations:
- Basic usage example
- Advanced usage examples
- Integration examples
Provider Documentation
Provider packages must additionally include:
- Provider-specific setup instructions
- Authentication requirements
- Supported features
- Limitations and constraints
- Integration examples
- Streaming support details
- Error handling examples
Pull Request Process
-
Create a new branch for your changes:
git checkout -b feature/your-feature-name -
Make your changes following the coding standards
-
Add tests for new functionality
-
Update documentation as needed
-
Create a changeset:
pnpm changeset -
Push your changes and create a pull request
-
Wait for review and address any feedback
Creating New Providers
-
Use the provider creation script:
pnpm create:provider my-provider [--agentic] -
Implement required methods:
- For non-agentic providers:
wrapToolandwrapTools, and helper functions - For agentic providers:
wrapTool,wrapTools, and execution handlers
- For non-agentic providers:
-
Add comprehensive tests
-
Add provider documentation
-
Create example implementations
Testing Guidelines
- Write unit tests for all new code
- Include integration tests for providers
- Test error cases
- Test edge cases
- Use mocks appropriately
- Test streaming functionality
- Test with different Node.js versions
Example test:
describe('ToolExecution', () => {
it('should execute a tool successfully', async () => {
const result = await executeTool('TEST_TOOL', {
userId: 'user123',
arguments: { test: true },
});
expect(result.successful).toBe(true);
});
it('should handle errors appropriately', async () => {
await expect(
executeTool('INVALID_TOOL', {
userId: 'user123',
arguments: {},
})
).rejects.toThrow(ToolNotFoundError);
});
});
Release Process
-
Create a release branch:
git checkout -b release/v1.2.3 -
Update version numbers:
pnpm changeset version -
Update CHANGELOG.md
-
Create a release commit:
git commit -am "Release v1.2.3" -
Create a pull request for the release
-
After approval, merge and tag:
git tag v1.2.3 git push origin v1.2.3 -
Publish to npm:
pnpm changeset publish
Questions and Support
- Join our Discord Community
- Check our Documentation
- File issues on GitHub
License
By contributing to Composio SDK, you agree that your contributions will be licensed under the ISC License.