mecha10-cli 0.1.20

Mecha10 CLI tool
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# Interactive Wizard Testing Guide

## Overview

This document describes how to test the new interactive `mecha10 init` wizard.

## Implementation Summary

The interactive wizard provides a comprehensive developer experience when initializing new robot projects. Instead of requiring command-line flags, users can now run `mecha10 init` and be guided through the complete configuration process, including hardware selection, behaviors, AI capabilities, and dashboard configuration.

### Phase 1 (Completed)
- Basic project name and robot type selection
- Simulation generation toggle
- Configuration summary

### Phase 2 (Completed - Current)
- Hardware component multi-select with smart defaults
- Behavior selection (navigate, follow, deliver, etc.)
- AI/ML capabilities (LLM control, object detection, speech recognition, etc.)
- Dashboard and control mode configuration
- Comprehensive configuration summary with confirmation
- Smart defaults based on robot type

## Files Modified

1. **Cargo.toml**
   - Added `dialoguer = "0.11"` dependency for interactive prompts

2. **src/main.rs**
   - Modified `Commands::Init` enum to make `name` and `template` optional
   - Added `cmd_init_interactive()` function with interactive prompts
   - Updated command dispatcher to call interactive mode when parameters are missing

## Testing Scenarios

### 1. Full Interactive Mode (Phase 2)

```bash
mecha10 init
```

**Expected behavior:**
1. Prompts for project name
2. Shows menu to select robot type (rover/humanoid/arm/basic)
3. **NEW:** Hardware component multi-select with smart defaults
   - Rover gets: camera, lidar, imu, motor_controller pre-selected
   - Humanoid gets: camera, imu, motor_controller, force_torque pre-selected
   - Arm gets: camera, imu, motor_controller, force_torque pre-selected
   - Basic gets: motor_controller only pre-selected
4. **NEW:** Behavior selection multi-select
   - Rover defaults: navigate, autonomous_docking
   - Humanoid defaults: follow_person, pick_and_place
   - Arm defaults: pick_and_place
5. **NEW:** AI/ML capabilities multi-select (optional)
   - LLM control, object detection, speech recognition, etc.
   - No defaults (all optional)
6. **NEW:** Dashboard configuration
   - Enable web dashboard? (default: Yes)
   - Enable LLM chat interface? (only if LLM control selected)
   - Control modes: manual, autonomous, semi-autonomous
7. Asks whether to generate simulation environments
8. **NEW:** Shows comprehensive configuration summary with all selections
9. **NEW:** Confirmation prompt before proceeding
10. Creates project with selected options

### 2. Partial Interactive Mode (Name Only)

```bash
mecha10 init my-robot
```

**Expected behavior:**
- Skips name prompt (uses "my-robot")
- Shows robot type selection menu
- Asks about simulation generation
- Creates project

### 3. Partial Interactive Mode (Template Only)

```bash
mecha10 init --template rover
```

**Expected behavior:**
- Prompts for project name
- Skips robot type selection (uses "rover")
- Asks about simulation generation
- Creates project

### 4. Non-Interactive Mode (Backward Compatibility)

```bash
mecha10 init my-robot --template rover
```

**Expected behavior:**
- No interactive prompts
- Uses provided parameters
- Asks about simulation generation
- Creates project (existing behavior preserved)

### 5. Skip Simulation Flag

```bash
mecha10 init --skip-sim
```

**Expected behavior:**
- Prompts for name and robot type
- Skips simulation generation question
- Creates project without simulation

## Manual Testing Steps

### Prerequisites
- Rust toolchain installed
- In the CLI package directory

### Build the CLI
```bash
cd packages/cli
cargo build --release
```

### Test Interactive Wizard
```bash
# Test 1: Full interactive
./target/release/mecha10 init

# Expected prompts:
# 1. "Project name:" (type: test-robot-1)
# 2. "What type of robot are you building?" (select: Rover)
# 3. "Generate simulation environments?" (select: Yes)

# Verify project created:
ls test-robot-1/
# Should show: drivers/, nodes/, config/, simulation/, etc.
```

### Test Partial Interactive
```bash
# Test 2: Name provided
./target/release/mecha10 init test-robot-2

# Expected prompts:
# 1. Robot type selection (select: Humanoid)
# 2. Simulation generation (select: Yes)

# Test 3: Template provided
./target/release/mecha10 init --template arm

# Expected prompts:
# 1. "Project name:" (type: test-robot-3)
# 2. Simulation generation (select: Yes)
```

### Test Backward Compatibility
```bash
# Test 4: Traditional usage
./target/release/mecha10 init test-robot-4 --template basic

# Expected: No interactive prompts
# Should work exactly as before
```

### Verify Project Structure

For each test, verify the created project has:

```
test-robot-X/
├── .mecha10/
├── clippy.toml
├── rustfmt.toml
├── .ls-lint.yml
├── config/
├── drivers/
├── logs/
├── mecha10.json
├── models/
├── nodes/
├── simulation/
└── tests/
```

### Verify mecha10.json

Check that `mecha10.json` contains the correct robot type:

```bash
cat test-robot-1/mecha10.json | grep platform
# Should show: "platform": "rover"
```

## Expected User Experience

### Before (Command-line only)
```bash
$ mecha10 init
error: the following required arguments were not provided:
  <NAME>

Usage: mecha10 init <NAME> --template <TEMPLATE>
```

### After Phase 2 (Interactive wizard with extended features)
```bash
$ mecha10 init
🤖 Mecha10 Project Initialization Wizard

? Project name: my-awesome-robot

? What type of robot are you building?
  ❯ Rover - 4-wheeled mobile robot with sensors
    Humanoid - Bipedal walking robot
    Robotic Arm - 6-DOF manipulator
    Basic - Minimal starting template

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Hardware Components
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

? Select hardware components (space to select, enter to continue)
  ◉ Camera (vision/perception)
  ◉ LiDAR (navigation/mapping)
  ◉ IMU (orientation/balance)
  ◯ GPS (outdoor localization)
  ◯ Depth Camera (3D perception)
  ◉ Motor Controller (movement)
  ◯ Ultrasonic Sensors (proximity detection)
  ◯ Force/Torque Sensor (manipulation feedback)
  ◯ Microphone (audio input)
  ◯ Speaker (audio output)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Robot Behaviors
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

? Select robot behaviors (space to select, enter to continue)
  ◉ Navigate (autonomous path planning & obstacle avoidance)
  ◯ Follow Person (track and follow a human)
  ◯ Deliver (autonomous delivery tasks)
  ◯ Patrol (surveillance and monitoring routes)
  ◯ Pick & Place (object manipulation)
  ◯ Voice Control (speech command interface)
  ◯ Gesture Recognition (visual gesture commands)
  ◉ Autonomous Docking (return to charging station)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AI & Machine Learning Capabilities
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

? Select AI/ML capabilities (optional, space to select, enter to continue)
  ◯ LLM Control (natural language command processing)
  ◯ Object Detection (vision-based object recognition)
  ◯ Speech Recognition (voice-to-text)
  ◯ Gesture Recognition ML (learned gesture patterns)
  ◯ Semantic Mapping (environment understanding)
  ◯ Person Detection & Tracking (human identification)
  ◯ Anomaly Detection (safety & monitoring)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Dashboard & Control Configuration
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

? Enable web dashboard interface? Yes

? Select control modes to enable
  ◉ Manual Teleoperation (keyboard/gamepad control)
  ◉ Autonomous Mode (behavior-based control)
  ◯ Semi-Autonomous (human-in-the-loop)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
RL Training & Simulation
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

? Generate Godot RL simulation environments? Yes

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Configuration Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Project Configuration:
  Name: my-awesome-robot
  Robot Type: rover

Hardware Components (4):
  - camera
  - lidar
  - imu
  - motor_controller

Behaviors (2):
  - navigate
  - autonomous_docking

AI/ML Capabilities (0):
  (none selected)

Dashboard & Control:
  Web Dashboard: Yes
  Control Modes: manual, autonomous

RL Training:
  Generate Simulation: Yes

? Proceed with project initialization? Yes

Note: Extended configuration (hardware, behaviors, AI capabilities) will be stored in mecha10.json
      Full template generation coming in next update!

🤖 Mecha10 Project Initialization

📋 Creating project: my-awesome-robot
  Platform: rover

📁 Creating project structure...
  ✓ drivers/
  ✓ nodes/
  ...
```

## Phase 2 Completion Status

### Completed Features
- ✅ Hardware component multi-select with 10 component types
- ✅ Smart defaults based on robot type (rover, humanoid, arm, basic)
- ✅ Behavior selection with 8 behavior options
- ✅ AI/ML capabilities with 7 AI options
- ✅ Dashboard configuration prompts
- ✅ LLM chat interface toggle (conditional on LLM control selection)
- ✅ Control mode multi-select (manual, autonomous, semi-autonomous)
- ✅ Comprehensive configuration summary with counts
- ✅ Confirmation prompt before project creation
- ✅ Backward compatibility preserved (all existing flags still work)

### Known Limitations (Phase 2)

The current implementation collects user preferences but does not yet generate customized templates based on selections. Future phases will add:

- **Template Generation:** Generate driver/node templates based on hardware selections
- **Behavior Templates:** Generate behavior code templates for selected capabilities
- **AI Model Integration:** Configure and setup AI models (YOLO, LLM endpoints, etc.)
- **Dashboard Generation:** Generate custom dashboard with selected control modes
- **Deployment Architecture:** Add deployment target selection (on-robot, edge, cloud)
- **SaaS Integration:** Optional cloud connection for fleet management

### What Works Now
- All interactive prompts function correctly
- Smart defaults are applied based on robot type
- Configuration is collected and displayed in summary
- Projects are created with standard structure
- Backward compatibility maintained

### What Needs Implementation
- Storing extended configuration in mecha10.json
- Generating driver stubs for selected hardware
- Creating behavior node templates
- Setting up AI model configurations
- Generating custom dashboard based on selections

## Troubleshooting

### Build Errors

If you see compilation errors, ensure:
1. Rust version >= 1.70
2. All dependencies are up to date: `cargo update`
3. Clean build: `cargo clean && cargo build`

### Interactive Prompts Not Showing

If prompts don't appear:
1. Check terminal supports ANSI colors
2. Try without `ColorfulTheme`: modify code to use `SimpleTheme`
3. Check stdin is not redirected

### Backward Compatibility Issues

If existing scripts break:
1. Verify they provide both `name` and `--template`
2. Update scripts to use explicit parameters
3. The old usage `mecha10 init <name> --template <type>` still works

## Next Steps (Phase 3)

Future enhancements planned:

1. **Template Generation from Selections**
   - Generate driver stubs for selected hardware components
   - Create behavior node templates based on selections
   - Configure AI model endpoints and configurations
   - Generate custom dashboard with selected control modes

2. **Advanced Configuration**
   - Deployment architecture selection (on-robot, edge, cloud)
   - Cloud integration and fleet management
   - Resource allocation and performance tuning
   - Security and authentication setup

3. **Component Ecosystem Integration**
   - Integrate with `mecha10 add` command for installing components
   - Component registry and marketplace
   - Dependency resolution and versioning
   - Auto-wiring of components in node graph

4. **Interactive Development Experience**
   - `mecha10 dev` interactive terminal (like `expo dev`)
   - Hot-reload capabilities
   - Live status monitoring
   - Interactive training and deployment

## References

- [IDEAL_DEVELOPER_EXPERIENCE.md]../../IDEAL_DEVELOPER_EXPERIENCE.md - Full vision
- [CLI README]./README.md - Command documentation
- [dialoguer documentation]https://docs.rs/dialoguer/ - Interactive prompt library