ArkTS-Sta Playground Runner
Overview
This skill runs ArkTS-Sta code using the ArkTS-Sta Playground HTTP API, providing fast and reliable code execution without browser automation.
Quick Start
Basic Usage
Run an ArkTS-Sta file:
bashpython3 scripts/run_playground.py path/to/code.ets
Run code directly as a string:
bashpython3 scripts/run_playground.py --code "let x: number = 42; console.log(x);"
Get JSON output for programmatic parsing:
bashpython3 scripts/run_playground.py --json --code "console.log('Hello');"
Setup Requirements
Install Python dependencies:
bashpip install -r scripts/requirements.txt
Required package: requests>=2.31.0
Usage Patterns
Pattern 1: Quick Code Testing
When testing ArkTS-Sta syntax or verifying code logic:
bashpython3 scripts/run_playground.py --code " enum Numbers { A = 10, B = 2.57, C = 0x2B7F, D = -1.5, E = 12 } "
Pattern 2: Batch Testing
For testing multiple files:
bashfor file in test/*.ets; do python3 scripts/run_playground.py --json "$file" > "results/$(basename $file .ets).json" done
How It Works
The script uses the HTTP API endpoint:
- Sends your ArkTS-Sta code to
https://arkts-play.cn.bz-openlab.ru:10443/compile - Receives compilation results and output
- Returns formatted results (success status, output, errors)
API Endpoint
Base URL: https://arkts-play.cn.bz-openlab.ru:10443/compile
Method: POST
Request:
json{ "code": "your ArkTS-Sta code here" }
Response:
json{ "output": "execution output or empty", "error": "error message if compilation failed, null otherwise" }
Troubleshooting
Connection issues
If you get connection errors:
- Check internet connectivity
- Verify the API endpoint is accessible
- Check firewall settings
bash# Test connectivity curl -X POST https://arkts-play.cn.bz-openlab.ru:10443/compile \ -H "Content-Type: application/json" \ -d '{"code":"let x: number = 42;"}'
Timeout issues
Increase timeout if the API is slow:
bashpython3 scripts/run_playground.py --timeout 60 path/to/code.ets
SSL certificate errors
If you encounter SSL certificate issues, you may need to:
- Ensure your system's CA certificates are up to date
- Or modify the script to disable SSL verification (not recommended for production)
Common Use Cases
Learn ArkTS Syntax
Test and explore ArkTS language features:
bashpython3 scripts/run_playground.py --code " // Test union types let value: string | number = 'hello'; value = 42; console.log(value); "
Quick Prototype Verification
Verify code logic before integrating into your project:
bashpython3 scripts/run_playground.py --code " function calculateSum(a: number, b: number): number { return a + b; } console.log('Sum:', calculateSum(10, 20)); "
Debug Code Snippets
Find compilation errors in your code:
bash# Run with JSON output for programmatic checking python3 scripts/run_playground.py --json problem.ets # Check exit status if python3 scripts/run_playground.py code.ets; then echo "Compilation successful" else echo "Compilation failed" fi
Script Output
The script returns a JSON structure (with --json flag):
json{ "success": true, "output": "Execution result here...", "error": null, "has_error": false }
Fields:
success: Boolean indicating if the API request succeededoutput: Code output or compilation outputerror: Error message if compilation failed,nullotherwisehas_error: Boolean indicating if the code has compilation errors
Example: Testing Enum with Floating Point
Test if enum with non-integer values causes errors:
bashpython3 scripts/run_playground.py --code " enum Numbers { A = 10, B = 2.57, C = 0x2B7F, D = -1.5, E = 12 } "
Expected result: Should fail with an error about enum values needing to be integers.
Limitations
- Requires internet access to the API endpoint
- API rate limiting may apply
- Compilation output format depends on the API response
Tips for Efficient Usage
- Use JSON output for programmatic processing (
--json) - Batch test multiple files using shell loops
- Check exit codes in scripts for success/failure


