- Automatic Memory Flush — Curates insights to ByteRover when the context window fills up
- Daily Knowledge Mining — Schedules a cron job to extract and store patterns from session notes
- ByteRover Context Plugin — Injects relevant memory context into every prompt via a hook-based plugin
Prerequisites
Before running the script, ensure the following are installed and available in yourPATH:
| Requirement | How to install |
|---|---|
| Node.js | nodejs.org |
OpenClaw CLI (openclaw) | docs.openclaw.ai/install |
Clawhub (clawhub) | Via OpenClaw’s skill system — install from the OpenClaw gateway console UI |
ByteRover CLI (brv) | docs |
The script verifies each prerequisite and stops with a clear error message if anything is missing. If the
byterover Clawhub skill is not installed, the script will attempt to install it automatically.Quick Start
Run the script with a single command:What the Script Does
Phase 1: Pre-flight Checks
The script verifies all prerequisites are met:- Node.js is installed
- Clawhub is installed
- ByteRover skill is available in Clawhub (auto-installs via
clawhub install --force byteroverif missing) - ByteRover CLI (
brv) is installed - OpenClaw CLI (
openclaw) is installed - Config file (
~/.openclaw/openclaw.json) exists and is valid JSON
openclaw.json.bak.20260226120000).
If the script encounters an error at any point, the backup is automatically restored.
Phase 2: Feature Configuration
You are prompted to enable or disable each feature. Declining a previously enabled feature will cleanly remove its configuration.Feature 1: Automatic Memory Flush
Prompt:Enable Automatic Memory Flush? (y/N)
When enabled, this patches openclaw.json to automatically curate insights to ByteRover when the agent’s context window approaches compaction. The agent will:
- Review the session for architectural decisions, bug fixes, or new patterns
- Run
brv curate "<summary>"to save valuable knowledge to the context tree - Write personal session notes to
memory/YYYY-MM-DD.md
openclaw.json):
Feature 2: Daily Knowledge Mining
Prompt:Enable Daily Knowledge Mining? (y/N)
When enabled, schedules a daily cron job via openclaw cron add that runs at 9:00 AM every day. The cron job:
- Reads the latest file in
memory/(e.g.,memory/2026-02-26.md) - Extracts architectural decisions, reusable patterns, or critical bug fixes
- Runs
brv curate "<summary>"to save findings to the context tree
| Property | Value |
|---|---|
| Name | ByteRover Knowledge Miner |
| Schedule | 0 9 * * * (daily at 9 AM) |
| Session | isolated |
| Announcements | Enabled |
Feature 3: ByteRover Context Plugin
Prompt:Install ByteRover Context Plugin? (y/N)
When enabled, installs a custom OpenClaw plugin that automatically enriches every prompt with relevant context from your ByteRover knowledge base. The plugin:
- Intercepts the
before_prompt_buildevent - Extracts the user’s query from the prompt
- Runs
brv query "<user query>"to retrieve relevant context - Prepends the results as a
## ByteRover Context (Auto-Enriched)section
| File | Location | Description |
|---|---|---|
index.ts | ~/.openclaw/extensions/byterover/ | Plugin implementation (TypeScript) |
openclaw.plugin.json | ~/.openclaw/extensions/byterover/ | Plugin manifest |
openclaw.json):
Phase 3: Workspace Protocol Updates
The script scans youropenclaw.json for configured agent workspaces and appends ByteRover protocol sections to:
- AGENTS.md — Adds a
## Knowledge Protocol (ByteRover)section with instructions for agents to usebrv queryandbrv curate - TOOLS.md — Adds a
## ByteRover (Memory)section with command reference forbrv query,brv curate,brv pull, andbrv push
How It Works
OpenClaw agents use multiple workspaces — one per agent:openclaw.json for configured workspaces and updates their protocol
files (AGENTS.md, TOOLS.md) with ByteRover usage instructions. The .brv/ context tree
directory is created automatically on first use — when an agent runs brv curate or brv query in a workspace:
.brv directory in the current workspace.
Uninstalling / Disabling Features
Re-run the script and decline each feature when prompted. The script will cleanly remove:- Memory Flush — Removes
compaction.memoryFlushandcompaction.reserveTokensFloorfromopenclaw.json - Daily Knowledge Mining — Removes the
ByteRover Knowledge Minercron job viaopenclaw cron remove - Context Plugin — Removes plugin files from
~/.openclaw/extensions/byterover/and disables the plugin entry inopenclaw.json
Troubleshooting
Config file not found
Config file not found
Cause: OpenClaw has not been initialized.Solution: Install and run OpenClaw first:
https://docs.openclaw.ai/install
Config file is not valid JSON
Config file is not valid JSON
Cause: Your
~/.openclaw/openclaw.json is corrupted.Solution: Restore from a backup. The script automatically reverts to the backup if an error occurs during patching. To restore manually:ByteRover CLI is missing
ByteRover CLI is missing
Cause: The
brv command is not in your PATH.Solution: Install the ByteRover CLI docsClawhub is missing
Clawhub is missing
Cause: The
clawhub command is not installed.Solution: Clawhub is part of the OpenClaw ecosystem. Refer to the Clawhub installation guide or install it from the OpenClaw gateway console UI.Failed to schedule cron job
Failed to schedule cron job
Cause: The OpenClaw CLI does not support cron commands or the command failed.Solution: Ensure the OpenClaw CLI supports cron commands:If the command is not recognized, update OpenClaw to the latest version.
Plugin not loading
Plugin not loading
Cause: Plugin files are missing,
brv is not in PATH, or the plugin is not enabled.Solution:- Verify plugin files exist:
- Check that
brvis in your PATH: - Check the plugin is enabled in config:
File Reference
| Path | Description |
|---|---|
~/.openclaw/openclaw.json | OpenClaw configuration (patched by script) |
~/.openclaw/openclaw.json.bak.* | Timestamped config backups |
~/.openclaw/{workspace}/.brv/ | ByteRover context tree storage |
~/.openclaw/extensions/byterover/index.ts | Context plugin source |
~/.openclaw/extensions/byterover/openclaw.plugin.json | Plugin manifest |