An open API service indexing awesome lists of open source software.

https://github.com/CodyBontecou/typescript-llm4tdd-example


https://github.com/CodyBontecou/typescript-llm4tdd-example

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# LLM4TDD: TypeScript Example

This project demonstrates Test-Driven Development (TDD) using Large Language Models (LLMs). The workflow consists of three main steps:

1. **Generate Test Skeleton**: Create a basic structure for tests
2. **Generate Complete Tests**: Flesh out the test skeleton with actual test cases
3. **Generate Function Implementation**: Create a function that passes all the tests

## Workflow

```mermaid
graph TD
A[Test skeleton created] --> B[Complete tests generated]
B --> C[Function implementation generated]
C --> D[Tests passing]
```

## Usage

Run the complete TDD workflow:

```bash
npm run tdd
```

This will:
1. Generate a test skeleton for a random function
2. Generate a complete test file from the skeleton
3. Generate a function implementation that passes all the tests

## Individual Steps

You can also run each step individually:

```bash
# Generate a test skeleton
npx tsx generateTestSkeleton.ts

# Generate a complete test from a skeleton
npx tsx generateTestFileFromSkeleton.ts

# Generate a function implementation from a test file
npx tsx generateFunctionFromSpec.ts
```

## Utilities

The project includes several utility functions in the `utils` directory:

- `generateTestSkeleton.ts`: Creates a test skeleton using OpenAI
- `generateTestFromSkeleton.ts`: Generates complete tests from a skeleton
- `generateFunctionFromSpec.ts`: Creates a function implementation that passes tests
- `chat.ts`: Utility for interacting with OpenAI
- `readFileContent.ts`: Utility for reading file content
- `writeFileContent.ts`: Utility for writing file content
- `runTests.ts`: Utility for running tests

## Requirements

- Node.js
- npm
- OpenAI API key (set as OPENAI_API_KEY environment variable)