Skip to main content

/license-activate - Activate CODITECT License

Activates a CODITECT license key and binds it to this machine for the current user.

Usage

# Interactive - prompts for license key
/license-activate

# Direct with license key
/license-activate PILOT-XXXX-XXXX-XXXX-XXXX

# JSON output for scripts
/license-activate --json PILOT-XXXX-XXXX-XXXX-XXXX

System Prompt

⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:

  1. IMMEDIATELY execute - no questions, no explanations first
  2. ALWAYS show full output from script/tool execution
  3. ALWAYS provide summary after execution completes

DO NOT:

  • Say "I don't need to take action" - you ALWAYS execute when invoked
  • Ask for confirmation unless requires_confirmation: true in frontmatter
  • Skip execution even if it seems redundant - run it anyway

The user invoking the command IS the confirmation.


You are helping activate a CODITECT license per ADR-067 Time-Controlled Licensing.

Execution Steps:

Step 1: Get License Key

If license key not provided in invocation, prompt the user:

Please enter your CODITECT license key:
Format: PILOT-XXXX-XXXX-XXXX-XXXX

>

Step 2: Validate Key Format

Check the license key format before calling API:

import re
# Valid formats: PILOT-XXXX-XXXX-XXXX-XXXX, PRO-XXXX-..., TEAM-XXXX-...
pattern = r'^(PILOT|PRO|TEAM|ENT)-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$'
if not re.match(pattern, license_key):
print("Invalid license key format. Please check and try again.")

Step 3: Run Activation Script

Execute the activation:

python3 ~/.coditect/scripts/core/license-activate.py "$LICENSE_KEY"

Or if the script doesn't exist yet, use this Python code:

#!/usr/bin/env python3
import json
import urllib.request
import urllib.error
import sys
from pathlib import Path
from datetime import datetime

# Paths
CODITECT_DIR = Path.home() / ".coditect"
LICENSING_DIR = CODITECT_DIR / "licensing"
LICENSE_FILE = LICENSING_DIR / "license.json"
MACHINE_ID_FILE = CODITECT_DIR / "machine-id.json"

# API endpoint
API_URL = "https://api.coditect.ai/api/v1/licenses/activate/"

def activate_license(license_key: str) -> dict:
"""Activate a license with the server."""
# Ensure directories exist
LICENSING_DIR.mkdir(parents=True, exist_ok=True)

# Get machine ID
machine_uuid = None
device_name = None
if MACHINE_ID_FILE.exists():
machine_data = json.loads(MACHINE_ID_FILE.read_text())
machine_uuid = machine_data.get("machine_uuid")
device_name = machine_data.get("hostname", "Unknown Device")

if not machine_uuid:
return {"success": False, "error": "Machine ID not found. Run CODITECT-CORE-INITIAL-SETUP.py first."}

# Build activation request
payload = {
"license_key": license_key,
"machine_uuid": machine_uuid,
"device_name": device_name
}

try:
req = urllib.request.Request(
API_URL,
data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"},
method="POST"
)

with urllib.request.urlopen(req, timeout=30) as response:
result = json.loads(response.read().decode())

if result.get("valid"):
# Save license file
license_data = {
"license_id": result.get("license_id"),
"license_key": license_key,
"tier": result.get("tier"),
"licensee": {
"email": result.get("email"),
"organization": result.get("organization")
},
"binding": {
"machine_uuid": machine_uuid,
"device_name": device_name,
"bound_at": datetime.now().isoformat()
},
"validity": {
"issued_at": result.get("issued_at"),
"expires_at": result.get("expires_at"),
"grace_period_days": result.get("grace_period_days", 7)
},
"offline": {
"max_offline_days": result.get("offline_tolerance_days", 7),
"last_server_check": datetime.now().isoformat()
},
"features": result.get("features", {}),
"signature": result.get("signature", {}),
"activated_at": datetime.now().isoformat()
}
LICENSE_FILE.write_text(json.dumps(license_data, indent=2))

return {
"success": True,
"license_id": license_data["license_id"],
"tier": license_data["tier"],
"email": license_data["licensee"]["email"],
"organization": license_data["licensee"]["organization"],
"expires_at": license_data["validity"]["expires_at"],
"message": f"License activated successfully for {device_name}!"
}
else:
return {
"success": False,
"error": result.get("error", "Activation failed")
}
except urllib.error.HTTPError as e:
error_body = e.read().decode() if e.fp else ""
try:
error_data = json.loads(error_body)
error_msg = error_data.get("error", error_data.get("detail", str(e)))
except:
error_msg = str(e)
return {"success": False, "error": f"Activation failed: {error_msg}"}
except urllib.error.URLError as e:
return {"success": False, "error": f"Network error: {e}. Check internet connection."}
except Exception as e:
return {"success": False, "error": str(e)}

# Run activation
if len(sys.argv) > 1:
result = activate_license(sys.argv[1])
print(json.dumps(result, indent=2))
else:
print("Usage: python3 license-activate.py PILOT-XXXX-XXXX-XXXX-XXXX")

Step 4: Display Result

On success:

✅ License Activated Successfully!

License ID: abc123...
Tier: Pilot
Organization: Acme Corp
Email: user@acme.com
Expires: 2026-04-13

Your CODITECT installation is now fully licensed.
Run /license-status to view details.

On failure:

❌ License Activation Failed

Error: [error message from server]

Common issues:
- Invalid license key format
- License key already activated on max devices
- License expired or revoked
- Network connectivity issues

Contact support@coditect.ai if you need help.

Activation Flow

User runs /license-activate


Enter license key (PILOT-XXXX-XXXX-XXXX-XXXX)


Validate format locally


POST to /api/v1/licenses/activate/

├─► Success: Save license.json, bind device

└─► Failure: Show error, suggest solutions
CommandPurpose
/license-statusView current license status
/license-deactivateUnbind license from this device
/orientSession orientation (shows license status)

Principles

This command embodies:

  • #3 Complete Execution - Full activation flow
  • #5 Self-Provisioning - Creates licensing directory structure
  • #9 Based on Facts - Validates with server before saving

ADR: ADR-067 Time-Controlled Licensing System


Script: scripts/core/license-activate.py License File: ~/.coditect/licensing/license.json Version: 1.0.0 Last Updated: 2026-01-13