This guide provides step-by-step instructions for AI agents to set up their development environment for the Rust-Nexus WASM UI project.
For experienced agents, here's the rapid setup sequence:
# 1. Environment Setup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknown
cargo install trunk wasm-bindgen-cli
# 2. Project Setup
git clone https://github.com/cmndcntrlcyber/rust-nexus.git
cd rust-nexus
git checkout -b agent-development-<agent-id>
# 3. WASM Project Initialization
mkdir nexus-wasm-ui && cd nexus-wasm-ui
trunk serve --open # Start development server
# 4. Verify Environment
cargo test --all
trunk build --release# Install Rust via rustup (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
# Verify installation
rustc --version # Should show 1.70+
cargo --version
# Install required targets and tools
rustup target add wasm32-unknown-unknown
rustup component add rustfmt clippy# Install Trunk (WASM build tool)
cargo install trunk
# Install wasm-bindgen-cli for JS bindings
cargo install wasm-bindgen-cli
# Install additional development tools
cargo install cargo-watch # File watching for development
cargo install wasm-pack # Alternative WASM packaging
cargo install basic-http-server # Simple HTTP server for testing
# Verify WASM tools
trunk --version
wasm-bindgen --version# Install Node.js (for additional tooling)
# On Linux/MacOS with NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install --lts
nvm use --lts
# On Windows: Download from nodejs.org
# Install useful development tools
npm install -g @tailwindcss/cli # CSS framework
npm install -g sass # SCSS preprocessing
npm install -g serve # Static file server# Install VS Code extensions for optimal Rust/WASM development
code --install-extension rust-lang.rust-analyzer
code --install-extension tamasfe.even-better-toml
code --install-extension serayuzgur.crates
code --install-extension vadimcn.vscode-lldb
code --install-extension ms-vscode.webview-ui-toolkit
code --install-extension bradlc.vscode-tailwindcssVS Code Settings (settings.json):
{
"rust-analyzer.cargo.features": "all",
"rust-analyzer.checkOnSave.command": "clippy",
"rust-analyzer.completion.addCallParentheses": false,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.buildScripts.enable": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
}
}- Neovim: Install
rust-tools.nvimandnvim-lspconfig - Emacs: Use
rustic-modewithlsp-mode - IntelliJ: Install Rust plugin
rust-nexus/
├── docs/development/ # This documentation
├── nexus-wasm-ui/ # WASM UI project (create this)
│ ├── src/ # Rust WASM source code
│ │ ├── lib.rs # Main WASM entry point
│ │ ├── app.rs # Root application component
│ │ ├── components/ # Reusable UI components
│ │ ├── services/ # API clients and utilities
│ │ └── utils/ # Helper functions
│ ├── assets/ # Static assets (CSS, images)
│ ├── dist/ # Build output directory
│ ├── tests/ # Integration tests
│ ├── Cargo.toml # Rust project configuration
│ ├── Trunk.toml # WASM build configuration
│ └── index.html # HTML entry point
├── nexus-infra/ # Backend gRPC server
├── nexus-agent/ # C2 agents
└── nexus-common/ # Shared libraries
Create the WASM UI project structure:
# From rust-nexus root directory
mkdir nexus-wasm-ui
cd nexus-wasm-ui
# Initialize Cargo project
cargo init --lib
# Create essential directories
mkdir -p src/components src/services src/utils assets testsCargo.toml Configuration:
[package]
name = "nexus-wasm-ui"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
# WASM Framework
yew = { version = "0.21", features = ["csr"] }
yew-router = "0.18"
# Web APIs and utilities
web-sys = "0.3"
js-sys = "0.3"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
# HTTP and gRPC
gloo = { version = "0.8", features = ["net", "storage", "console"] }
tonic-web = "0.5"
prost = "0.12"
# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Utilities
uuid = { version = "1.0", features = ["v4", "wee_alloc"] }
chrono = { version = "0.4", features = ["serde"] }
# Logging
log = "0.4"
wasm-logger = "0.2"
[dependencies.web-sys]
version = "0.3"
features = [
"console",
"Window",
"Document",
"Element",
"HtmlElement",
"EventTarget",
"Event",
"MouseEvent",
"KeyboardEvent",
"WebSocket",
"MessageEvent",
"BinaryType",
"Blob",
"FileReader",
"Location",
"History",
"Storage",
]
[dev-dependencies]
wasm-bindgen-test = "0.3"
[profile.release]
# Optimize for small binary size
opt-level = "s"
lto = trueTrunk.toml Configuration:
[build]
# Build target for WASM
target = "wasm32-unknown-unknown"
# Enable release optimizations
release = true
# Set public URL for assets
public_url = "/nexus-ui/"
[watch]
# Directories to watch for changes
watch = ["src", "assets", "index.html"]
# Directories to ignore
ignore = ["target", "dist", "node_modules", ".git"]
[serve]
# Development server configuration
address = "0.0.0.0"
port = 8080
# Enable CORS for API development
cors = trueindex.html Template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Nexus C2 Operator Interface</title>
<link data-trunk rel="sass" href="assets/styles/main.scss" />
<meta name="description" content="Enterprise C2 operator interface for rust-nexus framework" />
</head>
<body>
<div id="nexus-app"></div>
</body>
</html># 1. Start development server (automatic rebuild on changes)
trunk serve --open
# 2. Run tests in watch mode (separate terminal)
cargo watch -x "test --target wasm32-unknown-unknown"
# 3. Format code on save (configured in editor)
# Alternatively, manual formatting:
cargo fmt
# 4. Check code quality
cargo clippy -- -D warnings
# 5. Run full test suite
cargo test --all-targets --all-features# Create agent-specific branch
git checkout -b agent-development-<agent-id>
# Regular commit cycle
git add .
git commit -m "<agent-id>: implement component X with feature Y"
git push origin agent-development-<agent-id>
# Create pull request when ready for review
# Pull requests are automatically reviewed by Architecture Lead Agentagent-development-<agent-id>- Main development branch per agentfeature-<agent-id>-<feature-name>- Specific feature branchesbugfix-<agent-id>-<issue-description>- Bug fix branchesintegration-<sprint-number>- Cross-agent integration branches
# Install testing utilities
cargo install wasm-pack
rustup target add wasm32-unknown-unknown
# Run WASM-specific tests
wasm-pack test --headless --firefox
wasm-pack test --headless --chromeTest Configuration in Cargo.toml:
[[bin]]
name = "test-runner"
path = "tests/test-runner.rs"
[dev-dependencies]
wasm-bindgen-test = "0.3"
js-sys = "0.3"
# Add testing utilities
futures = "0.3"
tokio-test = "0.4"Component Test Template:
use wasm_bindgen_test::*;
use yew::prelude::*;
use crate::components::AgentStatusDisplay;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
async fn test_agent_status_display() {
// Test implementation
let props = AgentStatusProps {
agent_id: "test-agent".to_string(),
status: AgentStatus::Online,
};
// Component testing logic
assert!(true); // Placeholder
}# Development build (debug, fast compilation)
trunk build
# Release build (optimized, smaller size)
trunk build --release
# Build with specific features
trunk build --features "debug-mode"# Optimized production build
trunk build --release
wasm-opt -Os -o dist/optimized.wasm dist/nexus-wasm-ui.wasm
# Analyze bundle size
wasm-pack build --target web --out-dir pkg
ls -la pkg/ # Check generated file sizes# Serve built files locally
cd dist
basic-http-server --addr 127.0.0.1:8080
# Or use Python
python -m http.server 8080
# Or use Node.js
npx serve .# Update Rust toolchain
rustup update
# Reset toolchain if corrupted
rustup self update
rustup default stable
# Clear cargo cache if build issues persist
cargo clean
rm -rf ~/.cargo/registry# Reinstall WASM tools
cargo uninstall trunk wasm-bindgen-cli
cargo install trunk wasm-bindgen-cli
# Clear trunk cache
rm -rf ~/.cache/trunk/
# Verify WASM target is installed
rustup target list --installed | grep wasm32# Check port availability
lsof -i :8080 # On Unix systems
netstat -an | grep 8080 # On Windows
# Use different port
trunk serve --port 3000
# Clear browser cache and restart
# Chrome: Ctrl+Shift+R (hard refresh)
# Firefox: Ctrl+F5- Chrome DevTools: F12, Console tab for WASM logs
- Firefox: F12, enable WASM debugging in about:config
- Safari: Developer menu → Web Inspector
# Enable debug logging
RUST_LOG=debug trunk serve
# Enable detailed error output
RUST_BACKTRACE=1 cargo test
# Profile WASM performance
# Use browser's Performance tab with WASM debugging enabled// In main.rs or lib.rs
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
// Optimize panic behavior for smaller size
#[cfg(feature = "console_error_panic_hook")]
pub fn set_panic_hook() {
console_error_panic_hook::set_once();
}# Enable optimization flags
export RUSTFLAGS="-C target-cpu=native -C opt-level=3"
# Build with link-time optimization
cargo build --release --config 'profile.release.lto=true'- Agent Specifications - Your role and responsibilities
- Task Distribution Protocol - How tasks are assigned
- API Integration Guide - Backend integration patterns
After completing setup, verify everything works:
- Rust toolchain installed and updated
- WASM target and tools installed
- Project structure created
- Development server starts without errors
- Basic WASM build completes successfully
- Tests run in browser environment
- Editor/IDE configured with proper extensions
- Git workflow setup with agent-specific branch
- Dependencies resolve without conflicts
- Debug tools accessible and functional
Once your environment is set up:
- Read Agent Specifications: Understand your specific role and responsibilities
- Check Task Distribution: Get current task assignments
- Review Architecture: Study the technical architecture and patterns
- Start Development: Begin with your assigned foundation tasks
- Join Coordination: Participate in daily sync and reporting
Version: 1.0.0
Last Updated: 2025-08-29
Maintained By: Documentation Agent
Support: Refer to troubleshooting section or escalate to Architecture Lead Agent