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
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,23 +396,35 @@ context-mode runs as a native [OpenClaw](https://github.com/openclaw) gateway pl

**Install:**

1. Clone and install:
**Quick install** (one-liner):

```bash
git clone https://github.com/mksglu/context-mode.git
cd context-mode
npm run install:openclaw
```
```bash
curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash
```

The installer uses `$OPENCLAW_STATE_DIR` from your environment (default: `/openclaw`). To specify a custom path:
For a custom state directory:

```bash
npm run install:openclaw -- /path/to/openclaw-state
```
```bash
curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash -s -- ~/.openclaw
```

**Manual install:**

```bash
git clone https://github.com/mksglu/context-mode.git
cd context-mode
npm run install:openclaw
```

The installer uses `$OPENCLAW_STATE_DIR` from your environment (default: `/openclaw`). To specify a custom path:

```bash
npm run install:openclaw -- ~/.openclaw
```

Common locations: **Docker** — `/openclaw` (the default). **Local** — `~/.openclaw` or wherever you set `OPENCLAW_STATE_DIR`.
Common locations: **Docker** — `/openclaw` (the default). **Local** — `~/.openclaw` or wherever you set `OPENCLAW_STATE_DIR`.

The installer handles everything: `npm install`, `npm run build`, `better-sqlite3` native rebuild, extension registration in `runtime.json`, and gateway restart via SIGUSR1.
The installer handles everything: `npm install`, `npm run build`, `better-sqlite3` native rebuild, extension registration in `openclaw.json`, and gateway restart via SIGUSR1.

2. Open a Pi Agent session.

Expand Down
18 changes: 16 additions & 2 deletions docs/adapters/openclaw.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,21 @@ The context-mode adapter hooks into Pi Agent sessions specifically, intercepting

## Installation

### Quick install
### Quick install (one-liner)

```bash
curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash
```

For a custom state directory:

```bash
curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash -s -- ~/.openclaw
```

This clones context-mode, builds it, and registers the plugin into OpenClaw — all in one step.

### Quick install (from clone)

```bash
npm run install:openclaw
Expand Down Expand Up @@ -45,7 +59,7 @@ See [`scripts/install-openclaw-plugin.sh`](../../scripts/install-openclaw-plugin
OpenClaw creates this file on first launch. Start OpenClaw once (`openclaw gateway start`), then re-run the install script. This is the most common issue for users who install context-mode before ever starting OpenClaw.

**"OPENCLAW_STATE_DIR (/path) does not exist. Is OpenClaw installed?"**
The state directory doesn't exist at the expected path. If you installed OpenClaw via npm (not git clone), check where it stores state — common locations are `~/.openclaw` or `/openclaw`. Pass the correct path: `npm run install:openclaw -- /path/to/state`.
The state directory doesn't exist at the expected path. If you installed OpenClaw via npm (not git clone), check where it stores state — common locations are `~/.openclaw` or `/openclaw`. Pass the correct path: `npm run install:openclaw -- ~/.openclaw` or `curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash -s -- ~/.openclaw`.

**Plugin installed but not loading**
Clear the jiti cache (`rm -f /tmp/jiti/context-mode-*.cjs`) and restart the gateway. If the issue persists, verify the plugin appears in `openclaw plugins list`.
Expand Down
50 changes: 50 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash
#
# One-liner installer for context-mode (OpenClaw plugin).
# Clones the repo, builds, and registers the plugin into OpenClaw.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash
# curl -fsSL https://raw.githubusercontent.com/mksglu/context-mode/main/install.sh | bash -s -- /path/to/openclaw-state
#
# Environment variables:
# OPENCLAW_STATE_DIR — OpenClaw state directory (default: /openclaw)
# CONTEXT_MODE_DIR — Where to clone context-mode (default: /tmp/context-mode-install)

set -euo pipefail

OPENCLAW_STATE_DIR="${1:-${OPENCLAW_STATE_DIR:-/openclaw}}"
INSTALL_DIR="${CONTEXT_MODE_DIR:-/tmp/context-mode-install}"

echo "→ context-mode one-liner installer"
echo " openclaw state dir : $OPENCLAW_STATE_DIR"
echo " install dir : $INSTALL_DIR"

# Preflight
if ! command -v node &>/dev/null; then
echo "✗ node is required but not found in PATH" >&2
exit 1
fi

if [ ! -d "$OPENCLAW_STATE_DIR" ]; then
echo "✗ OPENCLAW_STATE_DIR ($OPENCLAW_STATE_DIR) does not exist. Is OpenClaw installed?" >&2
exit 1
fi

# Clone (shallow) if not already present
if [ ! -d "$INSTALL_DIR/.git" ]; then
echo "→ cloning context-mode..."
git clone --depth 1 https://github.com/mksglu/context-mode.git "$INSTALL_DIR"
else
echo "→ updating context-mode..."
git -C "$INSTALL_DIR" pull --ff-only || git -C "$INSTALL_DIR" fetch && git -C "$INSTALL_DIR" reset --hard origin/main
fi

# Run the installer
echo "→ running plugin installer..."
cd "$INSTALL_DIR"
bash scripts/install-openclaw-plugin.sh "$OPENCLAW_STATE_DIR"

echo ""
echo "✓ done — context-mode installed via one-liner"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"test:use-cases": "npx tsx tests/use-cases.ts",
"test:compare": "npx tsx tests/context-comparison.ts",
"test:ecosystem": "npx tsx tests/ecosystem-benchmark.ts",
"install:openclaw": "node -e \"if(process.platform==='win32'){console.error('OpenClaw install requires bash (Git Bash or WSL)');process.exit(1)}else{require('child_process').execSync('bash scripts/install-openclaw-plugin.sh',{stdio:'inherit'})}\"",
"install:openclaw": "node -e \"if(process.platform==='win32'){console.error('OpenClaw install requires bash (Git Bash or WSL)');process.exit(1)}else{const args=process.argv.slice(1).join(' ');require('child_process').execSync('bash scripts/install-openclaw-plugin.sh '+args,{stdio:'inherit'})}\"",
"postinstall": "node scripts/postinstall.mjs"
},
"dependencies": {
Expand Down