โ๏ธ 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โ
| 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 | โ |
| HEAD_REF | --head-ref | PR branch | โ Yes | โ |
For tokens and permissions, see:
โ๏ธ Optional Inputsโ
| 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 |
| MAX_CONCURRENCY | -c, --max-concurrency | Number of concurrent workers (1โ4) | 4 |
| 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_ORG | --git-org | GitHub org or username | โ |
| GIT_REPO | --git-repo | GitHub repo name | โ |
| 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"
๐งน Lint & Format Commandsโ
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
๐ง Memory & Concurrencyโ
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
๐งช Example: Local Executionโ
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
โ Exit Codesโ
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Configuration/environment error |
| 2 | Generation error |
| 3 | Commit/push failure |
๐ Next: Troubleshooting โ