https://github.com/CodyBontecou/typescript-llm4tdd-example
https://github.com/CodyBontecou/typescript-llm4tdd-example
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/CodyBontecou/typescript-llm4tdd-example
- Owner: CodyBontecou
- Created: 2025-03-04T01:23:36.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-10T19:55:47.000Z (2 months ago)
- Last Synced: 2025-03-11T14:47:43.004Z (2 months ago)
- Language: TypeScript
- Size: 83 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)