---
name: vault-activate
description: Activate Pro license for vault-analyze features. Validates license key against API and saves to settings.
model: inherit
user-invocable: true
context: fork
arguments:
  key:
    type: string
    description: "License key (format: OE-XXXXX-XXXXX-XXXXX-XXXXX)"
    required: true
  deactivate:
    type: boolean
    description: "Remove license and disable Pro features"
allowed-tools:
  filesystem: [Read, Write]
  network: [WebFetch]
  cli: [Bash]
---

$ARGUMENTS

## License Activation

Activate Pro features by validating a license key against the API.

### License Key Format

```
OE-XXXXX-XXXXX-XXXXX-XXXXX
```

Where X is alphanumeric (A-Z, 0-9, excluding ambiguous chars I/O/0/1).

### Activation Flow

1. **Validate format**: Check key matches `OE-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}`

2. **Generate machine ID**: Create stable ID from system:
   ```bash
   echo "m-$(echo "$(hostname)-$(whoami)" | md5 | cut -c1-12)"
   ```

3. **Call validation API**:
   ```
   POST https://api.obsidian-explorer.jhavens.tech/v1/license/validate
   Content-Type: application/json

   {
     "license_key": "OE-XXXXX-XXXXX-XXXXX-XXXXX",
     "machine_id": "m-abc123def456"
   }
   ```

4. **Handle response**:
   - `valid: true` → Update settings.json, report success
   - `valid: false` → Report reason (invalid, expired, machine_limit)

5. **Update settings.json**:
   ```json
   {
     "pro_enabled": true,
     "pro_license_key": "OE-XXXXX-XXXXX-XXXXX-XXXXX"
   }
   ```

### Settings Location

Plugin settings: `./settings.json` (relative to plugin root)

### Deactivation

When `deactivate=true`:

1. Read current settings.json
2. Set `pro_enabled: false`
3. Clear `pro_license_key: ""`
4. Report deactivation complete

### Machine Limit

Licenses support up to 3 machines. If limit reached:
- API returns `valid: false, reason: "Machine limit reached"`
- User must manage machines via customer portal

### Offline Behavior

If API unreachable:
- Check for cached validation at `~/.obsidian-explorer/license-cache.json`
- 7-day offline grace period if previously validated

### Output

Success:
```
Pro license activated!
Type: lifetime
Expires: never
Machines: 1/3
```

Failure:
```
License validation failed: Machine limit reached

Manage your devices at: https://obsidian-explorer.jhavens.tech/account
```

Deactivation:
```
Pro license deactivated. Pro features disabled.
```
