@a5c-ai/babysitter-pi 0.1.0 → 0.1.1-staging.90d37144
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/AGENTS.md +131 -0
- package/README.md +86 -35
- package/bin/cli.cjs +2 -10
- package/bin/install.cjs +26 -117
- package/bin/uninstall.cjs +24 -24
- package/commands/assimilate.md +37 -0
- package/commands/call.md +7 -0
- package/commands/cleanup.md +20 -0
- package/commands/contrib.md +33 -0
- package/commands/doctor.md +426 -0
- package/commands/forever.md +7 -0
- package/commands/help.md +244 -0
- package/commands/observe.md +12 -0
- package/commands/plan.md +7 -0
- package/commands/plugins.md +255 -0
- package/commands/project-install.md +17 -0
- package/commands/resume.md +8 -0
- package/commands/retrospect.md +55 -0
- package/commands/user-install.md +17 -0
- package/commands/yolo.md +7 -0
- package/extensions/index.ts +55 -0
- package/package.json +11 -8
- package/scripts/sync-command-docs.cjs +72 -81
- package/skills/assimilate/SKILL.md +38 -0
- package/skills/babysit/SKILL.md +36 -0
- package/skills/call/SKILL.md +8 -0
- package/skills/cleanup/SKILL.md +21 -0
- package/skills/contrib/SKILL.md +34 -0
- package/skills/doctor/SKILL.md +427 -0
- package/skills/forever/SKILL.md +8 -0
- package/skills/help/SKILL.md +245 -0
- package/skills/observe/SKILL.md +13 -0
- package/skills/plan/SKILL.md +8 -0
- package/skills/plugins/SKILL.md +257 -0
- package/skills/project-install/SKILL.md +18 -0
- package/skills/resume/SKILL.md +9 -0
- package/skills/retrospect/SKILL.md +56 -0
- package/skills/user-install/SKILL.md +18 -0
- package/skills/yolo/SKILL.md +8 -0
- package/versions.json +3 -0
- package/commands/babysitter-call.md +0 -12
- package/commands/babysitter-doctor.md +0 -10
- package/commands/babysitter-resume.md +0 -16
- package/commands/babysitter-status.md +0 -15
- package/extensions/babysitter/cli-wrapper.ts +0 -95
- package/extensions/babysitter/constants.ts +0 -77
- package/extensions/babysitter/custom-tools.ts +0 -208
- package/extensions/babysitter/effect-executor.ts +0 -362
- package/extensions/babysitter/guards.ts +0 -257
- package/extensions/babysitter/index.ts +0 -554
- package/extensions/babysitter/loop-driver.ts +0 -256
- package/extensions/babysitter/result-poster.ts +0 -115
- package/extensions/babysitter/sdk-bridge.ts +0 -243
- package/extensions/babysitter/session-binder.ts +0 -284
- package/extensions/babysitter/status-line.ts +0 -54
- package/extensions/babysitter/task-interceptor.ts +0 -82
- package/extensions/babysitter/todo-replacement.ts +0 -125
- package/extensions/babysitter/tool-renderer.ts +0 -263
- package/extensions/babysitter/tui-widgets.ts +0 -164
- package/extensions/babysitter/types.ts +0 -222
- package/skills/babysitter/SKILL.md +0 -45
package/AGENTS.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Agent Instructions -- Babysitter Orchestration Plugin for oh-my-pi
|
|
2
|
+
|
|
3
|
+
This file governs agent behavior when the babysitter-pi plugin is active in an oh-my-pi session. Babysitter is the orchestration layer -- it drives multi-step workflows through process definitions, effects, and an iteration loop.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Session Start -- Auto-Initialization
|
|
8
|
+
|
|
9
|
+
Babysitter initializes automatically on every oh-my-pi session start. The session-binder extension:
|
|
10
|
+
|
|
11
|
+
1. Binds the current pi session to the babysitter state directory (`.a5c/`).
|
|
12
|
+
2. Checks for an active run by inspecting `.a5c/runs/` for pending tasks.
|
|
13
|
+
3. If an active run exists, resumes from the first pending effect.
|
|
14
|
+
4. If no run exists, proceeds with normal session behavior until a babysitter command is issued.
|
|
15
|
+
|
|
16
|
+
You do not need to initialize babysitter manually -- the plugin handles it.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 2. Recognizing Babysitter Commands
|
|
21
|
+
|
|
22
|
+
When the user types a message starting with `/babysitter:` or `/babysitter`, treat it as a **slash command** and dispatch accordingly:
|
|
23
|
+
|
|
24
|
+
| Command | Description |
|
|
25
|
+
|---------|-------------|
|
|
26
|
+
| `/babysitter:call` | Start an orchestration run |
|
|
27
|
+
| `/babysitter:status` | Show current run status and pending effects |
|
|
28
|
+
| `/babysitter:resume` | Resume an existing run from where it left off |
|
|
29
|
+
|
|
30
|
+
Aliases:
|
|
31
|
+
- `/babysitter` (bare) = `/babysitter:call`
|
|
32
|
+
|
|
33
|
+
Load the corresponding skill from `skills/babysitter/SKILL.md` for detailed execution instructions.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 3. Babysitter Orchestration Protocol
|
|
38
|
+
|
|
39
|
+
The core loop works as follows:
|
|
40
|
+
|
|
41
|
+
1. **Create a run** -- A process definition (JS file) is loaded and a run is created under `.a5c/runs/<RUN_ID>/`.
|
|
42
|
+
2. **Iterate** -- The SDK replays resolved effects, then throws when it encounters an unresolved effect. The iteration returns a list of **pending effects** (tasks to execute).
|
|
43
|
+
3. **Execute effects** -- You execute each pending effect using the appropriate tool/action.
|
|
44
|
+
4. **Post results** -- Report the outcome back to babysitter via the SDK bridge.
|
|
45
|
+
5. **Repeat** -- The loop-driver triggers the next iteration automatically. Do NOT loop independently.
|
|
46
|
+
|
|
47
|
+
The plugin's loop-driver extension controls iteration flow. Complete one task, post the result, and the driver handles the rest.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 4. Effect Types
|
|
52
|
+
|
|
53
|
+
When babysitter presents pending effects, identify the `kind` field and execute accordingly:
|
|
54
|
+
|
|
55
|
+
| Kind | Action |
|
|
56
|
+
|------|--------|
|
|
57
|
+
| `agent` | Build a prompt from the agent definition and execute as a sub-agent task |
|
|
58
|
+
| `skill` | Invoke the named skill with the provided parameters |
|
|
59
|
+
| `shell` | Execute the shell command and capture stdout/stderr/exit code |
|
|
60
|
+
| `breakpoint` | Pause execution and present the breakpoint message to the user for approval |
|
|
61
|
+
| `sleep` | Wait until the specified timestamp (handled by the runtime) |
|
|
62
|
+
|
|
63
|
+
For PI-family generated-process guidance, treat `agent`, `skill`, `shell`, `breakpoint`, and `sleep` as the active effect kinds. Do not present `node` as a generated PI-family effect kind.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 5. Posting Results
|
|
68
|
+
|
|
69
|
+
After executing an effect, hand the outcome back to the Babysitter plugin/runtime bridge so the run state, journal, and pending-effect cache stay consistent.
|
|
70
|
+
|
|
71
|
+
Rules:
|
|
72
|
+
- Use the plugin-owned Babysitter bridge/command flow rather than inventing an alternate posting path.
|
|
73
|
+
- Complete one orchestration phase per harness turn, then let the loop-driver trigger the next phase.
|
|
74
|
+
- Do not abort the entire run on a single task failure -- return the effect outcome and let the orchestrator decide the next step.
|
|
75
|
+
- Keep low-level runtime mechanics in the command/extension implementation surface; this file is the behavioral contract for the active agent session.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 6. Task Interception Notice
|
|
80
|
+
|
|
81
|
+
During an active babysitter run, the plugin's task-interceptor extension **intercepts built-in task and todo tools**. This means:
|
|
82
|
+
|
|
83
|
+
- Any task/todo creation is routed through babysitter's effect system instead of the default pi task manager.
|
|
84
|
+
- Do not attempt to use native task tools to track babysitter work -- they are redirected automatically.
|
|
85
|
+
- This interception is only active while a run is in progress. Normal tool behavior resumes after the run completes.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 7. TUI Widgets
|
|
90
|
+
|
|
91
|
+
The babysitter-pi plugin renders TUI widgets showing run progress:
|
|
92
|
+
|
|
93
|
+
- **Status line** -- Current run ID, iteration count, and run state (running/waiting/completed/failed).
|
|
94
|
+
- **Effect queue** -- List of pending and completed effects with their status.
|
|
95
|
+
- **Progress indicator** -- Visual progress through the process definition.
|
|
96
|
+
|
|
97
|
+
These widgets update automatically as effects are resolved. No agent action is required to drive them.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 8. Run Completion
|
|
102
|
+
|
|
103
|
+
When the orchestration run completes successfully, the SDK returns a completion proof. You MUST output it in the following format:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
<promise>PROOF_VALUE</promise>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Where `PROOF_VALUE` is the exact proof string returned by the SDK. This signals to the wrapper and any upstream systems that the run finished with a verified result.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 9. Directory Layout Reference
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
.a5c/
|
|
117
|
+
runs/
|
|
118
|
+
<RUN_ID>/
|
|
119
|
+
run.json # Run metadata
|
|
120
|
+
inputs.json # Process inputs
|
|
121
|
+
journal/ # Append-only event log
|
|
122
|
+
000001.<ulid>.json
|
|
123
|
+
tasks/
|
|
124
|
+
<EFFECT_ID>/
|
|
125
|
+
task.json # Task definition (created by orchestrator)
|
|
126
|
+
result.json # Task result (created after posting)
|
|
127
|
+
state/
|
|
128
|
+
state.json # Derived replay cache
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
All paths are relative to the repository root.
|
package/README.md
CHANGED
|
@@ -1,77 +1,128 @@
|
|
|
1
1
|
# @a5c-ai/babysitter-pi
|
|
2
2
|
|
|
3
|
-
Babysitter
|
|
4
|
-
owns the Pi-specific install surface, command docs, and skill wiring while the
|
|
5
|
-
shared runtime internals remain compatible with the wider PI-family.
|
|
3
|
+
Babysitter package for the upstream `pi` coding agent.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
This is a thin Pi package:
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
- pi commands start or resume runs
|
|
13
|
-
- the harness advances one orchestration phase at a time
|
|
14
|
-
- the plugin runtime records effect outcomes and updates the run state
|
|
15
|
-
- completion requires the emitted `completionProof`
|
|
7
|
+
- `skills/` exposes Babysitter workflows through Pi's skill system
|
|
8
|
+
- `extensions/index.ts` adds lightweight slash-command aliases that forward to those skills
|
|
9
|
+
- the SDK remains responsible for orchestration, runs, tasks, and state
|
|
16
10
|
|
|
17
11
|
## Installation
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
Recommended:
|
|
20
14
|
|
|
21
15
|
```bash
|
|
22
|
-
|
|
16
|
+
pi install npm:@a5c-ai/babysitter-pi
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Verify the package is available:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
babysitter harness:discover --json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Project-local:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cd /path/to/repo
|
|
29
|
+
pi install -l npm:@a5c-ai/babysitter-pi
|
|
23
30
|
```
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
Development helper:
|
|
26
33
|
|
|
27
34
|
```bash
|
|
35
|
+
npx @a5c-ai/babysitter-pi install
|
|
28
36
|
npx @a5c-ai/babysitter-pi install --workspace /path/to/repo
|
|
29
37
|
```
|
|
30
38
|
|
|
31
|
-
|
|
39
|
+
Removal:
|
|
32
40
|
|
|
33
41
|
```bash
|
|
34
|
-
|
|
35
|
-
babysitter harness:install-plugin pi --workspace /path/to/repo
|
|
42
|
+
pi remove npm:@a5c-ai/babysitter-pi
|
|
36
43
|
```
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
## Using Babysitter
|
|
46
|
+
|
|
47
|
+
Start Pi, then use the thin Babysitter entrypoints exposed by the package:
|
|
48
|
+
|
|
49
|
+
- `/babysit` or `/babysitter`
|
|
50
|
+
- `/call`
|
|
51
|
+
- `/plan`
|
|
52
|
+
- `/resume`
|
|
53
|
+
- `/doctor`
|
|
54
|
+
- `/yolo`
|
|
55
|
+
|
|
56
|
+
Each command forwards into Pi's native `/skill:<name>` flow. The orchestration
|
|
57
|
+
contract lives in the skills; the extension only provides convenient aliases.
|
|
58
|
+
|
|
59
|
+
## Commands And Skills
|
|
60
|
+
|
|
61
|
+
The package mirrors the canonical Babysitter command docs and exposes the core
|
|
62
|
+
`babysit` skill plus command-backed skills such as `call`, `doctor`, `plan`,
|
|
63
|
+
`resume`, and `yolo`.
|
|
64
|
+
|
|
65
|
+
The extension layer is intentionally thin. It only forwards slash commands to
|
|
66
|
+
Pi's built-in `/skill:<name>` flow; it does not implement a custom loop driver,
|
|
67
|
+
custom tools, or direct run mutation logic.
|
|
68
|
+
|
|
69
|
+
## Plugin Layout
|
|
39
70
|
|
|
40
71
|
```text
|
|
41
|
-
|
|
72
|
+
plugins/babysitter-pi/
|
|
73
|
+
|-- package.json
|
|
74
|
+
|-- versions.json
|
|
75
|
+
|-- extensions/
|
|
76
|
+
| `-- index.ts
|
|
77
|
+
|-- commands/
|
|
78
|
+
|-- skills/
|
|
79
|
+
|-- bin/
|
|
80
|
+
`-- scripts/
|
|
42
81
|
```
|
|
43
82
|
|
|
44
|
-
|
|
45
|
-
|
|
83
|
+
## SDK Setup
|
|
84
|
+
|
|
85
|
+
Read the pinned SDK version from `versions.json` when you need a local CLI:
|
|
46
86
|
|
|
47
87
|
```bash
|
|
48
|
-
|
|
88
|
+
PLUGIN_ROOT="${PI_PLUGIN_ROOT:-$(pwd)}"
|
|
89
|
+
SDK_VERSION=$(node -e "try{const fs=require('fs');const path=require('path');const pluginRoot=process.env.PI_PLUGIN_ROOT||process.env.PLUGIN_ROOT||process.cwd();const probes=[path.join(pluginRoot,'versions.json'),path.join(pluginRoot,'plugins','babysitter-pi','versions.json'),path.join(pluginRoot,'node_modules','@a5c-ai','babysitter-pi','versions.json'),path.join(process.cwd(),'node_modules','@a5c-ai','babysitter-pi','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')}")
|
|
90
|
+
CLI="npx -y @a5c-ai/babysitter-sdk@$SDK_VERSION"
|
|
49
91
|
```
|
|
50
92
|
|
|
51
|
-
##
|
|
93
|
+
## Marketplace And Distribution
|
|
94
|
+
|
|
95
|
+
Pi discovers this package through its native package installation flow. Publish
|
|
96
|
+
new versions to npm under `@a5c-ai/babysitter-pi`, then users can install or
|
|
97
|
+
upgrade through `pi install npm:@a5c-ai/babysitter-pi`.
|
|
98
|
+
|
|
99
|
+
## Upgrade And Uninstall
|
|
52
100
|
|
|
53
|
-
|
|
101
|
+
Upgrade by reinstalling the package:
|
|
54
102
|
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
103
|
+
```bash
|
|
104
|
+
pi install npm:@a5c-ai/babysitter-pi
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Remove it with:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pi remove npm:@a5c-ai/babysitter-pi
|
|
111
|
+
```
|
|
59
112
|
|
|
60
113
|
## Troubleshooting
|
|
61
114
|
|
|
62
|
-
- `babysitter harness:discover --json
|
|
63
|
-
|
|
64
|
-
- If
|
|
65
|
-
|
|
115
|
+
- Verify the harness with `babysitter harness:discover --json`.
|
|
116
|
+
- If `pi` is not available, check `where pi` on Windows or `which pi` on Unix.
|
|
117
|
+
- If commands do not appear, restart Pi after installation so it reloads package metadata.
|
|
118
|
+
- If the wrong SDK version is used, inspect `versions.json` inside the installed package root.
|
|
119
|
+
- Regenerate mirrored commands and command-backed skills with `npm run sync:commands`.
|
|
66
120
|
|
|
67
121
|
## Tests
|
|
68
122
|
|
|
69
123
|
```bash
|
|
70
124
|
cd plugins/babysitter-pi
|
|
71
125
|
npm test
|
|
72
|
-
npm run test:integration
|
|
73
|
-
npm run test:harness
|
|
74
|
-
npm run test:tui
|
|
75
126
|
```
|
|
76
127
|
|
|
77
128
|
## License
|
package/bin/cli.cjs
CHANGED
|
@@ -23,11 +23,9 @@ function parseArgs(argv) {
|
|
|
23
23
|
const arg = argv[i];
|
|
24
24
|
if (arg === '--workspace') {
|
|
25
25
|
const next = argv[i + 1];
|
|
26
|
+
workspace = next && !next.startsWith('-') ? path.resolve(next) : process.cwd();
|
|
26
27
|
if (next && !next.startsWith('-')) {
|
|
27
|
-
workspace = path.resolve(next);
|
|
28
28
|
i += 1;
|
|
29
|
-
} else {
|
|
30
|
-
workspace = process.cwd();
|
|
31
29
|
}
|
|
32
30
|
continue;
|
|
33
31
|
}
|
|
@@ -65,13 +63,7 @@ function main() {
|
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
const parsed = parseArgs(rest);
|
|
68
|
-
const args = [];
|
|
69
|
-
if (parsed.workspace) {
|
|
70
|
-
args.push('--workspace', parsed.workspace);
|
|
71
|
-
} else {
|
|
72
|
-
args.push('--global');
|
|
73
|
-
}
|
|
74
|
-
|
|
66
|
+
const args = parsed.workspace ? ['--workspace', parsed.workspace] : ['--global'];
|
|
75
67
|
runNodeScript(path.join(PACKAGE_ROOT, 'bin', `${command}.cjs`), args);
|
|
76
68
|
}
|
|
77
69
|
|
package/bin/install.cjs
CHANGED
|
@@ -2,143 +2,52 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
const os = require('os');
|
|
6
5
|
const path = require('path');
|
|
7
6
|
const { spawnSync } = require('child_process');
|
|
8
7
|
|
|
9
8
|
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
10
|
-
const
|
|
11
|
-
{ source: 'package.json', required: true },
|
|
12
|
-
{ source: 'extensions', required: true },
|
|
13
|
-
{ source: 'skills', required: true },
|
|
14
|
-
{ source: 'commands', required: true },
|
|
15
|
-
{ source: 'scripts', required: true },
|
|
16
|
-
];
|
|
9
|
+
const PACKAGE_JSON = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
|
|
17
10
|
|
|
18
11
|
function parseArgs(argv) {
|
|
19
|
-
|
|
20
|
-
workspace: null,
|
|
21
|
-
};
|
|
12
|
+
let workspace = null;
|
|
22
13
|
for (let i = 2; i < argv.length; i += 1) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
throw new Error(`unknown argument: ${argv[i]}`);
|
|
14
|
+
const arg = argv[i];
|
|
15
|
+
if (arg === '--workspace') {
|
|
16
|
+
const next = argv[i + 1];
|
|
17
|
+
workspace = next && !next.startsWith('-') ? path.resolve(argv[++i]) : process.cwd();
|
|
18
|
+
continue;
|
|
29
19
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function getGlobalStateDir() {
|
|
35
|
-
if (process.env.BABYSITTER_GLOBAL_STATE_DIR) {
|
|
36
|
-
return path.resolve(process.env.BABYSITTER_GLOBAL_STATE_DIR);
|
|
37
|
-
}
|
|
38
|
-
return path.join(os.homedir(), '.a5c');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function getPluginRoot(args) {
|
|
42
|
-
const base = args.workspace ? path.resolve(args.workspace) : os.homedir();
|
|
43
|
-
return path.join(base, '.pi', 'plugins', 'babysitter');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function copyRecursive(src, dest) {
|
|
47
|
-
const stat = fs.statSync(src);
|
|
48
|
-
if (stat.isDirectory()) {
|
|
49
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
50
|
-
for (const entry of fs.readdirSync(src)) {
|
|
51
|
-
if (['node_modules', '.git', 'test', '.gitignore', 'state'].includes(entry)) continue;
|
|
52
|
-
copyRecursive(path.join(src, entry), path.join(dest, entry));
|
|
20
|
+
if (arg === '--global') {
|
|
21
|
+
workspace = null;
|
|
22
|
+
continue;
|
|
53
23
|
}
|
|
54
|
-
|
|
24
|
+
throw new Error(`unknown argument: ${arg}`);
|
|
55
25
|
}
|
|
56
|
-
|
|
57
|
-
fs.copyFileSync(src, dest);
|
|
26
|
+
return { workspace };
|
|
58
27
|
}
|
|
59
28
|
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
argsPrefix: [path.resolve(process.env.BABYSITTER_SDK_CLI)],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
return {
|
|
69
|
-
command: process.execPath,
|
|
70
|
-
argsPrefix: [
|
|
71
|
-
require.resolve('@a5c-ai/babysitter-sdk/dist/cli/main.js', {
|
|
72
|
-
paths: [packageRoot],
|
|
73
|
-
}),
|
|
74
|
-
],
|
|
75
|
-
};
|
|
76
|
-
} catch {
|
|
77
|
-
return {
|
|
78
|
-
command: 'babysitter',
|
|
79
|
-
argsPrefix: [],
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function runBabysitterCli(packageRoot, cliArgs) {
|
|
85
|
-
const resolved = resolveBabysitterCommand(packageRoot);
|
|
86
|
-
const result = spawnSync(resolved.command, [...resolved.argsPrefix, ...cliArgs], {
|
|
87
|
-
cwd: packageRoot,
|
|
88
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
89
|
-
encoding: 'utf8',
|
|
29
|
+
function run(command, args, cwd) {
|
|
30
|
+
const result = spawnSync(command, args, {
|
|
31
|
+
cwd,
|
|
32
|
+
stdio: 'inherit',
|
|
90
33
|
env: process.env,
|
|
91
34
|
});
|
|
92
|
-
if (result.status !== 0) {
|
|
93
|
-
|
|
94
|
-
const stdout = (result.stdout || '').trim();
|
|
95
|
-
throw new Error(
|
|
96
|
-
`babysitter ${cliArgs.join(' ')} failed` +
|
|
97
|
-
(stderr ? `: ${stderr}` : stdout ? `: ${stdout}` : ''),
|
|
98
|
-
);
|
|
35
|
+
if ((result.status ?? 1) !== 0) {
|
|
36
|
+
process.exit(result.status ?? 1);
|
|
99
37
|
}
|
|
100
|
-
return result.stdout;
|
|
101
38
|
}
|
|
102
39
|
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
)
|
|
109
|
-
);
|
|
110
|
-
console.log(`[babysitter] process library: ${active.binding?.dir}`);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function installEntry(pluginRoot, entry) {
|
|
114
|
-
const src = path.join(PACKAGE_ROOT, entry.source);
|
|
115
|
-
const dest = path.join(pluginRoot, entry.source);
|
|
116
|
-
if (!fs.existsSync(src)) {
|
|
117
|
-
if (entry.required) throw new Error(`required install payload is missing: ${src}`);
|
|
40
|
+
function main() {
|
|
41
|
+
const { workspace } = parseArgs(process.argv);
|
|
42
|
+
const packageSpec = `npm:${PACKAGE_JSON.name}@${PACKAGE_JSON.version}`;
|
|
43
|
+
if (workspace) {
|
|
44
|
+
console.log(`[babysitter] installing ${packageSpec} into project settings for ${workspace}`);
|
|
45
|
+
run('pi', ['install', '-l', packageSpec], workspace);
|
|
118
46
|
return;
|
|
119
47
|
}
|
|
120
|
-
copyRecursive(src, dest);
|
|
121
|
-
console.log(`[babysitter] ${entry.source}${fs.statSync(src).isDirectory() ? '/' : ''}`);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function main() {
|
|
125
|
-
const args = parseArgs(process.argv);
|
|
126
|
-
const pluginRoot = getPluginRoot(args);
|
|
127
|
-
console.log(`[babysitter] Installing pi plugin to ${pluginRoot}`);
|
|
128
48
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
fs.mkdirSync(pluginRoot, { recursive: true });
|
|
132
|
-
for (const entry of INSTALL_ENTRIES) {
|
|
133
|
-
installEntry(pluginRoot, entry);
|
|
134
|
-
}
|
|
135
|
-
fs.mkdirSync(path.join(pluginRoot, 'state'), { recursive: true });
|
|
136
|
-
ensureGlobalProcessLibrary();
|
|
137
|
-
console.log('[babysitter] Installation complete!');
|
|
138
|
-
} catch (err) {
|
|
139
|
-
console.error(`[babysitter] Failed to install plugin files: ${err.message}`);
|
|
140
|
-
process.exitCode = 1;
|
|
141
|
-
}
|
|
49
|
+
console.log(`[babysitter] installing ${packageSpec} into global pi settings`);
|
|
50
|
+
run('pi', ['install', packageSpec], process.cwd());
|
|
142
51
|
}
|
|
143
52
|
|
|
144
53
|
main();
|
package/bin/uninstall.cjs
CHANGED
|
@@ -2,39 +2,39 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
const os = require('os');
|
|
6
5
|
const path = require('path');
|
|
6
|
+
const { spawnSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
9
|
+
const PACKAGE_JSON = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
|
|
7
10
|
|
|
8
11
|
function parseArgs(argv) {
|
|
9
|
-
|
|
10
|
-
workspace: null,
|
|
11
|
-
};
|
|
12
|
+
let workspace = null;
|
|
12
13
|
for (let i = 2; i < argv.length; i += 1) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const arg = argv[i];
|
|
15
|
+
if (arg === '--workspace') {
|
|
16
|
+
const next = argv[i + 1];
|
|
17
|
+
workspace = next && !next.startsWith('-') ? path.resolve(argv[++i]) : process.cwd();
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (arg === '--global') {
|
|
21
|
+
workspace = null;
|
|
22
|
+
continue;
|
|
19
23
|
}
|
|
24
|
+
throw new Error(`unknown argument: ${arg}`);
|
|
20
25
|
}
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function getPluginRoot(args) {
|
|
25
|
-
const base = args.workspace ? path.resolve(args.workspace) : os.homedir();
|
|
26
|
-
return path.join(base, '.pi', 'plugins', 'babysitter');
|
|
26
|
+
return { workspace };
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function main() {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const { workspace } = parseArgs(process.argv);
|
|
31
|
+
const packageSpec = `npm:${PACKAGE_JSON.name}`;
|
|
32
|
+
const result = spawnSync('pi', workspace ? ['remove', '-l', packageSpec] : ['remove', packageSpec], {
|
|
33
|
+
cwd: workspace ?? process.cwd(),
|
|
34
|
+
stdio: 'inherit',
|
|
35
|
+
env: process.env,
|
|
36
|
+
});
|
|
37
|
+
process.exitCode = result.status ?? 1;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
main();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Assimilate an external methodology, harness, or specification into babysitter process definitions with skills and agents.
|
|
3
|
+
argument-hint: Target to assimilate (e.g. repo URL, harness name, or spec path)
|
|
4
|
+
allowed-tools: Read, Grep, Write, Task, Bash, Edit, Grep, Glob, WebFetch, WebSearch, Search, AskUserQuestion, TodoWrite, TodoRead, Skill, BashOutput, KillShell, MultiEdit, LS
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
|
|
8
|
+
|
|
9
|
+
Use the assimilation domain processes from the active process library to convert external sources into well-defined babysitter process definitions with accompanying skills/ and agents/ directories.
|
|
10
|
+
|
|
11
|
+
If the workspace does not already have an active process-library binding, initialize it first through the shared global SDK binding:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
babysitter process-library:active --json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Run the process after formalizing it.
|
|
18
|
+
|
|
19
|
+
Available assimilation workflows:
|
|
20
|
+
- **methodology-assimilation** (`specializations/meta/assimilation/workflows/methodology-assimilation`) - Learns an external methodology from its repo and converts procedural instructions, commands, and manual flows into babysitter processes with refactored skills and agents. Supports output as methodology or specialization.
|
|
21
|
+
- **harness integration** (`specializations/meta/assimilation/harness/*`) - Integrates babysitter SDK with a specific AI coding harness (generic, codex, opencode, gemini-cli, openclaw, antigravity).
|
|
22
|
+
|
|
23
|
+
During the interview phase, determine which assimilation workflow to use based on the user's target:
|
|
24
|
+
- If the target is a **repo URL or methodology name** then use the methodology-assimilation workflow.
|
|
25
|
+
- If the target is a **harness name** (e.g. codex, opencode, antigravity) then use the matching harness process.
|
|
26
|
+
- If the target is a **specification or other source** then adapt the methodology-assimilation workflow for the spec format.
|
|
27
|
+
- If unclear, ask the user to clarify the assimilation target and type.
|
|
28
|
+
|
|
29
|
+
## After Assimilation: Contribute Back
|
|
30
|
+
|
|
31
|
+
After successfully assimilating a methodology or harness integration, prompt the user to share it with the community. The assimilated process definitions, skills, and agents could benefit other babysitter users:
|
|
32
|
+
|
|
33
|
+
- **Completed a methodology assimilation**: `/babysitter:contrib library contribution: assimilated [methodology-name] into babysitter process definitions`
|
|
34
|
+
- **Completed a harness integration**: `/babysitter:contrib library contribution: [harness-name] harness integration`
|
|
35
|
+
- **Hit issues during assimilation** (e.g. unsupported patterns, missing SDK features): `/babysitter:contrib bug report: assimilation of [target] failed because [description]` or `/babysitter:contrib feature request: [what the SDK needs to support]`
|
|
36
|
+
|
|
37
|
+
Even just reporting that an assimilation didn't work well helps improve babysitter for everyone.
|
package/commands/call.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Orchestrate a babysitter run. use this command to start babysitting a complex workflow.
|
|
3
|
+
argument-hint: Specific instructions for the run.
|
|
4
|
+
allowed-tools: Read, Grep, Write, Task, Bash, Edit, Grep, Glob, WebFetch, WebSearch, Search, AskUserQuestion, TodoWrite, TodoRead, Skill, BashOutput, KillShell, MultiEdit, LS
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Clean up .a5c/runs and .a5c/processes directories. Aggregates insights from completed/failed runs into docs/run-history-insights.md, then removes old run data and orphaned process files.
|
|
3
|
+
argument-hint: "[--dry-run] [--keep-days N] Optional flags. --dry-run shows what would be removed without deleting. --keep-days N keeps runs newer than N days (default 7)."
|
|
4
|
+
allowed-tools: Read, Grep, Write, Task, Bash, Edit, Grep, Glob, WebFetch, WebSearch, Search, AskUserQuestion, TodoWrite, TodoRead, Skill, BashOutput, KillShell, MultiEdit, LS
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
|
|
8
|
+
|
|
9
|
+
Create and run a cleanup process using the process at `skills\babysit\process\cradle\cleanup-runs.js/processes/cleanup-runs.js`.
|
|
10
|
+
|
|
11
|
+
Implementation notes (for the process):
|
|
12
|
+
- Parse arguments for `--dry-run` flag (if present, set dryRun: true in inputs) and `--keep-days N` (default: 7)
|
|
13
|
+
- The process scans .a5c/runs/ for completed/failed runs, aggregates insights, writes summaries, then removes old data
|
|
14
|
+
- Always show the user what will be removed before removing (in interactive mode via breakpoints)
|
|
15
|
+
- In non-interactive mode (yolo), proceed with cleanup using defaults
|
|
16
|
+
- The insights file goes to docs/run-history-insights.md
|
|
17
|
+
- Only remove terminal runs (completed/failed) older than the keep-days threshold
|
|
18
|
+
- Never remove active/in-progress runs
|
|
19
|
+
- Remove orphaned process files not referenced by remaining runs
|
|
20
|
+
- After cleanup, show remaining run count and disk usage
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Submit feedback or contribute to babysitter project
|
|
3
|
+
argument-hint: Specific instructions for the run.
|
|
4
|
+
allowed-tools: Read, Grep, Write, Task, Bash, Edit, Grep, Glob, WebFetch, WebSearch, Search, AskUserQuestion, TodoWrite, TodoRead, Skill, BashOutput, KillShell, MultiEdit, LS
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
|
|
8
|
+
|
|
9
|
+
## Process Routing
|
|
10
|
+
|
|
11
|
+
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:
|
|
12
|
+
|
|
13
|
+
### Issue-based (opens a GitHub issue in a5c-ai/babysitter)
|
|
14
|
+
* **Bug report** → `cradle/bug-report.js#process` — Report a bug in the SDK, CLI, process library, etc.
|
|
15
|
+
* **Feature request** → `cradle/feature-request.js#process` — Request a new feature or enhancement
|
|
16
|
+
* **Documentation question** → `cradle/documentation-question.js#process` — Ask about undocumented behavior or missing docs
|
|
17
|
+
|
|
18
|
+
### PR-based (forks repo, creates branch, submits PR to a5c-ai/babysitter)
|
|
19
|
+
* **Bugfix** → `cradle/bugfix.js#process` — User already has the fix for a bug
|
|
20
|
+
* **Feature implementation** → `cradle/feature-implementation-contribute.js#process` — User already has a feature implementation
|
|
21
|
+
* **Harness integration** → `cradle/feature-harness-integration-contribute.js#process` — User has a harness (CI/CD, IDE, editor) integration
|
|
22
|
+
* **Library contribution** → `cradle/library-contribution.js#process` — New or improved process/skill/subagent for the library
|
|
23
|
+
* **Documentation answer** → `cradle/documentation-contribute-answer.js#process` — User has an answer for an unanswered docs question
|
|
24
|
+
|
|
25
|
+
### Router (when arguments are empty or general)
|
|
26
|
+
* **Contribute** → `cradle/contribute.js#process` — Explains contribution types and routes to the specific process
|
|
27
|
+
|
|
28
|
+
## Contribution Rules
|
|
29
|
+
|
|
30
|
+
* PR-based contributions: fork the babysitter repo (a5c-ai/babysitter) for the user, ask to star if not already starred, perform changes, submit PR
|
|
31
|
+
* Issue-based contributions: gather details, search for duplicates, review, then open an issue in a5c-ai/babysitter
|
|
32
|
+
* Add breakpoints (permissions) before ALL gh actions (fork, star, submit PR/issue) to allow user review and cancellation
|
|
33
|
+
* If arguments are empty: use the `contribute.js` router process to show options and route accordingly
|