@a5c-ai/babysitter-openclaw 0.1.1-staging.02a0ee21

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.
Files changed (50) hide show
  1. package/README.md +307 -0
  2. package/bin/cli.cjs +80 -0
  3. package/bin/install.cjs +370 -0
  4. package/bin/uninstall.cjs +172 -0
  5. package/commands/assimilate.md +37 -0
  6. package/commands/babysit.md +7 -0
  7. package/commands/call.md +7 -0
  8. package/commands/cleanup.md +20 -0
  9. package/commands/contrib.md +33 -0
  10. package/commands/doctor.md +426 -0
  11. package/commands/forever.md +7 -0
  12. package/commands/help.md +244 -0
  13. package/commands/observe.md +12 -0
  14. package/commands/plan.md +7 -0
  15. package/commands/plugins.md +255 -0
  16. package/commands/project-install.md +17 -0
  17. package/commands/resume.md +8 -0
  18. package/commands/retrospect.md +55 -0
  19. package/commands/user-install.md +17 -0
  20. package/commands/yolo.md +7 -0
  21. package/extensions/hooks/agent-end.ts +127 -0
  22. package/extensions/hooks/before-prompt-build.ts +98 -0
  23. package/extensions/hooks/session-end.ts +80 -0
  24. package/extensions/hooks/session-start.ts +81 -0
  25. package/extensions/index.ts +67 -0
  26. package/hooks/babysitter-session-start.sh +61 -0
  27. package/hooks/babysitter-stop-hook.sh +44 -0
  28. package/hooks.json +26 -0
  29. package/openclaw.plugin.json +17 -0
  30. package/package.json +67 -0
  31. package/plugin.json +25 -0
  32. package/scripts/setup.sh +99 -0
  33. package/scripts/sync-command-docs.cjs +106 -0
  34. package/skills/assimilate/SKILL.md +38 -0
  35. package/skills/babysit/SKILL.md +36 -0
  36. package/skills/call/SKILL.md +8 -0
  37. package/skills/cleanup/SKILL.md +21 -0
  38. package/skills/contrib/SKILL.md +34 -0
  39. package/skills/doctor/SKILL.md +427 -0
  40. package/skills/forever/SKILL.md +8 -0
  41. package/skills/help/SKILL.md +245 -0
  42. package/skills/observe/SKILL.md +13 -0
  43. package/skills/plan/SKILL.md +8 -0
  44. package/skills/plugins/SKILL.md +257 -0
  45. package/skills/project-install/SKILL.md +18 -0
  46. package/skills/resume/SKILL.md +9 -0
  47. package/skills/retrospect/SKILL.md +56 -0
  48. package/skills/user-install/SKILL.md +18 -0
  49. package/skills/yolo/SKILL.md +8 -0
  50. package/versions.json +3 -0
package/README.md ADDED
@@ -0,0 +1,307 @@
1
+ # @a5c-ai/babysitter-openclaw
2
+
3
+ Babysitter orchestration plugin for [OpenClaw](https://openclaw.dev), the daemon-based AI coding agent.
4
+
5
+ This package provides full Babysitter integration through OpenClaw's programmatic plugin API:
6
+
7
+ - **Programmatic hooks** via `api.on()` for session lifecycle and orchestration control
8
+ - **Skills** for process orchestration, diagnostics, and project management
9
+ - **Slash commands** forwarding to skills through OpenClaw's extension system
10
+ - **SDK-managed** process-library bootstrapping and state management
11
+
12
+ The SDK (`@a5c-ai/babysitter-sdk`) remains the single source of truth for orchestration, runs, tasks, replay, and state. This plugin is a thin adapter layer.
13
+
14
+ ## Installation
15
+
16
+ ### Primary: Babysitter Harness Install
17
+
18
+ ```bash
19
+ babysitter harness:install-plugin openclaw
20
+ ```
21
+
22
+ This installs the `@a5c-ai/babysitter-openclaw` npm package and registers it with OpenClaw.
23
+
24
+ ### Secondary: npm
25
+
26
+ ```bash
27
+ npm install -g @a5c-ai/babysitter-openclaw
28
+ ```
29
+
30
+ The `postinstall` script registers the plugin globally. To install into a specific workspace:
31
+
32
+ ```bash
33
+ npx @a5c-ai/babysitter-openclaw install --workspace /path/to/repo
34
+ ```
35
+
36
+ ### Verify Installation
37
+
38
+ ```bash
39
+ babysitter harness:discover --json
40
+ ```
41
+
42
+ ### Removal
43
+
44
+ ```bash
45
+ npm uninstall -g @a5c-ai/babysitter-openclaw
46
+ ```
47
+
48
+ ## Architecture
49
+
50
+ ### Daemon Model vs CLI Model
51
+
52
+ Most Babysitter harness plugins (Claude Code, Codex, Cursor) integrate with CLI-based agents that follow a **stop-hook model**: the agent runs, stops, a hook fires synchronously, and the agent resumes. This creates a natural iteration boundary.
53
+
54
+ OpenClaw is a **daemon-based harness**. It runs as a persistent process and exposes a programmatic plugin API rather than a filesystem-based hook surface. This changes the orchestration model:
55
+
56
+ | Aspect | CLI Harnesses (Claude Code, Codex) | OpenClaw (Daemon) |
57
+ |--------|-------------------------------------|-------------------|
58
+ | Agent lifecycle | Start, run, stop | Persistent daemon |
59
+ | Hook mechanism | Shell scripts via `hooks.json` | Programmatic `api.on()` callbacks |
60
+ | Iteration boundary | `Stop` hook (synchronous) | `agent_end` event (fire-and-forget) |
61
+ | Prompt injection | `UserPromptSubmit` hook | `before_prompt_build` callback |
62
+ | Session management | Implicit via CLI invocations | Explicit `session_start` / `session_end` events |
63
+
64
+ ### How Orchestration Works
65
+
66
+ 1. **Session starts** -- `session_start` hook fires, initializing Babysitter state via `babysitter hook:run --hook-type session-start --harness openclaw`.
67
+ 2. **Each agent turn begins** -- `before_prompt_build` hook injects orchestration context (active run state, pending tasks, iteration instructions) into the prompt.
68
+ 3. **Each agent turn ends** -- `agent_end` hook fires asynchronously (fire-and-forget via `spawn` + `unref`), triggering `babysitter hook:run --hook-type stop --harness openclaw` to advance the orchestration iteration.
69
+ 4. **Session ends** -- `session_end` hook finalizes any active Babysitter runs.
70
+
71
+ The `agent_end` handler intentionally uses `spawn` with `unref()` rather than `execFileSync` so it does not block the next agent turn. Errors are logged to `$BABYSITTER_LOG_DIR/babysitter-agent-end-hook.log` but never propagate to the agent.
72
+
73
+ ### Dual Hook Surface
74
+
75
+ The plugin ships both:
76
+
77
+ - **Programmatic hooks** (`extensions/hooks/*.ts`) -- registered via `api.on()` in `extensions/index.ts`. These are the primary integration path for OpenClaw's native plugin API.
78
+ - **Shell hooks** (`hooks/babysitter-session-start.sh`, `hooks/babysitter-stop-hook.sh`) -- declared in `hooks.json` for compatibility with harnesses that use the filesystem-based hook surface.
79
+
80
+ Both surfaces delegate to the same `babysitter hook:run` CLI commands.
81
+
82
+ ## Capabilities
83
+
84
+ The OpenClaw adapter declares the following harness capabilities:
85
+
86
+ | Capability | Supported | Notes |
87
+ |------------|-----------|-------|
88
+ | **SessionBinding** | Yes | Binds runs to OpenClaw sessions via `session_start` / `session_end` |
89
+ | **Mcp** | Yes | MCP server integration via `babysitter mcp:serve` |
90
+ | **HeadlessPrompt** | Yes | Programmatic prompt submission via `api.sendUserMessage()` |
91
+ | **StopHook** | No | OpenClaw uses `agent_end` + `before_prompt_build` instead of a synchronous stop-hook model |
92
+
93
+ ## Available Commands
94
+
95
+ The extension registers 17 slash commands (15 named commands plus `/babysit` and `/babysitter`). Each command forwards to its corresponding skill via OpenClaw's `/skill:<name>` mechanism.
96
+
97
+ | Command | Alias | Description |
98
+ |---------|-------|-------------|
99
+ | `/babysit` | `/babysitter` | Load the Babysitter orchestration skill |
100
+ | `/call` | `/babysitter:call` | Start orchestrating a complex workflow |
101
+ | `/plan` | `/babysitter:plan` | Plan a workflow without executing it |
102
+ | `/resume` | `/babysitter:resume` | Resume an existing orchestration run |
103
+ | `/yolo` | `/babysitter:yolo` | Run in non-interactive mode (no breakpoints) |
104
+ | `/forever` | `/babysitter:forever` | Start a never-ending orchestration loop |
105
+ | `/doctor` | `/babysitter:doctor` | Diagnose run health (journal, state, locks) |
106
+ | `/observe` | `/babysitter:observe` | Launch the real-time observer dashboard |
107
+ | `/retrospect` | `/babysitter:retrospect` | Analyze past runs for improvements |
108
+ | `/cleanup` | `/babysitter:cleanup` | Clean up old runs and aggregate insights |
109
+ | `/assimilate` | `/babysitter:assimilate` | Convert external methodologies into processes |
110
+ | `/contrib` | `/babysitter:contrib` | Submit feedback or contributions |
111
+ | `/help` | `/babysitter:help` | Babysitter documentation and usage help |
112
+ | `/plugins` | `/babysitter:plugins` | Manage Babysitter plugins |
113
+ | `/user-install` | `/babysitter:user-install` | Set up Babysitter for your user profile |
114
+ | `/project-install` | `/babysitter:project-install` | Onboard a project for Babysitter orchestration |
115
+
116
+ Every named command also has a `babysitter:` prefixed alias (e.g., `/babysitter:call`).
117
+
118
+ ## Available Skills
119
+
120
+ Skills are defined in `skills/` and exposed through OpenClaw's skill system:
121
+
122
+ | Skill | Description |
123
+ |-------|-------------|
124
+ | **babysit** | Core orchestration skill -- iterates `.a5c/runs/<runId>/` through the deterministic replay loop |
125
+ | **call** | Start a new orchestrated run for a complex workflow |
126
+ | **plan** | Create and refine a process definition without executing it |
127
+ | **resume** | Resume an incomplete run, auto-discovering candidates if none specified |
128
+ | **yolo** | Non-interactive orchestration with no breakpoints or user prompts |
129
+ | **forever** | Infinite-loop process (e.g., periodic task polling with `ctx.sleep`) |
130
+ | **doctor** | Diagnose run health -- journal integrity, state cache, effects, locks, disk usage |
131
+ | **observe** | Launch the browser-based observer dashboard for real-time run monitoring |
132
+ | **retrospect** | Post-run analysis with suggestions for process improvements |
133
+ | **cleanup** | Aggregate insights from completed/failed runs, then remove old data |
134
+ | **assimilate** | Convert external methodologies or specifications into Babysitter process definitions |
135
+ | **contrib** | Submit feedback or contribute to the Babysitter project |
136
+ | **help** | Documentation and usage guidance for commands, processes, and methodologies |
137
+ | **plugins** | List, install, configure, update, or uninstall Babysitter plugins |
138
+ | **user-install** | Guided user onboarding -- profile setup, dependency installation, preferences |
139
+ | **project-install** | Guided project onboarding -- codebase analysis, profile setup, CI/CD configuration |
140
+
141
+ ## Hook System
142
+
143
+ OpenClaw hooks are registered programmatically in `extensions/index.ts` via `api.on()`. Each hook delegates to the Babysitter SDK CLI.
144
+
145
+ ### session_start
146
+
147
+ **File:** `extensions/hooks/session-start.ts`
148
+ **Maps to:** `babysitter hook:run --hook-type session-start --harness openclaw`
149
+
150
+ Fires when an OpenClaw session begins. Initializes Babysitter state, ensures the CLI is available (falls back to `npx` if not installed globally), and sets up the state directory. Runs synchronously with a 30-second timeout (60 seconds for `npx` fallback). Errors are logged but do not block the session.
151
+
152
+ ### session_end
153
+
154
+ **File:** `extensions/hooks/session-end.ts`
155
+ **Maps to:** `babysitter hook:run --hook-type stop --harness openclaw`
156
+
157
+ Fires on session teardown. Finalizes any active Babysitter runs. Same synchronous execution model as `session_start`.
158
+
159
+ ### before_prompt_build
160
+
161
+ **File:** `extensions/hooks/before-prompt-build.ts`
162
+ **Maps to:** `babysitter hook:run --hook-type user-prompt-submit --harness openclaw`
163
+
164
+ Fires before OpenClaw assembles the system/user prompt for each agent turn. This is the primary orchestration injection point -- Babysitter returns JSON context containing iteration instructions, active run state, and pending task information. The return value is merged into the prompt context. Runs synchronously.
165
+
166
+ ### agent_end
167
+
168
+ **File:** `extensions/hooks/agent-end.ts`
169
+ **Maps to:** `babysitter hook:run --hook-type stop --harness openclaw`
170
+
171
+ Fires after each agent turn completes. This is the iteration driver -- it triggers Babysitter to advance the orchestration loop. Unlike other hooks, this runs **asynchronously** (fire-and-forget via `spawn` + `child.unref()`) so it does not block the next agent turn. Stderr is collected for diagnostic logging.
172
+
173
+ ## Configuration
174
+
175
+ ### Environment Variables
176
+
177
+ | Variable | Default | Description |
178
+ |----------|---------|-------------|
179
+ | `BABYSITTER_STATE_DIR` | `.a5c` (cwd-relative) | State directory for run storage and session data |
180
+ | `BABYSITTER_LOG_DIR` | `~/.a5c/logs` | Directory for hook execution logs |
181
+ | `BABYSITTER_RUNS_DIR` | `.a5c/runs` | Root directory for run storage |
182
+ | `BABYSITTER_GLOBAL_STATE_DIR` | `~/.a5c` | Global state directory |
183
+ | `OPENCLAW_PLUGIN_ROOT` | Auto-detected | Override the plugin root directory |
184
+
185
+ ### SDK Version Pinning
186
+
187
+ The SDK version is pinned in `versions.json`:
188
+
189
+ ```json
190
+ {"sdkVersion": "0.0.184-staging.58c6c09c"}
191
+ ```
192
+
193
+ When the `babysitter` CLI is not available globally, hooks fall back to `npx -y @a5c-ai/babysitter-sdk@<pinned-version>`.
194
+
195
+ ### Config Files
196
+
197
+ | File | Purpose |
198
+ |------|---------|
199
+ | `plugin.json` | Babysitter plugin manifest (name, version, hooks, commands, skills) |
200
+ | `openclaw.plugin.json` | OpenClaw-native plugin manifest (entrypoint, programmatic hooks, capabilities) |
201
+ | `hooks.json` | Shell-based hook declarations for filesystem hook surface |
202
+ | `versions.json` | Pinned SDK version for reproducible installations |
203
+
204
+ ## Plugin Layout
205
+
206
+ ```text
207
+ plugins/babysitter-openclaw/
208
+ |-- package.json # npm package manifest
209
+ |-- plugin.json # Babysitter plugin manifest
210
+ |-- openclaw.plugin.json # OpenClaw-native plugin manifest
211
+ |-- versions.json # Pinned SDK version
212
+ |-- hooks.json # Shell hook declarations
213
+ |-- extensions/
214
+ | |-- index.ts # Plugin entrypoint (api.on, registerCommand)
215
+ | `-- hooks/
216
+ | |-- session-start.ts # session_start handler
217
+ | |-- session-end.ts # session_end handler
218
+ | |-- before-prompt-build.ts # before_prompt_build handler
219
+ | `-- agent-end.ts # agent_end handler (async/fire-and-forget)
220
+ |-- hooks/
221
+ | |-- babysitter-session-start.sh # Shell fallback for session start
222
+ | `-- babysitter-stop-hook.sh # Shell fallback for stop
223
+ |-- skills/
224
+ | |-- babysit/SKILL.md
225
+ | |-- call/SKILL.md
226
+ | |-- plan/SKILL.md
227
+ | |-- resume/SKILL.md
228
+ | |-- yolo/SKILL.md
229
+ | |-- forever/SKILL.md
230
+ | |-- doctor/SKILL.md
231
+ | |-- observe/SKILL.md
232
+ | |-- retrospect/SKILL.md
233
+ | |-- cleanup/SKILL.md
234
+ | |-- assimilate/SKILL.md
235
+ | |-- contrib/SKILL.md
236
+ | |-- help/SKILL.md
237
+ | |-- plugins/SKILL.md
238
+ | |-- user-install/SKILL.md
239
+ | `-- project-install/SKILL.md
240
+ |-- commands/ # Mirrored command documentation (markdown)
241
+ |-- bin/
242
+ | |-- cli.cjs # Standalone CLI entrypoint
243
+ | |-- install.cjs # Global postinstall script
244
+ | `-- uninstall.cjs # Global preuninstall script
245
+ `-- scripts/
246
+ |-- setup.sh # Setup helper
247
+ `-- sync-command-docs.cjs # Regenerate mirrored command docs
248
+ ```
249
+
250
+ ## Development
251
+
252
+ ### Local Development
253
+
254
+ Clone the monorepo and work within the plugin directory:
255
+
256
+ ```bash
257
+ git clone https://github.com/a5c-ai/babysitter.git
258
+ cd babysitter
259
+ npm install
260
+ ```
261
+
262
+ ### Running Tests
263
+
264
+ ```bash
265
+ cd plugins/babysitter-openclaw
266
+ npm test
267
+ npm run test:integration
268
+ npm run test:packaged-install
269
+ ```
270
+
271
+ ### Syncing Command Docs
272
+
273
+ Regenerate mirrored command documentation from skill definitions:
274
+
275
+ ```bash
276
+ npm run sync:commands
277
+ ```
278
+
279
+ ### Publishing
280
+
281
+ ```bash
282
+ npm run deploy # Publish to npm (public)
283
+ npm run deploy:staging # Publish with staging tag
284
+ ```
285
+
286
+ ### SDK Setup for Development
287
+
288
+ Read the pinned SDK version from `versions.json`:
289
+
290
+ ```bash
291
+ PLUGIN_ROOT="$(pwd)"
292
+ SDK_VERSION=$(node -e "try{console.log(JSON.parse(require('fs').readFileSync('${PLUGIN_ROOT}/versions.json','utf8')).sdkVersion||'latest')}catch{console.log('latest')}")
293
+ CLI="npx -y @a5c-ai/babysitter-sdk@$SDK_VERSION"
294
+ ```
295
+
296
+ ## Troubleshooting
297
+
298
+ - Verify the harness with `babysitter harness:discover --json`.
299
+ - If `openclaw` is not detected, check `which openclaw` (Unix) or `where openclaw` (Windows).
300
+ - If commands do not appear, restart OpenClaw after installation so it reloads plugin metadata.
301
+ - If hooks fail silently, check log files in `$BABYSITTER_LOG_DIR` (defaults to `~/.a5c/logs/`).
302
+ - If the wrong SDK version is used, inspect `versions.json` inside the installed package root.
303
+ - Regenerate mirrored commands with `npm run sync:commands`.
304
+
305
+ ## License
306
+
307
+ MIT
package/bin/cli.cjs ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const path = require('path');
5
+ const { spawnSync } = require('child_process');
6
+
7
+ const PACKAGE_ROOT = path.resolve(__dirname, '..');
8
+
9
+ function printUsage() {
10
+ console.error([
11
+ 'Usage:',
12
+ ' babysitter-openclaw install [--global]',
13
+ ' babysitter-openclaw install --workspace [path]',
14
+ ' babysitter-openclaw uninstall [--global]',
15
+ ' babysitter-openclaw uninstall --workspace [path]',
16
+ ' babysitter-openclaw version',
17
+ ' babysitter-openclaw help',
18
+ ].join('\n'));
19
+ }
20
+
21
+ function parseArgs(argv) {
22
+ let workspace = null;
23
+
24
+ for (let i = 0; i < argv.length; i += 1) {
25
+ const arg = argv[i];
26
+ if (arg === '--workspace') {
27
+ const next = argv[i + 1];
28
+ workspace = next && !next.startsWith('-') ? path.resolve(next) : process.cwd();
29
+ if (next && !next.startsWith('-')) {
30
+ i += 1;
31
+ }
32
+ continue;
33
+ }
34
+ if (arg === '--global') {
35
+ workspace = null;
36
+ continue;
37
+ }
38
+ throw new Error(`unknown argument: ${arg}`);
39
+ }
40
+
41
+ return { workspace };
42
+ }
43
+
44
+ function runNodeScript(scriptPath, args) {
45
+ const result = spawnSync(process.execPath, [scriptPath, ...args], {
46
+ cwd: process.cwd(),
47
+ stdio: 'inherit',
48
+ env: process.env,
49
+ });
50
+ process.exitCode = result.status ?? 1;
51
+ }
52
+
53
+ function main() {
54
+ const [command, ...rest] = process.argv.slice(2);
55
+ if (!command || command === '--help' || command === '-h' || command === 'help') {
56
+ printUsage();
57
+ process.exitCode = command ? 0 : 1;
58
+ return;
59
+ }
60
+
61
+ if (command === 'version' || command === '--version' || command === '-v') {
62
+ const fs = require('fs');
63
+ const pkg = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
64
+ console.log(`${pkg.name}@${pkg.version}`);
65
+ return;
66
+ }
67
+
68
+ if (command !== 'install' && command !== 'uninstall') {
69
+ console.error(`[babysitter] Unknown command: ${command}`);
70
+ printUsage();
71
+ process.exitCode = 1;
72
+ return;
73
+ }
74
+
75
+ const parsed = parseArgs(rest);
76
+ const args = parsed.workspace ? ['--workspace', parsed.workspace] : ['--global'];
77
+ runNodeScript(path.join(PACKAGE_ROOT, 'bin', `${command}.cjs`), args);
78
+ }
79
+
80
+ main();