A controllable CLI agent for generating and running tests for Python operators and APIs (such as PyTorch and TensorFlow) through a fixed, human-approved workflow.
- π§ Tool Mode (Chat): Ad hoc queries and file operations
- π Workflow Mode: A 7-stage intelligent test generation pipeline
- 7-stage pipeline: Function understanding β requirements generation β test plan design β code generation β test execution β result analysis β report generation
- Smart feedback: Supports natural-language feedback and special commands (
/regenerate,/goto,/retry) - Persistent state: Supports interruption recovery, with versioned artifact management
- Custom execution: Configurable pytest commands, environment variables, and dependency installation
cd ATTest
pip install -e .attest chat --workspace ~/my-project# Interactive mode (recommended)
attest run -f torch.nn.functional.relu --workspace ./my-project/torch.nn.functional.relu
# Fully automatic mode
attest run -f torch.add --mode full-auto --workspace ./my-project/torch.add
# Fully automatic mode with multi-round iteration (3 rounds)
attest run -f torch.add --mode full-auto --epoch 3
# Specify the project root when it differs from workspace
attest run -f torch.add --workspace ./my-project --project-root ./my-project/src
# Resume an interrupted workflow
attest run -f torch.add --resume-
WORKFLOW_GUIDE.md - Complete usage guide (recommended)
- Detailed workflow mode walkthrough
- Custom build command configuration
- Testing and debugging
- Extension and customization
-
QUICK_REFERENCE.md - Quick reference card
- Common command cheat sheet
- Workflow interactive commands
- Configuration examples
-
USAGE.md - Chat mode usage guide
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ATTest Workflow - torch.add (python) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β [β] 1. Understand Function β
β [β] 2. Generate Requirements β
β [βΆ] 3. Design Test Plan β Current Stage β
β [ ] 4. Generate Code β
β [ ] 5. Execute Tests β
β [ ] 6. Analyze Results β
β [ ] 7. Generate Report β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
After each stage completes, you can:
- Press
Enterto continue - Use
/regenerateto regenerate the current stage - Use
/goto <stage>to jump to another stage - Provide natural-language feedback for smart interpretation
When you need to adjust the pytest command or environment variables, edit ~/.attest_cli/config.json:
{
"api": {
"model": "deepseek-chat",
"base_url": "https://api.deepseek.com/v1",
"api_key": "your-api-key",
"temperature": 0.2,
"max_tokens": 4096
},
"preferences": {
"auto_approve": false
},
"project": {
"root": ".",
"test_file_template": "tests/test_{target_slug}.py",
"build_dir": "",
"output_binary_template": ""
},
"commands": {
"compile": "",
"install": "",
"run_test": "PYTHONPATH={project_root}:$PYTHONPATH pytest -q {test_file_path}"
}
}Available variables:
{target}/{target_slug}- Target function FQN and its slug{project_root}- Project root directory{test_file_path}- Generated pytest file path
See WORKFLOW_GUIDE.md - Custom Build Commands for details.
attest config list # Show all configuration values
attest config set KEY VALUE # Set a configuration value
attest config get KEY # Get a configuration valueattest sessions list # List all sessions
attest sessions clear ID # Clear a specific sessionattest chat [--workspace DIR] [--auto-approve]attest run -f package.module:function \
[--workspace DIR] \
[--project-root DIR] \
[--mode interactive|full-auto] \
[--epoch N] \
[--resume]Arguments:
-f, --func: Fully qualified target function name (required)--workspace: Working directory, defaults to the current directory--project-root: Project root directory, defaults to the same value asworkspace--mode: Run mode, eitherinteractiveorfull-auto, defaults tointeractive--epoch: Number of iteration rounds in full-auto mode; afteranalyze_results, the workflow loops back togenerate_code; defaults to1--resume: Resume an interrupted workflow
- Create a tool class in
src/attest_cli/tools/builtin.py - Register it in
src/attest_cli/tools/runner.py - Add it to a stage's
toolslist
Edit the corresponding stage file, for example src/attest_cli/workflow/stages/requirements.py, and update _get_prompt_template().
- Create
src/attest_cli/workflow/stages/your_stage.py - Register it in
stages/__init__.py - Add it to
STAGE_NAMESinworkflow/engine.py
See WORKFLOW_GUIDE.md - Extension and Customization for details.
ATTest/
βββ src/attest_cli/
β βββ cli.py # CLI entry point
β βββ config.py # Configuration management
β βββ llm.py # LLM client
β βββ session.py # Session management
β βββ chat.py # Chat mode
β βββ tools/ # Tool system
β β βββ base.py
β β βββ builtin.py
β β βββ runner.py
β βββ workflow/ # Workflow engine
β βββ engine.py # Main controller
β βββ state.py # State management
β βββ stage.py # Stage base class
β βββ supervisor.py # Feedback interpretation
β βββ display.py # Progress display
β βββ stages/ # Individual stages
β βββ understand.py
β βββ requirements.py
β βββ planning.py
β βββ codegen.py
β βββ execution.py
β βββ analysis.py
β βββ report.py
βββ WORKFLOW_GUIDE.md # Complete usage guide
βββ QUICK_REFERENCE.md # Quick reference
βββ USAGE.md # Chat mode guide
# Test the core framework
python test_milestone1.py
# Test custom commands
python test_custom_commands.pyattest run -f torch.add --workspace ~/my-project --mode full-autoAutomatically generates pytest cases, executes them, and produces a test report.
attest config set commands.run_test "PYTHONPATH={project_root}:$PYTHONPATH pytest -q {test_file_path} -k gpu"
attest run -f torch.add --workspace ~/my-project --mode full-autoUses a custom command to run the generated tests, which can be reused in a virtual environment or CI pipeline.
attest chat --workspace ~/my-projectTemporarily inspect or analyze files, or generate small testing snippets.
Contributions are welcome. Main extension points include:
- New tools (file operations, analysis utilities, and so on)
- New workflow stages (performance testing, coverage analysis, and so on)
- Improved prompt templates
- Better error handling
MIT
Inspired by:
- CliAgent - Flow-first design
- Cougar-CLI - Config and session management
- mini-kode - Permission-aware tool execution
Quick start: See WORKFLOW_GUIDE.md for detailed usage.