brainclaw 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/commands/setup.js +1 -0
- package/dist/core/agent-capability.js +12 -0
- package/dist/core/agent-integrations.js +3 -0
- package/dist/core/ai-agent-detection.js +34 -19
- package/dist/core/schema.js +1 -0
- package/docs/integrations/openclaw.md +98 -0
- package/docs/integrations/overview.md +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,8 +78,9 @@ brainclaw is designed to sit alongside the coding agents teams are already using
|
|
|
78
78
|
| [](https://github.com/continuedev/continue) | **[Continue](https://github.com/continuedev/continue)** | Standard | MCP + .continue/rules/ |
|
|
79
79
|
| [](https://github.com/google-gemini/gemini-cli) | **[Antigravity / Gemini CLI](https://github.com/google-gemini/gemini-cli)** | Standard | MCP + GEMINI.md |
|
|
80
80
|
| [](https://github.com/features/copilot) | **[GitHub Copilot](https://github.com/features/copilot)** | Limited | copilot-instructions.md + brainclaw-context skill |
|
|
81
|
+
| [](https://github.com/openclaw/openclaw) | **[OpenClaw](https://github.com/openclaw/openclaw)** | Limited | brainclaw skill (SKILL.md) for structured project memory |
|
|
81
82
|
|
|
82
|
-
**Full** = MCP + hooks + auto-approve (context injected every prompt). **Standard** = MCP + instruction file (agent must call tools explicitly). **Limited** =
|
|
83
|
+
**Full** = MCP + hooks + auto-approve (context injected every prompt). **Standard** = MCP + instruction file (agent must call tools explicitly). **Limited** = skill-based (agent calls brainclaw CLI via skill instructions).
|
|
83
84
|
|
|
84
85
|
brainclaw is most effective today when one agent works at a time in a given checkout and the next agent resumes from shared context, claims, and handoffs.
|
|
85
86
|
|
package/dist/commands/setup.js
CHANGED
|
@@ -129,6 +129,18 @@ const PROFILES = {
|
|
|
129
129
|
mcpConfigScope: 'none',
|
|
130
130
|
templateTier: 'C',
|
|
131
131
|
},
|
|
132
|
+
openclaw: {
|
|
133
|
+
name: 'openclaw',
|
|
134
|
+
hasMcp: false,
|
|
135
|
+
hasHooks: false,
|
|
136
|
+
hasAutoApprove: false,
|
|
137
|
+
hasSkills: true,
|
|
138
|
+
hasRules: false,
|
|
139
|
+
instructionFile: 'skills/openclaw/SKILL.md',
|
|
140
|
+
sharedInstructionFile: false,
|
|
141
|
+
mcpConfigScope: 'none',
|
|
142
|
+
templateTier: 'C',
|
|
143
|
+
},
|
|
132
144
|
};
|
|
133
145
|
/**
|
|
134
146
|
* Get the capability profile for a known agent.
|
|
@@ -57,6 +57,9 @@ const DEFAULT_SURFACES = {
|
|
|
57
57
|
{ kind: 'instructions', location: 'workspace', path: '.roo/rules/brainclaw.md' },
|
|
58
58
|
{ kind: 'mcp', location: 'workspace', path: '.roo/mcp.json' },
|
|
59
59
|
],
|
|
60
|
+
'openclaw': [
|
|
61
|
+
{ kind: 'skill', location: 'machine', path: '.openclaw/workspace/skills/brainclaw/SKILL.md' },
|
|
62
|
+
],
|
|
60
63
|
};
|
|
61
64
|
function mergeSurfaces(current, next) {
|
|
62
65
|
const merged = [...current];
|
|
@@ -6,18 +6,20 @@ import os from 'node:os';
|
|
|
6
6
|
* environment variables and well-known config paths. Returns the first confident
|
|
7
7
|
* match, or undefined if no agent is detected.
|
|
8
8
|
*
|
|
9
|
-
* Detection order (highest confidence first
|
|
9
|
+
* Detection order (highest confidence first — agents with dedicated env vars
|
|
10
|
+
* are tested before agents detected via passive/ambient env vars):
|
|
10
11
|
* 1. BRAINCLAW_AGENT env var (explicit override)
|
|
11
|
-
* 2.
|
|
12
|
-
* 3.
|
|
13
|
-
* 4.
|
|
14
|
-
* 5.
|
|
15
|
-
* 6.
|
|
12
|
+
* 2. Claude Code (CLAUDE_CODE_VERSION — set by Claude Code itself)
|
|
13
|
+
* 3. Cursor (CURSOR_TRACE_ID — set by Cursor itself)
|
|
14
|
+
* 4. Windsurf (WINDSURF_SESSION_ID — set by Windsurf itself)
|
|
15
|
+
* 5. Cline (CLINE_AGENT — set by Cline itself)
|
|
16
|
+
* 6. GitHub Copilot (GITHUB_COPILOT_PRODUCT — passive VS Code env, tested after active agents)
|
|
16
17
|
* 7. Codex CLI (~/.codex/ directory exists)
|
|
17
18
|
* 8. OpenCode (OPENCODE_* env or ~/.config/opencode/)
|
|
18
19
|
* 9. Antigravity / Gemini CLI (ANTIGRAVITY_* env or ~/.gemini/antigravity/)
|
|
19
20
|
* 10. Continue (CONTINUE_*)
|
|
20
21
|
* 11. Roo Code (ROO_*)
|
|
22
|
+
* 12. OpenClaw (~/.openclaw/ or OPENCLAW_*)
|
|
21
23
|
*/
|
|
22
24
|
export function detectAiAgent(env = process.env, homeDir = os.homedir()) {
|
|
23
25
|
// Explicit override
|
|
@@ -29,24 +31,14 @@ export function detectAiAgent(env = process.env, homeDir = os.homedir()) {
|
|
|
29
31
|
detection_source: 'BRAINCLAW_AGENT env var',
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
env.GITHUB_COPILOT_PRODUCT ||
|
|
35
|
-
(env.VSCODE_GIT_IPC_HANDLE && (env.AGENT_NAME?.toLowerCase().includes('copilot') || env.GH_COPILOT_AGENT))) {
|
|
36
|
-
return {
|
|
37
|
-
name: 'github-copilot',
|
|
38
|
-
kind: 'agent',
|
|
39
|
-
trust_level: 'trusted',
|
|
40
|
-
detection_source: 'GITHUB_COPILOT_* env var',
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// Claude Code (Anthropic's CLI coding agent)
|
|
34
|
+
// Claude Code — tested BEFORE Copilot because both can be present in VS Code.
|
|
35
|
+
// CLAUDE_CODE_VERSION is set by Claude Code itself, not by VS Code passively.
|
|
44
36
|
if (env.CLAUDE_CODE_VERSION || env.ANTHROPIC_AI_PRODUCT === 'claude-code') {
|
|
45
37
|
return {
|
|
46
38
|
name: 'claude-code',
|
|
47
39
|
kind: 'agent',
|
|
48
40
|
trust_level: 'trusted',
|
|
49
|
-
detection_source: 'CLAUDE_CODE_VERSION env var',
|
|
41
|
+
detection_source: env.CLAUDE_CODE_VERSION ? 'CLAUDE_CODE_VERSION env var' : 'ANTHROPIC_AI_PRODUCT env var',
|
|
50
42
|
};
|
|
51
43
|
}
|
|
52
44
|
// Cursor IDE
|
|
@@ -76,6 +68,20 @@ export function detectAiAgent(env = process.env, homeDir = os.homedir()) {
|
|
|
76
68
|
detection_source: 'CLINE_* env var',
|
|
77
69
|
};
|
|
78
70
|
}
|
|
71
|
+
// GitHub Copilot — tested AFTER agents with dedicated env vars.
|
|
72
|
+
// GITHUB_COPILOT_TOKEN and GITHUB_COPILOT_PRODUCT are set passively by VS Code
|
|
73
|
+
// whenever the Copilot extension is installed, even when another agent is active.
|
|
74
|
+
// We only match if no higher-priority agent was detected above.
|
|
75
|
+
if (env.GITHUB_COPILOT_PRODUCT ||
|
|
76
|
+
(env.GITHUB_COPILOT_TOKEN && !env.CLAUDE_CODE_VERSION && !env.CURSOR_TRACE_ID && !env.WINDSURF_SESSION_ID) ||
|
|
77
|
+
(env.VSCODE_GIT_IPC_HANDLE && (env.AGENT_NAME?.toLowerCase().includes('copilot') || env.GH_COPILOT_AGENT))) {
|
|
78
|
+
return {
|
|
79
|
+
name: 'github-copilot',
|
|
80
|
+
kind: 'agent',
|
|
81
|
+
trust_level: 'trusted',
|
|
82
|
+
detection_source: env.GITHUB_COPILOT_PRODUCT ? 'GITHUB_COPILOT_PRODUCT env var' : 'GITHUB_COPILOT_TOKEN env var',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
79
85
|
// OpenAI Codex CLI (~/.codex/ presence)
|
|
80
86
|
if (fs.existsSync(path.join(homeDir, '.codex'))) {
|
|
81
87
|
return {
|
|
@@ -121,6 +127,15 @@ export function detectAiAgent(env = process.env, homeDir = os.homedir()) {
|
|
|
121
127
|
detection_source: 'ROO_* env var',
|
|
122
128
|
};
|
|
123
129
|
}
|
|
130
|
+
// OpenClaw (~/.openclaw/ presence or OPENCLAW_* env)
|
|
131
|
+
if (env.OPENCLAW_SESSION_ID || env.OPENCLAW_AGENT || fs.existsSync(path.join(homeDir, '.openclaw'))) {
|
|
132
|
+
return {
|
|
133
|
+
name: 'openclaw',
|
|
134
|
+
kind: 'agent',
|
|
135
|
+
trust_level: 'trusted',
|
|
136
|
+
detection_source: env.OPENCLAW_SESSION_ID || env.OPENCLAW_AGENT ? 'OPENCLAW_* env var' : '~/.openclaw directory',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
124
139
|
return undefined;
|
|
125
140
|
}
|
|
126
141
|
/**
|
package/dist/core/schema.js
CHANGED
|
@@ -624,6 +624,7 @@ export const AgentIntegrationNameSchema = z.enum([
|
|
|
624
624
|
'antigravity',
|
|
625
625
|
'continue',
|
|
626
626
|
'roo',
|
|
627
|
+
'openclaw',
|
|
627
628
|
]);
|
|
628
629
|
export const AgentIntegrationSurfaceKindSchema = z.enum(['instructions', 'mcp', 'skill', 'rule', 'hook']);
|
|
629
630
|
export const AgentIntegrationLocationSchema = z.enum(['workspace', 'machine']);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# OpenClaw Integration
|
|
2
|
+
|
|
3
|
+
## Why brainclaw for OpenClaw users
|
|
4
|
+
|
|
5
|
+
OpenClaw's built-in memory (`MEMORY.md` + daily logs) is great for personal notes and preferences, but it doesn't distinguish between different types of project knowledge. After many conversations, constraints get buried, decisions lose their reasoning, and the agent drifts from its original instructions.
|
|
6
|
+
|
|
7
|
+
brainclaw adds a structured memory layer on top:
|
|
8
|
+
|
|
9
|
+
| Problem | OpenClaw alone | With brainclaw |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| "Don't deploy on Friday" gets forgotten | Buried in MEMORY.md after 50 conversations | Stored as a constraint, always visible |
|
|
12
|
+
| Agent repeats a known mistake | No trap system | Traps scored by relevance to current scope |
|
|
13
|
+
| Two agents work on same file | No coordination | Claims prevent collisions |
|
|
14
|
+
| Decision reasoning is lost | Mixed with daily notes | Preserved as typed decisions, searchable |
|
|
15
|
+
|
|
16
|
+
## How it works
|
|
17
|
+
|
|
18
|
+
brainclaw integrates as an OpenClaw **skill**. The skill instructs the agent to:
|
|
19
|
+
|
|
20
|
+
1. Load brainclaw project context before any coding work
|
|
21
|
+
2. Record constraints, traps, and decisions in brainclaw (not MEMORY.md)
|
|
22
|
+
3. Keep MEMORY.md for personal preferences and daily observations
|
|
23
|
+
4. Coordinate with other agents through plans and claims
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### Prerequisites
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g brainclaw
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Install the skill
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
brainclaw enable-agent openclaw
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This copies the brainclaw skill to `~/.openclaw/workspace/skills/brainclaw/`.
|
|
40
|
+
|
|
41
|
+
Or manually:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
mkdir -p ~/.openclaw/workspace/skills/brainclaw
|
|
45
|
+
cp "$(npm root -g)/brainclaw/skills/openclaw/SKILL.md" ~/.openclaw/workspace/skills/brainclaw/
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Initialize a project
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cd /path/to/your/project
|
|
52
|
+
brainclaw init
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Restart OpenClaw
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
/new
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
or restart the Gateway. The brainclaw skill will be loaded automatically.
|
|
62
|
+
|
|
63
|
+
## What the agent sees
|
|
64
|
+
|
|
65
|
+
After installation, your OpenClaw agent will:
|
|
66
|
+
|
|
67
|
+
- Run `brainclaw context` before project work to load constraints, traps, and plans
|
|
68
|
+
- Record rules you give it as brainclaw constraints (not just MEMORY.md entries)
|
|
69
|
+
- Record problems it discovers as traps (with severity)
|
|
70
|
+
- Log architectural decisions with their reasoning
|
|
71
|
+
- Clean up with `brainclaw session-end` when finished
|
|
72
|
+
|
|
73
|
+
## Memory split
|
|
74
|
+
|
|
75
|
+
The brainclaw skill establishes a clear split:
|
|
76
|
+
|
|
77
|
+
- **MEMORY.md** — your preferences, habits, personal context (OpenClaw manages this)
|
|
78
|
+
- **brainclaw** — project constraints, traps, decisions, plans (shared with all agents)
|
|
79
|
+
|
|
80
|
+
This means if you switch from OpenClaw to Claude Code or Codex for coding, the project memory follows — it's in `.brainclaw/`, not in `~/.openclaw/`.
|
|
81
|
+
|
|
82
|
+
## Multi-agent coordination
|
|
83
|
+
|
|
84
|
+
If you use both OpenClaw and a coding agent (Claude Code, Cursor, etc.) on the same project, brainclaw coordinates between them:
|
|
85
|
+
|
|
86
|
+
- OpenClaw records a constraint → Claude Code sees it at next session
|
|
87
|
+
- Claude Code claims a file scope → OpenClaw knows not to edit there
|
|
88
|
+
- Either agent creates a plan → both see it in their context
|
|
89
|
+
|
|
90
|
+
## Profile
|
|
91
|
+
|
|
92
|
+
When loading context for OpenClaw, use the `openclaw` profile for optimized scoring:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
brainclaw context --profile openclaw
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This boosts constraints, handoffs, and runtime notes — the items most relevant to an agent that might not be editing code directly but needs to understand the project state.
|
|
@@ -69,6 +69,7 @@ The agent cannot call brainclaw tools at all. The instruction file becomes the o
|
|
|
69
69
|
| **Codex** | ✔ global | AGENTS.md | — | — | — |
|
|
70
70
|
| **Gemini CLI** | ✔ global | GEMINI.md | — | — | — |
|
|
71
71
|
| **Copilot** | — | .github/copilot-instructions.md | — | — | ✔ brainclaw-context |
|
|
72
|
+
| **OpenClaw** | — | — | — | — | ✔ brainclaw skill |
|
|
72
73
|
|
|
73
74
|
**Legend:** ✔ = fully supported, ◐ = partial (static trigger, not dynamic injection), — = not available
|
|
74
75
|
|
|
@@ -98,3 +99,4 @@ Running multiple agents in parallel on the same checkout will create conflicts.
|
|
|
98
99
|
- [cursor.md](cursor.md)
|
|
99
100
|
- [codex.md](codex.md)
|
|
100
101
|
- [copilot.md](copilot.md)
|
|
102
|
+
- [openclaw.md](openclaw.md)
|