Thank you for your interest in contributing to the Agentic Edge Functions repository! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Workflow
- Pull Request Process
- Coding Standards
- Documentation Guidelines
- Testing Guidelines
- Security Guidelines
- Community
This project adheres to a Code of Conduct that all contributors are expected to follow. Please read and understand it before contributing.
- Be respectful and inclusive
- Value different viewpoints and experiences
- Give and gracefully accept constructive feedback
- Focus on what is best for the community
- Show empathy towards other community members
Before you begin, ensure you have the following installed:
- Node.js (v16 or later)
- Deno (v1.28 or later)
- Supabase CLI
- Git
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/your-username/edge-agents.git cd edge-agents
- Add the original repository as an upstream remote:
git remote add upstream https://github.com/agentics-foundation/edge-agents.git
- Set up the development environment:
# Install Supabase CLI npm install -g supabase # Start Supabase local development supabase start
We follow a simplified Git workflow:
main
- The main branch containing stable codefeature/*
- Feature branches for new features or enhancementsbugfix/*
- Bugfix branches for bug fixesdocs/*
- Documentation branches for documentation changes
-
Ensure your fork is up to date:
git checkout main git pull upstream main
-
Create a new branch:
# For a new feature git checkout -b feature/your-feature-name # For a bug fix git checkout -b bugfix/issue-number-description # For documentation changes git checkout -b docs/what-you-are-documenting
-
Make your changes, following the coding standards
-
Test your changes locally:
# Serve the functions locally supabase functions serve --no-verify-jwt
-
Commit your changes:
git add . git commit -m "Your descriptive commit message"
-
Push your changes to your fork:
git push origin your-branch-name
- Create a pull request from your branch to the main repository's
main
branch - Fill in the pull request template with all required information
- Ensure all checks pass (linting, tests, etc.)
- Request a review from a maintainer
- Address any feedback or requested changes
- Once approved, a maintainer will merge your pull request
When creating a pull request, please include:
- A clear and descriptive title
- A detailed description of the changes
- References to any related issues
- Screenshots or examples if applicable
- Any breaking changes or dependencies
- Testing steps or considerations
We follow a consistent coding style across the project:
- Use TypeScript for all new code
- Follow the Deno Style Guide
- Use 2 spaces for indentation
- Use semicolons at the end of statements
- Use single quotes for strings
- Use camelCase for variables and functions
- Use PascalCase for classes and interfaces
- Use UPPER_CASE for constants
// Good example
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
const MAX_RETRIES = 3;
interface UserData {
id: string;
name: string;
email: string;
}
class UserService {
private baseUrl: string;
constructor(baseUrl: string) {
this.baseUrl = baseUrl;
}
async getUser(id: string): Promise<UserData> {
const response = await fetch(`${this.baseUrl}/users/${id}`);
return response.json();
}
}
serve(async (req) => {
const { id } = await req.json();
const userService = new UserService('https://api.example.com');
try {
const user = await userService.getUser(id);
return new Response(JSON.stringify(user), {
headers: { 'Content-Type': 'application/json' }
});
} catch (error) {
return new Response(JSON.stringify({ error: error.message }), {
status: 500,
headers: { 'Content-Type': 'application/json' }
});
}
});
- Write self-documenting code with clear variable and function names
- Keep functions small and focused on a single responsibility
- Avoid deep nesting of conditionals and loops
- Use early returns to reduce nesting
- Handle errors appropriately
- Add comments for complex logic, but prefer readable code over excessive comments
Good documentation is crucial for the project's usability and maintainability.
Each edge function should include:
-
A README.md file in the function directory explaining:
- Purpose of the function
- Input parameters and expected format
- Response format
- Example usage
- Any dependencies or requirements
-
Code comments for complex logic
-
TypeScript types/interfaces for all inputs and outputs
# User Authentication Function
This function handles user authentication using JWT tokens.
## Input
```json
{
"email": "user@example.com",
"password": "password123"
}
Success (200):
{
"token": "jwt-token-here",
"user": {
"id": "user-id",
"email": "user@example.com",
"name": "User Name"
}
}
Error (401):
{
"error": "Invalid credentials"
}
curl -X POST https://your-project-ref.supabase.co/functions/v1/auth \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'
JWT_SECRET
: Secret key for signing JWT tokens
## Testing Guidelines
### Types of Tests
We encourage writing different types of tests:
1. **Unit Tests**: Test individual functions or components in isolation
2. **Integration Tests**: Test interactions between components
3. **End-to-End Tests**: Test complete workflows
### Writing Tests
For Deno functions, use the built-in testing framework:
```typescript
// user_service_test.ts
import { assertEquals } from 'https://deno.land/std@0.168.0/testing/asserts.ts';
import { UserService } from './user_service.ts';
Deno.test('UserService.getUser returns user data', async () => {
// Mock fetch
globalThis.fetch = async (url: string) => {
return {
json: async () => ({ id: '123', name: 'Test User', email: 'test@example.com' })
} as Response;
};
const userService = new UserService('https://api.example.com');
const user = await userService.getUser('123');
assertEquals(user.id, '123');
assertEquals(user.name, 'Test User');
assertEquals(user.email, 'test@example.com');
});
# Run all tests
deno test
# Run tests with coverage
deno test --coverage
# Run a specific test file
deno test user_service_test.ts
Security is a top priority for this project. Please follow these guidelines:
- Never hardcode sensitive information (API keys, passwords, etc.)
- Use environment variables for all secrets
- Validate and sanitize all user inputs
- Implement proper authentication and authorization
- Follow the principle of least privilege
- Keep dependencies up to date
If you discover a security vulnerability, please do NOT open an issue. Instead, email security@agentics.org with details about the vulnerability.
- GitHub Issues: For bug reports, feature requests, and discussions
- Discord: For real-time communication and community support
- Email: For private communications and security issues
All contributors will be recognized in the project's contributors list. We value and appreciate all contributions, whether they're code, documentation, bug reports, or feature suggestions.
Created by rUv, Agentics Foundation founder.