npm package: @radishkit/accli
Description: A modern, lightweight CLI tool for developing, testing, and deploying Accela EMSE scripts with RadishKit integration. Execute scripts remotely, deploy to Accela environments, manage batch parameters, test event handlers, and streamline your Accela develop
Author: Aaron Williams
Latest version: 0.2.2

# Accela CLI (@radishkit/accli)

A lightweight CLI for testing Accela EMSE scripts with [RadishKit](https://radishkit.com) integration. Stop wasting time in the UI.

[![npm version](https://badge.fury.io/js/%40radishkit%2Faccli.svg)](https://www.npmjs.com/package/@radishkit/accli)
[![Node.js Version](https://img.shields.io/node/v/@radishkit/accli.svg)](https://nodejs.org)

## Features

- 🔐 **Simple Authentication** - Quick login with RadishKit integration
- 📁 **Project-Based Configuration** - Link projects to specific Accela environments
- 🧪 **Script Testing** - Execute EMSE scripts remotely with transaction control
- 🚀 **Script Deployment** - Deploy scripts directly to Accela environments
- 📦 **Parameter Management** - Flexible `--param key=value` system with save/reuse functionality
- 🌍 **Multi-Environment** - Support for TEST, PROD, CIVCON, SUPP, and custom environments
- 🔄 **Transaction Safety** - Default rollback mode for safe testing
- 📊 **Rich Output** - Detailed execution results and logging
- ⚡ **Event Script Testing** - Full support for ASA, WTUA, and IRSA event types
- 💾 **Parameter Persistence** - Automatically saves and reuses test parameters
- 🏷️ **Smart Type Detection** - Automatically categorizes scripts (Batch, Event, Helper, Solution)

## Quick Start

### Install
```bash
npm install -g @radishkit/accli
```

### 2. Sign Up for RadishKit

Before using the CLI, you'll need a RadishKit account:

1. **Visit**: [https://radishkit.com](https://radishkit.com)
2. **Sign Up**: Create your free account
3. **Add Environment**: Configure your Accela environment in RadishKit
4. **Add Agency**: Link your Accela agency

### 3. Install the CLI Wrapper Script

Before using the CLI, you must install the `RADISH_ACCELA_CLI.js` script in your Accela environment. This script acts as a wrapper for executing your EMSE scripts remotely.

**Installation Steps:**

1. **Download the script**: The script is included in the CLI package
2. **Upload to Accela**: In your Accela Admin interface:
   - Navigate to **Settings** → **Scripts** → **EMSE Scripts**
   - Click **Add New Script**
   - Set **Script Name**: `RADISH_ACCELA_CLI`
   - Copy and paste the contents of the wrapper script
   - Save the script
3. **Verify installation**: The script should appear in your EMSE Scripts list

**Important Notes:**
- This script must be installed in **every Accela environment** you plan to test against (CIVCON, SUPP, NONPROD1, etc.)
- The script name must be exactly `RADISH_ACCELA_CLI` (case-sensitive)
- You only need to install this once per environment - it will be reused for all your script testing

### 4. Initialize Your Project

```bash
# Navigate to your Accela project directory
cd your-accli-project

# Initialize project structure (includes VS Code extension setup)
accli init

# Login to RadishKit
accli login

# Link project to Accela environment
accli link


# Install extra radishkit tools to make your life even easier
accli install-tools
```

**Note**: The `accli init` command automatically sets up your project config in the root of your project /.accela-cli/ 

### 5. Test Your Setup

```bash
# Check status
accli status

# Run hello world test (verifies end-to-end connectivity)
accli hello

# Test a script (safe - rollback mode)
accli test script Scripts/Tests/MyScript.js

# Run a script with changes committed
accli run script Scripts/Tests/MyScript.js
```

## Development Tools

The CLI includes comprehensive development tools to enhance your Accela scripting workflow:

### VS Code / Cursor Extension
- **RadishKit Extension**: Provides syntax highlighting, snippets, and IntelliSense for Accela EMSE scripts
- **Auto-installation**: Run `accli init` to automatically install the extension
- **Features**: Code completion, error detection, and Accela API documentation

### AI Agent Support
- **Cursor Rules**: Pre-configured rules for Accela script development with AI assistants
- **Development Guides**: Structured prompts and guidelines for LLM agents
- **Debugging Assistance**: Templates for troubleshooting scripts with AI help
- **Best Practices**: Curated patterns for effective AI-assisted Accela development

### Installation
```bash
# Install all development tools (VS Code extension, Cursor rules, guides)
accli install-tools

# Or install specific tools interactively
accli install-tools --interactive
```

The tools are designed to work seamlessly with modern AI-powered editors like Cursor, providing context-aware assistance for Accela script development.

## Core Commands

### Script Testing
```bash
# Test script (safe, rolls back by default)
accli test script Scripts/Solution/my-script.js

# Test with commit (applies changes)
accli test script Scripts/Solution/my-script.js --commit

# Test with record context
accli test script Scripts/Solution/my-script.js --record "PR2024001"

# Test event scripts
accli test event asa Scripts/Event/asa-script.js --record "PR2024001"
accli test event wtua Scripts/Event/wtua-script.js --record "PR2024001" --task "Review" --status "Complete"

# Test batch scripts
accli test batch Scripts/Batch/batch-script.js --param "StartDate=2024-01-01"
```

### Script Deployment
```bash
# Deploy script to linked environment
accli deploy script Scripts/Solution/my-script.js

# Deploy with custom Accela script name
accli deploy script Scripts/Solution/my-script.js --name "ProductionScript"

# Deploy without confirmation (automation-friendly)
accli deploy script Scripts/Solution/my-script.js --yes

# Non-interactive mode for CI/CD
accli deploy script Scripts/Solution/my-script.js --yes --non-interactive
```

### Production Execution
```bash
# Run with commit (shortcut for test --commit)
accli run script Scripts/Solution/my-script.js
accli run batch Scripts/Batch/batch-script.js
accli run event asa Scripts/Event/asa-script.js --record "PR2024001"
```

### SQL Queries
```bash
# Execute SELECT queries (safe, TOP 1000 limit by default)
accli test sql queries/my-query.sql

# Remove TOP 1000 limit (use with caution)
accli test sql queries/my-query.sql --no-limit
```

### Management
```bash
# Authentication & setup
accli login                    # Login to RadishKit
accli link                     # Link project to agency environment
accli status                   # Show connection status

# Configuration
accli config show             # Show current config
accli config set key value    # Set config value

# Updates
accli update                   # Check for CLI updates

# Utilities
accli hello                    # Test connectivity
```

## Key Options

All test/run commands support:
- `--param key=value` - Set parameters (can be used multiple times)
- `--commit` - Apply changes instead of rolling back
- `--no-save` - Don't save to script library (use for temporary debugging scripts)

Use `accli <command> --help` for complete option details.

## Safety Features

- **Default Rollback**: All `test` commands rollback by default
- **Confirmation Prompts**: Commit operations ask for confirmation
- **Parameter Validation**: Validates required parameters before execution
- **Environment Isolation**: Can only link a workspace to ONE environment at at time

## Requirements

- **Node.js**: 18.18.0 or higher
- **RadishKit Account**: Free at [radishkit.com](https://radishkit.com)
- **Accela Environment**: Access to an Accela environment (CIVCON, SUPP, NONPROD, etc.)

## Support

- **Documentation**: Use `--help` with any command
- **Issues**: aaron@radishapps.com

---

**Remember**: Use `accli test` for safe testing, `accli run` to commit to the DB. When in doubt, test first!