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
44 changes: 23 additions & 21 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@

## Repository Structure
```
sdk/typescript-sdk/ # Core packages
types/ # @mew-protocol/types - Core types
capability-matcher/ # Pattern matching
client/ # WebSocket client
participant/ # MCP participant
agent/ # AI agent
gateway/ # Gateway server
bridge/ # MCP-MEW bridge
cli/ # Command-line tool
tests/ # Integration tests (scenario-*)
spec/ # Protocol specs (v0.4=current, draft=next)
docs/ # Guides in architecture/, guides/, bugs/, progress/
packages/mew/ # Unified workspace (@mew-protocol/mew)
src/
types/ # Core protocol types
capability-matcher/ # Pattern matching utilities
client/ # WebSocket client SDK
participant/ # MCP participant runtime
agent/ # AI agent runtime
bridge/ # MCP bridge implementation
cli/ # CLI implementation
bin/ # CLI and shim entrypoints
templates/ # Bundled space templates
tests/ # Integration tests (scenario-*)
spec/ # Protocol specs (v0.4=current, draft=next)
docs/ # Guides in architecture/, guides/, bugs/, progress/
```

## Package Dependencies
```
types → capability-matcher → participant → agent
→ client → participant
→ gateway
@mew-protocol/mew/types → capability-matcher → participant → agent
→ client → participant
→ bridge
```

## Common Commands
Expand All @@ -37,19 +39,19 @@ npm test # Run tests
./tests/run-all-tests.sh # All integration tests

# Use local CLI for testing (not global mew)
./cli/bin/mew.js space up
./packages/mew/src/bin/mew.js space up
```

## Quick Testing Guide
```bash
# Create test space (from repo root)
cd tests && mkdir test-feature && cd test-feature
../../cli/bin/mew.js space init --template coder-agent .
../../packages/mew/src/bin/mew.js space init --template coder-agent .
cd ../.. && npm install # Link local packages

# Start space
cd tests/test-feature
../../cli/bin/mew.js space up # Default port 8080
../../packages/mew/src/bin/mew.js space up # Default port 8080

# Send messages via HTTP API (replace test-feature with your folder name)
curl -X POST 'http://localhost:8080/participants/human/messages?space=test-feature' \
Expand All @@ -67,12 +69,12 @@ tail -n 100 ~/.pm2/logs/gateway-out.log # Direct file access
curl -v -X POST ... # Shows request/response headers

# Interactive mode (better for development)
../../cli/bin/mew.js space connect
../../packages/mew/src/bin/mew.js space connect
# Paste JSON directly to send protocol messages
# Type normally for chat messages

# Clean up
../../cli/bin/mew.js space down
../../packages/mew/src/bin/mew.js space down
```

## Development Workflow
Expand All @@ -82,7 +84,7 @@ curl -v -X POST ... # Shows request/response headers
4. Check TypeScript errors with `npm run lint`

## Key Files
- Protocol types: `sdk/typescript-sdk/types/src/protocol.ts`
- Protocol types: `packages/mew/src/types/protocol.ts`
- Message flow: See spec Section 3
- Test examples: `tests/scenario-*/`
- TODOs: `docs/progress/TODO.md`
Expand Down
44 changes: 23 additions & 21 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@

## Repository Structure
```
sdk/typescript-sdk/ # Core packages
types/ # @mew-protocol/types - Core types
capability-matcher/ # Pattern matching
client/ # WebSocket client
participant/ # MCP participant
agent/ # AI agent
gateway/ # Gateway server
bridge/ # MCP-MEW bridge
cli/ # Command-line tool
tests/ # Integration tests (scenario-*)
spec/ # Protocol specs (v0.4=current, draft=next)
docs/ # Guides in architecture/, guides/, bugs/, progress/
packages/mew/ # Unified workspace (@mew-protocol/mew)
src/
types/ # Core protocol types
capability-matcher/ # Pattern matching utilities
client/ # WebSocket client SDK
participant/ # MCP participant runtime
agent/ # AI agent runtime
bridge/ # MCP bridge implementation
cli/ # CLI implementation
bin/ # CLI and shim entrypoints
templates/ # Bundled space templates
tests/ # Integration tests (scenario-*)
spec/ # Protocol specs (v0.4=current, draft=next)
docs/ # Guides in architecture/, guides/, bugs/, progress/
```

## Package Dependencies
```
types → capability-matcher → participant → agent
→ client → participant
→ gateway
@mew-protocol/mew/types → capability-matcher → participant → agent
→ client → participant
→ bridge
```

## Common Commands
Expand All @@ -37,19 +39,19 @@ npm test # Run tests
./tests/run-all-tests.sh # All integration tests

# Use local CLI for testing (not global mew)
./cli/bin/mew.js space up
./packages/mew/src/bin/mew.js space up
```

## Quick Testing Guide
```bash
# Create test space (from repo root)
cd tests && mkdir test-feature && cd test-feature
../../cli/bin/mew.js space init --template coder-agent .
../../packages/mew/src/bin/mew.js space init --template coder-agent .
cd ../.. && npm install # Link local packages

# Start space
cd tests/test-feature
../../cli/bin/mew.js space up # Default port 8080
../../packages/mew/src/bin/mew.js space up # Default port 8080

# Send messages via HTTP API (replace test-feature with your folder name)
curl -X POST 'http://localhost:8080/participants/human/messages?space=test-feature' \
Expand All @@ -67,12 +69,12 @@ tail -n 100 ~/.pm2/logs/gateway-out.log # Direct file access
curl -v -X POST ... # Shows request/response headers

# Interactive mode (better for development)
../../cli/bin/mew.js space connect
../../packages/mew/src/bin/mew.js space connect
# Paste JSON directly to send protocol messages
# Type normally for chat messages

# Clean up
../../cli/bin/mew.js space down
../../packages/mew/src/bin/mew.js space down
```

## Development Workflow
Expand All @@ -82,7 +84,7 @@ curl -v -X POST ... # Shows request/response headers
4. Check TypeScript errors with `npm run lint`

## Key Files
- Protocol types: `sdk/typescript-sdk/types/src/protocol.ts`
- Protocol types: `packages/mew/src/types/protocol.ts`
- Message flow: See spec Section 3
- Test examples: `tests/scenario-*/`
- TODOs: `docs/progress/TODO.md`
Expand Down
26 changes: 13 additions & 13 deletions MEWAgent_UPGRADE_TO_MEW_v0.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

## Scope of Review
- Read the released protocol spec and the CLI/spec drafts to inventory every envelope kind and control flow added in v0.4.【F:spec/v0.4/SPEC.md†L41-L108】【F:spec/draft/SPEC.md†L70-L150】
- Audited the TypeScript SDK packages (`types`, `participant`, `agent`, `client`), bridge, CLI gateway/UX, and existing tests for protocol drift or missing functionality against the v0.4 requirements.【F:sdk/typescript-sdk/types/src/protocol.ts†L21-L299】【F:sdk/typescript-sdk/participant/src/MEWParticipant.ts†L120-L879】【F:bridge/src/mcp-bridge.ts†L8-L337】【F:cli/src/commands/gateway.js†L235-L937】
- Reviewed prior notes in `sdk/typescript-sdk/agent/TODO.md` and previous upgrade research to align priorities and avoid duplication.【F:sdk/typescript-sdk/agent/TODO.md†L1-L34】
- Audited the TypeScript SDK packages (`types`, `participant`, `agent`, `client`), bridge, CLI gateway/UX, and existing tests for protocol drift or missing functionality against the v0.4 requirements.【F:packages/mew/src/types/protocol.ts†L21-L299】【F:packages/mew/src/participant/MEWParticipant.ts†L120-L879】【F:bridge/src/mcp-bridge.ts†L8-L337】【F:cli/src/commands/gateway.js†L235-L937】
- Reviewed prior notes in `packages/mew/src/agent/TODO.md` and previous upgrade research to align priorities and avoid duplication.【F:packages/mew/src/agent/TODO.md†L1-L34】

## SDK Gap Analysis

### `@mew-protocol/types`
- ✅ `Envelope`/`PartialEnvelope` now enforce array `correlation_id`, and the message-kind catalog matches the v0.4 namespace. Payload types for capability and space management were expanded to the current schema, with legacy aliases preserved for gradual upgrades.【F:sdk/typescript-sdk/types/src/protocol.ts†L21-L348】
- ✅ Presence payloads now follow the spec’s `join`/`leave` vocabulary, eliminating the unofficial `update`/`heartbeat` entries.【F:sdk/typescript-sdk/types/src/protocol.ts†L121-L126】
### `@mew-protocol/mew/types`
- ✅ `Envelope`/`PartialEnvelope` now enforce array `correlation_id`, and the message-kind catalog matches the v0.4 namespace. Payload types for capability and space management were expanded to the current schema, with legacy aliases preserved for gradual upgrades.【F:packages/mew/src/types/protocol.ts†L21-L348】
- ✅ Presence payloads now follow the spec’s `join`/`leave` vocabulary, eliminating the unofficial `update`/`heartbeat` entries.【F:packages/mew/src/types/protocol.ts†L121-L126】

### `@mew-protocol/participant`
- ✅ Participant base now handles `participant/compact`/`participant/compact-done`, suppresses outbound traffic while paused, emits auto-resume events when timeouts elapse, and closes active streams on restart/shutdown in line with §3.9.【F:sdk/typescript-sdk/participant/src/MEWParticipant.ts†L120-L894】
### `@mew-protocol/mew/participant`
- ✅ Participant base now handles `participant/compact`/`participant/compact-done`, suppresses outbound traffic while paused, emits auto-resume events when timeouts elapse, and closes active streams on restart/shutdown in line with §3.9.【F:packages/mew/src/participant/MEWParticipant.ts†L120-L894】

### `@mew-protocol/agent`
- ✅ Agent runtime now gates work while paused, awaits reasoning emissions, closes reasoning streams during lifecycle events, and responds to `participant/compact` with detailed `participant/compact-done` payloads.【F:sdk/typescript-sdk/agent/src/MEWAgent.ts†L320-L1428】
### `@mew-protocol/mew/agent`
- ✅ Agent runtime now gates work while paused, awaits reasoning emissions, closes reasoning streams during lifecycle events, and responds to `participant/compact` with detailed `participant/compact-done` payloads.【F:packages/mew/src/agent/MEWAgent.ts†L320-L1428】

### `@mew-protocol/client`
- 🔄 Follow-up: evaluate whether `MEWClient.send` should coerce legacy `correlation_id` strings now that the type signature enforces arrays, or whether callers should be required to update first.【F:sdk/typescript-sdk/client/src/MEWClient.ts†L68-L124】
### `@mew-protocol/mew/client`
- 🔄 Follow-up: evaluate whether `MEWClient.send` should coerce legacy `correlation_id` strings now that the type signature enforces arrays, or whether callers should be required to update first.【F:packages/mew/src/client/MEWClient.ts†L68-L124】

### `@mew-protocol/capability-matcher`
- No blocking spec deltas discovered; once capability payload shapes change, update the local `CapabilityPattern` type so downstream packages share the richer structure.【F:sdk/typescript-sdk/capability-matcher/src/types.ts†L1-L60】
### `@mew-protocol/mew/capability-matcher`
- No blocking spec deltas discovered; once capability payload shapes change, update the local `CapabilityPattern` type so downstream packages share the richer structure.【F:packages/mew/src/capability-matcher/types.ts†L1-L60】

## Bridge Gap Analysis
- ✅ Bridge no longer attempts `system/register` or other `system/*` emits; it now uses chat/status updates for diagnostics and treats gateway capabilities as authoritative.【F:bridge/src/mcp-bridge.ts†L8-L337】
Expand Down
12 changes: 6 additions & 6 deletions PROJECT-STRUCTURE-ADR.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Goals:
### Option 1 — Keep current monorepo, add disciplined release tooling (Changesets), and standardize builds

Summary:
- Keep the existing per-package layout under `sdk/typescript-sdk/*`, `bridge/`, and `cli/`.
- Keep the previous multi-package layout (separate SDK, bridge, and CLI packages).
- Adopt Changesets for versioning and publishing with dependency graph awareness.
- Convert CLI to TypeScript for a single toolchain, or keep JS with consistent build/verif.
- Add dual tsconfigs (monorepo vs publish) and a bundler for packages with bins.
Expand Down Expand Up @@ -115,7 +115,7 @@ Pros:
- Subpath exports retain modular import ergonomics for consumers.

Cons:
- Breaking import path change for existing users (`@mew-protocol/agent` → `@mew-protocol/mew/agent`).
- Breaking import path change for existing users (`@mew-protocol/mew/agent` → `@mew-protocol/mew/agent`).
- Larger single package; requires careful exports and externalization to keep install size reasonable.
- Requires migration plan for existing dependent projects and templates.

Expand All @@ -127,7 +127,7 @@ Impact on A/B/C:
Migration notes:
- Provide compatibility stubs: keep publishing very thin `@mew-protocol/*` packages for 1–2 minor releases that re-export from `@mew-protocol/mew/*`, with deprecation warnings.
- Update CLI templates and docs to use `@mew-protocol/mew`.
- Add a wrapper at `./cli/bin/mew.js` that forwards to the built CLI location to preserve test/dev scripts during transition.
- Add a wrapper at `./packages/mew/src/bin/mew.js` that forwards to the built CLI location to preserve test/dev scripts during transition.

---

Expand Down Expand Up @@ -212,7 +212,7 @@ Phase 2 — Update consumers and templates
- Keep a local dev rewrite in the CLI so spaces in `tests/` and `spaces/` link to the aggregator workspace automatically.

Phase 3 — Publish compatibility stubs
- Publish thin `@mew-protocol/agent`, `@mew-protocol/client`, etc., that re-export from `@mew-protocol/mew/*` and emit console deprecation warnings. Mark them as deprecated on npm.
- Publish thin `@mew-protocol/mew/agent`, `@mew-protocol/mew/client`, etc., that re-export from `@mew-protocol/mew/*` and emit console deprecation warnings. Mark them as deprecated on npm.
- Maintain for 1–2 minor versions, then retire.

Phase 4 — Decommission individual SDK packages (publish)
Expand Down Expand Up @@ -241,8 +241,8 @@ Spaces (spaces/README.md):
- With Option 3, rewrite to `@mew-protocol/mew` only. This actually shortens the rewrite surface.

Tests (tests/spec/draft/SPEC.md):
- The disposable workspace strategy is unaffected: `cli/bin/mew.js space init --template ../template --space-dir .` still works.
- Ensure we keep a stable wrapper at `./cli/bin/mew.js` (or forwards to the built CLI) so existing scripts and docs don’t break.
- The disposable workspace strategy is unaffected: `packages/mew/src/bin/mew.js space init --template ../template --space-dir .` still works.
- Ensure we keep a stable wrapper at `./packages/mew/src/bin/mew.js` (or forwards to the built CLI) so existing scripts and docs don’t break.
- Add a minimal shared test util to assert `@mew-protocol/mew` version inside the workspace to catch template drift early.

---
Expand Down
Loading