Skip to content

Commit 71b2373

Browse files
committed
Fix OpenClaw plugin registration and compat
1 parent af9e2b5 commit 71b2373

13 files changed

Lines changed: 522 additions & 584 deletions

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,27 @@ clawvault setup --theme neural --canvas --bases
267267

268268
## OpenClaw Integration
269269

270-
For hook-based lifecycle integration with OpenClaw:
270+
For native plugin-based lifecycle integration with OpenClaw:
271271

272272
```bash
273-
# Install and enable hook pack
274-
openclaw hooks install clawvault
275-
openclaw hooks enable clawvault
273+
# Install ClawVault and allow the plugin
274+
npm install -g clawvault
275+
openclaw config set plugins.allow '["clawvault"]'
276+
openclaw config set plugins.slots.memory clawvault
277+
278+
# Configure the plugin
279+
openclaw config set plugins.entries.clawvault.config.vaultPath ~/memory
280+
openclaw config set plugins.entries.clawvault.config.allowClawvaultExec true
276281

277282
# Verify
278-
openclaw hooks list --verbose
279-
openclaw hooks check
283+
openclaw doctor
280284
clawvault compat
281285
```
282286

283-
The hook automatically:
284-
- Detects context death and injects recovery alerts
285-
- Auto-checkpoints before session resets
286-
- Provides `--profile auto` for context queries
287+
The plugin can automatically:
288+
- Detect context death and inject recovery alerts
289+
- Auto-checkpoint before session resets
290+
- Provide structured memory tools and lifecycle-driven recall
287291

288292
### MEMORY.md vs Vault
289293

@@ -351,27 +355,29 @@ clawvault compat
351355

352356
## OpenClaw Setup (Canonical)
353357

354-
If you want hook-based lifecycle integration, use this sequence:
358+
If you want native OpenClaw plugin integration, use this sequence:
355359

356360
```bash
357361
# Install CLI
358362
npm install -g clawvault
359363

360-
# Install and enable hook pack
361-
openclaw hooks install clawvault
362-
openclaw hooks enable clawvault
364+
# Enable the native plugin slot
365+
openclaw config set plugins.allow '["clawvault"]'
366+
openclaw config set plugins.slots.memory clawvault
367+
368+
# Configure the plugin
369+
openclaw config set plugins.entries.clawvault.config.vaultPath ~/memory
370+
openclaw config set plugins.entries.clawvault.config.allowClawvaultExec true
363371

364372
# Verify
365-
openclaw hooks list --verbose
366-
openclaw hooks info clawvault
367-
openclaw hooks check
373+
openclaw doctor
368374
clawvault compat
369375
```
370376

371377
Important:
372378

373-
- `clawhub install clawvault` installs skill guidance, but does not replace hook-pack installation.
374-
- After enabling hooks, restart the OpenClaw gateway process so hook registration reloads.
379+
- `clawhub install clawvault` installs skill guidance, but does not replace native plugin configuration.
380+
- Legacy `openclaw hooks install ...` / `openclaw hooks enable ...` flows are compatibility-only guidance for older deployments and should not be your primary install path.
375381

376382
## Minimal AGENTS.md Additions
377383

@@ -489,8 +495,8 @@ vault/
489495
- `qmd` is optional; in-process BM25 search is available without it
490496
- if you want fallback compatibility, ensure `qmd --version` works in the same shell
491497
- Hook/plugin not active in OpenClaw:
492-
- run `openclaw hooks install clawvault`
493-
- run `openclaw hooks enable clawvault`
498+
- run `openclaw config set plugins.allow '["clawvault"]'`
499+
- run `openclaw config set plugins.slots.memory clawvault`
494500
- verify with `openclaw hooks list --verbose`
495501
- OpenClaw integration drift:
496502
- run `clawvault compat`

SECURITY.md

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Security Model: ClawVault OpenClaw Plugin
22

3-
This document explains the security posture of the OpenClaw plugin (`hooks/clawvault/handler.js`), why child process execution exists, and how risk is constrained.
3+
This document explains the security posture of the native OpenClaw plugin (`openclaw.plugin.json` + `dist/openclaw-plugin.js`), why child process execution exists, and how risk is constrained.
44

55
## Threat Model
66

@@ -22,7 +22,7 @@ This document explains the security posture of the OpenClaw plugin (`hooks/clawv
2222

2323
## Why child process execution is required
2424

25-
The plugin integrates with the existing `clawvault` CLI as the compatibility contract with OpenClaw hooks.
25+
The plugin integrates with the existing `clawvault` CLI for selected lifecycle features such as recovery, context injection, checkpointing, and observation workflows.
2626
`clawvault context` and related commands may invoke `qmd` for retrieval/search. This is required for semantic/BM25 lookup and cannot be replaced by static in-process data access without duplicating core CLI behavior.
2727

2828
Security controls are applied around this execution path instead of removing it:
@@ -33,18 +33,16 @@ Security controls are applied around this execution path instead of removing it:
3333

3434
## Execution hardening controls
3535

36-
`hooks/clawvault/integrity.js` implements:
37-
- `resolveExecutablePath(...)`
38-
Resolves an absolute executable path (explicit path or PATH search), rejects non-executable targets.
39-
- `sanitizeExecArgs(...)`
40-
Enforces array-based argv and rejects null-byte arguments.
41-
- `verifyExecutableIntegrity(...)`
42-
Optional SHA-256 verification for pinned binary integrity.
36+
`src/plugin/integrity.ts` implements:
37+
- `resolveExecutablePath(...)`
38+
- `sanitizeExecArgs(...)`
39+
- `verifyExecutableIntegrity(...)`
4340

44-
`hooks/clawvault/handler.js` enforces:
45-
- `shell: false` for all `execFileSync` calls.
46-
- No string-concatenated command lines.
47-
- Execution only when `allowClawvaultExec=true`.
41+
The native plugin runtime enforces:
42+
- `shell: false` for child-process execution paths
43+
- no string-concatenated command lines
44+
- execution only when `allowClawvaultExec=true`
45+
- manifest-based configuration validation before runtime load
4846

4947
## Privileged feature opt-ins
5048

@@ -67,18 +65,12 @@ Legacy aliases remain supported for compatibility (`autoCheckpoint`, `observeOnH
6765

6866
The plugin intentionally limits env reads to a documented allowlist:
6967

70-
- `OPENCLAW_STATE_DIR` *(only when `allowEnvAccess=true`)*
71-
Resolve OpenClaw state location for active-session observation.
72-
- `OPENCLAW_HOME` *(only when `allowEnvAccess=true`)*
73-
Fallback state root for OpenClaw session files.
74-
- `OPENCLAW_PLUGIN_CLAWVAULT_VAULTPATH` *(only when `allowEnvAccess=true`)*
75-
OpenClaw-injected vault path fallback.
76-
- `CLAWVAULT_PATH` *(only when `allowEnvAccess=true`)*
77-
Operator-provided fallback vault path.
78-
- `OPENCLAW_AGENT_ID` *(only when `allowEnvAccess=true`)*
79-
Agent resolution fallback when session key is absent.
80-
- `PATH` / `PATHEXT`
81-
Used only for executable path resolution when `clawvaultBinaryPath` is not pinned.
68+
- `OPENCLAW_STATE_DIR` *(only when `allowEnvAccess=true`)*
69+
- `OPENCLAW_HOME` *(only when `allowEnvAccess=true`)*
70+
- `OPENCLAW_PLUGIN_CLAWVAULT_VAULTPATH` *(only when `allowEnvAccess=true`)*
71+
- `CLAWVAULT_PATH` *(only when `allowEnvAccess=true`)*
72+
- `OPENCLAW_AGENT_ID` *(only when `allowEnvAccess=true`)*
73+
- `PATH` / `PATHEXT`
8274

8375
No broad environment enumeration is performed.
8476

SKILL.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ metadata: {"openclaw":{"emoji":"🐘","requires":{"bins":["clawvault","qmd"],"en
1515

1616
An elephant never forgets. Structured memory for OpenClaw agents.
1717

18-
> **Built for [OpenClaw](https://openclaw.ai)**. Canonical install: npm CLI + hook install + hook enable.
18+
> **Built for [OpenClaw](https://openclaw.ai)**. Canonical install: npm CLI + native plugin enablement via `plugins.allow` and `plugins.slots.memory`.
1919
2020
## Security & Transparency
2121

2222
**What this skill does:**
2323
- Reads/writes markdown files in your vault directory (`CLAWVAULT_PATH` or auto-discovered)
2424
- `repair-session` reads and modifies OpenClaw session transcripts (`~/.openclaw/agents/`) — creates backups before writing
25-
- Provides an OpenClaw **hook pack** (`hooks/clawvault/handler.js`) with lifecycle events (`gateway:startup`, `gateway:heartbeat`, `command:new`, `session:start`, `compaction:memoryFlush`, `cron.weekly`). Hook is opt-in and must be installed/enabled.
25+
- Provides a native OpenClaw **memory plugin** via `openclaw.plugin.json` + `dist/openclaw-plugin.js`, plus legacy hook-compatible guidance for older deployments. Native plugin enablement is opt-in.
2626
- `observe --compress` makes LLM API calls (Gemini Flash by default) to compress session transcripts into observations
2727

2828
**Environment variables used:**
@@ -32,25 +32,25 @@ An elephant never forgets. Structured memory for OpenClaw agents.
3232

3333
**No cloud sync — all data stays local. No network calls except LLM API for observe compression.**
3434

35-
**This is a full CLI tool, not instruction-only.** It writes files, registers hooks, and runs code.
35+
**This is a full CLI tool, not instruction-only.** It writes files, registers the native OpenClaw memory plugin, and runs code.
3636

37-
**Auditability:** the published ClawHub skill bundle includes `SKILL.md`, `HOOK.md`, and `hooks/clawvault/handler.js` so users can inspect hook behavior before enabling it.
37+
**Auditability:** the published package ships `openclaw.plugin.json` and `dist/openclaw-plugin.js` so users can inspect plugin metadata and runtime behavior before enabling it.
3838

3939
## Install (Canonical)
4040

4141
```bash
4242
npm install -g clawvault
43-
openclaw hooks install clawvault
44-
openclaw hooks enable clawvault
45-
46-
# Verify and reload
47-
openclaw hooks list --verbose
48-
openclaw hooks info clawvault
49-
openclaw hooks check
50-
# restart gateway process
43+
openclaw config set plugins.allow '["clawvault"]'
44+
openclaw config set plugins.slots.memory clawvault
45+
openclaw config set plugins.entries.clawvault.config.vaultPath ~/my-vault
46+
openclaw config set plugins.entries.clawvault.config.allowClawvaultExec true
47+
48+
# Verify
49+
openclaw doctor
50+
clawvault compat
5151
```
5252

53-
`clawhub install clawvault` can install skill guidance, but does not replace explicit hook pack installation.
53+
`clawhub install clawvault` can install skill guidance, but does not replace explicit native plugin configuration.
5454

5555
### Recommended Safe Install Flow
5656

@@ -62,16 +62,17 @@ npm view clawvault version dist.integrity dist.tarball repository.url
6262
npm install -g clawvault@latest
6363
npm install -g github:tobi/qmd
6464

65-
# 3) Install hook pack, but DO NOT enable yet
66-
openclaw hooks install clawvault
65+
# 3) Review the shipped native plugin manifest before enabling
66+
node -e "const fs=require('fs');const p='openclaw.plugin.json';console.log(fs.readFileSync(p,'utf8'))"
6767

68-
# 4) Review hook source locally before enabling
69-
node -e "const fs=require('fs');const p='hooks/clawvault/handler.js';console.log(fs.existsSync(p)?p:'hook file not found in current directory')"
70-
openclaw hooks info clawvault
68+
# 4) Enable the native memory plugin explicitly
69+
openclaw config set plugins.allow '["clawvault"]'
70+
openclaw config set plugins.slots.memory clawvault
71+
openclaw config set plugins.entries.clawvault.config.vaultPath ~/my-vault
7172

72-
# 5) Enable only after review
73-
openclaw hooks enable clawvault
74-
openclaw hooks check
73+
# 5) Verify before working
74+
openclaw doctor
75+
clawvault compat
7576
```
7677

7778
## Setup
@@ -104,6 +105,10 @@ clawvault sleep "PR review + type guards" --next "respond to CI" --blocked "wait
104105
clawvault doctor
105106
```
106107

108+
## Legacy Hook Compatibility
109+
110+
If you still operate an older hook-pack-based OpenClaw deployment, treat it as legacy compatibility mode rather than the primary install flow. Prefer the native plugin path above for new installs.
111+
107112
## Reality Checks Before Use
108113

109114
```bash
@@ -332,7 +337,7 @@ Backups are created automatically (use `--no-backup` to skip).
332337
- **Inbox backlog warning** — process or archive inbox items
333338
- **"unexpected tool_use_id" error** — run `clawvault repair-session`
334339
- **OpenClaw integration drift** — run `clawvault compat`
335-
- **Hook enable fails / hook not found** — run `openclaw hooks install clawvault`, then `openclaw hooks enable clawvault`, restart gateway, and verify via `openclaw hooks list --verbose`
340+
- **Plugin not active** — run `openclaw config set plugins.allow '["clawvault"]'`, `openclaw config set plugins.slots.memory clawvault`, confirm `plugins.entries.clawvault.config.vaultPath`, then verify with `openclaw doctor` and `clawvault compat`
336341
- **Graph out of date** — run `clawvault graph --refresh`
337342
- **Wrong context for task** — try `clawvault context --profile incident` or `--profile planning`
338343

docs/clawhub-security-release-playbook.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# ClawHub Security Release Playbook
22

3-
This playbook captures what kept the ClawHub/OpenClaw security review stable for `clawvault` and what repeatedly caused "suspicious" regressions.
3+
This playbook captures what kept the ClawHub/OpenClaw security review stable for `clawvault` and what repeatedly caused suspicious regressions.
44

55
## Goal
66

7-
Keep ClawHub scanner classification at least `Benign` by ensuring bundle metadata, SKILL frontmatter, and shipped files stay consistent.
7+
Keep ClawHub scanner classification at least `Benign` by ensuring bundle metadata, SKILL frontmatter, plugin manifest metadata, and shipped files stay consistent.
88

99
## Known-good frontmatter contract
1010

@@ -19,21 +19,19 @@ For `openclaw` and `metadata.openclaw`, use only documented fields:
1919

2020
- `emoji`
2121
- `requires.bins`
22-
- `requires.env` (can be `[]` if no required env vars)
23-
- `install` (installer spec array)
22+
- `requires.env`
23+
- `install`
2424
- `homepage`
2525

26-
Avoid non-spec keys inside `openclaw` metadata (for example ad-hoc fields such as `env_optional`), because strict scanners may treat the metadata block as invalid and fall back to "no requirements/install spec".
27-
2826
## Bundle composition
2927

3028
Always publish a minimal auditable bundle:
3129

3230
- `SKILL.md`
33-
- `hooks/clawvault/HOOK.md`
34-
- `hooks/clawvault/handler.js`
31+
- `openclaw.plugin.json`
32+
- `dist/openclaw-plugin.js`
3533

36-
If the hook file is not present in the published bundle, scanners flag a visibility/supply-chain concern.
34+
If the native manifest or built plugin entrypoint is not present in the published bundle, scanners and operators lose the cheap metadata path that OpenClaw uses for discovery and config validation.
3735

3836
## Required pre-publish checks
3937

@@ -42,7 +40,8 @@ If the hook file is not present in the published bundle, scanners flag a visibil
4240
- frontmatter metadata (`requires.bins`, `install`)
4341
- human docs in SKILL (`Install (Canonical)`, safe install flow)
4442
3. Confirm `source` and `homepage` fields are present and accurate.
45-
4. Confirm hook paths referenced in SKILL exist in the bundle.
43+
4. Confirm `package.json#openclaw.plugin` and `package.json#openclaw.extensions` point to files that exist in the bundle.
44+
5. Run `clawvault compat` against the release workspace to verify package metadata, manifest, and extension alignment.
4645

4746
## Publish + verify workflow
4847

@@ -57,8 +56,6 @@ If the hook file is not present in the published bundle, scanners flag a visibil
5756

5857
## If scanner regresses
5958

60-
If warning text mentions mismatch between registry metadata and SKILL/docs:
61-
6259
1. Compare scanner claim to frontmatter values first.
6360
2. Remove unsupported keys from metadata block.
6461
3. Re-publish patch version with normalized metadata.
@@ -68,8 +65,8 @@ If warning text mentions mismatch between registry metadata and SKILL/docs:
6865

6966
Even with clean metadata, this skill can still receive cautionary language because it:
7067

71-
- runs lifecycle hooks,
68+
- runs lifecycle-aware memory automation,
7269
- reads/modifies OpenClaw session files,
7370
- and relies on external CLI packages (`clawvault`, `qmd`).
7471

75-
That caution is expected and should be addressed with transparent docs, explicit safe-install guidance, and auditable shipped hook code.
72+
That caution is expected and should be addressed with transparent docs, explicit safe-install guidance, and auditable shipped plugin metadata/runtime code.

docs/getting-started/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ clawvault doctor
8282
- This is optional. In-process BM25 search still works.
8383
- Install qmd only if you need fallback compatibility paths.
8484
- OpenClaw plugin not registered
85-
- Run: `openclaw hooks install clawvault && openclaw hooks enable clawvault`
86-
- Verify: `openclaw hooks list --verbose`
85+
- Run: `openclaw config set plugins.allow '["clawvault"]' && openclaw config set plugins.slots.memory clawvault`
86+
- Verify: `openclaw doctor`

docs/openclaw-plugin-usage.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ See the [README](../README.md#openclaw-integration) for canonical installation s
88

99
```bash
1010
npm install -g clawvault
11-
openclaw hooks install clawvault
12-
openclaw hooks enable clawvault
11+
openclaw config set plugins.allow '["clawvault"]'
12+
openclaw config set plugins.slots.memory clawvault
13+
openclaw config set plugins.entries.clawvault.config.vaultPath ~/my-vault
1314
```
1415

1516
## MEMORY.md vs Vault: Understanding the Relationship
@@ -161,7 +162,7 @@ openclaw config set plugins.entries.clawvault.config.maxContextResults 6
161162
openclaw config set plugins.entries.clawvault.config.contextProfile planning
162163
```
163164

164-
See [HOOK.md](../hooks/clawvault/HOOK.md) for all configuration options.
165+
The native plugin manifest is shipped at [openclaw.plugin.json](../openclaw.plugin.json). Use `clawvault compat` to verify the package metadata, manifest, and built extension stay aligned.
165166

166167
## Workflow Integration
167168

@@ -202,12 +203,12 @@ If MEMORY.md and vault conflict, instruct the agent to trust `clawvault wake` ou
202203

203204
### Context injection not working
204205

205-
1. Verify hook is enabled: `openclaw hooks list --verbose`
206-
2. Check vault path: `openclaw config get plugins.entries.clawvault`
207-
3. Run compatibility check: `clawvault compat`
206+
1. Verify the plugin is allowed and selected: `openclaw config get plugins.allow` and `openclaw config get plugins.slots.memory`
207+
2. Check plugin config: `openclaw config get plugins.entries.clawvault`
208+
3. Run `openclaw doctor` and `clawvault compat`
208209

209210
## Related Documentation
210211

211212
- [README: OpenClaw Integration](../README.md#openclaw-integration)
212-
- [HOOK.md: Hook Configuration](../hooks/clawvault/HOOK.md)
213+
- [openclaw.plugin.json: Native Plugin Manifest](../openclaw.plugin.json)
213214
- [SKILL.md: Skill Documentation](../SKILL.md)

0 commit comments

Comments
 (0)