|
| 1 | +#!/usr/bin/env bash |
| 2 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 3 | +# VIBEE Multi-Language Codegen Demo |
| 4 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 5 | +# Demonstrates VIBEE's ability to generate code for multiple languages from a |
| 6 | +# single .vibee specification with custom implementations. |
| 7 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 8 | + |
| 9 | +set -e |
| 10 | + |
| 11 | +echo "╔══════════════════════════════════════════════════════════════════════════════╗" |
| 12 | +echo "║ VIBEE Multi-Language Codegen Demo ║" |
| 13 | +echo "║ φ² + 1/φ² = 3 ║" |
| 14 | +echo "╚══════════════════════════════════════════════════════════════════════════════╝" |
| 15 | +echo "" |
| 16 | + |
| 17 | +# Colors |
| 18 | +GREEN='\033[0;32m' |
| 19 | +BLUE='\033[0;34m' |
| 20 | +YELLOW='\033[1;33m' |
| 21 | +NC='\033[0m' # No Color |
| 22 | + |
| 23 | +# ============================================================================ |
| 24 | +# Demo 1: Zig Generation (default) |
| 25 | +# ============================================================================ |
| 26 | +echo -e "${BLUE}━━━ Demo 1: Zig Code Generation ━━━${NC}" |
| 27 | +echo "Spec: vsa_swarm_cluster_16.vibee (24 behaviors, 27 tests)" |
| 28 | +echo "" |
| 29 | + |
| 30 | +zig build vibee -- gen specs/tri/vsa_swarm_cluster_16.vibee 2>&1 | grep -E "(Input|Output)" |
| 31 | + |
| 32 | +echo "" |
| 33 | +echo "Generated code preview:" |
| 34 | +head -20 generated/vsa_swarm_cluster_16.zig |
| 35 | +echo "..." |
| 36 | +echo "" |
| 37 | + |
| 38 | +# ============================================================================ |
| 39 | +# Demo 2: Python Generation |
| 40 | +# ============================================================================ |
| 41 | +echo -e "${BLUE}━━━ Demo 2: Python Code Generation ━━━${NC}" |
| 42 | +echo "Spec: vsa_multilang_python_native.vibee" |
| 43 | +echo "" |
| 44 | + |
| 45 | +cat > /tmp/demo_python.vibee << 'YAML' |
| 46 | +name: demo_python |
| 47 | +version: "1.0.0" |
| 48 | +language: python |
| 49 | +module: demo_python |
| 50 | +
|
| 51 | +types: |
| 52 | + Vector: |
| 53 | + fields: |
| 54 | + x: Float |
| 55 | + y: Float |
| 56 | +
|
| 57 | +behaviors: |
| 58 | + - name: add |
| 59 | + given: two vectors |
| 60 | + when: adding them |
| 61 | + then: return sum |
| 62 | + implementation: | |
| 63 | + def add(a: Vector, b: Vector) -> Vector: |
| 64 | + return Vector(x=a.x + b.x, y=a.y + b.y) |
| 65 | +
|
| 66 | + - name: magnitude |
| 67 | + given: a vector |
| 68 | + when: computing length |
| 69 | + then: return scalar magnitude |
| 70 | + implementation: | |
| 71 | + import math |
| 72 | + def magnitude(v: Vector) -> float: |
| 73 | + return math.sqrt(v.x**2 + v.y**2) |
| 74 | +YAML |
| 75 | + |
| 76 | +zig build vibee -- gen /tmp/demo_python.vibee 2>&1 | grep -E "(Input|Output)" |
| 77 | +echo "" |
| 78 | +echo "Generated Python:" |
| 79 | +cat generated/demo_python.py |
| 80 | +echo "" |
| 81 | + |
| 82 | +# ============================================================================ |
| 83 | +# Demo 3: TypeScript Generation |
| 84 | +# ============================================================================ |
| 85 | +echo -e "${BLUE}━━━ Demo 3: TypeScript Code Generation ━━━${NC}" |
| 86 | +echo "Spec: vsa_multilang_typescript.vibee" |
| 87 | +echo "" |
| 88 | + |
| 89 | +cat > /tmp/demo_typescript.vibee << 'YAML' |
| 90 | +name: demo_ts |
| 91 | +version: "1.0.0" |
| 92 | +language: typescript |
| 93 | +module: demo_ts |
| 94 | +
|
| 95 | +types: |
| 96 | + Vector: |
| 97 | + fields: |
| 98 | + x: number |
| 99 | + y: number |
| 100 | +
|
| 101 | +behaviors: |
| 102 | + - name: add |
| 103 | + given: two vectors |
| 104 | + when: adding them |
| 105 | + then: return sum |
| 106 | + implementation: | |
| 107 | + export function add(a: Vector, b: Vector): Vector { |
| 108 | + return { x: a.x + b.x, y: a.y + b.y }; |
| 109 | + } |
| 110 | +
|
| 111 | + - name: magnitude |
| 112 | + given: a vector |
| 113 | + when: computing length |
| 114 | + then: return scalar magnitude |
| 115 | + implementation: | |
| 116 | + export function magnitude(v: Vector): number { |
| 117 | + return Math.sqrt(v.x ** 2 + v.y ** 2); |
| 118 | + } |
| 119 | +YAML |
| 120 | + |
| 121 | +zig build vibee -- gen /tmp/demo_typescript.vibee 2>&1 | grep -E "(Input|Output)" |
| 122 | +echo "" |
| 123 | +echo "Generated TypeScript:" |
| 124 | +cat generated/demo_ts.ts |
| 125 | +echo "" |
| 126 | + |
| 127 | +# ============================================================================ |
| 128 | +# Demo 4: Rust Generation |
| 129 | +# ============================================================================ |
| 130 | +echo -e "${BLUE}━━━ Demo 4: Rust Code Generation ━━━${NC}" |
| 131 | +echo "Spec: vsa_multilang_rust.vibee" |
| 132 | +echo "" |
| 133 | + |
| 134 | +cat > /tmp/demo_rust.vibee << 'YAML' |
| 135 | +name: demo_rust |
| 136 | +version: "1.0.0" |
| 137 | +language: rust |
| 138 | +module: demo_rust |
| 139 | +
|
| 140 | +types: |
| 141 | + Vector: |
| 142 | + fields: |
| 143 | + x: Float |
| 144 | + y: Float |
| 145 | +
|
| 146 | +behaviors: |
| 147 | + - name: add |
| 148 | + given: two vectors |
| 149 | + when: adding them |
| 150 | + then: return sum |
| 151 | + implementation: | |
| 152 | + pub fn add(a: &Vector, b: &Vector) -> Vector { |
| 153 | + Vector { x: a.x + b.x, y: a.y + b.y } |
| 154 | + } |
| 155 | +
|
| 156 | + - name: magnitude |
| 157 | + given: a vector |
| 158 | + when: computing length |
| 159 | + then: return scalar magnitude |
| 160 | + implementation: | |
| 161 | + pub fn magnitude(v: &Vector) -> f64 { |
| 162 | + (v.x * v.x + v.y * v.y).sqrt() |
| 163 | + } |
| 164 | +YAML |
| 165 | + |
| 166 | +zig build vibee -- gen /tmp/demo_rust.vibee 2>&1 | grep -E "(Input|Output)" |
| 167 | +echo "" |
| 168 | +echo "Generated Rust:" |
| 169 | +cat generated/demo_rust.rs |
| 170 | +echo "" |
| 171 | + |
| 172 | +# ============================================================================ |
| 173 | +# Demo 5: Production Swarm Cluster |
| 174 | +# ============================================================================ |
| 175 | +echo -e "${BLUE}━━━ Demo 5: Production 16-Agent Swarm Cluster ━━━${NC}" |
| 176 | +echo "Spec: vsa_swarm_cluster_16.vibee" |
| 177 | +echo "" |
| 178 | +echo "Features:" |
| 179 | +echo " • 24 behaviors (agent discovery, consensus, self-healing)" |
| 180 | +echo " • 27 test cases (all passing)" |
| 181 | +echo " • Phi-spiral consensus algorithm" |
| 182 | +echo " • Task distribution and load balancing" |
| 183 | +echo "" |
| 184 | + |
| 185 | +echo "Running tests:" |
| 186 | +zig test generated/vsa_swarm_cluster_16.zig 2>&1 | tail -5 |
| 187 | + |
| 188 | +echo "" |
| 189 | +echo -e "${GREEN}━━━ Demo Complete ━━━${NC}" |
| 190 | +echo "" |
| 191 | +echo "Supported Languages: Zig, Python, TypeScript, Rust, Go, Swift, Kotlin, Java, C" |
| 192 | +echo "" |
| 193 | +echo "Usage:" |
| 194 | +echo " zig build vibee -- gen <spec.vibee>" |
| 195 | +echo "" |
0 commit comments