Codebase Development Guide
This document outlines the patterns and conventions to follow when working with this codebase.
Schema Patterns
Schema Definitions
- All schemas must be defined in
src/schemas/
directory - Each schema should have:
- A TypeScript interface
- Added to
SchemaType
enum inSchemaTypes.ts
- Schema files should:
- Be named
<SchemaName>Response.ts
for response types - Export both interface and schema (if needed)
- Include JSDoc comments for all properties
Example schema file:
export interface ExampleResponse {
/**
* Description of property
*/
property: string;
}
Schema Usage
- Always use
getGeneratedSchema()
to get schema definitions - Use
StructuredOutputPrompt
for LLM requests - Schema types should match the response interface
Executor Patterns
Executor Structure
- Must implement
StepExecutor
interface - Use
@StepExecutorDecorator
for registration - Follow dependency injection pattern in constructor
- Use
modelHelpers.generate()
for LLM interactions
Common Patterns
- URL handling:
- Use
scrapeHelper.normalizeUrl()
- Track visited URLs with Set
- Validate URLs with
new URL()
- Artifact management:
- Use
artifactManager.saveArtifact()
- Include metadata with:
- URL
- Task/step
- Project ID
- Token usage
- Error handling:
- Use Logger.error()
- Return meaningful error responses
- Catch and handle specific errors
Testing Guidelines
- Tests should:
- Mock external dependencies
- Test error cases
- Verify schema usage
- Check token tracking
- Use Jest for testing
- Follow Arrange-Act-Assert pattern
Documentation Standards
- Add JSDoc comments for:
- All public methods
- Interface properties
- Complex logic
- Use markdown format for documentation
- Keep documentation in
/docs
folder - Update documentation with changes
Code Style
- Follow TypeScript best practices
- Use async/await for promises
- Prefer functional patterns over imperative
- Keep methods focused and small
- Use descriptive variable names
- Follow existing code style and patterns
This guide documents the key patterns and conventions used in the codebase. Let me know if you'd like me to add any additional sections or details!