Skip to content

Goku007007/ai-test-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Test Generator (Pre-commit)

This project includes a pre-commit workflow that uses Codex to generate or update tests for the current git changes, then runs only those managed tests before allowing a commit.

What it does

  • Builds or refreshes test-memory.json from package.json to capture framework, versions, and test setup.
  • Sends the current git diff and test-memory.json to Codex for test generation or updates.
  • Tracks all test files written by the hook in test-memory.json and runs only those files.
  • Stages generated tests and test-memory.json automatically.
  • Blocks the commit if Codex fails or managed tests fail.

How it works

  1. Read package.json to detect framework, language, and test setup.
  2. Load or create test-memory.json.
  3. Build the git diff (staged + unstaged).
  4. Run codex exec with the diff and memory.
  5. Register any changed tests in test-memory.json.
  6. Run npm test -- --watchAll=false --runTestsByPath <managed_files>.
  7. Allow the commit only if tests pass.

Files

The workflow generates and maintains internal metadata and logs as part of the pre-commit process.

Setup

chmod +x scripts/ai_test_gen_precommit.py
cat > .git/hooks/pre-commit <<'SH'
#!/bin/sh
python3 scripts/ai_test_gen_precommit.py
SH
chmod +x .git/hooks/pre-commit

Configuration

  • CODEX_CMD to override the Codex CLI (default: codex exec --color=never).
  • CODEX_TIMEOUT to limit Codex runtime in seconds (default: 300).

Screenshot

Codex pre-commit run

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors