Skip to content

iSEngLab/ATTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ATTest

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.

✨ Key Features

Dual-Mode Operation

  • πŸ”§ Tool Mode (Chat): Ad hoc queries and file operations
  • πŸ”„ Workflow Mode: A 7-stage intelligent test generation pipeline

Workflow Highlights

  • 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

πŸš€ Quick Start

Installation

cd ATTest
pip install -e .

Basic Usage

Chat Mode (Ad Hoc Tasks)

attest chat --workspace ~/my-project

Workflow Mode (Full Test Generation)

# 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

πŸ“– Documentation

  • 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


🎯 Workflow Stages

╔═══════════════════════════════════════════════════╗
β•‘   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 Enter to continue
  • Use /regenerate to regenerate the current stage
  • Use /goto <stage> to jump to another stage
  • Provide natural-language feedback for smart interpretation

πŸ”§ Custom Build Commands

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.


πŸ“‹ Command Reference

Configuration Management

attest config list              # Show all configuration values
attest config set KEY VALUE     # Set a configuration value
attest config get KEY           # Get a configuration value

Session Management

attest sessions list            # List all sessions
attest sessions clear ID        # Clear a specific session

Chat Mode

attest chat [--workspace DIR] [--auto-approve]

Workflow Mode

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 as workspace
  • --mode: Run mode, either interactive or full-auto, defaults to interactive
  • --epoch: Number of iteration rounds in full-auto mode; after analyze_results, the workflow loops back to generate_code; defaults to 1
  • --resume: Resume an interrupted workflow

πŸ› οΈ Extension and Customization

Add a New Tool

  1. Create a tool class in src/attest_cli/tools/builtin.py
  2. Register it in src/attest_cli/tools/runner.py
  3. Add it to a stage's tools list

Modify a Stage Prompt

Edit the corresponding stage file, for example src/attest_cli/workflow/stages/requirements.py, and update _get_prompt_template().

Add a New Stage

  1. Create src/attest_cli/workflow/stages/your_stage.py
  2. Register it in stages/__init__.py
  3. Add it to STAGE_NAMES in workflow/engine.py

See WORKFLOW_GUIDE.md - Extension and Customization for details.


πŸ“‚ Project Structure

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

πŸ§ͺ Tests

# Test the core framework
python test_milestone1.py

# Test custom commands
python test_custom_commands.py

πŸ“ Examples

Fully Automatic Workflow for a PyTorch Operator

attest run -f torch.add --workspace ~/my-project --mode full-auto

Automatically generates pytest cases, executes them, and produces a test report.

Workflow with a Custom Pytest Command

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-auto

Uses a custom command to run the generated tests, which can be reused in a virtual environment or CI pipeline.

Quick Checks in Chat Mode

attest chat --workspace ~/my-project

Temporarily inspect or analyze files, or generate small testing snippets.


🀝 Contributing

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

πŸ“„ License

MIT


πŸ™ Acknowledgements

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages