Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"ref": "master"
},
"description": "Multi-agent intelligence powered by Grok 4.20 via OpenRouter. 4-agent swarm with ~2M token context for code analysis, refactoring, and reasoning.",
"version": "1.3.5",
"version": "1.3.6",
"author": {
"name": "Billy Brenner & Claude"
},
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to the Grok Swarm tool.

## [1.3.6] - 2026-04-16

### Fixed

- Replaced the non-portable Claude plugin MCP config with a `${CLAUDE_PLUGIN_ROOT}` wrapper entrypoint
- Added first-start MCP runtime bootstrapping so plugin MCP can create/use the plugin-local `.venv`
- Stopped setup from creating duplicate manual `grok-swarm` MCP entries when Claude manages the plugin-scoped server
- Added release checks that block machine-local absolute paths and `${PLUGIN_ROOT}` from shipping in Claude MCP config

## [1.3.3] - 2026-04-08

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion CLAWHUB.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| Field | Value |
|-------|-------|
| **Name** | `grok-swarm` |
| **Version** | `1.3.5` |
| **Version** | `1.3.6` |
| **Min OpenClaw** | `2026.3.0` |

## Installation
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.5
1.3.6
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@khaentertainment/grok-swarm",
"version": "1.3.5",
"version": "1.3.6",
"description": "Multi-agent intelligence powered by Grok 4.20 via OpenRouter. Give any AI coding agent access to a 4-agent swarm with ~2M token context.",
"keywords": [
"grok",
Expand Down
2 changes: 1 addition & 1 deletion platforms/claude/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifestVersion": 1,
"name": "grok-swarm",
"version": "1.3.5",
"version": "1.3.6",
"displayName": "Grok Swarm",
"description": "Multi-agent intelligence powered by Grok 4.20 via OpenRouter. Use for codebase analysis, refactoring, code generation, and complex reasoning.",
"author": {
Expand Down
86 changes: 14 additions & 72 deletions platforms/claude/.claude-plugin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ set -euo pipefail
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
CONFIG_DIR="${HOME}/.config/grok-swarm"
CONFIG_FILE="${CONFIG_DIR}/config.json"
VENV_DIR="${PLUGIN_ROOT}/.venv"
REQUIREMENTS_FILE="${PLUGIN_ROOT}/src/requirements.txt"
MCP_SERVER="${PLUGIN_ROOT}/src/mcp/grok_server.py"
OAUTH_SCRIPT="${PLUGIN_ROOT}/src/bridge/oauth_setup.py"
BOOTSTRAP_SCRIPT="${PLUGIN_ROOT}/scripts/bootstrap-runtime.sh"
PYTHON_BIN=""
SYSTEM_PYTHON=""
STAMP_FILE="${VENV_DIR}/.grok-swarm-requirements.sha256"

# Colors
RED='\033[0;31m'
Expand All @@ -25,73 +21,19 @@ log() { echo -e "${GREEN}[+]${NC} $1"; }
warn() { echo -e "${YELLOW}[!]${NC} $1" >&2; }
error() { echo -e "${RED}[✗]${NC} $1" >&2; }

resolve_system_python() {
if command -v python3 >/dev/null 2>&1; then
SYSTEM_PYTHON="$(command -v python3)"
elif command -v python >/dev/null 2>&1; then
SYSTEM_PYTHON="$(command -v python)"
else
error "Python 3 is required. Install Python 3.8+ and re-run setup."
exit 1
fi
}

requirements_hash() {
"$SYSTEM_PYTHON" - <<'PY' "$REQUIREMENTS_FILE"
import hashlib
import pathlib
import sys

path = pathlib.Path(sys.argv[1])
print(hashlib.sha256(path.read_bytes()).hexdigest())
PY
}

ensure_runtime() {
resolve_system_python

if [ ! -f "$REQUIREMENTS_FILE" ]; then
error "Plugin runtime is incomplete: missing ${REQUIREMENTS_FILE}."
error "Reinstall the Grok Swarm Claude plugin so the bundled runtime is present."
exit 1
fi

if [ ! -f "$OAUTH_SCRIPT" ] || [ ! -f "$MCP_SERVER" ]; then
error "Plugin runtime files are missing from ${PLUGIN_ROOT}/src."
if [ ! -f "$BOOTSTRAP_SCRIPT" ]; then
error "Plugin runtime is incomplete: missing ${BOOTSTRAP_SCRIPT}."
error "Reinstall the Grok Swarm Claude plugin and try again."
exit 1
fi

if [ ! -d "$VENV_DIR" ]; then
log "Creating plugin-local Python environment..."
"$SYSTEM_PYTHON" -m venv "$VENV_DIR"
fi

PYTHON_BIN="${VENV_DIR}/bin/python3"
if [ ! -x "$PYTHON_BIN" ]; then
PYTHON_BIN="${VENV_DIR}/bin/python"
fi

PYTHON_BIN="$("$BOOTSTRAP_SCRIPT")"
if [ ! -x "$PYTHON_BIN" ]; then
error "Failed to create a usable Python interpreter in ${VENV_DIR}."
error "Bootstrap did not return a usable Python interpreter."
exit 1
fi

local wanted_hash=""
local current_hash=""
wanted_hash="$(requirements_hash)"
if [ -f "$STAMP_FILE" ]; then
current_hash="$(cat "$STAMP_FILE" 2>/dev/null || true)"
fi

if [ "$wanted_hash" != "$current_hash" ] || ! "$PYTHON_BIN" -c "import openai" >/dev/null 2>&1; then
log "Installing Grok Swarm Python dependencies into ${VENV_DIR}..."
"$PYTHON_BIN" -m pip install --quiet --upgrade pip
"$PYTHON_BIN" -m pip install --quiet -r "$REQUIREMENTS_FILE"
printf '%s\n' "$wanted_hash" > "$STAMP_FILE"
else
log "Plugin-local Python dependencies already installed"
fi
log "Plugin-local Python runtime ready at ${PYTHON_BIN}"
}

echo "=========================================="
Expand Down Expand Up @@ -128,19 +70,19 @@ if [ "$HAVE_KEY" -eq 0 ]; then
fi
fi

# Register MCP server for native tool integration
# Claude Code starts plugin MCP servers automatically from .mcp.json.
# Remove the legacy manual entry created by older setup flows when the plugin
# scoped server is visible, otherwise users see duplicate Grok MCP servers.
if command -v claude >/dev/null 2>&1; then
echo
log "Registering Grok Swarm MCP server..."
claude mcp remove grok-swarm >/dev/null 2>&1 || true
if claude mcp add grok-swarm -- "$PYTHON_BIN" "$MCP_SERVER" 2>/dev/null; then
log "MCP server registered — grok_query, grok_session_start/continue, grok_agent tools available"
if claude mcp list 2>/dev/null | grep -q '^plugin:grok-swarm:grok-swarm:'; then
claude mcp remove grok-swarm >/dev/null 2>&1 || true
log "Plugin MCP server is managed by Claude Code"
else
warn "MCP registration failed (non-fatal). Register manually:"
warn " claude mcp add grok-swarm -- $PYTHON_BIN $MCP_SERVER"
warn "Plugin MCP server is not visible yet. Restart Claude Code or re-enable the plugin if MCP tools do not appear."
fi
else
warn "Claude CLI not found, skipping MCP registration."
warn "Claude CLI not found; plugin MCP will be managed by Claude Code when available."
fi

echo
Expand Down
12 changes: 7 additions & 5 deletions platforms/claude/.mcp.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"grok-swarm": {
"command": "python3",
"args": ["${PLUGIN_ROOT}/src/mcp/grok_server.py"],
"env": {
"PYTHONPATH": "${PLUGIN_ROOT}/src"
"mcpServers": {
"grok-swarm": {
"command": "bash",
"args": ["${CLAUDE_PLUGIN_ROOT}/scripts/mcp-server.sh"],
"env": {
"PYTHONPATH": "${CLAUDE_PLUGIN_ROOT}/src"
}
}
}
}
3 changes: 2 additions & 1 deletion platforms/claude/commands/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ if [ "$NEEDS_SETUP" -eq 0 ] && ! "$PYTHON_BIN" -c "import openai" >/dev/null 2>&
fi

if command -v claude >/dev/null 2>&1; then
if ! claude mcp list 2>/dev/null | grep -q '^grok-swarm:'; then
if ! claude mcp list 2>/dev/null | grep -Eq '^(plugin:grok-swarm:grok-swarm|grok-swarm):'; then
log "Grok Swarm MCP server is not visible yet; setup will verify runtime and credentials."
NEEDS_SETUP=1
fi
fi
Expand Down
81 changes: 81 additions & 0 deletions platforms/claude/scripts/bootstrap-runtime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# Bootstrap the plugin-local Python runtime and print the interpreter path.

set -euo pipefail

PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
VENV_DIR="${PLUGIN_ROOT}/.venv"
REQUIREMENTS_FILE="${PLUGIN_ROOT}/src/requirements.txt"
OAUTH_SCRIPT="${PLUGIN_ROOT}/src/bridge/oauth_setup.py"
MCP_SERVER="${PLUGIN_ROOT}/src/mcp/grok_server.py"
STAMP_FILE="${VENV_DIR}/.grok-swarm-requirements.sha256"
SYSTEM_PYTHON=""
PYTHON_BIN=""

log() { printf '%s\n' "$*" >&2; }

resolve_system_python() {
if command -v python3 >/dev/null 2>&1; then
SYSTEM_PYTHON="$(command -v python3)"
elif command -v python >/dev/null 2>&1; then
SYSTEM_PYTHON="$(command -v python)"
else
log "ERROR: Python 3 is required. Install Python 3.8+ and re-run /grok-swarm-setup."
exit 1
fi
}

requirements_hash() {
"$SYSTEM_PYTHON" - <<'PY' "$REQUIREMENTS_FILE"
import hashlib
import pathlib
import sys

path = pathlib.Path(sys.argv[1])
print(hashlib.sha256(path.read_bytes()).hexdigest())
PY
}

if [ ! -f "$REQUIREMENTS_FILE" ]; then
log "ERROR: Plugin runtime is incomplete: missing ${REQUIREMENTS_FILE}."
log "Reinstall the Grok Swarm Claude plugin so the bundled runtime is present."
exit 1
fi

if [ ! -f "$OAUTH_SCRIPT" ] || [ ! -f "$MCP_SERVER" ]; then
log "ERROR: Plugin runtime files are missing from ${PLUGIN_ROOT}/src."
log "Reinstall the Grok Swarm Claude plugin and try again."
exit 1
fi

resolve_system_python

if [ ! -d "$VENV_DIR" ]; then
log "Creating Grok Swarm plugin-local Python environment..."
"$SYSTEM_PYTHON" -m venv "$VENV_DIR"
fi

PYTHON_BIN="${VENV_DIR}/bin/python3"
if [ ! -x "$PYTHON_BIN" ]; then
PYTHON_BIN="${VENV_DIR}/bin/python"
fi

if [ ! -x "$PYTHON_BIN" ]; then
log "ERROR: Failed to create a usable Python interpreter in ${VENV_DIR}."
exit 1
fi

wanted_hash="$(requirements_hash)"
current_hash=""
if [ -f "$STAMP_FILE" ]; then
current_hash="$(cat "$STAMP_FILE" 2>/dev/null || true)"
fi

if [ "$wanted_hash" != "$current_hash" ] || ! "$PYTHON_BIN" -c "import openai" >/dev/null 2>&1; then
log "Installing Grok Swarm Python dependencies into ${VENV_DIR}..."
"$PYTHON_BIN" -m pip install --quiet --upgrade pip
"$PYTHON_BIN" -m pip install --quiet -r "$REQUIREMENTS_FILE"
printf '%s\n' "$wanted_hash" > "$STAMP_FILE"
fi

printf '%s\n' "$PYTHON_BIN"
9 changes: 9 additions & 0 deletions platforms/claude/scripts/mcp-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Claude plugin MCP entrypoint. Bootstraps runtime before execing the server.

set -euo pipefail

PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
PYTHON_BIN="$("$PLUGIN_ROOT/scripts/bootstrap-runtime.sh")"

exec "$PYTHON_BIN" "$PLUGIN_ROOT/src/mcp/grok_server.py"
2 changes: 1 addition & 1 deletion platforms/claude/skills/grok-swarm/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: grok-swarm
description: Multi-agent intelligence powered by Grok 4.20 via OpenRouter. Use for codebase analysis, refactoring, code generation, and complex reasoning. Triggers: "use grok swarm", "grok 4.20", "multi-agent analysis", "codebase audit", "grok refactor", "16 agent mode"
author: OpenClaw
version: 1.3.4
version: 1.3.6
---

# Grok Swarm
Expand Down
2 changes: 1 addition & 1 deletion platforms/claude/src/mcp/grok_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
# ---------------------------------------------------------------------------

SERVER_NAME = "grok-swarm"
SERVER_VERSION = "1.3.4"
SERVER_VERSION = "1.3.6"
PROTOCOL_VERSION = "2024-11-05"

# ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "grok-swarm"
version = "1.3.5"
version = "1.3.6"
description = "Multi-agent intelligence powered by Grok 4.20 via OpenRouter"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
14 changes: 14 additions & 0 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const requiredClaudeCommands = [
'platforms/claude/commands/grok-swarm-stats.md',
'platforms/claude/commands/grok-swarm-set-key.md',
'platforms/claude/commands/setup.sh',
'platforms/claude/scripts/bootstrap-runtime.sh',
'platforms/claude/scripts/mcp-server.sh',
];

console.log('Running Grok Swarm CLI tests...\n');
Expand All @@ -34,6 +36,18 @@ if (missingFiles.length > 0) {

console.log(`✓ Claude bundle command files present (${requiredClaudeCommands.length})`);

const mcpConfigPath = path.join(root, 'platforms/claude/.mcp.json');
const mcpConfig = fs.readFileSync(mcpConfigPath, 'utf8');
if (!mcpConfig.includes('${CLAUDE_PLUGIN_ROOT}/scripts/mcp-server.sh')) {
console.log('✗ Claude MCP config does not use the plugin-local wrapper');
process.exit(1);
}
if (mcpConfig.includes('${PLUGIN_ROOT}') || /\/Users\/|\/home\/|[A-Za-z]:\\/.test(mcpConfig)) {
console.log('✗ Claude MCP config contains non-portable paths');
process.exit(1);
}
console.log('✓ Claude MCP config is portable');

// Test: grok-swarm --help
const help = spawn('node', [grokBin, '--help'], { stdio: 'pipe' });

Expand Down
Loading