use super::WorkflowTemplate;
pub fn get_tier1_workflows() -> Vec<WorkflowTemplate> {
vec![
WorkflowTemplate {
filename: "01-exec-basics.nika.yaml",
tier_dir: "tier-1-no-deps",
content: WORKFLOW_01_EXEC_BASICS,
},
WorkflowTemplate {
filename: "02-fetch-http.nika.yaml",
tier_dir: "tier-1-no-deps",
content: WORKFLOW_02_FETCH_HTTP,
},
WorkflowTemplate {
filename: "03-builtins-core.nika.yaml",
tier_dir: "tier-1-no-deps",
content: WORKFLOW_03_BUILTINS_CORE,
},
]
}
pub const WORKFLOW_01_EXEC_BASICS: &str = r##"# ══════════════════════════════════════════════════════════════════════════════
# 🖥️ 01 - EXEC BASICS
# ══════════════════════════════════════════════════════════════════════════════
#
# Learn shell command execution with Nika - no API keys needed!
#
# ┌─────────────────────────────────────────────────────────────────────────────┐
# │ WORKFLOW FLOW │
# ├─────────────────────────────────────────────────────────────────────────────┤
# │ │
# │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
# │ │ get_date │ │ get_user │ │ list_files │ │
# │ │ exec: │ │ exec: │ │ exec: │ │
# │ │ "date" │ │ "whoami" │ │ "ls -la" │ │
# │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
# │ │ │ │ │
# │ └────────────────────┼────────────────────┘ │
# │ │ │
# │ ▼ │
# │ ┌──────────────────────┐ │
# │ │ show_system_info │ │
# │ │ exec: │ │
# │ │ "echo System Info" │ │
# │ └──────────┬────────────┘ │
# │ │ │
# │ ▼ │
# │ ┌──────────────────────┐ │
# │ │ with_cwd │ │
# │ │ exec: │ │
# │ │ cwd: "/tmp" │ │
# │ └──────────────────────┘ │
# │ │
# └─────────────────────────────────────────────────────────────────────────────┘
#
# FEATURES DEMONSTRATED:
# ├── exec: shorthand syntax (just a string)
# ├── exec: full form with options
# ├── shell: true vs false (security)
# ├── cwd: working directory
# ├── timeout: command timeout (seconds)
# ├── env: environment variables
# ├── with: bindings between tasks
# └── depends_on: task dependencies
#
# PREREQUISITES: None! Works out of the box.
#
# RUN: nika run workflows/tier-1-no-deps/01-exec-basics.nika.yaml
#
# ══════════════════════════════════════════════════════════════════════════════
schema: "nika/workflow@0.12"
workflow: exec-basics
description: "Learn shell command execution - no API keys needed!"
tasks:
# ─────────────────────────────────────────────────────────────────────────────
# SHORTHAND SYNTAX: Just pass a command string
# ─────────────────────────────────────────────────────────────────────────────
- id: get_date
# Shorthand: exec: "command" (simplest form)
exec: "date '+%Y-%m-%d %H:%M:%S'"
- id: get_user
# Another shorthand example
exec: "whoami"
- id: list_files
# List files in current directory (pipe requires shell: true)
exec:
command: "ls -la | head -10"
shell: true
# ─────────────────────────────────────────────────────────────────────────────
# FULL FORM: With all options
# ─────────────────────────────────────────────────────────────────────────────
- id: show_system_info
depends_on: [get_date, get_user, list_files]
# Bind outputs from previous tasks
with:
date_result: $get_date # Output of get_date task
user_result: $get_user # Output of get_user task
files_result: $list_files # Output of list_files task
# Full form with explicit options
exec:
# The command to run
command: |
echo "═══════════════════════════════════════"
echo " SYSTEM INFORMATION"
echo "═══════════════════════════════════════"
echo ""
echo "📅 Date: {{with.date_result}}"
echo "👤 User: {{with.user_result}}"
echo ""
echo "📁 Files:"
echo "{{with.files_result}}"
# shell: true allows pipes, redirects, and variables
# WARNING: Only use shell: true when you need shell features!
# shell: false (default) is more secure
shell: true
# Timeout in seconds
timeout: 30
# ─────────────────────────────────────────────────────────────────────────────
# WORKING DIRECTORY: Run commands in specific directory
# ─────────────────────────────────────────────────────────────────────────────
- id: with_cwd
depends_on: [show_system_info]
exec:
command: "pwd && ls -la"
shell: true
# Optional: run in specific directory
cwd: "/tmp"
# ─────────────────────────────────────────────────────────────────────────────
# ENVIRONMENT VARIABLES: Set custom env vars for the command
# ─────────────────────────────────────────────────────────────────────────────
- id: with_env_vars
depends_on: [with_cwd]
exec:
command: 'echo "App: $APP_NAME v$APP_VERSION (env: $NODE_ENV)"'
shell: true
# Environment variables for this command
env:
APP_NAME: "Nika"
APP_VERSION: "0.30.5"
NODE_ENV: "production"
DEBUG: "false"
# ─────────────────────────────────────────────────────────────────────────────
# SHELL-FREE MODE (Default & Secure)
# ─────────────────────────────────────────────────────────────────────────────
- id: secure_command
depends_on: [with_env_vars]
exec:
# shell: false (default) - command is parsed with shlex, no shell injection
command: "echo 'This runs without shell - more secure!'"
shell: false
# Working directory (optional)
# working_dir: /tmp
# ─────────────────────────────────────────────────────────────────────────────
# FINAL SUMMARY
# ─────────────────────────────────────────────────────────────────────────────
- id: summary
depends_on: [secure_command]
with:
sys_info: $show_system_info
cwd_demo: $with_cwd
env_demo: $with_env_vars
secure: $secure_command
exec:
command: |
echo ""
echo "✅ All exec: examples completed successfully!"
echo ""
echo "💡 Key takeaways:"
echo " • Use shorthand 'exec: \"command\"' for simple commands"
echo " • Use full form for cwd, timeouts, shell mode"
echo " • shell: false (default) is more secure"
echo " • shell: true needed for pipes, redirects, variables"
echo " • env: { KEY: value } sets environment variables"
shell: true
"##;
pub const WORKFLOW_02_FETCH_HTTP: &str = r##"# ══════════════════════════════════════════════════════════════════════════════
# 🌐 02 - FETCH HTTP
# ══════════════════════════════════════════════════════════════════════════════
#
# Learn HTTP requests with Nika - GET, POST, headers, and JSON parsing!
#
# ┌─────────────────────────────────────────────────────────────────────────────┐
# │ WORKFLOW FLOW │
# ├─────────────────────────────────────────────────────────────────────────────┤
# │ │
# │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
# │ │ simple_get │ │ get_json │ │ get_headers │ │
# │ │ fetch: │ │ fetch: │ │ fetch: │ │
# │ │ GET /ip │ │ GET /json │ │ GET /headers │ │
# │ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘ │
# │ │ │ │ │
# │ └────────────────────┼────────────────────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────────────┐ │
# │ │ post_data │ │
# │ │ fetch: │ │
# │ │ POST /post │ │
# │ │ body: "{ ... }" │ │
# │ └───────────┬───────────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────────────┐ │
# │ │ with_auth_header │ │
# │ │ fetch: │ │
# │ │ Authorization: ... │ │
# │ └───────────┬───────────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────────────┐ │
# │ │ display_results │ │
# │ │ exec: │ │
# │ │ "echo All done!" │ │
# │ └───────────────────────┘ │
# │ │
# └─────────────────────────────────────────────────────────────────────────────┘
#
# FEATURES DEMONSTRATED:
# ├── fetch: with GET method
# ├── fetch: with POST and body (string)
# ├── fetch: with POST and json (auto-serialized)
# ├── headers: custom HTTP headers
# ├── timeout: request timeout (seconds)
# └── with: parsing JSON responses
#
# PREREQUISITES: None! Uses httpbin.org (free public API)
#
# RUN: nika run workflows/tier-1-no-deps/02-fetch-http.nika.yaml
#
# ══════════════════════════════════════════════════════════════════════════════
schema: "nika/workflow@0.12"
workflow: fetch-http
description: "Learn HTTP requests - GET, POST, headers, JSON parsing"
tasks:
# ─────────────────────────────────────────────────────────────────────────────
# SIMPLE GET REQUEST
# ─────────────────────────────────────────────────────────────────────────────
- id: simple_get
fetch:
# URL to fetch
url: "https://httpbin.org/ip"
# HTTP method (GET is default, but explicit is clearer)
method: GET
# Timeout in seconds
timeout: 10
# ─────────────────────────────────────────────────────────────────────────────
# GET JSON DATA
# ─────────────────────────────────────────────────────────────────────────────
- id: get_json
fetch:
url: "https://httpbin.org/json"
method: GET
# Response is automatically parsed if Content-Type is application/json
# ─────────────────────────────────────────────────────────────────────────────
# GET WITH CUSTOM HEADERS
# ─────────────────────────────────────────────────────────────────────────────
- id: get_headers
fetch:
url: "https://httpbin.org/headers"
method: GET
# Custom headers to send
headers:
Accept: "application/json"
X-Custom-Header: "Nika-Workflow"
User-Agent: "Nika/0.30.5"
# ─────────────────────────────────────────────────────────────────────────────
# POST WITH JSON BODY (String Method)
# ─────────────────────────────────────────────────────────────────────────────
- id: post_data
depends_on: [simple_get, get_json]
with:
# Reference results from previous tasks
my_ip: $simple_get
json_data: $get_json
fetch:
url: "https://httpbin.org/post"
method: POST
# Headers for JSON content
headers:
Content-Type: "application/json"
Accept: "application/json"
# Body as JSON string (old method - still works)
body: '{"message": "Hello from Nika!", "ip": "{{with.my_ip}}", "nested": {"key": "value", "number": 42}}'
# ─────────────────────────────────────────────────────────────────────────────
# POST WITH JSON (Auto-serialized)
# ─────────────────────────────────────────────────────────────────────────────
- id: post_json_auto
depends_on: [post_data]
fetch:
url: "https://httpbin.org/post"
method: POST
# json: auto-serializes and sets Content-Type header
# No need to manually stringify or set Content-Type!
json:
message: "Hello from Nika!"
features:
- "auto-serialization"
- "automatic Content-Type header"
- "cleaner YAML syntax"
nested:
key: "value"
number: 42
enabled: true
# ─────────────────────────────────────────────────────────────────────────────
# AUTHENTICATED REQUEST
# ─────────────────────────────────────────────────────────────────────────────
- id: with_auth_header
depends_on: [post_json_auto]
fetch:
url: "https://httpbin.org/bearer"
method: GET
headers:
# Bearer token authentication (this is a test endpoint)
Authorization: "Bearer test-token-12345"
Accept: "application/json"
# Request timeout
timeout: 10
# ─────────────────────────────────────────────────────────────────────────────
# DISPLAY ALL RESULTS
# ─────────────────────────────────────────────────────────────────────────────
- id: display_results
depends_on: [with_auth_header]
with:
ip_result: $simple_get
json_result: $get_json
headers_result: $get_headers
post_result: $post_data
post_json_result: $post_json_auto
auth_result: $with_auth_header
exec:
command: |
echo "══════════════════════════════════════════════════════════════"
echo " 🌐 HTTP FETCH RESULTS"
echo "══════════════════════════════════════════════════════════════"
echo ""
echo "📡 GET /ip:"
echo "{{with.ip_result}}"
echo ""
echo "📦 GET /json:"
echo "{{with.json_result}}" | head -5
echo ""
echo "📋 GET /headers (with custom headers):"
echo "{{with.headers_result}}" | head -5
echo ""
echo "📤 POST /post (with body: string):"
echo "{{with.post_result}}" | head -8
echo ""
echo "🆕 POST /post (with json: auto-serialized):"
echo "{{with.post_json_result}}" | head -8
echo ""
echo "🔐 GET /bearer (with auth):"
echo "{{with.auth_result}}"
echo ""
echo "══════════════════════════════════════════════════════════════"
echo "✅ All fetch examples completed successfully!"
echo ""
echo "💡 Key takeaways:"
echo " • Use method: GET, POST, PUT, DELETE, PATCH"
echo " • Add custom headers: for auth, content-type, etc."
echo " • Use body: for request body (string)"
echo " • Use json: for auto-serialized JSON body"
echo " • timeout: prevents hanging on slow endpoints (seconds)"
shell: true
"##;
pub const WORKFLOW_03_BUILTINS_CORE: &str = r##"# ══════════════════════════════════════════════════════════════════════════════
# 🔧 03 - BUILTIN CORE TOOLS
# ══════════════════════════════════════════════════════════════════════════════
#
# Learn Nika's core builtin tools - logging, sleeping, events, and assertions!
#
# ┌─────────────────────────────────────────────────────────────────────────────┐
# │ WORKFLOW FLOW │
# ├─────────────────────────────────────────────────────────────────────────────┤
# │ │
# │ ┌───────────────┐ │
# │ │ start │ │
# │ │ nika:log │◄── "Workflow starting..." │
# │ └───────┬───────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────┐ │
# │ │ validate │ │
# │ │ nika:assert │◄── condition: true (passes!) │
# │ └───────┬───────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────┐ │
# │ │ emit_event │ │
# │ │ nika:emit │◄── custom event with payload │
# │ └───────┬───────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────┐ │
# │ │ pause_1s │ │
# │ │ nika:sleep │◄── duration: "1s" │
# │ └───────┬───────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────┐ │
# │ │ progress │ │
# │ │ nika:emit │◄── progress: 50% │
# │ └───────┬───────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────┐ │
# │ │ pause_500ms │ │
# │ │ nika:sleep │◄── duration: "500ms" │
# │ └───────┬───────┘ │
# │ │ │
# │ ▼ │
# │ ┌───────────────┐ │
# │ │ complete │ │
# │ │ nika:log │◄── level: info "Done!" │
# │ └───────────────┘ │
# │ │
# └─────────────────────────────────────────────────────────────────────────────┘
#
# BUILTIN TOOLS DEMONSTRATED:
# ├── nika:log → Emit log events (trace/debug/info/warn/error)
# ├── nika:sleep → Pause execution (humantime: "1s", "500ms", "2m30s")
# ├── nika:emit → Emit custom events with JSON payload
# └── nika:assert → Validate conditions (fails workflow if false)
#
# OTHER BUILTINS (not in this demo):
# ├── nika:prompt → Ask user for input (HITL)
# ├── nika:run → Execute sub-workflow
# └── nika:complete → Signal agent completion (agent-only)
#
# PREREQUISITES: None! Works out of the box.
#
# RUN: nika run workflows/tier-1-no-deps/03-builtins-core.nika.yaml
#
# ══════════════════════════════════════════════════════════════════════════════
schema: "nika/workflow@0.12"
workflow: builtins-core
description: "Learn Nika's core builtin tools - log, sleep, emit, assert"
tasks:
# ─────────────────────────────────────────────────────────────────────────────
# nika:log - Emit log events at different levels
# ─────────────────────────────────────────────────────────────────────────────
- id: start_log
invoke:
# For builtin tools, we don't need an MCP server
# Just specify the tool directly
tool: nika:log
params:
# Log levels: trace, debug, info, warn, error
level: info
message: "🚀 Workflow starting! This is nika:log in action."
# ─────────────────────────────────────────────────────────────────────────────
# nika:assert - Validate conditions
# ─────────────────────────────────────────────────────────────────────────────
- id: validate_condition
depends_on: [start_log]
invoke:
tool: nika:assert
params:
# Condition must be true, otherwise workflow fails with NIKA-213
condition: true
# Custom message shown if assertion fails
message: "This assertion should pass!"
- id: validate_expression
depends_on: [validate_condition]
invoke:
tool: nika:assert
params:
# You can use more complex boolean conditions
condition: true # In real workflows, this could check bindings
message: "Validating that setup completed correctly"
# ─────────────────────────────────────────────────────────────────────────────
# nika:emit - Emit custom events with payload
# ─────────────────────────────────────────────────────────────────────────────
- id: emit_start_event
depends_on: [validate_expression]
invoke:
tool: nika:emit
params:
# Event name (appears in trace)
name: "workflow_started"
# JSON payload (any structure)
payload:
workflow: "builtins-core"
version: "1.0.0"
timestamp: "now"
metadata:
source: "nika-init-example"
tier: 1
# ─────────────────────────────────────────────────────────────────────────────
# nika:sleep - Pause execution
# ─────────────────────────────────────────────────────────────────────────────
- id: pause_1_second
depends_on: [emit_start_event]
invoke:
tool: nika:sleep
params:
# Humantime format: "1s", "500ms", "2m30s", "1h", etc.
duration: "1s"
- id: log_after_sleep
depends_on: [pause_1_second]
invoke:
tool: nika:log
params:
level: debug
message: "⏰ Slept for 1 second. Continuing..."
# ─────────────────────────────────────────────────────────────────────────────
# PROGRESS TRACKING with nika:emit
# ─────────────────────────────────────────────────────────────────────────────
- id: emit_progress_50
depends_on: [log_after_sleep]
invoke:
tool: nika:emit
params:
name: "progress"
payload:
percent: 50
stage: "midpoint"
message: "Halfway there!"
- id: pause_500ms
depends_on: [emit_progress_50]
invoke:
tool: nika:sleep
params:
duration: "500ms"
- id: emit_progress_100
depends_on: [pause_500ms]
invoke:
tool: nika:emit
params:
name: "progress"
payload:
percent: 100
stage: "complete"
message: "All done!"
# ─────────────────────────────────────────────────────────────────────────────
# FINAL LOG
# ─────────────────────────────────────────────────────────────────────────────
- id: final_log
depends_on: [emit_progress_100]
invoke:
tool: nika:log
params:
level: info
message: |
✅ Builtins demo complete!
Tools demonstrated:
• nika:log - Log messages at different levels
• nika:assert - Validate conditions
• nika:emit - Emit custom events
• nika:sleep - Pause execution
Check your trace file to see all events!
# ─────────────────────────────────────────────────────────────────────────────
# SUMMARY (using exec to show results)
# ─────────────────────────────────────────────────────────────────────────────
- id: summary
depends_on: [final_log]
exec:
command: |
echo ""
echo "══════════════════════════════════════════════════════════════"
echo " 🔧 BUILTIN TOOLS SUMMARY"
echo "══════════════════════════════════════════════════════════════"
echo ""
echo "Core Builtins (6):"
echo " nika:log Log messages (trace/debug/info/warn/error)"
echo " nika:sleep Pause execution (humantime format)"
echo " nika:emit Emit custom events with JSON payload"
echo " nika:assert Validate conditions (fail if false)"
echo " nika:prompt Ask user for input (HITL)"
echo " nika:run Execute sub-workflow"
echo ""
echo "File Builtins (5) - Agent-only:"
echo " nika:read Read file content"
echo " nika:write Create/overwrite file"
echo " nika:edit Find & replace in file"
echo " nika:glob Find files by pattern"
echo " nika:grep Search content with regex"
echo ""
echo "Agent Completion:"
echo " nika:complete Signal agent task completion"
echo ""
echo "══════════════════════════════════════════════════════════════"
shell: true
"##;