โ๏ธ Configuration โ Early CLI
The Early CLI (@earlyai/cli) mirrors GitHub Action options but is CI-agnostic.
Use it in Jenkins, CircleCI, GitLab, Bitbucket, or locally.
๐ Required Inputsโ
These inputs are required for both JavaScript/TypeScript and Python projects:
| Variable | CLI Flag | Description | Required | Default |
|---|---|---|---|---|
| API_KEY | -k, --api-key | Early API key | โ Yes | โ |
| TOKEN | -t, --token | GitHub token with PR access | โ Yes | โ |
| PR_NUMBER | --pr-number | PR number | โ Yes | โ |
| REF_NAME | --ref-name | PR branch | โ Yes | โ |
For tokens and permissions, see:
โ๏ธ Optional Inputsโ
- JavaScript / TypeScript
- Python
| Variable | CLI Flag | Description | Default |
|---|---|---|---|
| TEST_STRUCTURE | -s, --test-structure | rootFolder or siblingFolder | siblingFolder |
| TEST_FRAMEWORK | -f, --test-framework | jest, mocha (planned), vitest (planned) | jest |
| TEST_FILE_SUFFIX | --test-suffix | spec or test | test |
| TEST_FILE_NAMING | --test-file-naming | camelCase or kebabCase | camelCase |
| CHANGED_METHODS_ONLY | --changed-methods-only | Generate tests for changed code only. See Changed methods only | true |
| MAX_TESTABLES | --max-testables | MAX number of methods to generate tests for. See MAX testables | 5 |
| SKIP_COVERAGE_AFTER | --skip-coverage-after | Skip calculating coverage after test generation. See Skip coverage after | false |
| MAX_CONCURRENCY | -c, --max-concurrency | Number of concurrent workers (1โ4) | 1 |
| AUTO_COMMIT | --auto-commit | true or false | true |
| TEST_COMMAND | --test-command | Command to validate generated tests | See Agent Jest Commands โ |
| COVERAGE_COMMAND | --coverage-command | Command to collect coverage | See Agent Jest Commands โ |
| CONTINUE-ON_TEST_ERRORS | --continue-on-test-errors | continue the operation if current tests fail. | See Agent Jest Commands - tests fail โ |
| LINT_COMMAND | --lint-command | Linting command. See Lint & Format | npx --no eslint $early_filename --fix |
| PRETTIER_COMMAND | --prettier-command | Prettier formatting command. See Lint & Format | npx --no prettier $early_filename --write |
| GIT_USER_EMAIL | --git-user-email | Git commit author email | โ |
| GIT_USER_NAME | --git-user-name | Git commit author name | โ |
| SCM_PROVIDER | --scm-provider | github (default), bitbucket, etc. | github |
โ ๏ธ When using
MAX_CONCURRENCY=4, set:export NODE_OPTIONS="--max-old-space-size=5120"
| Variable | CLI Flag | Description | Default |
|---|---|---|---|
| TEST_FRAMEWORK | -f, --test-framework | Test framework. Auto-set to pytest for Python. | pytest |
| TEST_STRUCTURE | -s, --test-structure | Folder structure: siblingFolder or rootFolder. | siblingFolder |
| TEST_FILE_NAMING | --test-file-naming | Naming style: camelCase or kebabCase. | camelCase |
| MAX_TESTABLES | --max-testables | Max number of methods to generate tests for. | 5 |
| MAX_CONCURRENCY | -c, --max-concurrency | Parallel workers (1โ3). | 3 |
| AUTO_COMMIT | --auto-commit | Commit and push generated test files: true or false. | true |
| AUTO_COMMIT_SKIP_CI | --auto-commit-skip-ci | Append [skip ci] to the auto-commit message. | true |
| GIT_USER_EMAIL | --git-user-email | Commit author email. | Early-Agent[bot] noreply address |
| GIT_USER_NAME | --git-user-name | Commit author name. | early-agent[bot] |
| SCM_PROVIDER | --scm-provider | github or bitbucket. See SCM Support | github |
Note: Options like
--test-command,--coverage-command,--lint-command, and--prettier-commandare not yet supported for Python.
Auto-commit and required inputsโ
When AUTO_COMMIT is enabled (the default), the CLI checks out the branch specified by REF_NAME, commits any generated .early. test files, and pushes to the remote. This requires:
TOKENโ used to authenticate thegit push. The token must have write access to the repository.REF_NAMEโ the branch to check out and push to. Must exist on the remote.
Set AUTO_COMMIT=false if you want to inspect generated tests before committing, or if your CI pipeline handles commits separately.
๐งน Lint & Format Commandsโ
- JavaScript / TypeScript
- Python
Define these if your repo uses lint-staged, Husky, or CI linting.
LINT_COMMAND="npx --no eslint $early_filename --fix"
PRETTIER_COMMAND="npx --no prettier $early_filename --write"
See - Linting & Formatting
Lint and formatting hooks are not yet supported for Python projects. Generated test files follow standard pytest conventions.
๐ง Memory & Concurrencyโ
- JavaScript / TypeScript
- Python
Default: MAX_CONCURRENCY=4
If your runner crashes:
export NODE_OPTIONS="--max-old-space-size=5120"
To reduce memory:
export MAX_CONCURRENCY=2
Do not exceed --max-old-space-size=6000 on standard runners.
See Memory Tuning
Default: MAX_CONCURRENCY=3
Python test generation does not require NODE_OPTIONS memory tuning. The py-agent manages its own memory usage.
๐งช Example: Local Executionโ
- JavaScript / TypeScript
- Python
export API_KEY=sk-abc123
export TOKEN=ghp-xyz456
export PR_NUMBER=14
export HEAD_REF=feature/refactor
export BASE_REF=main
export GIT_HOST=github.com
export GIT_ORG=earlyai
export GIT_REPO=backend
export SCM_PROVIDER=github
export AUTO_COMMIT=true
export TEST_FRAMEWORK=jest
export MAX_CONCURRENCY=4
export NODE_OPTIONS="--max-old-space-size=5120"
export LINT_COMMAND="npx --no eslint $early_filename --fix"
export PRETTIER_COMMAND="npx --no prettier $early_filename --write"
early generate-pr
export API_KEY=sk-abc123
export TOKEN=ghp-xyz456
export PR_NUMBER=14
export HEAD_REF=feature/refactor
export BASE_REF=main
export GIT_HOST=github.com
export GIT_ORG=earlyai
export GIT_REPO=backend
export SCM_PROVIDER=github
export AUTO_COMMIT=true
export TEST_FRAMEWORK=pytest
export MAX_CONCURRENCY=3
early generate-pr
โ Exit Codesโ
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Configuration/environment error |
| 2 | Generation error |
| 3 | Commit/push failure |
๐ Next: Troubleshooting โ