一键导入
testing-rustyclaw-cli
Test RustyClaw CLI commands end-to-end. Use when verifying CLI changes, swarm commands, new subcommands, or gateway error handling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Test RustyClaw CLI commands end-to-end. Use when verifying CLI changes, swarm commands, new subcommands, or gateway error handling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | testing-rustyclaw-cli |
| description | Test RustyClaw CLI commands end-to-end. Use when verifying CLI changes, swarm commands, new subcommands, or gateway error handling. |
The CLI binary is in the rustyclaw package (crate path: crates/rustyclaw-cli).
# Minimal build (TUI only, no desktop/GPU deps):
cargo build -p rustyclaw --no-default-features --features tui
# Binary location:
target/debug/rustyclaw
Feature flags:
tui — terminal UI (ratatui). Use this for CLI-only testing.desktop — Dioxus desktop UI. Requires GTK/webkit libs; skip on headless VMs.--no-default-features --features tui to avoid desktop build deps.# Full test suite:
cargo test -p rustyclaw-core
# Focused error module tests:
cargo test -p rustyclaw-core -- gateway::errors::tests --nocapture
# Clippy (treat warnings as errors):
cargo clippy -p rustyclaw-core -- -D warnings -A clippy::needless_option_as_deref
The swarm subcommand manages multi-agent orchestration:
rustyclaw swarm templates # List available swarm templates
rustyclaw swarm list # List active swarms (empty by default)
rustyclaw swarm create [TEMPLATE] # Create swarm (default: swarm)
rustyclaw swarm send <SWARM> <MESSAGE> # Send message to swarm
rustyclaw swarm status <SWARM> # Show swarm status
rustyclaw swarm stop <SWARM> # Stop a swarm
The gateway error system lives in crates/rustyclaw-core/src/gateway/errors.rs.
All gateway errors are unified into a GatewayError enum with variants:
Auth { provider, message } — authentication failures (401/403)Provider { message } — generic model provider errorsTokenLimit — context window exceededToolLoopExhausted { rounds } — tool call loop limitContextCompaction { message } — non-fatal compaction failureCancelled — user cancellationVault { message } — vault/secret storage errorsDeviceFlow { message } — OAuth device flow failuresConfig { message } — configuration errorsTokenRefresh { message } — OAuth token refresh failuresUnexpectedFinish { reason } — model finished with unusual finish_reasonDifferent error variants route through different frame types:
send_info: UnexpectedFinish, ContextCompaction (non-fatal/informational)send_error: Provider, Vault, TokenRefresh (actual errors)Auth triggers credential request or device flow, DeviceFlow triggers device flow dialogImportant: The TUI treats ServerFrameType::Info and ServerFrameType::Error differently — Info frames go through GwEvent::Info() while Error frames go through GwEvent::error(). Changing the frame type is a client-visible behavioral change.
Providers using OAuth device flow (e.g., GitHub Copilot) have auth_method == DeviceFlow. When these providers encounter auth errors OR token refresh failures:
handle_device_flow() which calls start_device_flow()DeviceFlowStart frame is sent to the TUI with verification URL + user codeDeviceFlowDialog component for user to complete OAuth flowAPI key providers get the CredentialRequest dialog instead.
When verifying error handling changes without a live gateway:
Unit tests: Run cargo test -p rustyclaw-core -- gateway::errors::tests to verify:
ErrorKind string tags (as_str() method)Display impl output for each variantis_non_fatal() classificationinto_traced() carries correct anyhow-tracing fieldsCode contract verification: Grep to confirm routing:
# Verify which handler uses send_info vs send_error:
grep -n 'send_info\|send_error' crates/rustyclaw-core/src/gateway/errors.rs
# Verify call site uses correct variant:
grep -n 'GatewayError::' crates/rustyclaw-core/src/gateway/mod.rs
# Verify device flow is called from both Auth and TokenRefresh handlers:
grep -n 'handle_device_flow' crates/rustyclaw-core/src/gateway/errors.rs
Build verification: TUI build confirms all call sites compile:
cargo build -p rustyclaw --no-default-features --features tui
The handle() function takes &mut ResolvedModel. When accessing fields like resolved.provider for lookups before passing &mut resolved to a sub-handler, clone the field first to avoid borrow conflicts:
let provider_id = resolved.provider.clone();
let secret_name = provider_by_id(&provider_id)...;
handle_device_flow(writer, resolved, ...) // now safe to pass &mut resolved
OnceLock<Arc<Mutex<SwarmManager>>>. State does NOT persist across CLI invocations. Each command runs in its own process.templates (8 agents listed), create swarm (success + agent list), list (empty state message)create nonexistent (exit 1), send nonexistent "msg" (exit 1), stop nonexistent (exit 1), send swarm with no message (exit 1)--help for each subcommand — verify args, defaults, optionscargo check -p rustyclaw-desktop on CI.No secrets required for CLI testing or gateway error module testing. Full E2E testing of the device flow would require a running gateway with a GitHub Copilot OAuth token, but unit-level and structural verification works without credentials.