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
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
members = [
"glsp-mcp-server",
"glsp-tauri/src-tauri",
#"composer",
"tasklist_mcp_client"
]
resolver = "2"

Expand Down Expand Up @@ -58,4 +60,4 @@ once_cell = "1.0"
parking_lot = "0.12"
validator = "0.18"
futures-util = "0.3"
lru = "0.12"
lru = "0.12"
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@

## 📊 Current Status

**Functional MVP with Strong Foundation**
**Functional MVP with UML Diagram Support**

✅ **Working Components:**
- Complete MCP server with 7 diagram tools implemented
- Complete MCP server with 8+ diagram tools implemented
- TypeScript frontend with Canvas rendering
- Ollama integration with model auto-detection
- Basic diagram creation and manipulation
- Comprehensive documentation and startup instructions
- UML class diagram creation with attributes, methods, and associations
- Diagram deletion and management tools
- Comprehensive error handling and user feedback

⚠️ **Ready for Use:**
- Creates sample diagrams with basic node types
- Creates sample UML diagrams with Person/Car classes and relationships
- AI generates intelligent diagram planning (text-based)
- Manual editing supports position updates and basic interactions
- All three services integrate smoothly
Expand Down Expand Up @@ -109,6 +110,20 @@ ollama serve

## 🎨 Usage Examples

### UML Class Diagram Creation
The system now supports creating detailed UML class diagrams with:
- **Class attributes** with types and visibility (public/private)
- **Class methods** with return types and parameters
- **Association relationships** between classes
- **Automatic ID extraction** from server responses

**Example**: Run the tasklist MCP client to create a sample diagram:
```bash
cd tasklist_mcp_client
cargo run --bin tasklist_mcp_client
```
This creates a Person-Car relationship diagram with full attributes and methods.

### Natural Language Diagram Creation
```
"Create a workflow for e-commerce order fulfillment with payment validation, inventory check, and shipping"
Expand Down Expand Up @@ -182,13 +197,21 @@ curl -X POST http://127.0.0.1:3000/mcp/rpc \
- **[API Reference](docs/API_REFERENCE.md)**: Complete MCP protocol documentation
- **[AI Integration Examples](examples/ai_agent_demo.py)**: Python demonstration scripts
- **[Development Notes](CLAUDE.md)**: Implementation details and architecture decisions
- **[Screenshots](docs/pictures/)**: Visual examples including current UML class diagrams

### 📸 Screenshots

- **[Class Diagram Example](docs/pictures/Class_diagram.png)** - Shows a complete UML class diagram with Person and Car classes, their attributes, methods, and association relationships created via MCP tools.

![UML Class Diagram](docs/pictures/Class_diagram.png)

## 🌐 MCP Protocol Integration

This implementation provides:

### Tools (7 available)
- `create_diagram`, `create_node`, `create_edge`, `delete_element`
### Tools (8+ available)
- `create_diagram`, `delete_diagram`, `create_node`, `create_edge`
- `add_uml_class`, `remove_uml_class`, `update_uml_class`, `delete_element`
- `update_element`, `apply_layout`, `export_diagram`

### Resources (Dynamic)
Expand Down
11 changes: 11 additions & 0 deletions composer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "composer"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
wit-bindgen = "0.43.0"

135 changes: 135 additions & 0 deletions composer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# WIT Composition Project

This project demonstrates the composition of WebAssembly Interface Types (WIT) definitions using `math.wit`, `user.wit`, and `world.wit`. The project provides a clear example of how multiple WIT definitions can interact and be composed in Rust using the WebAssembly component model.

## Project Structure

```
wit-composition-project/
├── wit/
│ ├── math.wit
│ ├── user.wit
│ └── world.wit
└── src/
└── lib.rs
```

## WIT Interfaces

### math.wit

Defines basic mathematical operations.

```wit
interface math {
add: func(a: f32, b: f32) -> f32
subtract: func(a: f32, b: f32) -> f32
multiply: func(a: f32, b: f32) -> f32
divide: func(a: f32, b: f32) -> result<f32, string>
}
```

### user.wit

Defines user-related functionality.

```wit
interface user {
record User {
id: u32,
name: string,
}

get-user: func(id: u32) -> option<User>
create-user: func(name: string) -> User
}
```

### world.wit

Composes the interfaces and defines the main entry point.

```wit
world world {
import math
import user

export greet-user: func(id: u32) -> string
export calculate-and-greet: func(id: u32, a: f32, b: f32) -> string
}
```

## Rust Implementation (`src/lib.rs`)

The Rust library provides implementations for the composed WIT interfaces.

```rust
use wit_bindgen::generate;

// Generate Rust bindings from WIT definitions
generate!("world");

struct UserService;
struct MathService;

impl world::user::User for UserService {
fn get_user(id: u32) -> Option<world::user::User> {
Some(world::user::User { id, name: format!("User{id}") })
}

fn create_user(name: String) -> world::user::User {
world::user::User { id: 1, name }
}
}

impl world::math::Math for MathService {
fn add(a: f32, b: f32) -> f32 { a + b }
fn subtract(a: f32, b: f32) -> f32 { a - b }
fn multiply(a: f32, b: f32) -> f32 { a * b }

fn divide(a: f32, b: f32) -> Result<f32, String> {
if b == 0.0 {
Err("Cannot divide by zero".into())
} else {
Ok(a / b)
}
}
}

pub struct Component;

impl world::World for Component {
fn greet_user(id: u32) -> String {
match UserService::get_user(id) {
Some(user) => format!("Hello, {}!", user.name),
None => "User not found".into(),
}
}

fn calculate_and_greet(id: u32, a: f32, b: f32) -> String {
match MathService::divide(a, b) {
Ok(result) => format!("Hello User{}, the result is {:.2}", id, result),
Err(e) => format!("Calculation error: {}", e),
}
}
}
```

## Usage

Compile the project using Cargo with WASM support:

```bash
cargo build --target wasm32-unknown-unknown --release
```

## Tools and Dependencies

* Rust
* WebAssembly Interface Types (WIT)
* `wit-bindgen` for Rust bindings generation

## License

MIT License

11 changes: 11 additions & 0 deletions composer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "wasm-composer-project",
"version": "1.0.0",
"scripts": {
"build:wasm": "cargo build --target wasm32-unknown-unknown --release",
"build": " npm run build:wasm"
},
"devDependencies": {
"wit-bindgen": "^0.20.0"
}
}
22 changes: 22 additions & 0 deletions composer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
wit_bindgen::generate!({
path: "../wit",
world: "math",
exports: {
generate_all,
}
});

pub struct Math;

impl Math {
pub fn add_points(p1: bindings::Point, p2: bindings::Point) -> bindings::Point {
bindings::Point {
x: p1.x + p2.x,
y: p1.y + p2.y,
}
}
}

pub fn compose_points(p1: bindings::Point, p2: bindings::Point) -> bindings::Point {
Math::add_points(p1, p2)
}
11 changes: 11 additions & 0 deletions composer/wit/example/math.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package example:math

interface math {
record point {
x: f64,
y: f64,
}

distance-from-origin: func(p: point) -> f64
}

12 changes: 12 additions & 0 deletions composer/wit/example/user.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package example:user

interface user {
record user-profile {
id: u32,
username: string,
is-active: bool,
}

greet-user: func(profile: user-profile) -> string
}

9 changes: 9 additions & 0 deletions composer/wit/world.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package composer:test

world my-world {
import example:math/math;
import example:user/user;
}
# this is a test world for the composer package
# it imports the math and user packages from the example namespace
# it is used to test the composer functionality
Loading