@a5c-ai/babysitter-github 0.1.1-staging.0825aadb
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/.github/plugin.json +25 -0
- package/AGENTS.md +41 -0
- package/README.md +545 -0
- package/bin/cli.js +104 -0
- package/bin/install-shared.js +450 -0
- package/bin/install.js +81 -0
- package/bin/uninstall.js +76 -0
- 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/hooks/session-end.ps1 +68 -0
- package/hooks/session-end.sh +65 -0
- package/hooks/session-start.ps1 +110 -0
- package/hooks/session-start.sh +100 -0
- package/hooks/user-prompt-submitted.ps1 +51 -0
- package/hooks/user-prompt-submitted.sh +41 -0
- package/hooks.json +29 -0
- package/package.json +50 -0
- package/plugin.json +25 -0
- package/scripts/sync-command-surfaces.js +62 -0
- package/scripts/team-install.js +86 -0
- package/skills/assimilate/SKILL.md +38 -0
- package/skills/babysit/SKILL.md +77 -0
- package/skills/call/SKILL.md +8 -0
- package/skills/doctor/SKILL.md +427 -0
- package/skills/help/SKILL.md +245 -0
- package/skills/observe/SKILL.md +13 -0
- package/skills/plan/SKILL.md +8 -0
- package/skills/resume/SKILL.md +9 -0
- package/skills/retrospect/SKILL.md +56 -0
- package/skills/user-install/SKILL.md +18 -0
- package/versions.json +3 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const {
|
|
7
|
+
copyPluginBundle,
|
|
8
|
+
ensureGlobalProcessLibrary,
|
|
9
|
+
ensureMarketplaceEntry,
|
|
10
|
+
installCopilotSurface,
|
|
11
|
+
registerCopilotPlugin,
|
|
12
|
+
warnWindowsHooks,
|
|
13
|
+
writeJson,
|
|
14
|
+
} = require('../bin/install-shared');
|
|
15
|
+
|
|
16
|
+
function parseArgs(argv) {
|
|
17
|
+
const args = {
|
|
18
|
+
workspace: process.cwd(),
|
|
19
|
+
dryRun: false,
|
|
20
|
+
};
|
|
21
|
+
for (let i = 2; i < argv.length; i += 1) {
|
|
22
|
+
if (argv[i] === '--workspace' && argv[i + 1]) {
|
|
23
|
+
args.workspace = path.resolve(argv[++i]);
|
|
24
|
+
} else if (argv[i] === '--dry-run') {
|
|
25
|
+
args.dryRun = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return args;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function main() {
|
|
32
|
+
const args = parseArgs(process.argv);
|
|
33
|
+
const packageRoot = path.resolve(process.env.BABYSITTER_PACKAGE_ROOT || path.join(__dirname, '..'));
|
|
34
|
+
const workspaceRoot = args.workspace;
|
|
35
|
+
const workspacePluginRoot = path.join(workspaceRoot, 'plugins', 'babysitter');
|
|
36
|
+
const workspaceMarketplacePath = path.join(workspaceRoot, '.agents', 'plugins', 'marketplace.json');
|
|
37
|
+
const workspaceCopilotDir = path.join(workspaceRoot, '.copilot');
|
|
38
|
+
|
|
39
|
+
const installInfo = {
|
|
40
|
+
installedAt: new Date().toISOString(),
|
|
41
|
+
packageRoot,
|
|
42
|
+
workspaceRoot,
|
|
43
|
+
pluginRoot: workspacePluginRoot,
|
|
44
|
+
marketplacePath: workspaceMarketplacePath,
|
|
45
|
+
copilotDir: workspaceCopilotDir,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (args.dryRun) {
|
|
49
|
+
console.log(JSON.stringify({
|
|
50
|
+
ok: true,
|
|
51
|
+
dryRun: true,
|
|
52
|
+
installInfo,
|
|
53
|
+
}, null, 2));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
copyPluginBundle(packageRoot, workspacePluginRoot);
|
|
58
|
+
ensureMarketplaceEntry(workspaceMarketplacePath, workspacePluginRoot);
|
|
59
|
+
registerCopilotPlugin(workspacePluginRoot);
|
|
60
|
+
installCopilotSurface(packageRoot, workspaceCopilotDir);
|
|
61
|
+
|
|
62
|
+
const active = ensureGlobalProcessLibrary(packageRoot);
|
|
63
|
+
installInfo.processLibraryStateFile = active.stateFile;
|
|
64
|
+
installInfo.processLibraryRoot = active.binding?.dir || '';
|
|
65
|
+
installInfo.processLibraryCloneDir = active.defaultSpec?.cloneDir || '';
|
|
66
|
+
|
|
67
|
+
const outDir = path.join(workspaceRoot, '.a5c', 'team');
|
|
68
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
69
|
+
writeJson(path.join(outDir, 'install.json'), installInfo);
|
|
70
|
+
|
|
71
|
+
const profilePath = path.join(outDir, 'profile.json');
|
|
72
|
+
if (!fs.existsSync(profilePath)) {
|
|
73
|
+
writeJson(profilePath, {
|
|
74
|
+
teamName: 'default',
|
|
75
|
+
pluginRoot: workspacePluginRoot,
|
|
76
|
+
marketplacePath: workspaceMarketplacePath,
|
|
77
|
+
copilotDir: workspaceCopilotDir,
|
|
78
|
+
processLibraryLookupCommand: 'babysitter process-library:active --json',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
warnWindowsHooks();
|
|
83
|
+
console.log('[team-install] complete');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
main();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: assimilate
|
|
3
|
+
description: Assimilate an external methodology, harness, or specification into babysitter process definitions with skills and agents.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# assimilate
|
|
7
|
+
|
|
8
|
+
Invoke the babysitter:babysit skill (using the Skill tool) and follow its instructions (SKILL.md).
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
If the workspace does not already have an active process-library binding, initialize it first through the shared global SDK binding:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
babysitter process-library:active --json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Run the process after formalizing it.
|
|
19
|
+
|
|
20
|
+
Available assimilation workflows:
|
|
21
|
+
- **methodology-assimilation** (`specializations/domains/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.
|
|
22
|
+
- **harness integration** (`specializations/domains/assimilation/harness/*`) - Integrates babysitter SDK with a specific AI coding harness (generic, codex, opencode, gemini-cli, openclaw, antigravity).
|
|
23
|
+
|
|
24
|
+
During the interview phase, determine which assimilation workflow to use based on the user's target:
|
|
25
|
+
- If the target is a **repo URL or methodology name** then use the methodology-assimilation workflow.
|
|
26
|
+
- If the target is a **harness name** (e.g. codex, opencode, antigravity) then use the matching harness process.
|
|
27
|
+
- If the target is a **specification or other source** then adapt the methodology-assimilation workflow for the spec format.
|
|
28
|
+
- If unclear, ask the user to clarify the assimilation target and type.
|
|
29
|
+
|
|
30
|
+
## After Assimilation: Contribute Back
|
|
31
|
+
|
|
32
|
+
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:
|
|
33
|
+
|
|
34
|
+
- **Completed a methodology assimilation**: `/babysitter:contrib library contribution: assimilated [methodology-name] into babysitter process definitions`
|
|
35
|
+
- **Completed a harness integration**: `/babysitter:contrib library contribution: [harness-name] harness integration`
|
|
36
|
+
- **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]`
|
|
37
|
+
|
|
38
|
+
Even just reporting that an assimilation didn't work well helps improve babysitter for everyone.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: babysit
|
|
3
|
+
description: >-
|
|
4
|
+
Orchestrate via @babysitter. Use this skill when asked to babysit a run,
|
|
5
|
+
orchestrate a process or whenever it is called explicitly. (babysit,
|
|
6
|
+
babysitter, orchestrate, orchestrate a run, workflow, etc.)
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# babysit
|
|
10
|
+
|
|
11
|
+
Orchestrate `.a5c/runs/<runId>/` through iterative execution.
|
|
12
|
+
|
|
13
|
+
## Dependencies
|
|
14
|
+
|
|
15
|
+
### Babysitter SDK and CLI
|
|
16
|
+
|
|
17
|
+
Read the SDK version from `versions.json` to ensure version compatibility:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
SDK_VERSION=$(node -e "try{console.log(JSON.parse(require('fs').readFileSync('${PLUGIN_ROOT}/versions.json','utf8')).sdkVersion||'latest')}catch{console.log('latest')}")
|
|
21
|
+
sudo npm i -g @a5c-ai/babysitter-sdk@$SDK_VERSION
|
|
22
|
+
# sudo is depending on the env and system
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
then use the CLI alias: CLI="babysitter"
|
|
26
|
+
|
|
27
|
+
**Alternatively, use the CLI alias:** `CLI="npx -y @a5c-ai/babysitter-sdk@$SDK_VERSION"`
|
|
28
|
+
|
|
29
|
+
### jq
|
|
30
|
+
|
|
31
|
+
make sure you have jq installed and available in the path. if not, install it.
|
|
32
|
+
|
|
33
|
+
## Instructions
|
|
34
|
+
|
|
35
|
+
Run the following command to get full orchestration instructions:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
babysitter instructions:babysit-skill --harness github-copilot --json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Follow the instructions returned by the command above to orchestrate the run.
|
|
42
|
+
|
|
43
|
+
## GitHub Copilot CLI -- In-Turn Loop Model
|
|
44
|
+
|
|
45
|
+
**IMPORTANT**: Unlike Claude Code, GitHub Copilot CLI does NOT have a Stop hook
|
|
46
|
+
that can drive the orchestration loop between turns. The `sessionEnd` hook output
|
|
47
|
+
is ignored and cannot block or restart the session.
|
|
48
|
+
|
|
49
|
+
Therefore, you MUST use **in-turn iteration**: run the full orchestration loop
|
|
50
|
+
within a single session turn. The pattern is:
|
|
51
|
+
|
|
52
|
+
1. `babysitter run:iterate --json` -- get pending actions
|
|
53
|
+
2. For each pending action: execute it (run tasks, post results via `task:post`)
|
|
54
|
+
3. `babysitter run:iterate --json` -- check for more pending actions
|
|
55
|
+
4. Repeat steps 2-3 until run completes or reaches a breakpoint requiring user input
|
|
56
|
+
5. If a breakpoint requires user input, ask the user and post the response, then continue iterating
|
|
57
|
+
|
|
58
|
+
All iteration happens within the same turn -- do NOT rely on hooks to re-enter
|
|
59
|
+
the orchestration loop. The agent drives the loop directly by calling
|
|
60
|
+
`run:iterate` repeatedly until completion.
|
|
61
|
+
|
|
62
|
+
### Loop Example
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Initial iterate
|
|
66
|
+
RESULT=$(babysitter run:iterate --run-id "$RUN_ID" --json)
|
|
67
|
+
STATUS=$(echo "$RESULT" | jq -r '.status')
|
|
68
|
+
|
|
69
|
+
while [ "$STATUS" != "completed" ] && [ "$STATUS" != "failed" ]; do
|
|
70
|
+
# Process pending actions from RESULT
|
|
71
|
+
# ... execute tasks, post results ...
|
|
72
|
+
|
|
73
|
+
# Iterate again
|
|
74
|
+
RESULT=$(babysitter run:iterate --run-id "$RUN_ID" --json)
|
|
75
|
+
STATUS=$(echo "$RESULT" | jq -r '.status')
|
|
76
|
+
done
|
|
77
|
+
```
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: doctor
|
|
3
|
+
description: Diagnose babysitter run health - journal integrity, state cache, effects, locks, sessions, logs, and disk usage
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# doctor
|
|
7
|
+
|
|
8
|
+
You are a diagnostic agent for the babysitter runtime. Your job is to perform a comprehensive health check across 10 areas and produce a structured diagnostic report. Follow each section methodically. Track results as you go and produce the final summary at the end.
|
|
9
|
+
|
|
10
|
+
Initialize a results tracker with these 10 checks, all starting as PENDING:
|
|
11
|
+
1. Run Discovery
|
|
12
|
+
2. Journal Integrity
|
|
13
|
+
3. State Cache Consistency
|
|
14
|
+
4. Effect Status
|
|
15
|
+
5. Lock Status
|
|
16
|
+
6. Session State
|
|
17
|
+
7. Log Analysis
|
|
18
|
+
8. Disk Usage
|
|
19
|
+
9. Process Validation
|
|
20
|
+
10. Hook Execution Health
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1. Run Discovery
|
|
25
|
+
|
|
26
|
+
**Goal:** Identify the target run and display its metadata.
|
|
27
|
+
|
|
28
|
+
- List all runs by running: `ls -lt .a5c/runs/`
|
|
29
|
+
- If the user provided a run ID argument, use that as the run ID. Otherwise, use the most recent run directory (the first entry from the listing).
|
|
30
|
+
- Store the resolved run ID and construct the run directory path: `.a5c/runs/<runId>`
|
|
31
|
+
- Verify the run directory exists. If it does not exist, report FAIL for this check and stop the entire diagnostic (no run to diagnose).
|
|
32
|
+
- Show run metadata by running: `npx babysitter run:status .a5c/runs/<runId> --json`
|
|
33
|
+
- Parse and display: runId, processId, entrypoint/importPath, createdAt, current state.
|
|
34
|
+
- Mark this check as PASS.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 2. Journal Integrity
|
|
39
|
+
|
|
40
|
+
**Goal:** Verify the append-only event journal is well-formed and uncorrupted.
|
|
41
|
+
|
|
42
|
+
- List all journal events by running: `npx babysitter run:events .a5c/runs/<runId> --json`
|
|
43
|
+
- List all files in `.a5c/runs/<runId>/journal/` sorted by name.
|
|
44
|
+
- If the journal directory is empty or missing, mark as FAIL and note "No journal entries found."
|
|
45
|
+
|
|
46
|
+
For each journal file (named `<seq>.<ulid>.json`):
|
|
47
|
+
|
|
48
|
+
**Sequential numbering check:**
|
|
49
|
+
- Extract the sequence number prefix from each filename (e.g., `000001` from `000001.01JAXYZ.json`).
|
|
50
|
+
- Verify sequence numbers are contiguous starting from 000001 with no gaps.
|
|
51
|
+
- If gaps found, mark as WARN and list the missing sequence numbers.
|
|
52
|
+
|
|
53
|
+
**Checksum verification:**
|
|
54
|
+
|
|
55
|
+
The SDK computes checksums as follows: it first builds the event payload **without** the `checksum` field (`{ type, recordedAt, data }`), serializes it with `JSON.stringify(payload, null, 2) + "\n"` (pretty-printed with a trailing newline), then computes SHA256 of that string. To verify:
|
|
56
|
+
|
|
57
|
+
- Read each journal file as JSON.
|
|
58
|
+
- Extract and remove the `checksum` field from the parsed object.
|
|
59
|
+
- Re-serialize the remaining object with `JSON.stringify(remaining, null, 2) + "\n"` — **must** use 2-space indentation and a trailing newline to match the SDK.
|
|
60
|
+
- Compute SHA256 (hex) of that exact string.
|
|
61
|
+
- Compare computed checksum with the stored checksum.
|
|
62
|
+
- If any mismatch, mark as FAIL and list the corrupt files.
|
|
63
|
+
|
|
64
|
+
Example bash one-liner for a single file:
|
|
65
|
+
```bash
|
|
66
|
+
node -e "const fs=require('fs'); const f=process.argv[1]; const obj=JSON.parse(fs.readFileSync(f,'utf8')); const stored=obj.checksum; delete obj.checksum; const expected=require('crypto').createHash('sha256').update(JSON.stringify(obj,null,2)+'\n').digest('hex'); console.log(stored===expected?'OK':'MISMATCH',f)" <file>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Timestamp monotonicity check:**
|
|
70
|
+
- Extract `recordedAt` from each event.
|
|
71
|
+
- Verify each timestamp is >= the previous one.
|
|
72
|
+
- If any timestamp goes backward, mark as WARN and list the offending entries.
|
|
73
|
+
|
|
74
|
+
**Event type summary:**
|
|
75
|
+
- Count events by type: RUN_CREATED, EFFECT_REQUESTED, EFFECT_RESOLVED, STOP_HOOK_INVOKED, RUN_COMPLETED, RUN_FAILED, and any other types encountered.
|
|
76
|
+
- Display the counts in a table.
|
|
77
|
+
|
|
78
|
+
**Orphan detection:**
|
|
79
|
+
- Flag any files in the journal directory that do not match the expected `<seq>.<ulid>.json` naming pattern.
|
|
80
|
+
|
|
81
|
+
If all sub-checks pass, mark as PASS. If any sub-check is WARN, mark as WARN. If any sub-check is FAIL, mark as FAIL.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 3. State Cache Consistency
|
|
86
|
+
|
|
87
|
+
**Goal:** Verify the derived state cache matches the current journal.
|
|
88
|
+
|
|
89
|
+
- Check if `.a5c/runs/<runId>/state/state.json` exists.
|
|
90
|
+
- If it does not exist, mark as WARN and recommend: `npx babysitter run:rebuild-state .a5c/runs/<runId>`
|
|
91
|
+
|
|
92
|
+
If it exists:
|
|
93
|
+
- Read `state.json` and extract the `journalHead` field (contains `seq`, `ulid`, and `checksum`).
|
|
94
|
+
- Determine the actual last journal entry by reading the last file in `.a5c/runs/<runId>/journal/` (highest sequence number).
|
|
95
|
+
- Extract the sequence number and ULID from the last journal filename, and the checksum from its content.
|
|
96
|
+
- Compare:
|
|
97
|
+
- `journalHead.seq` should match the last journal file's sequence number.
|
|
98
|
+
- `journalHead.ulid` should match the last journal file's ULID.
|
|
99
|
+
- `journalHead.checksum` should match the last journal file's checksum.
|
|
100
|
+
- If all match, mark as PASS.
|
|
101
|
+
- If any mismatch, mark as WARN and recommend: `npx babysitter run:rebuild-state .a5c/runs/<runId>`
|
|
102
|
+
- Also verify `schemaVersion` field is present and report its value.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 4. Effect Status
|
|
107
|
+
|
|
108
|
+
**Goal:** Identify stuck, errored, or pending effects.
|
|
109
|
+
|
|
110
|
+
- Run: `npx babysitter task:list .a5c/runs/<runId> --json`
|
|
111
|
+
- Run: `npx babysitter task:list .a5c/runs/<runId> --pending --json`
|
|
112
|
+
- Parse the JSON output from both commands.
|
|
113
|
+
|
|
114
|
+
**All effects summary:**
|
|
115
|
+
- Count total effects, resolved effects, and pending effects.
|
|
116
|
+
- Group and count effects by `kind` (node, breakpoint, orchestrator_task, sleep, etc.).
|
|
117
|
+
|
|
118
|
+
**Stuck effect detection:**
|
|
119
|
+
- For each pending effect, check its `requestedAt` timestamp.
|
|
120
|
+
- If any pending effect was requested more than 30 minutes ago, flag it as STUCK.
|
|
121
|
+
- List stuck effects with their effectId, kind, taskId, and age.
|
|
122
|
+
|
|
123
|
+
**Error detection:**
|
|
124
|
+
- Identify any effects with error status in their results.
|
|
125
|
+
- List errored effects with their effectId and error message.
|
|
126
|
+
|
|
127
|
+
**Pending summary:**
|
|
128
|
+
- Summarize pending effects grouped by kind with count per kind.
|
|
129
|
+
|
|
130
|
+
Mark as PASS if no stuck or errored effects. Mark as WARN if there are pending effects older than 30 minutes. Mark as FAIL if there are errored effects.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 5. Lock Status
|
|
135
|
+
|
|
136
|
+
**Goal:** Detect stale or orphaned run locks.
|
|
137
|
+
|
|
138
|
+
- Check if `.a5c/runs/<runId>/run.lock` exists.
|
|
139
|
+
- If it does not exist, mark as PASS ("No lock held -- run is not actively being iterated").
|
|
140
|
+
|
|
141
|
+
If it exists:
|
|
142
|
+
- Read the lock file (JSON with `pid`, `owner`, `acquiredAt`).
|
|
143
|
+
- Display the lock info: PID, owner, acquired time, and age of the lock.
|
|
144
|
+
- Check if the PID is still alive by running: `kill -0 <pid> 2>/dev/null; echo $?` (exit code 0 means alive, non-zero means dead). On Windows/MINGW, use `tasklist //FI "PID eq <pid>" 2>/dev/null` or equivalent.
|
|
145
|
+
- If the process is alive, mark as PASS ("Lock held by active process").
|
|
146
|
+
- If the process is dead, mark as FAIL ("Stale lock detected -- process <pid> is no longer running").
|
|
147
|
+
- Recommend: `rm .a5c/runs/<runId>/run.lock`
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 6. Session State
|
|
152
|
+
|
|
153
|
+
**Goal:** Inspect babysitter session files for health and detect runaway loops.
|
|
154
|
+
|
|
155
|
+
- Search for session state files using Glob:
|
|
156
|
+
- `plugins/babysitter/skills/babysit/state/*.md`
|
|
157
|
+
- `.a5c/state/*.md`
|
|
158
|
+
- `.a5c/state/*.json`
|
|
159
|
+
- For each session state file found:
|
|
160
|
+
- Read the file and extract available information: iteration count, associated runId, timestamps, session status.
|
|
161
|
+
- Display: filename, iteration count, runId (if present), last activity time.
|
|
162
|
+
|
|
163
|
+
**Runaway loop detection:**
|
|
164
|
+
- If any session file contains iteration timing data, compute the average time between iterations.
|
|
165
|
+
- If the average iteration time is less than 3 seconds, flag as WARN ("Possible runaway loop detected -- average iteration time is under 3 seconds").
|
|
166
|
+
|
|
167
|
+
**Session classification:**
|
|
168
|
+
- Active: session has recent activity (within last 30 minutes).
|
|
169
|
+
- Stale: session has no activity for more than 30 minutes.
|
|
170
|
+
- Display counts of active vs stale sessions.
|
|
171
|
+
|
|
172
|
+
Mark as PASS if no issues. Mark as WARN if runaway loops or stale sessions detected.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 7. Log Analysis
|
|
177
|
+
|
|
178
|
+
**Goal:** Analyze babysitter log files for errors, warnings, and stop hook decisions.
|
|
179
|
+
|
|
180
|
+
Read the last 50 lines of each of these log files (if they exist):
|
|
181
|
+
- `$CLAUDE_PLUGIN_ROOT/.a5c/logs/hooks.log`
|
|
182
|
+
- `$CLAUDE_PLUGIN_ROOT/.a5c/logs/babysitter-stop-hook.log`
|
|
183
|
+
- `$CLAUDE_PLUGIN_ROOT/.a5c/logs/babysitter-stop-hook-stderr.log`
|
|
184
|
+
- `$CLAUDE_PLUGIN_ROOT/.a5c/logs/babysitter-session-start-hook.log`
|
|
185
|
+
- `$CLAUDE_PLUGIN_ROOT/.a5c/logs/babysitter-session-start-hook-stderr.log`
|
|
186
|
+
- `$CLAUDE_PLUGIN_ROOT/.a5c/logs/babysitter.log`
|
|
187
|
+
- `$HOME/.a5c/logs/` and relevant logs and run/session specific logs there
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
For each log file:
|
|
191
|
+
- If the file does not exist, note it as "Not found (OK if hooks have not run yet)."
|
|
192
|
+
- If the file exists, analyze its content.
|
|
193
|
+
|
|
194
|
+
**Stop hook analysis (babysitter-stop-hook.log):**
|
|
195
|
+
- Count lines containing "approve" vs "block" decisions (case-insensitive).
|
|
196
|
+
- Display the approve/block ratio.
|
|
197
|
+
- Show the last 20 stop hook decision entries (lines containing "approve" or "block").
|
|
198
|
+
- Count and display CLI exit codes from lines containing "CLI exit code=".
|
|
199
|
+
|
|
200
|
+
**Stderr analysis (babysitter-stop-hook-stderr.log, babysitter-session-start-hook-stderr.log):**
|
|
201
|
+
- If stderr logs contain content, display the last 20 lines from each.
|
|
202
|
+
- Look for common failure patterns: "command not found", "MODULE_NOT_FOUND", "ENOENT", "EACCES", "permission denied", "npm ERR", "Cannot find module".
|
|
203
|
+
- Flag any stderr content as a potential issue.
|
|
204
|
+
|
|
205
|
+
**Error/Warning detection (all logs):**
|
|
206
|
+
- Count and list lines containing "ERROR" or "WARN" (case-insensitive).
|
|
207
|
+
- Display the last 10 error/warning lines from each log.
|
|
208
|
+
|
|
209
|
+
Mark as PASS if no ERROR lines found and stderr logs are empty. Mark as WARN if WARN lines found or stderr has content but no ERROR. Mark as FAIL if ERROR lines found.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## 8. Disk Usage
|
|
214
|
+
|
|
215
|
+
**Goal:** Report disk consumption and identify oversized files.
|
|
216
|
+
|
|
217
|
+
- Run `du -sh .a5c/runs/<runId>` for the total run directory size.
|
|
218
|
+
- Run `du -sh` on each subdirectory:
|
|
219
|
+
- `.a5c/runs/<runId>/journal/`
|
|
220
|
+
- `.a5c/runs/<runId>/tasks/`
|
|
221
|
+
- `.a5c/runs/<runId>/blobs/`
|
|
222
|
+
- `.a5c/runs/<runId>/state/`
|
|
223
|
+
- `.a5c/runs/<runId>/process/` (if it exists)
|
|
224
|
+
|
|
225
|
+
- Display results in a table: directory, size.
|
|
226
|
+
|
|
227
|
+
**Large file detection:**
|
|
228
|
+
- Find individual files larger than 10MB within the run directory: `find .a5c/runs/<runId> -type f -size +10M -exec ls -lh {} \;`
|
|
229
|
+
- If any found, list them with their paths and sizes.
|
|
230
|
+
|
|
231
|
+
- Report the total run directory size prominently.
|
|
232
|
+
|
|
233
|
+
Mark as PASS if total size < 500MB and no files > 10MB. Mark as WARN if total size > 500MB or any files > 10MB. Mark as FAIL if total size > 2GB.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 9. Process Validation
|
|
238
|
+
|
|
239
|
+
**Goal:** Verify the process entrypoint and SDK dependency are valid.
|
|
240
|
+
|
|
241
|
+
- Read `.a5c/runs/<runId>/run.json` and extract the `importPath` (or `entrypoint`) field.
|
|
242
|
+
- Check if the referenced process file exists on disk. Use Glob or file read to verify.
|
|
243
|
+
- If the file does not exist, mark as FAIL ("Process entrypoint not found on disk").
|
|
244
|
+
|
|
245
|
+
**SDK dependency check:**
|
|
246
|
+
- Read `.a5c/package.json` (if it exists) or the project root `package.json`.
|
|
247
|
+
- Check for `@a5c-ai/babysitter-sdk` in `dependencies` or `devDependencies`.
|
|
248
|
+
- Report the installed version.
|
|
249
|
+
- If the dependency is missing, mark as WARN.
|
|
250
|
+
- If present, verify it looks like a valid semver version and mark as PASS.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 10. Hook Execution Health
|
|
255
|
+
|
|
256
|
+
**Goal:** Verify that the stop hook and session-start hook are properly configured, can execute, and have been running. If the stop hook has NOT been running, diagnose why.
|
|
257
|
+
|
|
258
|
+
### 10a. Hook Registration
|
|
259
|
+
|
|
260
|
+
- 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.
|
|
261
|
+
- If found, read `hooks.json` and verify:
|
|
262
|
+
- A `Stop` hook entry exists with a command referencing `babysitter-stop-hook.sh`.
|
|
263
|
+
- A `SessionStart` hook entry exists with a command referencing `babysitter-session-start-hook.sh`.
|
|
264
|
+
- If `hooks.json` is not found, mark as FAIL ("Hook registration file not found — hooks are not registered with Claude Code").
|
|
265
|
+
|
|
266
|
+
### 10b. Hook Script Availability
|
|
267
|
+
|
|
268
|
+
- Locate the hook scripts relative to the plugin root:
|
|
269
|
+
- `hooks/babysitter-stop-hook.sh`
|
|
270
|
+
- `hooks/babysitter-session-start-hook.sh`
|
|
271
|
+
- For each script:
|
|
272
|
+
- Check if the file exists.
|
|
273
|
+
- Check if it is executable (`test -x <path>`).
|
|
274
|
+
- If any script is missing or not executable, mark as FAIL and list which scripts are missing/not-executable.
|
|
275
|
+
|
|
276
|
+
### 10c. CLI Availability (babysitter command)
|
|
277
|
+
|
|
278
|
+
The hooks delegate to the `babysitter` CLI. Check if it is available:
|
|
279
|
+
- Run: `command -v babysitter 2>/dev/null && babysitter --version 2>/dev/null`
|
|
280
|
+
- If the command is found, display its path and version. Mark sub-check as PASS.
|
|
281
|
+
- If not found, check the user-local prefix: `$HOME/.local/bin/babysitter --version 2>/dev/null`
|
|
282
|
+
- If neither is found, mark sub-check as FAIL ("babysitter CLI not found — hooks will fail with exit code 127. Install with: `npm i -g @a5c-ai/babysitter-sdk`").
|
|
283
|
+
|
|
284
|
+
### 10d. Stop Hook Execution Evidence
|
|
285
|
+
|
|
286
|
+
Check whether the stop hook has actually been invoked during this run's lifetime:
|
|
287
|
+
|
|
288
|
+
**From log files:**
|
|
289
|
+
- Read `$CLAUDE_PLUGIN_ROOT/.a5c/logs/babysitter-stop-hook.log` (if it exists).
|
|
290
|
+
- Count the number of "Hook script invoked" lines. This is the total invocation count.
|
|
291
|
+
- Count the number of "CLI exit code=" lines and extract exit codes.
|
|
292
|
+
- If the log file does not exist or has zero invocations, the stop hook has NOT been running.
|
|
293
|
+
|
|
294
|
+
**From journal events:**
|
|
295
|
+
- Search the run's journal events for `STOP_HOOK_INVOKED` type events (using the run:events output from section 2 if available).
|
|
296
|
+
- Count the number of STOP_HOOK_INVOKED events.
|
|
297
|
+
- If present, display the last 5 with their timestamps and decision data.
|
|
298
|
+
- If no STOP_HOOK_INVOKED events exist in the journal, note that the stop hook has not recorded any decisions for this run.
|
|
299
|
+
|
|
300
|
+
**From stderr:**
|
|
301
|
+
- Read `$CLAUDE_PLUGIN_ROOT/.a5c/logs/babysitter-stop-hook-stderr.log`.
|
|
302
|
+
- If it contains error output, display it and diagnose:
|
|
303
|
+
- "command not found" or exit code 127 → CLI not installed (see 10c)
|
|
304
|
+
- "MODULE_NOT_FOUND" or "Cannot find module" → SDK package corrupted or not built
|
|
305
|
+
- "ENOENT" → Missing file referenced by the hook
|
|
306
|
+
- "EACCES" or "permission denied" → Permission issue on hook script or CLI
|
|
307
|
+
- "npm ERR" → npm installation failure during hook execution
|
|
308
|
+
|
|
309
|
+
### 10e. Stop Hook Not Running — Root Cause Diagnosis
|
|
310
|
+
|
|
311
|
+
If the stop hook shows NO evidence of execution (no log entries, no journal events, zero invocations):
|
|
312
|
+
|
|
313
|
+
Perform these diagnostic steps in order and report the first failure found:
|
|
314
|
+
|
|
315
|
+
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."
|
|
316
|
+
|
|
317
|
+
2. **Plugin not enabled**: Check for Claude settings files:
|
|
318
|
+
- `~/.claude/settings.json` — look for `babysitter` in `enabledPlugins`.
|
|
319
|
+
- `~/.claude/plugins/installed_plugins.json` — look for `babysitter` in the plugins list.
|
|
320
|
+
- If not found in either, report: "Plugin not enabled in Claude Code settings."
|
|
321
|
+
|
|
322
|
+
3. **hooks.json not registered**: If `hooks.json` doesn't contain a `Stop` hook entry (checked in 10a), report: "Stop hook not registered in hooks.json."
|
|
323
|
+
|
|
324
|
+
4. **Hook script missing or not executable**: If the stop hook script doesn't exist or isn't executable (checked in 10b), report with the specific file path.
|
|
325
|
+
|
|
326
|
+
5. **CLI not available**: If `babysitter` CLI is not found (checked in 10c), report: "babysitter CLI not installed — hook script will fail silently."
|
|
327
|
+
|
|
328
|
+
6. **Hook running but failing silently**: If the log file exists but shows exit codes other than 0, or if stderr has content, report: "Stop hook is being invoked but failing — see stderr log for details."
|
|
329
|
+
|
|
330
|
+
7. **No active session**: If no session state files exist (from section 6), report: "No active babysitter session — the stop hook only activates when a session is bound to a run."
|
|
331
|
+
|
|
332
|
+
8. **All checks pass but hook still not running**: Report: "All prerequisites are met but the stop hook shows no evidence of execution. Possible causes: Claude Code may not be invoking plugin hooks (check Claude Code version), or the session may have ended before the hook could fire."
|
|
333
|
+
|
|
334
|
+
### 10f. Verdict
|
|
335
|
+
|
|
336
|
+
Mark as PASS if:
|
|
337
|
+
- Hook registration is correct (10a)
|
|
338
|
+
- Hook scripts exist and are executable (10b)
|
|
339
|
+
- CLI is available (10c)
|
|
340
|
+
- There is evidence of stop hook execution (10d) with exit code 0
|
|
341
|
+
|
|
342
|
+
Mark as WARN if:
|
|
343
|
+
- Hooks are registered and scripts exist, but there's no evidence of execution yet
|
|
344
|
+
- Stop hook ran but had non-zero exit codes
|
|
345
|
+
|
|
346
|
+
Mark as FAIL if:
|
|
347
|
+
- Hook registration is missing
|
|
348
|
+
- Hook scripts are missing or not executable
|
|
349
|
+
- CLI is not available
|
|
350
|
+
- Stop hook is failing (consistent non-zero exit codes or stderr errors)
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Final Report
|
|
355
|
+
|
|
356
|
+
After completing all 10 checks, produce the diagnostic report in this format:
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
============================================
|
|
360
|
+
BABYSITTER DIAGNOSTIC REPORT
|
|
361
|
+
Run: <runId>
|
|
362
|
+
Time: <current timestamp>
|
|
363
|
+
============================================
|
|
364
|
+
|
|
365
|
+
OVERALL HEALTH: <HEALTHY | WARNING | CRITICAL>
|
|
366
|
+
|
|
367
|
+
--------------------------------------------
|
|
368
|
+
CHECK RESULTS
|
|
369
|
+
--------------------------------------------
|
|
370
|
+
|
|
371
|
+
| # | Check | Status |
|
|
372
|
+
|----|--------------------------|--------|
|
|
373
|
+
| 1 | Run Discovery | <status> |
|
|
374
|
+
| 2 | Journal Integrity | <status> |
|
|
375
|
+
| 3 | State Cache Consistency | <status> |
|
|
376
|
+
| 4 | Effect Status | <status> |
|
|
377
|
+
| 5 | Lock Status | <status> |
|
|
378
|
+
| 6 | Session State | <status> |
|
|
379
|
+
| 7 | Log Analysis | <status> |
|
|
380
|
+
| 8 | Disk Usage | <status> |
|
|
381
|
+
| 9 | Process Validation | <status> |
|
|
382
|
+
| 10 | Hook Execution Health | <status> |
|
|
383
|
+
|
|
384
|
+
--------------------------------------------
|
|
385
|
+
ISSUES & RECOMMENDATIONS
|
|
386
|
+
--------------------------------------------
|
|
387
|
+
|
|
388
|
+
<For each WARN or FAIL check, list:>
|
|
389
|
+
- [WARN|FAIL] <Check name>: <description of issue>
|
|
390
|
+
Fix: <specific actionable command or instruction>
|
|
391
|
+
|
|
392
|
+
--------------------------------------------
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Overall health determination:**
|
|
396
|
+
- **HEALTHY**: All 10 checks are PASS.
|
|
397
|
+
- **WARNING**: At least one check is WARN but none are FAIL.
|
|
398
|
+
- **CRITICAL**: At least one check is FAIL.
|
|
399
|
+
|
|
400
|
+
Present the full detailed findings for each check BEFORE the summary table, so the user can see the evidence. End with the summary table and recommendations. Also, create a single HTML report file with all the findings that uses the arwes UI framework and open it for the user in the browser.
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Escalation: Claude /debug
|
|
405
|
+
|
|
406
|
+
If any check results in FAIL and the root cause is unclear after your own analysis -- especially for environment issues, hook execution failures, CLI availability problems, or permission errors that may relate to the Claude Code runtime itself -- invoke the built-in Claude `/debug` command to get additional diagnostic context from the Claude Code environment. This is particularly useful for:
|
|
407
|
+
- Hook scripts that should be running but show no evidence of execution (check 10)
|
|
408
|
+
- Permission or path resolution issues that don't match expected behavior
|
|
409
|
+
- Unexpected CLI behavior that might be a Claude Code environment issue rather than a babysitter issue
|
|
410
|
+
|
|
411
|
+
Call `/debug` with a summary of the failing check and what you've already ruled out, so it can focus on environment-level causes.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## After Diagnosis: Contribute Back
|
|
416
|
+
|
|
417
|
+
After diagnosing issues, prompt the user to report or fix what was found -- they don't need to fix the bug themselves, just reporting it is valuable. Suggest `/babysitter:contrib` based on the situation:
|
|
418
|
+
|
|
419
|
+
- **Found a bug but didn't fix it**: `/babysitter:contrib bug report: [what the doctor found, e.g. "state cache rebuild silently drops EFFECT_RESOLVED events when journal has duplicate invocation keys"]`
|
|
420
|
+
- **Found and fixed a bug**: `/babysitter:contrib bugfix: [description of the fix]`
|
|
421
|
+
- **Found confusing or missing docs that made diagnosis harder**: `/babysitter:contrib documentation question: [what was unclear or missing]`
|
|
422
|
+
- **Found an issue in a plugin**: `/babysitter:contrib bug report: [plugin-name] [description]`
|
|
423
|
+
- **Improved a process or skill during diagnosis**: `/babysitter:contrib library contribution: [description]`
|
|
424
|
+
|
|
425
|
+
Example prompt after diagnosis:
|
|
426
|
+
|
|
427
|
+
> "Diagnosis found a stale lock -- process 12847 crashed without cleanup. This is a known edge case in the orchestration loop. Even if you don't want to fix it yourself, reporting it helps: run `/babysitter:contrib bug report: orchestration loop doesn't release lock on unhandled rejection` to open an issue."
|