device-pair

DivayJainDJ/Cape-clone

Otheropenclawby DivayJainDJ

Summary

OpenClaw plugin exposing 0 skills.

Install to Claude Code

openclaw plugin add DivayJainDJ/Cape-clone

Run in Claude Code. Add the marketplace first with /plugin marketplace add DivayJainDJ/Cape-clone if you haven't already.

README.md

๐Ÿง  CAPE: Context-Aware Policy Engine

Transform your Android device into an intelligent personal assistant that adapts to your life in real-time.

CAPE is a cutting-edge Android-first automation system that leverages AI to understand your context and automatically optimize your device behavior. By sensing calendar events, location, usage patterns, and biometric signals, CAPE coordinates with OpenClaw AI agents to apply the right "behavior pack" at exactly the right time.

๐ŸŒŸ Key Features

๐Ÿ“ฑ Intelligent Context Sensing

  • Calendar Intelligence: Automatically reads upcoming meetings and prepares focus mode
  • Location Awareness: Detects home, office, college, and commuting patterns
  • Usage Analytics: Monitors screen time, app switching, and notification patterns
  • Sleep Tracking: Integrates sleep debt data into decision-making
  • Commute Pressure: Real-time traffic and travel time analysis

๐Ÿค– AI-Powered Decision Making

  • OpenClaw Integration: Leverages advanced AI agents for intelligent decisions
  • Stress Scoring: Real-time assessment of user cognitive load
  • Adaptive Learning: Improves recommendations based on user feedback
  • Multi-Agent Orchestration: Coordinates specialized AI agents for different contexts

๐ŸŽฏ Smart Automation Packs

  • Focus Mode: Blocks distractions during work/study sessions
  • Relax Mode: Optimizes device for downtime and recovery
  • Commute Mode: Provides navigation assistance and travel updates
  • Home Mode: Creates a comfortable personal environment

๐Ÿ”’ Privacy-First Architecture

  • Local Processing: All data processed locally on your machine
  • USB Bridge: Secure communication between phone and gateway
  • No Cloud Dependencies: Your data never leaves your devices
  • Open Source: Fully transparent and auditable codebase

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 22+ (for gateway server)
  • JDK 25+ (required for Android build)
  • Android SDK with ADB (for phone communication)
  • Android device with USB debugging enabled
  • Google Maps API Key (for location services)

Installation & Setup

๐ŸŽ macOS / Linux

# Clone and install dependencies
git clone <repository-url>
cd CAPE2
npm install

# Build the Android APK
./tools/build-apk.sh

# Start the gateway server (Terminal 1)
./tools/start-gateway.sh

# Install and launch app (Terminal 2)
./tools/install-apk.sh

๐ŸชŸ Windows

# Install JDK 25 (if not already installed)
winget install Microsoft.OpenJDK.25

# Clone and install dependencies
git clone <repository-url>
cd CAPE2
npm install

# Build the Android APK
.\tools\build-apk.ps1

# Start the gateway server (Terminal 1)
.\tools\start-gateway.ps1

# Install and launch app (Terminal 2)
.\tools\install-apk.ps1

๐Ÿ”ง Configuration

1. Enable USB Debugging on your Android device:

  • Settings โ†’ About Phone โ†’ Tap "Build Number" 7 times
  • Settings โ†’ Developer Options โ†’ Enable "USB Debugging"

2. Connect your device via USB and authorize debugging

3. Configure Environment (required):

   cp .env.example .env
   # Edit .env with your preferences and API keys

Required Environment Variables:

   GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
   OPENCLAW_BASE_URL=http://127.0.0.1:18789  # Optional
   OPENCLAW_TOKEN=your_openclaw_token_here        # Optional

๐Ÿ“Š Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    USB/ADB     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    HTTP     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Android App   โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚  Gateway Server โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚  OpenClaw AI    โ”‚
โ”‚                 โ”‚                โ”‚   (Node.js)     โ”‚             โ”‚   Agents        โ”‚
โ”‚ โ€ข Context Sense โ”‚                โ”‚                 โ”‚             โ”‚                 โ”‚
โ”‚ โ€ข UI Interface  โ”‚                โ”‚ โ€ข Decision API  โ”‚             โ”‚ โ€ข Stress Scoringโ”‚
โ”‚ โ€ข Automation    โ”‚                โ”‚ โ€ข Feedback Loop โ”‚             โ”‚ โ€ข Learning      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                โ”‚ โ€ข Memory Store  โ”‚             โ”‚ โ€ข Orchestration โ”‚
                                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Core Components

  • packages/cape-core: JavaScript reference implementation for stress scoring and decision logic
  • packages/cape-gateway: HTTP server handling communication between Android and AI agents
  • android/: Kotlin/Jetpack Compose application with modern UI
  • openclaw/: AI agent configurations, memory stores, and skill definitions

๐ŸŽฎ Usage Guide

First-Time Setup

1. Launch the CAPE app on your Android device 2. Complete onboarding with your name and frequently visited places 3. Grant permissions for location, calendar, notifications, and usage access 4. Choose your current context (Home, Office, College, Commute, or Relaxing) 5. Apply your first behavior pack and experience intelligent automation

Daily Use

  • Automatic Detection: CAPE automatically detects when you arrive at saved locations
  • Smart Transitions: Device behavior adapts as you move between contexts
  • Feedback Loop: Provide feedback to improve AI recommendations
  • Commute Assistance: Get real-time traffic updates and route suggestions
  • USB Sync: Automatic connection maintenance via keep-phone-synced.ps1
  • Local Processing: All data stays on your devices, no cloud dependencies

๐Ÿงช Testing

Core Logic Tests

npm test

Gateway Tests

npm run gateway:test

Demo Scenarios

npm run demo:scenarios

๐Ÿ”Œ API Endpoints

The gateway server exposes RESTful APIs at http://127.0.0.1:8787:

Core Endpoints

  • POST /v1/context/decision - Get AI-powered context decisions
  • POST /v1/feedback - Submit user feedback for learning
  • GET /v1/openclaw/status - Check AI agent status

Location Services

  • POST /v1/maps/geocode - Convert addresses to coordinates
  • POST /v1/maps/search - Search for places by name

๐Ÿค– OpenClaw Integration

CAPE leverages the OpenClaw personal AI assistant framework for advanced decision-making:

Setup Options

Option 1: Full OpenClaw Integration (Recommended)

# Install OpenClaw
npm install -g openclaw@latest
openclaw onboard --install-daemon
openclaw gateway --port 18789 --verbose

# Bootstrap CAPE workspace
node tools/openclaw-bootstrap.mjs

# Start CAPE with OpenClaw brain
OPENCLAW_REQUIRED=true OPENCLAW_BASE_URL="http://127.0.0.1:18789" OPENCLAW_TOKEN="your-token" npm run gateway:start

Option 2: Local Fallback Mode

# Uses built-in decision logic when OpenClaw is unavailable
npm run gateway:start

Configuration

Configure OpenClaw integration via environment variables:

  • OPENCLAW_REQUIRED=true - Require OpenClaw for all decisions
  • OPENCLAW_BASE_URL - OpenClaw gateway URL
  • OPENCLAW_TOKEN - Authentication token
  • OPENCLAW_AGENT_ID - Agent identifier (default: "cape")

๏ฟฝ Direct APK Installation

For quick testing without building from source:

1. Download Cape.apk from repository 2. Enable USB debugging on Android device:

  • Settings โ†’ About Phone โ†’ Tap "Build Number" 7 times
  • Settings โ†’ Developer Options โ†’ Enable "USB Debugging"

3. Install APK: adb install Cape.apk 4. Start gateway server: .\tools\start-gateway.ps1 5. Connect phone via USB - app will automatically sync

๏ฟฝ๏ฟฝ Project Structure

CAPE/
โ”œโ”€โ”€ CAPE2/                   # Main development workspace
โ”‚   โ”œโ”€โ”€ packages/
โ”‚   โ”‚   โ”œโ”€โ”€ cape-core/          # Core decision logic and stress scoring
โ”‚   โ”‚   โ””โ”€โ”€ cape-gateway/       # HTTP gateway server
โ”‚   โ”œโ”€โ”€ android/                # Android application source
โ”‚   โ”œโ”€โ”€ openclaw/               # AI agent configurations
โ”‚   โ”œโ”€โ”€ tools/                  # Build and deployment scripts
โ”‚   โ””โ”€โ”€ .env.example            # Environment configuration template
โ”œโ”€โ”€ Cape.apk                 # Pre-built APK for distribution
โ”œโ”€โ”€ README.md                 # This file
โ””โ”€โ”€ openclaw/                 # OpenClaw workspace and memory

๐Ÿ”ง Development

Building from Source

# Install dependencies
npm install

# Build all packages
npm run build

# Run in development mode
npm run dev

USB Connection Maintenance

The system includes automatic USB connection management:

  • keep-phone-synced.ps1 maintains gateway and ADB reverse port forwarding
  • Runs in background to ensure continuous phone-gateway communication
  • Automatically restarts gateway if connection is lost
  • Monitors device connection status every 10 seconds

Contributing

1. Fork the repository 2. Create a feature branch 3. Implement your changes with tests 4. Submit a pull request with detailed description

๐ŸŽฏ Use Cases

For Professionals

  • Meeting Preparation: Automatically enables focus mode before important calls
  • Work-Life Balance: Smoothly transitions between work and home environments
  • Productivity Optimization: Reduces distractions during deep work sessions

For Students

  • Study Sessions: Creates optimal learning environment during class/homework time
  • Campus Navigation: Assists with commute between campus locations
  • Exam Preparation: Minimizes distractions during critical study periods

For Everyone

  • Digital Wellness: Promotes healthy device usage patterns
  • Sleep Quality: Reduces evening blue light exposure
  • Stress Management: Adapts device behavior based on cognitive load

๐Ÿ† Awards & Recognition

Built for Samsung PRISM OpenClaw Hackathon - Demonstrating the future of personal AI assistants that truly understand and adapt to human behavior.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Support

  • Documentation: See /docs directory for detailed architecture notes
  • Issues: Report bugs and request features via GitHub Issues
  • Community: Join our Discord community for discussions and support

---

CAPE: Where AI meets everyday life. Experience the future of personal automation today. ๐Ÿš€

Related plugins

Browse all โ†’