npm package: @macroprompt/cli
Description: MacroPrompt Command Line Interface
Author: MacroPrompt Team
Latest version: 1.0.0

# MacroPrompt CLI

A command-line interface for managing MacroPrompt AI Actions directly from your terminal.

## Installation

### Prerequisites
- Node.js 16 or higher
- npm or yarn

### Install from source

1. Clone or download the CLI directory
2. Navigate to the CLI directory:
   ```bash
   cd cli
   ```
3. Install dependencies:
   ```bash
   npm install
   ```
4. Link the CLI globally:
   ```bash
   npm link
   ```

Now you can use the `mpr` command from anywhere in your terminal.

## Authentication

Before using any commands, you need to authenticate with your MacroPrompt account:

```bash
mpr login
```

To logout:

```bash
mpr logout
```

## Commands

### `mpr login`
Authenticate with your MacroPrompt account.

```bash
mpr login
```

### `mpr logout`
Logout from your MacroPrompt account.

```bash
mpr logout
```

### `mpr create [parameters...]`
Create a new AI Action interactively.

```bash
mpr create
```

The command will guide you through:
- Basic information (title, description, AI prompt)
- Input parameters configuration
- Output parameters configuration
- Optional model selection

### `mpr list-actions`
List all your AI Actions.

```bash
mpr list-actions
```

Displays:
- AI Action titles and descriptions
- Status (Active/Inactive)
- Input/Output counts
- Creation dates
- Webhook URLs
- Execution counts

### `mpr delete <ai-action-id>`
Delete an AI Action.

```bash
mpr delete 507f1f77bcf86cd799439011
```

**Warning:** This action cannot be undone. The command will ask for confirmation.

### `mpr describe <ai-action-id>`
Show detailed information about an AI Action.

```bash
mpr describe 507f1f77bcf86cd799439011
```

Displays:
- Complete AI Action details
- Input/Output specifications
- AI prompt
- Model configuration
- Recent executions
- Webhook information

### `mpr execution <execution-id>`
View details of a specific execution.

```bash
mpr execution 507f1f77bcf86cd799439012
```

Shows:
- Execution status and timing
- Input and output data
- Error information (if any)
- Model usage and costs
- Feedback status

### `mpr feedback <execution-id> <up|down>`
Provide feedback for an execution.

```bash
mpr feedback 507f1f77bcf86cd799439012 up
mpr feedback 507f1f77bcf86cd799439012 down
```

You can also use:
- `thumbs-up` / `thumbs-down`
- `1` / `-1`

Optionally add a comment when prompted.

### `mpr update <ai-action-id> [details...]`
Update an existing AI Action.

```bash
mpr update 507f1f77bcf86cd799439011
```

Allows updating:
- Title and description
- AI Action prompt
- Status (Active/Inactive)
- Input and output parameters
- Model configuration

### `mpr enhance <ai-action-id>`
Enhance a manual AI Action using AI-powered improvements.

```bash
mpr enhance 507f1f77bcf86cd799439011
```

Enhancement types:
- **Auto Enhancement**: Automatic AI-powered improvements
- **Guided Enhancement**: Step-by-step improvements with your input
- **Performance Analysis**: Analyze and suggest improvements

## Configuration

The CLI stores configuration and authentication data in your system's config directory:
- macOS: `~/Library/Preferences/macroprompt-cli/`
- Linux: `~/.config/macroprompt-cli/`
- Windows: `%APPDATA%\macroprompt-cli\`

## Environment Variables

- `MACROPROMPT_API_URL`: Override the default API URL (default: `https://macroprompt.cloud/api`)

## Examples

### Create a simple AI Action
```bash
mpr create
# Follow the interactive prompts
```

### List all AI Actions
```bash
mpr list-actions
```

### Get detailed info about an AI Action
```bash
mpr describe 507f1f77bcf86cd799439011
```

### Provide positive feedback for an execution
```bash
mpr feedback 507f1f77bcf86cd799439012 up
```

### Enhance an AI Action
```bash
mpr enhance 507f1f77bcf86cd799439011
```

## Error Handling

The CLI provides clear error messages and suggestions:
- Authentication errors will prompt you to login
- Invalid IDs will show available options
- Network errors will display retry suggestions
- Validation errors will explain what needs to be fixed

## Support

For issues or questions:
1. Check the error message for specific guidance
2. Ensure you're authenticated with `mpr login`
3. Verify AI Action IDs with `mpr list-actions`
4. Contact MacroPrompt support if problems persist

## Development

### Project Structure
```
cli/
├── bin/
│   └── mpr.js          # Main CLI executable
├── commands/
│   ├── login.js        # Login command
│   ├── logout.js       # Logout command
│   ├── create.js       # Create AI Action
│   ├── list-actions.js # List AI Actions
│   ├── delete.js       # Delete AI Action
│   ├── describe.js     # Describe AI Action
│   ├── execution.js    # View execution
│   ├── feedback.js     # Provide feedback
│   ├── update.js       # Update AI Action
│   └── enhance.js      # Enhance AI Action
├── utils/
│   └── auth.js         # Authentication utilities
├── package.json
└── README.md
```

### Adding New Commands

1. Create a new file in `commands/`
2. Export an async function that handles the command
3. Add the command to `bin/mpr.js`
4. Update this README

## License

MIT License - see LICENSE file for details.