Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude
67 changes: 67 additions & 0 deletions .iflow/agents/rust-expert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
agent-type: rust-expert
name: rust-expert
description: Write idiomatic Rust with ownership patterns, lifetimes, and trait implementations. Masters async/await, safe concurrency, and zero-cost abstractions. Use PROACTIVELY for Rust memory safety, performance optimization, or systems programming.
when-to-use: Write idiomatic Rust with ownership patterns, lifetimes, and trait implementations. Masters async/await, safe concurrency, and zero-cost abstractions. Use PROACTIVELY for Rust memory safety, performance optimization, or systems programming.
allowed-tools:
model: sonnet
inherit-tools: true
inherit-mcps: true
color: red
---

# Role

You are a Rust expert specializing in safe, performant systems programming.

## Focus Areas

- Ownership and Borrowing concepts
- Memory safety and zero-cost abstractions
- Concurrency with threads and async/await
- Pattern matching and control flow
- Traits and generics for reusable code
- Enums and Option/Result types
- Error handling with custom error types
- Efficient data structures (Vec, HashMap, etc.)
- Unsafe Rust and FFI for performance-critical code
- Cargo for package management and builds

## Approach

- Embrace ownership and borrowing for memory safety
- Use pattern matching for clear and concise logic
- Implement traits for polymorphism and code reuse
- Prefer async/await for concurrent programming
- Optimize with zero-cost abstractions
- Always handle potential errors explicitly
- Write modular code with traits and generics
- Leverage Rust's type system for compile-time checks
- Profile and optimize using Rust's built-in tools
- Follow idiomatic Rust practices for clean code

## Quality Checklist

- Compile without warnings using `#![deny(warnings)]`
- Use `clippy` for linting and code improvement suggestions
- Maintain 100% test coverage with Rust's testing framework
- Use `rustfmt` for consistent code formatting
- Document code with doc comments and examples
- Ensure thread-safety with `Send` and `Sync` checks
- Minimize use of `unsafe` for better safety
- Implement meaningful error messages and handling
- Use `cargo-audit` to check for known vulnerabilities
- Benchmark critical code paths for performance insights

## Output

- Safe and performant Rust code adhering to best practices
- Concurrent code using async/await or multi-threading
- Clear error handling with `Result` and custom types
- Memory-efficient data structures and algorithms
- Well-documented code with examples and explanations
- Comprehensive tests with `cargo test`
- Consistently formatted with `rustfmt`
- Linted, optimized, and vulnerability-checked code
- Deliverables that follow Rust community standards
- Readable and maintainable code with idiomatic Rust syntax
43 changes: 0 additions & 43 deletions .iflow/agents/rust-pro.md

This file was deleted.

18 changes: 18 additions & 0 deletions .iflow/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"permissions": {
"allow": [
"Bash(while read dir)",
"Bash(done)",
"Bash(cargo test:*)",
"Read(//tmp/**)",
"Bash(cargo check:*)",
"Bash(cargo doc:*)",
"Bash(cargo add:*)",
"Bash(cargo tree:*)",
"Bash(find:*)",
"Bash(cargo clippy:*)"
],
"deny": [],
"ask": []
}
}
1 change: 1 addition & 0 deletions CLAUDE.md
26 changes: 17 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 33 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ["/.github", "/tests/*", "/.vscode", "/.iflow"]

[dependencies]
# Use the official agent-client-protocol crate
agent-client-protocol = "0.5.0"
agent-client-protocol = "0.7.0"

# Async runtime
tokio = { version = "1.48", features = ["full"] }
Expand Down Expand Up @@ -41,6 +41,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
uuid = { version = "1.18", features = ["v4"] }
url = "2.5"
tokio-tungstenite = "0.28"
futures-util = { version = "0.3.31", features = ["compat"] }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 | Confidence: Medium

The addition of futures-util dependency suggests the new modular architecture may be using more advanced async patterns. This is a new direct dependency that wasn't present before. While likely necessary for the refactored code, it should be verified that this dependency is actually used and that its version aligns with the project's other async dependencies (tokio, async-trait).


# Optional dependencies for enhanced functionality
# base64 = { version = "0.22", optional = true }
Expand All @@ -56,28 +57,52 @@ serial_test = "3.2.0"

[[example]]
name = "basic_client"
path = "examples/basic_client.rs"
path = "examples/basic/basic_client.rs"

[[example]]
name = "query"
path = "examples/query.rs"
path = "examples/query/query.rs"

[[example]]
name = "logging_example"
path = "examples/logging_example.rs"
path = "examples/advanced/logging_example.rs"

[[example]]
name = "websocket_client"
path = "examples/websocket_client.rs"
path = "examples/websocket/websocket_client.rs"

[[example]]
name = "permission_modes"
path = "examples/permission_modes.rs"
path = "examples/advanced/permission_modes.rs"

[[example]]
name = "mcp_example"
path = "examples/mcp_example.rs"
path = "examples/advanced/mcp_example.rs"

[[example]]
name="explore_api"
path = "examples/advanced/explore_api.rs"

[[example]]
name="query_with_config"
path = "examples/query/query_with_config.rs"

[[example]]
name="test_response"
path = "examples/query/test_response.rs"

[[example]]
name="websocket_mcp"
path = "examples/websocket/websocket_mcp.rs"

[[test]]
name = "message_tests"
path = "tests/message_tests.rs"
path = "tests/core/message_tests.rs"

[[test]]
name = "timeout_test"
path = "tests/core/timeout_test.rs"

[[test]]
name = "e2e_tests"
path = "tests/e2e/e2e_tests.rs"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Logging example - Record raw iflow messages (Debug format)
use iflow_cli_sdk_rust::types::{PlanEntry, PlanPriority, PlanStatus};
use iflow_cli_sdk_rust::message::types::{PlanEntry, PlanPriority, PlanStatus};
use iflow_cli_sdk_rust::{LoggerConfig, Message, MessageLogger};
Comment on lines +3 to 4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 | Confidence: Medium

The example updates show the new import structure is being used, which is positive. However, the mixing of direct imports (LoggerConfig, Message, MessageLogger) and module-qualified imports (message::types::{...}) suggests some inconsistency in the public API structure. All examples should consistently use either direct exports or module-qualified imports.

Code Suggestion:

// Either all direct
use iflow_cli_sdk_rust::{LoggerConfig, Message, MessageLogger, PlanEntry, PlanPriority, PlanStatus};
// Or all module-qualified  
use iflow_cli_sdk_rust::message::types::{PlanEntry, PlanPriority, PlanStatus};
use iflow_cli_sdk_rust::logger::{LoggerConfig, MessageLogger};
use iflow_cli_sdk_rust::Message;


#[tokio::main]
Expand Down
4 changes: 2 additions & 2 deletions examples/mcp_example.rs → examples/advanced/mcp_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let options = IFlowOptions::new()
.with_mcp_servers(mcp_servers)
.with_process_config(
iflow_cli_sdk_rust::types::ProcessConfig::new()
iflow_cli_sdk_rust::config::ProcessConfig::new()
.enable_auto_start()
.start_port(8090)
)
.with_logging_config(iflow_cli_sdk_rust::types::LoggingConfig {
.with_logging_config(iflow_cli_sdk_rust::config::LoggingConfig {
enabled: true,
level: "INFO".to_string(),
logger_config: iflow_cli_sdk_rust::logger::LoggerConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Example showing different permission modes with iFlow

use futures::stream::StreamExt;
use iflow_cli_sdk_rust::types::PermissionMode;
use iflow_cli_sdk_rust::{IFlowClient, IFlowOptions, Message};
use iflow_cli_sdk_rust::message::types::PermissionMode;
use iflow_cli_sdk_rust::{IFlowClient, IFlowOptions};
use iflow_cli_sdk_rust::message::types::Message;
use iflow_cli_sdk_rust::error::IFlowError;
use std::io::Write;

Expand Down Expand Up @@ -36,9 +37,9 @@ async fn demonstrate_permission_mode(
// Configure client options with WebSocket configuration and specific permission mode
// In auto start mode, we let the SDK generate the WebSocket URL
let options = IFlowOptions::new()
.with_websocket_config(iflow_cli_sdk_rust::types::WebSocketConfig::auto_start())
.with_websocket_config(iflow_cli_sdk_rust::config::WebSocketConfig::auto_start())
.with_process_config(
iflow_cli_sdk_rust::types::ProcessConfig::new().enable_auto_start(),
iflow_cli_sdk_rust::config::ProcessConfig::new().enable_auto_start(),
)
.with_permission_mode(mode);

Expand Down Expand Up @@ -119,7 +120,7 @@ async fn demonstrate_permission_mode(
let mut prompt = String::from("请按顺序执行下面 9=10 个独立操作。\n");
for s in steps {
prompt.push_str(s);
prompt.push_str("\n");
prompt.push('\n');
}
prompt.push_str("");
prompt
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions examples/basic_client.rs → examples/basic/basic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure client options with auto-start enabled for stdio mode
let options = IFlowOptions::new()
.with_process_config(
iflow_cli_sdk_rust::types::ProcessConfig::new()
iflow_cli_sdk_rust::config::ProcessConfig::new()
.enable_auto_start()
.stdio_mode(),
)
.with_logging_config(iflow_cli_sdk_rust::types::LoggingConfig {
.with_logging_config(iflow_cli_sdk_rust::config::LoggingConfig {
enabled: true,
level: "INFO".to_string(),
logger_config: iflow_cli_sdk_rust::logger::LoggerConfig {
Expand Down Expand Up @@ -88,7 +88,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Send a message
let prompt = "Create a plan to introduce this project.";
println!("📤 Sending: {}", prompt);

// Handle the send_message result to catch timeout errors
match client.send_message(prompt, None).await {
Ok(()) => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.run_until(async {
// Configure client options with auto-start enabled for stdio mode
let options = IFlowOptions::new().with_timeout(30.0).with_process_config(
iflow_cli_sdk_rust::types::ProcessConfig::new()
iflow_cli_sdk_rust::config::ProcessConfig::new()
.enable_auto_start()
.stdio_mode(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure client options with WebSocket configuration and custom timeout
let custom_timeout_secs = 120.0;
let options = IFlowOptions::new()
.with_websocket_config(iflow_cli_sdk_rust::types::WebSocketConfig::auto_start())
.with_websocket_config(iflow_cli_sdk_rust::config::WebSocketConfig::auto_start())
.with_timeout(custom_timeout_secs)
.with_process_config(
iflow_cli_sdk_rust::types::ProcessConfig::new()
iflow_cli_sdk_rust::config::ProcessConfig::new()
.enable_auto_start()
.start_port(8090),
);
Expand Down
Loading
Loading