@a5c-ai/babysitter-opencode 5.0.1-staging.e4f17eff → 5.0.1-staging.e920fef118ef

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 (55) hide show
  1. package/README.md +19 -21
  2. package/bin/cli.cjs +1 -191
  3. package/bin/cli.js +90 -49
  4. package/bin/install-shared.cjs +1 -478
  5. package/bin/install-shared.js +615 -0
  6. package/bin/install.cjs +1 -143
  7. package/bin/install.js +18 -98
  8. package/bin/uninstall.cjs +1 -87
  9. package/bin/uninstall.js +12 -34
  10. package/commands/call.md +5 -1
  11. package/commands/cleanup.md +30 -8
  12. package/commands/doctor.md +7 -8
  13. package/commands/help.md +246 -244
  14. package/commands/observe.md +17 -12
  15. package/commands/yolo.md +11 -7
  16. package/hooks/babysitter-proxied-session-created.js +18 -212
  17. package/hooks/babysitter-proxied-session-created.sh +11 -0
  18. package/hooks/babysitter-proxied-shell-env.js +21 -145
  19. package/hooks/babysitter-proxied-shell-env.sh +3 -0
  20. package/hooks/babysitter-proxied-stop-hook.sh +3 -0
  21. package/hooks/babysitter-proxied-tool-execute-after.js +20 -160
  22. package/hooks/babysitter-proxied-tool-execute-after.sh +3 -0
  23. package/hooks/babysitter-proxied-tool-execute-before.js +20 -162
  24. package/hooks/babysitter-proxied-tool-execute-before.sh +3 -0
  25. package/hooks/hooks.json +14 -22
  26. package/package.json +21 -19
  27. package/plugin.json +6 -4
  28. package/scripts/create-release-tag.mjs +18 -0
  29. package/scripts/publish-from-tag.mjs +41 -0
  30. package/scripts/team-install.js +23 -0
  31. package/skills/accomplish-status/SKILL.md +1 -1
  32. package/skills/babysit/SKILL.md +4 -3
  33. package/skills/call/SKILL.md +5 -1
  34. package/skills/cleanup/SKILL.md +30 -8
  35. package/skills/contrib/SKILL.md +25 -25
  36. package/skills/doctor/SKILL.md +7 -8
  37. package/skills/help/SKILL.md +4 -2
  38. package/skills/observe/SKILL.md +7 -2
  39. package/skills/plugins/SKILL.md +243 -243
  40. package/skills/project-install/SKILL.md +3 -3
  41. package/skills/resume/SKILL.md +1 -1
  42. package/skills/retrospect/SKILL.md +48 -48
  43. package/skills/user-install/SKILL.md +3 -3
  44. package/skills/yolo/SKILL.md +5 -1
  45. package/versions.json +2 -2
  46. package/hooks/babysitter-proxied-session-idle.js +0 -173
  47. package/hooks/hooks.json.legacy +0 -46
  48. package/hooks/proxied-hooks.json +0 -47
  49. package/hooks/session-created.js +0 -182
  50. package/hooks/session-idle.js +0 -124
  51. package/hooks/shell-env.js +0 -88
  52. package/hooks/tool-execute-after.js +0 -107
  53. package/hooks/tool-execute-before.js +0 -109
  54. package/scripts/sync-command-docs.cjs +0 -107
  55. package/scripts/sync-command-surfaces.js +0 -52
@@ -1,166 +1,24 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * Unified Tool Execute Before Hook for OpenCode
4
- * Routes through hooks-proxy for all hook execution.
5
- *
6
- * Fires before a tool execution in OpenCode. Delegates to
7
- * `babysitter hook:run --hook-type pre-tool-use` via hooks-proxy.
8
- *
9
- * This hook can be used to:
10
- * - Log tool invocations for babysitter run observability
11
- * - Block certain tool calls during specific orchestration phases
12
- * - Inject babysitter context into tool arguments
13
- *
14
- * OpenCode plugin protocol:
15
- * - Receives tool context as JSON via stdin
16
- * - Outputs JSON to stdout (empty = allow, { block: true } = block)
17
- * - Exit 0 = success
18
- */
19
-
20
2
  "use strict";
21
-
22
- const { execSync } = require("child_process");
23
- const { readFileSync, mkdirSync, appendFileSync, existsSync, writeFileSync } = require("fs");
24
- const os = require("os");
25
- const path = require("path");
26
-
27
- const PLUGIN_ROOT = process.env.OPENCODE_PLUGIN_ROOT || path.resolve(__dirname, "..");
28
- const GLOBAL_ROOT = process.env.BABYSITTER_GLOBAL_STATE_DIR || path.join(os.homedir(), ".a5c");
29
- const STATE_DIR = process.env.BABYSITTER_STATE_DIR || path.join(GLOBAL_ROOT, "state");
30
- const LOG_DIR = process.env.BABYSITTER_LOG_DIR || path.join(GLOBAL_ROOT, "logs");
31
- const LOG_FILE = path.join(LOG_DIR, "babysitter-tool-before-hook.log");
32
- const PROXY_MARKER = path.join(PLUGIN_ROOT, ".hooks-proxy-install-attempted");
33
-
34
- function ensureDir(dir) {
35
- try { mkdirSync(dir, { recursive: true }); } catch { /* best-effort */ }
36
- }
37
-
38
- function blog(msg) {
39
- ensureDir(LOG_DIR);
40
- const ts = new Date().toISOString();
41
- try {
42
- appendFileSync(LOG_FILE, `[INFO] ${ts} ${msg}\n`);
43
- } catch { /* best-effort */ }
44
- }
45
-
46
- function getSdkVersion() {
47
- try {
48
- const versions = JSON.parse(readFileSync(path.join(PLUGIN_ROOT, "versions.json"), "utf8"));
49
- return versions.sdkVersion || "latest";
50
- } catch {
51
- return "latest";
52
- }
53
- }
54
-
55
- function resolveHooksProxy() {
56
- try {
57
- execSync("a5c-hooks-proxy --version", { stdio: "pipe", timeout: 5000 });
58
- return "a5c-hooks-proxy";
59
- } catch { /* not in PATH */ }
60
-
61
- const localProxy = path.join(
62
- process.env.HOME || process.env.USERPROFILE || "~",
63
- ".local", "bin", process.platform === "win32" ? "a5c-hooks-proxy.exe" : "a5c-hooks-proxy"
64
- );
65
- if (existsSync(localProxy)) {
66
- return localProxy;
67
- }
68
-
69
- return null;
70
- }
71
-
72
- function installHooksProxy(version) {
73
- if (existsSync(PROXY_MARKER)) return;
74
-
75
- try {
76
- execSync(`npm i -g "@a5c-ai/hooks-proxy-cli@${version}" --loglevel=error`, {
77
- stdio: "pipe",
78
- timeout: 120000,
79
- });
80
- blog(`Installed hooks-proxy globally (${version})`);
81
- } catch {
82
- try {
83
- const prefix = path.join(process.env.HOME || process.env.USERPROFILE || "~", ".local");
84
- execSync(`npm i -g "@a5c-ai/hooks-proxy-cli@${version}" --prefix "${prefix}" --loglevel=error`, {
85
- stdio: "pipe",
86
- timeout: 120000,
87
- });
88
- blog(`Installed hooks-proxy to user prefix (${version})`);
89
- } catch {
90
- blog("hooks-proxy installation failed");
91
- }
92
- }
93
-
94
- try { writeFileSync(PROXY_MARKER, version); } catch { /* best-effort */ }
95
- }
96
-
97
- function main() {
98
- const sessionId = process.env.BABYSITTER_SESSION_ID
99
- || process.env.OPENCODE_SESSION_ID
100
- || "";
101
-
102
- if (!sessionId) {
103
- // No session -- pass through without intervention
104
- process.stdout.write("{}\n");
105
- return;
106
- }
107
-
108
- // Read stdin for tool context
109
- let inputData = "";
110
- try {
111
- inputData = require("fs").readFileSync(0, "utf8");
112
- } catch {
113
- // No stdin available
114
- }
115
-
116
- blog(`Unified tool-execute-before: session=${sessionId}`);
117
-
118
- const hookInput = JSON.stringify({
119
- session_id: sessionId,
120
- cwd: process.cwd(),
121
- harness: "opencode",
122
- plugin_root: PLUGIN_ROOT,
123
- tool_context: inputData ? JSON.parse(inputData) : {},
3
+ var execSync = require("child_process").execSync;
4
+ var path = require("path");
5
+ var readFileSync = require("fs").readFileSync;
6
+
7
+ var PLUGIN_ROOT = process.env.PLUGIN_ROOT || process.env.PLUGIN_ROOT || path.resolve(__dirname, "..");
8
+ var stdin = "";
9
+ try { stdin = readFileSync(0, "utf8"); } catch {}
10
+ try {
11
+ var result = execSync("bash " + JSON.stringify(path.join(PLUGIN_ROOT, "hooks/pre-tool-use.sh")), {
12
+ input: stdin,
13
+ stdio: ["pipe", "pipe", "pipe"],
14
+ timeout: 30000,
15
+ env: Object.assign({}, process.env, {
16
+ HOOK_TYPE: process.env.HOOK_TYPE || "",
17
+ ADAPTER_NAME: process.env.ADAPTER_NAME || "opencode",
18
+ PLUGIN_ROOT: PLUGIN_ROOT
19
+ })
124
20
  });
125
-
126
- const sdkVersion = getSdkVersion();
127
-
128
- // Ensure hooks-proxy is installed
129
- let proxy = resolveHooksProxy();
130
- if (!proxy) {
131
- installHooksProxy(sdkVersion);
132
- proxy = resolveHooksProxy();
133
- }
134
-
135
- const handler = `babysitter hook:run --harness unified --hook-type pre-tool-use --plugin-root ${PLUGIN_ROOT} --state-dir ${STATE_DIR} --json`;
136
-
137
- try {
138
- let result;
139
- if (proxy) {
140
- blog(`Using hooks-proxy: ${proxy}`);
141
- result = execSync(`"${proxy}" invoke --adapter opencode --handler "${handler}" --json`, {
142
- input: hookInput,
143
- stdio: ["pipe", "pipe", "pipe"],
144
- timeout: 10000,
145
- env: { ...process.env, BABYSITTER_STATE_DIR: STATE_DIR },
146
- });
147
- } else {
148
- blog("hooks-proxy not found after install, using npx fallback");
149
- result = execSync(`npx -y "@a5c-ai/hooks-proxy-cli@${sdkVersion}" invoke --adapter opencode --handler "${handler}" --json`, {
150
- input: hookInput,
151
- stdio: ["pipe", "pipe", "pipe"],
152
- timeout: 30000,
153
- env: { ...process.env, BABYSITTER_STATE_DIR: STATE_DIR },
154
- });
155
- }
156
- const output = result.toString("utf8").trim();
157
- blog(`Hook result: ${output}`);
158
- process.stdout.write((output || "{}") + "\n");
159
- } catch (err) {
160
- // On failure, allow the tool execution to proceed
161
- blog(`Pre-tool-use hook failed: ${err.message} -- allowing execution`);
162
- process.stdout.write("{}\n");
163
- }
21
+ process.stdout.write(result);
22
+ } catch (e) {
23
+ process.stdout.write("{}\n");
164
24
  }
165
-
166
- main();
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ babysitter hook:run --harness unified --hook-type pre-tool-use --json
package/hooks/hooks.json CHANGED
@@ -1,45 +1,37 @@
1
1
  {
2
2
  "version": 1,
3
- "description": "Babysitter hook registration for OpenCode. Maps OpenCode plugin events to unified babysitter hook scripts with hooks-proxy support.",
3
+ "description": "babysitter hook registration for OpenCode.",
4
4
  "hooks": {
5
5
  "session.created": [
6
6
  {
7
7
  "type": "command",
8
- "script": "hooks/babysitter-proxied-session-created.js",
9
- "description": "Initialize babysitter session state and inject context (proxied via a5c-hooks-proxy)",
8
+ "script": "./hooks/babysitter-proxied-session-created.js",
9
+ "description": "babysitter SessionStart hook",
10
10
  "timeoutMs": 30000
11
11
  }
12
12
  ],
13
- "session.idle": [
13
+ "tool.execute.before": [
14
14
  {
15
15
  "type": "command",
16
- "script": "hooks/babysitter-proxied-session-idle.js",
17
- "description": "Check for pending babysitter effects when agent goes idle (proxied via a5c-hooks-proxy)",
16
+ "script": "./hooks/babysitter-proxied-tool-execute-before.js",
17
+ "description": "babysitter PreToolUse hook",
18
18
  "timeoutMs": 30000
19
19
  }
20
20
  ],
21
- "shell.env": [
22
- {
23
- "type": "command",
24
- "script": "hooks/babysitter-proxied-shell-env.js",
25
- "description": "Inject BABYSITTER_SESSION_ID and other env vars into shell (proxied via a5c-hooks-proxy)",
26
- "timeoutMs": 5000
27
- }
28
- ],
29
- "tool.execute.before": [
21
+ "tool.execute.after": [
30
22
  {
31
23
  "type": "command",
32
- "script": "hooks/babysitter-proxied-tool-execute-before.js",
33
- "description": "Pre-tool-use hook for babysitter awareness (proxied via a5c-hooks-proxy)",
34
- "timeoutMs": 10000
24
+ "script": "./hooks/babysitter-proxied-tool-execute-after.js",
25
+ "description": "babysitter PostToolUse hook",
26
+ "timeoutMs": 30000
35
27
  }
36
28
  ],
37
- "tool.execute.after": [
29
+ "shell.env": [
38
30
  {
39
31
  "type": "command",
40
- "script": "hooks/babysitter-proxied-tool-execute-after.js",
41
- "description": "Post-tool-use hook for babysitter awareness (proxied via a5c-hooks-proxy)",
42
- "timeoutMs": 10000
32
+ "script": "./hooks/babysitter-proxied-shell-env.js",
33
+ "description": "babysitter ShellEnv hook",
34
+ "timeoutMs": 5000
43
35
  }
44
36
  ]
45
37
  }
package/package.json CHANGED
@@ -1,46 +1,48 @@
1
1
  {
2
2
  "name": "@a5c-ai/babysitter-opencode",
3
- "version": "5.0.1-staging.e4f17eff",
4
- "description": "Babysitter orchestration plugin for OpenCode with SDK-managed process-library bootstrapping and in-turn iteration model",
3
+ "version": "5.0.1-staging.e920fef118ef",
4
+ "description": "Orchestrate complex, multi-step workflows with event-sourced state management, hook-based extensibility, and human-in-the-loop approval",
5
5
  "scripts": {
6
- "test": "node test/integration.test.js",
7
- "test:integration": "node test/integration.test.js",
8
- "sync:commands": "node scripts/sync-command-docs.cjs",
9
- "postinstall": "node bin/install.cjs",
10
- "preuninstall": "node bin/uninstall.cjs",
11
6
  "deploy": "npm publish --access public",
12
- "deploy:staging": "npm publish --access public --tag staging"
7
+ "deploy:staging": "npm publish --access public --tag staging",
8
+ "postinstall": "node bin/install.js",
9
+ "preuninstall": "node bin/uninstall.js",
10
+ "team:install": "node scripts/team-install.js",
11
+ "test": "node test/integration.test.js"
13
12
  },
14
13
  "bin": {
15
- "babysitter-opencode": "bin/cli.cjs"
14
+ "babysitter-opencode": "bin/cli.js"
16
15
  },
17
16
  "files": [
18
17
  "bin/",
19
- "commands/",
20
18
  "hooks/",
21
- "scripts/",
22
19
  "skills/",
20
+ "commands/",
21
+ "scripts/",
23
22
  "plugin.json",
24
- "versions.json"
23
+ "README.md",
24
+ "versions.json",
25
+ "package.json"
25
26
  ],
26
27
  "keywords": [
27
28
  "babysitter",
28
29
  "opencode",
29
- "orchestration",
30
- "ai-agent",
31
- "sdk-integration"
30
+ "orchestration"
32
31
  ],
33
32
  "author": "a5c.ai",
34
33
  "license": "MIT",
35
34
  "publishConfig": {
36
35
  "access": "public"
37
36
  },
37
+ "dependencies": {
38
+ "@a5c-ai/babysitter-sdk": "5.0.1-staging.e920fef118ef"
39
+ },
38
40
  "repository": {
39
41
  "type": "git",
40
- "url": "https://github.com/a5c-ai/babysitter"
42
+ "url": "git+https://github.com/a5c-ai/babysitter-opencode.git"
41
43
  },
42
- "homepage": "https://github.com/a5c-ai/babysitter/tree/main/plugins/babysitter-opencode#readme",
43
- "dependencies": {
44
- "@a5c-ai/babysitter-sdk": "5.0.1-staging.e4f17eff"
44
+ "homepage": "https://github.com/a5c-ai/babysitter-opencode#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/a5c-ai/babysitter-opencode/issues"
45
47
  }
46
48
  }
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "babysitter",
3
- "version": "5.0.1-staging.e4f17eff",
4
- "description": "Orchestrate complex, multi-step workflows with event-sourced state management, hook-based extensibility, and human-in-the-loop approval -- powered by the Babysitter SDK",
3
+ "version": "5.0.1-staging.e920fef118ef",
4
+ "description": "Orchestrate complex, multi-step workflows with event-sourced state management, hook-based extensibility, and human-in-the-loop approval",
5
5
  "author": "a5c.ai",
6
6
  "license": "MIT",
7
7
  "harness": "opencode",
@@ -18,8 +18,10 @@
18
18
  "automation",
19
19
  "event-sourced",
20
20
  "hooks",
21
- "opencode",
21
+ "TDD",
22
+ "quality-convergence",
22
23
  "agent",
23
- "LLM"
24
+ "LLM",
25
+ "opencode"
24
26
  ]
25
27
  }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+
5
+ function run(command, args) {
6
+ const result = spawnSync(command, args, { encoding: 'utf8', stdio: 'inherit' });
7
+ if (result.status !== 0) process.exit(result.status || 1);
8
+ }
9
+
10
+ const branch = process.env.GITHUB_REF_NAME || 'develop';
11
+ const sha = (process.env.GITHUB_SHA || '').slice(0, 12);
12
+ const version = existsSync('package.json') ? JSON.parse(readFileSync('package.json', 'utf8')).version : JSON.parse(readFileSync('versions.json', 'utf8')).sdkVersion;
13
+ const normalized = String(version).replace(/[^0-9A-Za-z._-]/g, '-');
14
+ const tag = 'release/' + branch + '/v' + normalized + '-' + sha;
15
+ run('git', ['config', 'user.name', 'github-actions[bot]']);
16
+ run('git', ['config', 'user.email', 'github-actions[bot]@users.noreply.github.com']);
17
+ run('git', ['tag', tag]);
18
+ run('git', ['push', 'origin', tag]);
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import { readFileSync } from 'node:fs';
4
+
5
+ function run(command, args, options = {}) {
6
+ const result = spawnSync(command, args, { stdio: options.stdio || 'inherit', encoding: options.encoding });
7
+ if (result.status !== 0 && !options.allowFailure) process.exit(result.status || 1);
8
+ return result;
9
+ }
10
+
11
+ function npmView(packageSpec) {
12
+ return run('npm', ['view', packageSpec, 'version'], { allowFailure: true, stdio: 'pipe', encoding: 'utf8' }).status === 0;
13
+ }
14
+
15
+ const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
16
+ const ref = process.env.GITHUB_REF_NAME || '';
17
+ const branch = ref.split('/')[1] || 'develop';
18
+ const tag = branch === 'main' ? 'latest' : branch;
19
+
20
+ if (!process.env.NODE_AUTH_TOKEN) {
21
+ console.log('NODE_AUTH_TOKEN is not configured; skipping npm publish.');
22
+ process.exit(0);
23
+ }
24
+
25
+ if (npmView(pkg.name + '@' + pkg.version)) {
26
+ console.log(pkg.name + '@' + pkg.version + ' already exists; ensuring dist-tag ' + tag + '.');
27
+ run('npm', ['dist-tag', 'add', pkg.name + '@' + pkg.version, tag], { allowFailure: true });
28
+ process.exit(0);
29
+ }
30
+
31
+ for (const field of ['dependencies', 'peerDependencies', 'optionalDependencies']) {
32
+ for (const [name, version] of Object.entries(pkg[field] || {})) {
33
+ if (!name.startsWith('@a5c-ai/') || version.startsWith('^') || version.startsWith('~') || version === '*' || version.startsWith('workspace:')) continue;
34
+ if (!npmView(name + '@' + version)) {
35
+ console.log('Required internal dependency ' + name + '@' + version + ' is not published yet; skipping npm publish.');
36
+ process.exit(0);
37
+ }
38
+ }
39
+ }
40
+
41
+ run('npm', ['publish', '--access', 'public', '--tag', tag]);
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var path = require('path');
5
+ var shared = require('../bin/install-shared');
6
+
7
+ var workspace = process.cwd();
8
+ for (var i = 0; i < process.argv.length; i++) {
9
+ if (process.argv[i] === '--workspace' && process.argv[i + 1]) {
10
+ workspace = path.resolve(process.argv[i + 1]);
11
+ }
12
+ }
13
+
14
+ var src = process.env.PLUGIN_PACKAGE_ROOT || path.resolve(__dirname, '..');
15
+ var dest = shared.getHomePluginRoot('workspace');
16
+ console.log('[babysitter] Team install to ' + dest);
17
+
18
+ shared.copyPluginBundle(src, dest);
19
+ if (typeof shared.harnessTeamInstall === 'function') {
20
+ shared.harnessTeamInstall(src, dest, workspace);
21
+ }
22
+ shared.runPostInstall(dest);
23
+ console.log('[babysitter] Team install complete.');
@@ -29,7 +29,7 @@ Where `OPENCODE_CONFIG_DIR` is resolved from the `OPENCODE_CONFIG_DIR` environme
29
29
  Read the SDK version from `versions.json` to ensure version compatibility:
30
30
 
31
31
  ```bash
32
- SDK_VERSION=$(node -e "try{const fs=require('fs');const probes=['./plugins/babysitter-opencode/versions.json','./node_modules/@a5c-ai/babysitter-opencode/versions.json'];for(const probe of probes){if(fs.existsSync(probe)){console.log(JSON.parse(fs.readFileSync(probe,'utf8')).sdkVersion||'latest');process.exit(0)}}console.log('latest')}catch{console.log('latest')}")
32
+ SDK_VERSION=$(node -e "try{const fs=require('fs');const probes=['./plugins/babysitter-unified/versions.json','./node_modules/@a5c-ai/babysitter-opencode/versions.json'];for(const probe of probes){if(fs.existsSync(probe)){console.log(JSON.parse(fs.readFileSync(probe,'utf8')).sdkVersion||'latest');process.exit(0)}}console.log('latest')}catch{console.log('latest')}")
33
33
  npm i -g @a5c-ai/babysitter-sdk@$SDK_VERSION
34
34
 
35
35
  CLI="npx -y @a5c-ai/babysitter-sdk@$SDK_VERSION"
@@ -1,11 +1,12 @@
1
1
  ---
2
2
  name: babysit
3
- description: Orchestrate via @babysitter. Use this skill when asked to babysit a run, orchestrate a process or whenever it is called explicitly. (babysit, babysitter, orchestrate, orchestrate a run, workflow, etc.)
3
+ description: >-
4
+ Execute via @babysitter. Use this skill when asked to babysit a task, do anything that is structured process-driven (even a loop) or whenever it is called explicitly. (babysit, babysitter, with a process, orchestrate, orchestrate a run, workflow, loop until, etc.)
4
5
  ---
5
6
 
6
7
  # babysit
7
8
 
8
- Orchestrate `.a5c/runs/<runId>/` through iterative execution.
9
+ Follow the commands below exactly. but apply judgement and creativity to get the job done. no matter how small or simple the task may seem, you must use the babysitter SDK and run lifecycle to execute it. This is non-negotiable. If you are asked to do something that seems like it could be done with a simple tool call, you must still use the babysitter SDK to create a run, define tasks, execute them, and complete the run. This is how you will learn and demonstrate mastery of the babysitter system. Always follow the full process, even for trivial tasks.
9
10
 
10
11
  ## Dependencies
11
12
 
@@ -14,7 +15,7 @@ Orchestrate `.a5c/runs/<runId>/` through iterative execution.
14
15
  Read the SDK version from `versions.json` to ensure version compatibility:
15
16
 
16
17
  ```bash
17
- SDK_VERSION=$(node -e "try{const fs=require('fs');const probes=['./plugins/babysitter-opencode/versions.json','./node_modules/@a5c-ai/babysitter-opencode/versions.json'];for(const probe of probes){if(fs.existsSync(probe)){console.log(JSON.parse(fs.readFileSync(probe,'utf8')).sdkVersion||'latest');process.exit(0)}}console.log('latest')}catch{console.log('latest')}")
18
+ SDK_VERSION=$(node -e "try{const fs=require('fs');const probes=['./plugins/babysitter-unified/versions.json','./node_modules/@a5c-ai/babysitter-opencode/versions.json'];for(const probe of probes){if(fs.existsSync(probe)){console.log(JSON.parse(fs.readFileSync(probe,'utf8')).sdkVersion||'latest');process.exit(0)}}console.log('latest')}catch{console.log('latest')}")
18
19
 
19
20
  npm i -g @a5c-ai/babysitter-sdk@$SDK_VERSION
20
21
  CLI="npx -y @a5c-ai/babysitter-sdk@$SDK_VERSION"
@@ -5,4 +5,8 @@ description: Orchestrate a babysitter run. use this command to start babysitting
5
5
 
6
6
  # call
7
7
 
8
- Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
8
+ Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md). Then continue executing the returned instructions in this same turn. Do not stop after the Skill tool returns; carry the requested run through to completion proof.
9
+
10
+ User arguments for this command:
11
+
12
+ $ARGUMENTS
@@ -11,11 +11,33 @@ Create and run a cleanup process using the process at `skills\babysit\process\cr
11
11
 
12
12
  Implementation notes (for the process):
13
13
  - Parse arguments for `--dry-run` flag (if present, set dryRun: true in inputs) and `--keep-days N` (default: 7)
14
- - The process scans .a5c/runs/ for completed/failed runs, aggregates insights, writes summaries, then removes old data
15
- - Always show the user what will be removed before removing (in interactive mode via breakpoints)
16
- - In non-interactive mode (yolo), proceed with cleanup using defaults
17
- - The insights file goes to docs/run-history-insights.md
18
- - Only remove terminal runs (completed/failed) older than the keep-days threshold
19
- - Never remove active/in-progress runs
20
- - Remove orphaned process files not referenced by remaining runs
21
- - After cleanup, show remaining run count and disk usage
14
+
15
+ CRITICAL: The cleanup MUST follow this exact phase order. Do NOT delete any run before Phase 2 completes.
16
+
17
+ Phase 1 Scan:
18
+ - Scan .a5c/runs/ for all runs
19
+ - Classify each as terminal (completed/failed) or active (in-progress/created)
20
+ - Identify terminal runs older than the keep-days threshold as removal candidates
21
+ - Never mark active/in-progress runs for removal
22
+ - Count and report: total runs, terminal, active, removal candidates, disk usage
23
+
24
+ Phase 2 — Aggregate insights (BEFORE any deletion):
25
+ - For EVERY removal candidate, read its run.json and journal/ events
26
+ - Extract: processId, prompt, status, event count, created date, task summaries
27
+ - Group by process type and extract patterns (retry counts, convergence behavior, failure modes)
28
+ - Append a new dated section to docs/run-history-insights.md with:
29
+ - Summary statistics (runs removed, disk freed, runs retained)
30
+ - Run categories with counts and descriptions
31
+ - Key patterns observed (multi-batch convergence, retry behavior, etc.)
32
+ - What worked well / what didn't from the run data
33
+ - This file MUST be written and verified before proceeding to Phase 3
34
+
35
+ Phase 3 — Confirm removal:
36
+ - In interactive mode, show the user what will be removed via a breakpoint
37
+ - In non-interactive mode (yolo), proceed with defaults
38
+ - In dry-run mode, stop here and show what would be removed
39
+
40
+ Phase 4 — Remove:
41
+ - Delete the terminal runs older than keep-days threshold
42
+ - Identify and remove orphaned process files not referenced by remaining runs
43
+ - Show remaining run count and disk usage after cleanup
@@ -5,30 +5,30 @@ description: Submit feedback or contribute to babysitter project
5
5
 
6
6
  # contrib
7
7
 
8
- Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
9
-
10
- ## Process Routing
11
-
8
+ Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
9
+
10
+ ## Process Routing
11
+
12
12
  Contribution processes live under the active process library's `cradle/` directory. Resolve the active library root with `babysitter process-library:active --json` and route based on arguments:
13
-
14
- ### Issue-based (opens a GitHub issue in a5c-ai/babysitter)
15
- * **Bug report** → `cradle/bug-report.js#process` — Report a bug in the SDK, CLI, process library, etc.
16
- * **Feature request** → `cradle/feature-request.js#process` — Request a new feature or enhancement
17
- * **Documentation question** → `cradle/documentation-question.js#process` — Ask about undocumented behavior or missing docs
18
-
19
- ### PR-based (forks repo, creates branch, submits PR to a5c-ai/babysitter)
20
- * **Bugfix** → `cradle/bugfix.js#process` — User already has the fix for a bug
21
- * **Feature implementation** → `cradle/feature-implementation-contribute.js#process` — User already has a feature implementation
22
- * **Harness integration** → `cradle/feature-harness-integration-contribute.js#process` — User has a harness (CI/CD, IDE, editor) integration
23
- * **Library contribution** → `cradle/library-contribution.js#process` — New or improved process/skill/subagent for the library
24
- * **Documentation answer** → `cradle/documentation-contribute-answer.js#process` — User has an answer for an unanswered docs question
25
-
26
- ### Router (when arguments are empty or general)
27
- * **Contribute** → `cradle/contribute.js#process` — Explains contribution types and routes to the specific process
28
-
29
- ## Contribution Rules
30
-
31
- * PR-based contributions: fork the babysitter repo (a5c-ai/babysitter) for the user, ask to star if not already starred, perform changes, submit PR
32
- * Issue-based contributions: gather details, search for duplicates, review, then open an issue in a5c-ai/babysitter
33
- * Add breakpoints (permissions) before ALL gh actions (fork, star, submit PR/issue) to allow user review and cancellation
13
+
14
+ ### Issue-based (opens a GitHub issue in a5c-ai/babysitter)
15
+ * **Bug report** → `cradle/bug-report.js#process` — Report a bug in the SDK, CLI, process library, etc.
16
+ * **Feature request** → `cradle/feature-request.js#process` — Request a new feature or enhancement
17
+ * **Documentation question** → `cradle/documentation-question.js#process` — Ask about undocumented behavior or missing docs
18
+
19
+ ### PR-based (forks repo, creates branch, submits PR to a5c-ai/babysitter)
20
+ * **Bugfix** → `cradle/bugfix.js#process` — User already has the fix for a bug
21
+ * **Feature implementation** → `cradle/feature-implementation-contribute.js#process` — User already has a feature implementation
22
+ * **Harness integration** → `cradle/feature-harness-integration-contribute.js#process` — User has a harness (CI/CD, IDE, editor) integration
23
+ * **Library contribution** → `cradle/library-contribution.js#process` — New or improved process/skill/subagent for the library
24
+ * **Documentation answer** → `cradle/documentation-contribute-answer.js#process` — User has an answer for an unanswered docs question
25
+
26
+ ### Router (when arguments are empty or general)
27
+ * **Contribute** → `cradle/contribute.js#process` — Explains contribution types and routes to the specific process
28
+
29
+ ## Contribution Rules
30
+
31
+ * PR-based contributions: fork the babysitter repo (a5c-ai/babysitter) for the user, ask to star if not already starred, perform changes, submit PR
32
+ * Issue-based contributions: gather details, search for duplicates, review, then open an issue in a5c-ai/babysitter
33
+ * Add breakpoints (permissions) before ALL gh actions (fork, star, submit PR/issue) to allow user review and cancellation
34
34
  * If arguments are empty: use the `contribute.js` router process to show options and route accordingly
@@ -157,7 +157,6 @@ If it exists:
157
157
  **Goal:** Inspect babysitter session files for health and detect runaway loops.
158
158
 
159
159
  - Search for session state files using Glob:
160
- - `plugins/babysitter/skills/babysit/state/*.md`
161
160
  - `.a5c/state/*.md`
162
161
  - `.a5c/state/*.json`
163
162
  - For each session state file found:
@@ -261,7 +260,7 @@ Mark as PASS if total size < 500MB and no files > 10MB. Mark as WARN if total si
261
260
 
262
261
  ### 10a. Hook Registration
263
262
 
264
- - Locate the plugin root. Check for `CLAUDE_PLUGIN_ROOT` env var, or search for `plugins/babysitter/hooks/hooks.json` by walking up from the current directory.
263
+ - Locate the plugin root. Check for `CLAUDE_PLUGIN_ROOT` env var first, or search for a babysitter `hooks.json` by walking up from the current directory.
265
264
  - If found, read `hooks.json` and verify:
266
265
  - A `Stop` hook entry exists with a command referencing `babysitter-stop-hook.sh`.
267
266
  - A `SessionStart` hook entry exists with a command referencing `babysitter-session-start-hook.sh`.
@@ -316,7 +315,7 @@ If the stop hook shows NO evidence of execution (no log entries, no journal even
316
315
 
317
316
  Perform these diagnostic steps in order and report the first failure found:
318
317
 
319
- 1. **Plugin not installed**: Check if `plugins/babysitter/` exists relative to the project root and if `CLAUDE_PLUGIN_ROOT` is set. If the plugin directory doesn't exist, report: "Plugin not installed — the babysitter plugin directory is missing."
318
+ 1. **Plugin not installed**: Check if `CLAUDE_PLUGIN_ROOT` is set or if a babysitter plugin directory exists relative to the project root. If neither exists, report: "Plugin not installed — the babysitter plugin directory is missing."
320
319
 
321
320
  2. **Plugin not enabled**: Check for Claude settings files:
322
321
  - `~/.claude/settings.json` — look for `babysitter` in `enabledPlugins`.
@@ -363,13 +362,13 @@ Mark as FAIL if:
363
362
  - Parse the output and inspect the `resolvedFrom` field. Classify as follows:
364
363
  - `resolvedFrom: "pid-marker"` → mark as PASS ("Session ID derives from the live Claude Code ancestor process -- authoritative").
365
364
  - `resolvedFrom: "env-file"` → mark as PASS with a note ("CLAUDE_ENV_FILE was used; typically healthy").
366
- - `resolvedFrom: "env-var"` → mark as WARN ("`BABYSITTER_SESSION_ID` is set without a corroborating PID marker. Likely stale from a prior Claude Code session -- see GitHub issue #130").
367
- - Remediation: run `babysitter session:cleanup` and start a fresh Claude Code session, or `unset BABYSITTER_SESSION_ID` before invoking babysitter.
365
+ - `resolvedFrom: "env-var"` → mark as WARN ("`AGENT_SESSION_ID` is set without a corroborating PID marker. Likely stale from a prior Claude Code session -- see GitHub issue #130").
366
+ - Remediation: run `babysitter session:cleanup` and start a fresh Claude Code session, or `unset AGENT_SESSION_ID` before invoking babysitter.
368
367
  - `resolvedFrom: "none"` → mark as ERROR ("No session ID resolvable. Either no session-start hook fired, or the ancestor walk failed").
369
368
 
370
369
  **Env-var shadow check:**
371
370
  - Independently inspect `envVarPresent` and `envVarMatches` in the output.
372
- - If `envVarPresent && !envVarMatches`, mark as WARN ("`BABYSITTER_SESSION_ID` in env does not match the resolved session ID; a stale value is shadowing the authoritative one. Unset the env var").
371
+ - If `envVarPresent && !envVarMatches`, mark as WARN ("`AGENT_SESSION_ID` in env does not match the resolved session ID; a stale value is shadowing the authoritative one. Unset the env var").
373
372
 
374
373
  ---
375
374
 
@@ -391,7 +390,7 @@ Mark as FAIL if:
391
390
 
392
391
  - Enumerate files in `~/.a5c/` matching the pattern `current-session-*-pid-*`.
393
392
  - Count markers per harness (derived from the filename).
394
- - If more than one live marker exists for the same harness, mark as INFO ("Multiple live Claude Code / harness sessions detected; ensure each shell scopes `BABYSITTER_SESSION_ID` appropriately -- the PID marker handles this automatically").
393
+ - If more than one live marker exists for the same harness, mark as INFO ("Multiple live Claude Code / harness sessions detected; ensure each shell scopes `AGENT_SESSION_ID` appropriately -- the PID marker handles this automatically").
395
394
  - Otherwise mark as PASS.
396
395
 
397
396
  ---
@@ -502,7 +501,7 @@ babysitter session:cleanup --dry-run # preview
502
501
  babysitter session:cleanup # apply
503
502
 
504
503
  # 2. Unset a stale env var
505
- unset BABYSITTER_SESSION_ID
504
+ unset AGENT_SESSION_ID
506
505
 
507
506
  # 3. Re-bind a run explicitly if needed
508
507
  babysitter session:resume --session-id <fresh-id> --state-dir ~/.a5c --run-id <runId> --runs-dir .a5c/runs