@a5c-ai/babysitter-opencode 5.0.1-staging.e4f17eff → 5.0.1-staging.fcac7259
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 -2
- package/bin/cli.cjs +1 -191
- package/bin/cli.js +90 -49
- package/bin/install-shared.cjs +1 -478
- package/bin/install-shared.js +615 -0
- package/bin/install.cjs +1 -143
- package/bin/install.js +18 -98
- package/bin/uninstall.cjs +1 -87
- package/bin/uninstall.js +13 -34
- package/commands/doctor.md +5 -5
- package/commands/help.md +245 -244
- package/commands/observe.md +12 -12
- package/hooks/babysitter-proxied-session-created.js +18 -212
- package/hooks/babysitter-proxied-session-created.sh +11 -0
- package/hooks/babysitter-proxied-session-idle.js +18 -167
- package/hooks/babysitter-proxied-session-idle.sh +3 -0
- package/hooks/babysitter-proxied-shell-env.js +21 -145
- package/hooks/babysitter-proxied-shell-env.sh +3 -0
- package/hooks/babysitter-proxied-tool-execute-after.js +20 -160
- package/hooks/babysitter-proxied-tool-execute-after.sh +3 -0
- package/hooks/babysitter-proxied-tool-execute-before.js +20 -162
- package/hooks/babysitter-proxied-tool-execute-before.sh +3 -0
- package/hooks/hooks.json +18 -18
- package/package.json +19 -19
- package/plugin.json +6 -4
- package/scripts/team-install.js +23 -0
- package/skills/contrib/SKILL.md +25 -25
- package/skills/doctor/SKILL.md +5 -5
- package/skills/help/SKILL.md +3 -2
- package/skills/observe/SKILL.md +1 -1
- package/skills/plugins/SKILL.md +243 -243
- package/skills/project-install/SKILL.md +3 -3
- package/skills/resume/SKILL.md +1 -1
- package/skills/retrospect/SKILL.md +48 -48
- package/skills/user-install/SKILL.md +3 -3
- package/versions.json +1 -1
- package/hooks/hooks.json.legacy +0 -46
- package/hooks/proxied-hooks.json +0 -47
- package/hooks/session-created.js +0 -182
- package/hooks/session-idle.js +0 -124
- package/hooks/shell-env.js +0 -88
- package/hooks/tool-execute-after.js +0 -107
- package/hooks/tool-execute-before.js +0 -109
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Babysitter Tool Execute After Hook for OpenCode
|
|
4
|
-
*
|
|
5
|
-
* Fires after a tool execution in OpenCode. Delegates to
|
|
6
|
-
* `babysitter hook:run --hook-type post-tool-use` for post-tool-use awareness.
|
|
7
|
-
*
|
|
8
|
-
* This hook can be used to:
|
|
9
|
-
* - Log tool execution results for babysitter run observability
|
|
10
|
-
* - Trigger babysitter effects based on tool outputs
|
|
11
|
-
* - Update session state after tool executions
|
|
12
|
-
*
|
|
13
|
-
* OpenCode plugin protocol:
|
|
14
|
-
* - Receives tool result context as JSON via stdin
|
|
15
|
-
* - Outputs JSON to stdout
|
|
16
|
-
* - Exit 0 = success
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
"use strict";
|
|
20
|
-
|
|
21
|
-
const { execSync } = require("child_process");
|
|
22
|
-
const { readFileSync, mkdirSync, appendFileSync } = require("fs");
|
|
23
|
-
const os = require("os");
|
|
24
|
-
const path = require("path");
|
|
25
|
-
|
|
26
|
-
const PLUGIN_ROOT = process.env.OPENCODE_PLUGIN_ROOT || path.resolve(__dirname, "..");
|
|
27
|
-
const GLOBAL_ROOT = process.env.BABYSITTER_GLOBAL_STATE_DIR || path.join(os.homedir(), ".a5c");
|
|
28
|
-
const STATE_DIR = process.env.BABYSITTER_STATE_DIR || path.join(GLOBAL_ROOT, "state");
|
|
29
|
-
const LOG_DIR = process.env.BABYSITTER_LOG_DIR || path.join(GLOBAL_ROOT, "logs");
|
|
30
|
-
const LOG_FILE = path.join(LOG_DIR, "babysitter-tool-after-hook.log");
|
|
31
|
-
|
|
32
|
-
function ensureDir(dir) {
|
|
33
|
-
try { mkdirSync(dir, { recursive: true }); } catch { /* best-effort */ }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function blog(msg) {
|
|
37
|
-
ensureDir(LOG_DIR);
|
|
38
|
-
const ts = new Date().toISOString();
|
|
39
|
-
try {
|
|
40
|
-
appendFileSync(LOG_FILE, `[INFO] ${ts} ${msg}\n`);
|
|
41
|
-
} catch { /* best-effort */ }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getSdkVersion() {
|
|
45
|
-
try {
|
|
46
|
-
const versions = JSON.parse(readFileSync(path.join(PLUGIN_ROOT, "versions.json"), "utf8"));
|
|
47
|
-
return versions.sdkVersion || "latest";
|
|
48
|
-
} catch {
|
|
49
|
-
return "latest";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function main() {
|
|
54
|
-
const sessionId = process.env.BABYSITTER_SESSION_ID
|
|
55
|
-
|| process.env.OPENCODE_SESSION_ID
|
|
56
|
-
|| "";
|
|
57
|
-
|
|
58
|
-
if (!sessionId) {
|
|
59
|
-
process.stdout.write("{}\n");
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Read stdin for tool result context
|
|
64
|
-
let inputData = "";
|
|
65
|
-
try {
|
|
66
|
-
inputData = require("fs").readFileSync(0, "utf8");
|
|
67
|
-
} catch {
|
|
68
|
-
// No stdin available
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
blog(`tool-execute-after: session=${sessionId}`);
|
|
72
|
-
|
|
73
|
-
const hookInput = JSON.stringify({
|
|
74
|
-
session_id: sessionId,
|
|
75
|
-
cwd: process.cwd(),
|
|
76
|
-
harness: "opencode",
|
|
77
|
-
plugin_root: PLUGIN_ROOT,
|
|
78
|
-
tool_result: inputData ? JSON.parse(inputData) : {},
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const sdkVersion = getSdkVersion();
|
|
82
|
-
const args = [
|
|
83
|
-
"hook:run",
|
|
84
|
-
"--hook-type", "post-tool-use",
|
|
85
|
-
"--harness", "opencode",
|
|
86
|
-
"--plugin-root", PLUGIN_ROOT,
|
|
87
|
-
"--state-dir", STATE_DIR,
|
|
88
|
-
"--json",
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
const result = execSync(`babysitter ${args.join(" ")}`, {
|
|
93
|
-
input: hookInput,
|
|
94
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
95
|
-
timeout: 10000,
|
|
96
|
-
env: { ...process.env, BABYSITTER_STATE_DIR: STATE_DIR },
|
|
97
|
-
});
|
|
98
|
-
const output = result.toString("utf8").trim();
|
|
99
|
-
blog(`Hook result: ${output}`);
|
|
100
|
-
process.stdout.write((output || "{}") + "\n");
|
|
101
|
-
} catch {
|
|
102
|
-
blog("Post-tool-use hook failed -- non-blocking");
|
|
103
|
-
process.stdout.write("{}\n");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
main();
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Babysitter Tool Execute Before Hook for OpenCode
|
|
4
|
-
*
|
|
5
|
-
* Fires before a tool execution in OpenCode. Delegates to
|
|
6
|
-
* `babysitter hook:run --hook-type pre-tool-use` for pre-tool-use awareness.
|
|
7
|
-
*
|
|
8
|
-
* This hook can be used to:
|
|
9
|
-
* - Log tool invocations for babysitter run observability
|
|
10
|
-
* - Block certain tool calls during specific orchestration phases
|
|
11
|
-
* - Inject babysitter context into tool arguments
|
|
12
|
-
*
|
|
13
|
-
* OpenCode plugin protocol:
|
|
14
|
-
* - Receives tool context as JSON via stdin
|
|
15
|
-
* - Outputs JSON to stdout (empty = allow, { block: true } = block)
|
|
16
|
-
* - Exit 0 = success
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
"use strict";
|
|
20
|
-
|
|
21
|
-
const { execSync } = require("child_process");
|
|
22
|
-
const { readFileSync, mkdirSync, appendFileSync } = require("fs");
|
|
23
|
-
const os = require("os");
|
|
24
|
-
const path = require("path");
|
|
25
|
-
|
|
26
|
-
const PLUGIN_ROOT = process.env.OPENCODE_PLUGIN_ROOT || path.resolve(__dirname, "..");
|
|
27
|
-
const GLOBAL_ROOT = process.env.BABYSITTER_GLOBAL_STATE_DIR || path.join(os.homedir(), ".a5c");
|
|
28
|
-
const STATE_DIR = process.env.BABYSITTER_STATE_DIR || path.join(GLOBAL_ROOT, "state");
|
|
29
|
-
const LOG_DIR = process.env.BABYSITTER_LOG_DIR || path.join(GLOBAL_ROOT, "logs");
|
|
30
|
-
const LOG_FILE = path.join(LOG_DIR, "babysitter-tool-before-hook.log");
|
|
31
|
-
|
|
32
|
-
function ensureDir(dir) {
|
|
33
|
-
try { mkdirSync(dir, { recursive: true }); } catch { /* best-effort */ }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function blog(msg) {
|
|
37
|
-
ensureDir(LOG_DIR);
|
|
38
|
-
const ts = new Date().toISOString();
|
|
39
|
-
try {
|
|
40
|
-
appendFileSync(LOG_FILE, `[INFO] ${ts} ${msg}\n`);
|
|
41
|
-
} catch { /* best-effort */ }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getSdkVersion() {
|
|
45
|
-
try {
|
|
46
|
-
const versions = JSON.parse(readFileSync(path.join(PLUGIN_ROOT, "versions.json"), "utf8"));
|
|
47
|
-
return versions.sdkVersion || "latest";
|
|
48
|
-
} catch {
|
|
49
|
-
return "latest";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function main() {
|
|
54
|
-
const sessionId = process.env.BABYSITTER_SESSION_ID
|
|
55
|
-
|| process.env.OPENCODE_SESSION_ID
|
|
56
|
-
|| "";
|
|
57
|
-
|
|
58
|
-
if (!sessionId) {
|
|
59
|
-
// No session -- pass through without intervention
|
|
60
|
-
process.stdout.write("{}\n");
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Read stdin for tool context
|
|
65
|
-
let inputData = "";
|
|
66
|
-
try {
|
|
67
|
-
inputData = require("fs").readFileSync(0, "utf8");
|
|
68
|
-
} catch {
|
|
69
|
-
// No stdin available
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
blog(`tool-execute-before: session=${sessionId}`);
|
|
73
|
-
|
|
74
|
-
const hookInput = JSON.stringify({
|
|
75
|
-
session_id: sessionId,
|
|
76
|
-
cwd: process.cwd(),
|
|
77
|
-
harness: "opencode",
|
|
78
|
-
plugin_root: PLUGIN_ROOT,
|
|
79
|
-
tool_context: inputData ? JSON.parse(inputData) : {},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const sdkVersion = getSdkVersion();
|
|
83
|
-
const args = [
|
|
84
|
-
"hook:run",
|
|
85
|
-
"--hook-type", "pre-tool-use",
|
|
86
|
-
"--harness", "opencode",
|
|
87
|
-
"--plugin-root", PLUGIN_ROOT,
|
|
88
|
-
"--state-dir", STATE_DIR,
|
|
89
|
-
"--json",
|
|
90
|
-
];
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
const result = execSync(`babysitter ${args.join(" ")}`, {
|
|
94
|
-
input: hookInput,
|
|
95
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
96
|
-
timeout: 10000,
|
|
97
|
-
env: { ...process.env, BABYSITTER_STATE_DIR: STATE_DIR },
|
|
98
|
-
});
|
|
99
|
-
const output = result.toString("utf8").trim();
|
|
100
|
-
blog(`Hook result: ${output}`);
|
|
101
|
-
process.stdout.write((output || "{}") + "\n");
|
|
102
|
-
} catch {
|
|
103
|
-
// On failure, allow the tool execution to proceed
|
|
104
|
-
blog("Pre-tool-use hook failed -- allowing execution");
|
|
105
|
-
process.stdout.write("{}\n");
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
main();
|