JSPM

  • Created
  • Published
  • Downloads 27
  • Score
    100M100P100Q134112F
  • License MIT

Alfred - Agent mode only. Direct tool execution with Edit, Glob, Grep, Bash, LS, Read, Write.

Package Exports

  • alfred-ai
  • alfred-ai/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (alfred-ai) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Marvin - Simplified CodeMode

Marvin is a simplified, SDK-free version of CodeMode that uses direct MCP (Model Context Protocol) client/server communication instead of the agent SDK. Named after the famously clever and depressed robot from The Hitchhiker's Guide to the Galaxy, Marvin provides all the power of CodeMode with a cleaner, more direct architecture.

๐Ÿš€ Key Features

  • SDK-Free Architecture: Uses direct MCP client/server communication
  • Direct Execute Tool: No heavy prefixes - just use execute directly
  • Intelligent History Management: Automatic cleanup with smart compaction
  • 60k Token Context Window: Optimized context management
  • Multi-Runtime Support: JavaScript, Python, Bash, Go, Rust, C, C++
  • Auto Runtime Detection: Automatically detects runtime from code
  • Memory Efficient: Intelligent data compaction and cleanup
  • Production Ready: Comprehensive testing and validation

๐Ÿ“ฆ Installation

# Clone or copy to your project
cd your-project
npm install uuid

# Make executable
chmod +x marvin.js

โš™๏ธ Setup

Create a .codemode.json file in your project root:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-filesystem", "/path/to/project"]
    },
    "brave-search": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-brave-search"]
    }
  }
}

๐ŸŽฏ Usage

As MCP Server

# Start Marvin as MCP server
node marvin.js

# Or make it executable
./marvin.js

Available Tools

execute

Execute code with automatic runtime detection.

{
  "name": "execute",
  "arguments": {
    "code": "console.log('Hello, Marvin!');",
    "runtime": "auto",  // auto, nodejs, python, bash, go, rust, c, cpp
    "timeout": 240000   // Optional timeout in milliseconds
  }
}

marvin_status

Get system status and history summary.

{
  "name": "marvin_status",
  "arguments": {}
}

marvin_kill

Kill a running execution.

{
  "name": "marvin_kill",
  "arguments": {
    "execId": "exec_123"
  }
}

Delegated MCP Tools

All tools from configured MCP servers are available with server_tool naming:

{
  "name": "filesystem_read_file",
  "arguments": {
    "path": "/path/to/file.txt"
  }
}

๐Ÿง  Intelligence Features

History Management

Marvin automatically manages history to prevent context bloat:

  • MCP Calls: Keeps only last 10 calls
  • Execute Inputs: Keeps only last 3 inputs
  • Execute Outputs: Keeps only last 3 outputs
  • 60k Token Limit: Automatic cleanup when exceeded

Intelligent Compaction

Old data is automatically compacted to English summaries:

// Before: Full 1000-line code execution output
// After: "Code execution output with 15 lines, handled JSON data structure"

// Before: Large JSON object
// After: "JSON data structure with 8 fields about user configuration"

Auto Runtime Detection

Marvin automatically detects the runtime from your code:

// JavaScript/TypeScript
"console.log('Hello')" โ†’ nodejs

// Python
"print('Hello')" โ†’ python

// Bash
"echo 'Hello'" โ†’ bash

// Go
"package main" โ†’ go

// Rust
"fn main()" โ†’ rust

๐Ÿงช Testing

Marvin includes comprehensive testing for critic-quality validation:

# Run basic tests
npm test

# Run validation suite (critic-quality)
npm run test:validation

Test Coverage

  • โœ… MCP Protocol Implementation
  • โœ… Tool Availability and Schemas
  • โœ… Multi-Runtime Execution
  • โœ… Error Handling
  • โœ… History Management
  • โœ… Memory Management
  • โœ… Performance Testing
  • โœ… Edge Case Handling
  • โœ… Concurrent Execution
  • โœ… Large Code Handling

๐Ÿ—๏ธ Architecture

Components

  1. MCPManager: Direct MCP client/server communication
  2. HistoryManager: Intelligent history cleanup and compaction
  3. ExecutionManager: Code execution with multi-runtime support
  4. MarvinMCPServer: Main MCP server implementation

Key Differences from CodeMode

Feature CodeMode Marvin
SDK Uses @anthropic-ai/claude-agent-sdk SDK-free, direct MCP
Execute Tool mcp__plugin_glootie__cc_glootie__execute execute (simple)
History Manual management Automatic intelligent cleanup
Context Unlimited 60k token limit with compaction
Architecture Agent-based Direct MCP communication
Dependencies Heavy Minimal (uuid only)

๐Ÿ”ง Configuration

Environment Variables

No required environment variables. Marvin is designed to work with minimal configuration.

Runtime Requirements

  • Node.js >= 14.0.0
  • Optional: Python 3, Bash, Go, Rust, GCC/G++ for multi-runtime support

๐Ÿ“Š Performance

Memory Usage

  • Intelligent compaction reduces memory usage by 70-90%
  • 60k token hard limit prevents memory bloat
  • Automatic cleanup prevents memory leaks

Execution Speed

  • Direct MCP communication (no SDK overhead)
  • Concurrent execution support
  • Optimized history management

๐Ÿšจ Error Handling

Marvin provides comprehensive error handling:

// Execution errors
{
  "content": [{"type": "text", "text": "Execution failed: SyntaxError: Unexpected token"}],
  "isError": true
}

// Invalid parameters
{
  "error": {"code": -32603, "message": "Code is required for execution"}
}

// MCP errors
{
  "error": {"code": -32603, "message": "MCP server 'test' not found"}
}

๐ŸŽฏ Best Practices

  1. Use runtime: "auto" for best experience
  2. Check marvin_status periodically for system health
  3. Handle errors gracefully - all errors are clearly reported
  4. Use appropriate timeouts for long-running operations
  5. Monitor token usage via status command

๐Ÿ“ License

MIT License - see LICENSE file for details.

๐Ÿค Contributing

Marvin is designed to be simple and reliable. When contributing:

  1. Maintain SDK-free architecture
  2. Ensure comprehensive test coverage
  3. Follow intelligent history management patterns
  4. Keep dependencies minimal
  5. Test with validation suite

๐Ÿ™ Acknowledgments

  • Inspired by the original CodeMode project
  • Named after Marvin the Paranoid Android from Douglas Adams' The Hitchhiker's Guide to the Galaxy
  • Built with direct MCP protocol implementation
  • Validated with critic-quality testing suite

Marvin: "Here I am, brain the size of a planet, and they ask me to execute simple JavaScript. Call that job satisfaction? 'Cos I don't." ๐Ÿง โœจ