@a5c-ai/babysitter-cursor 0.1.1-staging.400de59e

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 (42) hide show
  1. package/.cursor-plugin/plugin.json +22 -0
  2. package/.cursorrules +55 -0
  3. package/README.md +488 -0
  4. package/bin/cli.js +104 -0
  5. package/bin/install-shared.js +394 -0
  6. package/bin/install.js +46 -0
  7. package/bin/uninstall.js +40 -0
  8. package/commands/assimilate.md +37 -0
  9. package/commands/call.md +7 -0
  10. package/commands/cleanup.md +20 -0
  11. package/commands/contrib.md +33 -0
  12. package/commands/doctor.md +423 -0
  13. package/commands/forever.md +7 -0
  14. package/commands/help.md +244 -0
  15. package/commands/observe.md +12 -0
  16. package/commands/plan.md +7 -0
  17. package/commands/plugins.md +255 -0
  18. package/commands/project-install.md +17 -0
  19. package/commands/resume.md +8 -0
  20. package/commands/retrospect.md +55 -0
  21. package/commands/user-install.md +17 -0
  22. package/commands/yolo.md +7 -0
  23. package/hooks/hooks-cursor.json +21 -0
  24. package/hooks/session-start.ps1 +115 -0
  25. package/hooks/session-start.sh +105 -0
  26. package/hooks/stop-hook.ps1 +72 -0
  27. package/hooks/stop-hook.sh +64 -0
  28. package/hooks.json +21 -0
  29. package/package.json +48 -0
  30. package/plugin.json +24 -0
  31. package/scripts/team-install.js +81 -0
  32. package/skills/assimilate/SKILL.md +17 -0
  33. package/skills/babysit/SKILL.md +81 -0
  34. package/skills/call/SKILL.md +17 -0
  35. package/skills/doctor/SKILL.md +16 -0
  36. package/skills/help/SKILL.md +15 -0
  37. package/skills/observe/SKILL.md +15 -0
  38. package/skills/plan/SKILL.md +16 -0
  39. package/skills/resume/SKILL.md +15 -0
  40. package/skills/retrospect/SKILL.md +55 -0
  41. package/skills/user-install/SKILL.md +15 -0
  42. package/versions.json +3 -0
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Launch the babysitter observer dashboard. Installs and runs the real-time observer UI that watches babysitter runs, displaying task progress, journal events, and orchestration state in your browser.
3
+ argument-hint: [--watch-dir <dir>]
4
+ allowed-tools: Read, Grep, Write, Task, Bash
5
+ ---
6
+
7
+ Run the babysitter observer dashboard:
8
+
9
+ 1. Determine the watch directory — this is usually the project's container directory (the parent of the project dir), or the current working directory if not specified.
10
+ 2. Launch the dashboard: `npx -y @a5c-ai/babysitter-observer-dashboard@latest --watch-dir <dir>`
11
+ 3. This is a blocking process — it will keep running until stopped.
12
+ 4. Open the browser at the URL printed by the dashboard.
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Plan a babysitter run. use this command to plan a complex workflow, without actually running it.
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). focus on creating the best process possible, but without creating and running the actual run.
@@ -0,0 +1,255 @@
1
+ ---
2
+ description: manage babysitter plugins. use this command to see the list of installed babysitter plugins, their status, and manage them (install, update, uninstall, list from marketplace, add marketplace, configure plugin, create new plugin, etc).
3
+ argument-hint: Specific instructions.
4
+ ---
5
+
6
+ This command installs and manages plugins for babysitter. A plugin is a version-managed package of contextual instructions (for install, uninstall, configure, and update/migrate between versions), not a conventional software plugin.
7
+
8
+ if the command is run without arguments, it lists all installed plugins with their name, version, marketplace, installation date, and last update date. as well as marketplaces added to the system. and instructions on how to install new plugins from marketplaces.
9
+ if there are no marketplaces added, add the default marketplace:
10
+ ```bash
11
+ babysitter plugin:add-marketplace --marketplace-url https://github.com/a5c-ai/babysitter --marketplace-path plugins/a5c/marketplace/marketplace.json --global --json
12
+ ```
13
+
14
+ Plugins can be installed at two scopes:
15
+ - **global** (`--global`): stored under `~/.a5c/`, available for all projects
16
+ - **project** (`--project`): stored under `<projectDir>/.a5c/`, project-specific
17
+
18
+ ## Marketplace Management
19
+
20
+ Marketplaces are git repositories containing a `marketplace.json` manifest and plugin package directories. The SDK clones them locally with `--depth 1`.
21
+
22
+ **Storage locations:**
23
+ - Global: `~/.a5c/marketplaces/<name>/`
24
+ - Project: `<projectDir>/.a5c/marketplaces/<name>/`
25
+
26
+ The marketplace name is derived from the git URL's last path segment (stripping `.git` suffix and trailing slashes).
27
+
28
+ ### Adding a marketplace
29
+
30
+ ```bash
31
+ babysitter plugin:add-marketplace --marketplace-url <url> [--marketplace-path <relative-path>] [--marketplace-branch <ref>] [--force] --global|--project [--json]
32
+ ```
33
+
34
+ Clones the marketplace repository to the local marketplaces directory. Use `--marketplace-path` to specify the relative path to `marketplace.json` within the repo (for monorepos or repos where the manifest is not at the root). Use `--marketplace-branch` to clone a specific branch, tag, or ref (defaults to the repo's default branch). Use `--force` to replace an existing marketplace clone (deletes and re-clones).
35
+
36
+ ### Updating a marketplace
37
+
38
+ ```bash
39
+ babysitter plugin:update-marketplace --marketplace-name <name> [--marketplace-branch <ref>] --global|--project [--json]
40
+ ```
41
+
42
+ Runs `git pull` on the local marketplace clone to fetch latest changes. Use `--marketplace-branch` to switch to a different branch before pulling (works even with shallow clones).
43
+
44
+ ### Listing plugins in a marketplace
45
+
46
+ ```bash
47
+ babysitter plugin:list-plugins --marketplace-name <name> --global|--project [--json]
48
+ ```
49
+
50
+ Reads the `marketplace.json` manifest and returns all available plugins sorted alphabetically by name. Each entry includes: name, description, latestVersion, versions array, packagePath, tags, and author.
51
+
52
+ ## Plugin Installation
53
+
54
+ **Note:** For `plugin:install`, `plugin:update`, `plugin:configure`, and `plugin:list-plugins`, the `--marketplace-name` flag is auto-detected when only one marketplace is cloned for the given scope. You can omit it if there's only one marketplace.
55
+
56
+ ### Flow
57
+
58
+ 1. Update the marketplace: `babysitter plugin:update-marketplace --marketplace-name <name> --global|--project`
59
+ 2. Check current state: `babysitter plugin:list-installed --global|--project` to see installed plugins and versions
60
+ 3. Install the plugin:
61
+
62
+ ```bash
63
+ babysitter plugin:install --plugin-name <name> [--marketplace-name <mp>] --global|--project [--json]
64
+ ```
65
+
66
+ This command resolves the plugin package path from the marketplace manifest, reads `install.md` from the plugin package directory, and returns the installation instructions. If an `install-process.js` file exists, the instructions may reference it as an automated install process.
67
+
68
+ 4. The agent performs the installation steps as defined in `install.md`
69
+ 5. The agent updates the registry:
70
+
71
+ ```bash
72
+ babysitter plugin:update-registry --plugin-name <name> --plugin-version <ver> --marketplace-name <mp> --global|--project [--json]
73
+ ```
74
+
75
+ ## Plugin Update (with migrations)
76
+
77
+ ```bash
78
+ babysitter plugin:update --plugin-name <name> --marketplace-name <mp> --global|--project [--json]
79
+ ```
80
+
81
+ This command:
82
+ 1. Reads the currently installed version from the registry
83
+ 2. Resolves the latest version from the marketplace manifest
84
+ 3. Looks in the plugin package's `migrations/` directory for migration files
85
+ 4. Uses BFS over the migration graph to find the shortest path from the installed version to the target version
86
+ 5. Returns the ordered migration instructions (content of each migration file in sequence)
87
+
88
+ **Migration filename format:** `<fromVersion>_to_<toVersion>.<ext>` where:
89
+ - Versions may contain alphanumerics, dots, dashes (e.g. `1.0.0`, `2.0.0-beta`)
90
+ - Extensions: `.md` for markdown instructions, `.js` for executable process files
91
+ - Examples: `1.0.0_to_1.1.0.md`, `2.0.0-beta_to_2.0.0.js`
92
+
93
+ After performing the migration steps, update the registry:
94
+
95
+ ```bash
96
+ babysitter plugin:update-registry --plugin-name <name> --plugin-version <new-ver> --marketplace-name <mp> --global|--project [--json]
97
+ ```
98
+
99
+ ## Plugin Uninstallation
100
+
101
+ ```bash
102
+ babysitter plugin:uninstall --plugin-name <name> --marketplace-name <mp> --global|--project [--json]
103
+ ```
104
+
105
+ Reads `uninstall.md` from the plugin package directory and returns the uninstall instructions. After performing the uninstall steps, remove from registry:
106
+
107
+ ```bash
108
+ babysitter plugin:remove-from-registry --plugin-name <name> --global|--project [--json]
109
+ ```
110
+
111
+ ## Plugin Configuration
112
+
113
+ ```bash
114
+ babysitter plugin:configure --plugin-name <name> --marketplace-name <mp> --global|--project [--json]
115
+ ```
116
+
117
+ Reads `configure.md` from the plugin package directory and returns configuration instructions.
118
+
119
+ ## Registry Management
120
+
121
+ The plugin registry (`plugin-registry.json`) tracks installed plugins with schema version `2026.01.plugin-registry-v1`. Writes use atomic file operations (temp + rename) for crash safety.
122
+
123
+ **Storage locations:**
124
+ - Global: `~/.a5c/plugin-registry.json`
125
+ - Project: `<projectDir>/.a5c/plugin-registry.json`
126
+
127
+ ### List installed plugins
128
+
129
+ ```bash
130
+ babysitter plugin:list-installed --global|--project [--json]
131
+ ```
132
+
133
+ Returns all installed plugins sorted alphabetically. In `--json` mode, returns an array of registry entries. In human mode, displays a formatted table with name, version, marketplace, and timestamps.
134
+
135
+ ### Remove from registry
136
+
137
+ ```bash
138
+ babysitter plugin:remove-from-registry --plugin-name <name> --global|--project [--json]
139
+ ```
140
+
141
+ Removes a plugin entry from the registry. Returns error if the plugin is not present.
142
+
143
+ ## Plugin Creation
144
+
145
+ To create a new plugin package from scratch, use the `meta/plugin-creation` babysitter process. This process guides you through requirements analysis, structure design, instruction authoring, optional process file generation, validation, and marketplace integration.
146
+
147
+ ### Using the plugin creation process
148
+
149
+ Orchestrate a babysitter run with the plugin creation process:
150
+
151
+ ```bash
152
+ # Create inputs file
153
+ cat > /tmp/plugin-inputs.json << 'EOF'
154
+ {
155
+ "pluginName": "my-plugin",
156
+ "description": "What the plugin does — be specific about install/configure/uninstall behavior",
157
+ "scope": "project",
158
+ "outputDir": "./plugins",
159
+ "components": {
160
+ "installProcess": false,
161
+ "configureProcess": false,
162
+ "uninstallProcess": false,
163
+ "migrations": false,
164
+ "processFiles": false
165
+ },
166
+ "marketplace": {
167
+ "name": "my-marketplace",
168
+ "author": "my-org",
169
+ "tags": ["category1", "category2"]
170
+ }
171
+ }
172
+ EOF
173
+
174
+ # Create and run
175
+ babysitter run:create \
176
+ --process-id meta/plugin-creation \
177
+ --entry library/specializations/meta/plugin-creation.js#process \
178
+ --inputs /tmp/plugin-inputs.json \
179
+ --prompt "Create a new babysitter plugin package" \
180
+ --json
181
+ ```
182
+
183
+ ### What the process generates
184
+
185
+ The process creates a complete plugin package directory:
186
+
187
+ | File | Description |
188
+ |------|-------------|
189
+ | `install.md` | Agent-readable installation instructions with numbered steps |
190
+ | `uninstall.md` | Reversal instructions for clean removal |
191
+ | `configure.md` | Configuration options table and adjustment instructions |
192
+ | `install-process.js` | *(optional)* Automated babysitter process for complex install steps |
193
+ | `configure-process.js` | *(optional)* Automated configuration process |
194
+ | `process/main.js` | *(optional)* Main process the plugin contributes |
195
+ | `marketplace-entry.json` | Ready-to-use marketplace.json entry for publishing |
196
+
197
+ ### Process phases
198
+
199
+ 1. **Requirements Analysis** — Analyzes plugin purpose, prerequisites, config options, file structure
200
+ 2. **Structure Design** — Plans directory layout and file inventory (with review breakpoint)
201
+ 3. **Instruction Authoring** — Writes install.md, uninstall.md, configure.md
202
+ 4. **Process Files** — Creates optional babysitter process files (install-process.js, configure-process.js, process/main.js)
203
+ 5. **Validation** — Verifies package completeness, instruction quality, path correctness
204
+ 6. **Marketplace Integration** — Generates marketplace.json entry for publishing
205
+
206
+ ### Quick creation (without orchestration)
207
+
208
+ For simple plugins that only need instruction files, you can create the package manually following the structure below and the [Plugin Author Guide](docs/plugins/plugin-author-guide.md).
209
+
210
+ ## Plugin Package Structure
211
+
212
+ ```
213
+ my-plugin/
214
+ package.json # Optional (name field used as plugin ID, falls back to directory name)
215
+ install.md # Markdown instructions for installation
216
+ uninstall.md # Markdown instructions for removal
217
+ configure.md # Markdown instructions for configuration
218
+ install-process.js # Optional automated install process
219
+ uninstall-process.js # Optional automated uninstall process
220
+ configure-process.js # Optional automated configure process
221
+ migrations/ # Version migration files
222
+ 1.0.0_to_1.1.0.md
223
+ 1.1.0_to_2.0.0.js
224
+ process/ # Process definition files (collected recursively)
225
+ main.js
226
+ ```
227
+
228
+ ## All CLI Commands Summary
229
+
230
+ All commands accept `--json` for machine-readable output and `--global|--project`.
231
+
232
+ | Command | Required Flags | Description |
233
+ |---------|---------------|-------------|
234
+ | `plugin:add-marketplace` | `--marketplace-url`, `--global\|--project` [`--marketplace-path`, `--marketplace-branch`, `--force`] | Clone a marketplace repository |
235
+ | `plugin:update-marketplace` | `--marketplace-name`, `--global\|--project` [`--marketplace-branch`] | Pull latest marketplace changes (optionally switch branch) |
236
+ | `plugin:list-plugins` | `--marketplace-name`, `--global\|--project` | List available plugins in a marketplace |
237
+ | `plugin:install` | `--plugin-name`, `--marketplace-name`, `--global\|--project` | Get install instructions for a plugin |
238
+ | `plugin:uninstall` | `--plugin-name`, `--marketplace-name`, `--global\|--project` | Get uninstall instructions for a plugin |
239
+ | `plugin:update` | `--plugin-name`, `--marketplace-name`, `--global\|--project` | Resolve migration chain and get update instructions |
240
+ | `plugin:configure` | `--plugin-name`, `--marketplace-name`, `--global\|--project` | Get configuration instructions for a plugin |
241
+ | `plugin:list-installed` | `--global\|--project` | List all installed plugins |
242
+ | `plugin:update-registry` | `--plugin-name`, `--plugin-version`, `--marketplace-name`, `--global\|--project` | Register or update a plugin entry |
243
+ | `plugin:remove-from-registry` | `--plugin-name`, `--global\|--project` | Remove a plugin entry from the registry |
244
+
245
+ ## After Plugin Work: Contribute Back
246
+
247
+ After working with plugins, prompt the user to share improvements or report issues:
248
+
249
+ - **Improved a plugin's install/configure/uninstall instructions**: `/babysitter:contrib library contribution: improved [plugin-name] [install|configure|uninstall] instructions`
250
+ - **Created a new plugin**: `/babysitter:contrib library contribution: new plugin [plugin-name] -- [description]`
251
+ - **Found a bug in a plugin or the plugin system**: `/babysitter:contrib bug report: [description, e.g. "plugin:update-registry fails when marketplace hasn't been cloned"]`
252
+ - **Plugin install/configure instructions were confusing or wrong**: `/babysitter:contrib bug report: [plugin-name] install instructions [description of what was wrong]`
253
+ - **Have an idea for a new plugin**: `/babysitter:contrib feature request: plugin idea -- [description]`
254
+
255
+ Even reporting that a plugin's instructions were unclear helps improve it for the next user.
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Set up a project for babysitting. Guides you through onboarding a new or existing project — researches the codebase, interviews you about goals and workflows, builds the project profile, installs the best tools, and optionally configures CI/CD integration.
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
+ Before using the process library, resolve the active library root through the SDK CLI. If no binding exists yet, initialize the shared global SDK binding with:
10
+
11
+ ```bash
12
+ babysitter process-library:active --json
13
+ ```
14
+
15
+ Then use the `cradle/project-install` process from the active process library.
16
+
17
+ When the run completes, end with a friendly message that includes a polite and humorous ask to star the repo on GitHub: https://github.com/a5c-ai/babysitter
@@ -0,0 +1,8 @@
1
+ ---
2
+ description: Resume orchestrating of a babysitter run. use this command to resume babysitting a complex workflow.
3
+ argument-hint: Specific run to resume
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). to resume a run.
8
+ if no run was given, discover the runs and suggest which incomplete run to resume based on the run's status, inputs, process , etc.
@@ -0,0 +1,55 @@
1
+ ---
2
+ description: Analysis for a run and its results, process, suggestions for process improvements, process optimizations, fixes, etc. for the next runs.
3
+ argument-hint: "[run-id...] [--all] Specific run IDs, --all for all runs, or defaults to latest"
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 retrospect process:
10
+
11
+ ### Run Selection
12
+
13
+ - `--all` or "all runs": list all completed/failed runs and analyze collectively
14
+ - Multiple run IDs: analyze each specified run
15
+ - Single run ID or no ID: existing behavior (latest run)
16
+ - In interactive mode with no run specified: ask user whether to analyze latest, select specific runs, or all runs
17
+
18
+ ### Cross-Run Analysis (multi-run mode)
19
+
20
+ When analyzing multiple runs, the retrospect process should additionally cover:
21
+ - Common failure patterns across runs
22
+ - Velocity trends (tasks/time across runs)
23
+ - Process evolution (how processes changed)
24
+ - Repeated breakpoint patterns
25
+ - Aggregate quality metrics
26
+
27
+ implementations notes (for the process):
28
+ - The process should analyze the run, the process that was followed, and provide suggestions for improvements, optimizations, and fixes.
29
+ - The process should such have many breakpoints where the user can steer the process, provide feedback, and make decisions about how to proceed with the retrospect.
30
+ - The process should be designed to be flexible and adaptable to different types of runs, projects, and goals, and should be able to provide insights and suggestions that are relevant and actionable for the user. (modification to the process, skills, etc.)
31
+ - The process should be designed to be iterative, allowing the user to go through multiple rounds of analysis and improvement, and should be able to track the changes and improvements made over time.
32
+ - The process should cover:
33
+ - Analysis of the run and its results, including what went well, what didn't go well, and what could be improved.
34
+ - Analysis of the process that was followed, including what steps were taken, what tools were used, and how effective they were.
35
+ - Suggestions for improvements, optimizations, and fixes for both the run and the process.
36
+ - Implementing the improvements, optimizations, and fixes, and tracking the changes made over time.
37
+ ### Cleanup Suggestion
38
+
39
+ After retrospect analysis, suggest running `/babysitter:cleanup` to clean up old run data and reclaim disk space.
40
+
41
+ - Ending by explicitly prompting the user to contribute back -- even just reporting an issue is valuable, they don't need to implement the fix themselves. After analysis, display a clear call-to-action:
42
+
43
+ "You've identified [specific insight/improvement]. This could help other babysitter users too. Run `/babysitter:contrib` to share it upstream -- you can either report it as an issue or submit a PR with the fix."
44
+
45
+ Route to the specific contrib workflow based on what the user wants to do:
46
+
47
+ **Just reporting (no code changes needed):**
48
+ - Found a bug or weakness in a process -> `/babysitter:contrib bug report: [description of what went wrong]`
49
+ - Found missing or confusing documentation -> `/babysitter:contrib documentation question: [what was unclear]`
50
+ - Have an idea for improvement but don't want to implement it -> `/babysitter:contrib feature request: [description]`
51
+
52
+ **Contributing code changes:**
53
+ - Process/skill/agent improvements -> `/babysitter:contrib library contribution: [description]`
54
+ - Bug fixes in SDK or CLI -> `/babysitter:contrib bugfix: [description]`
55
+ - Plugin instruction improvements -> `/babysitter:contrib library contribution: improved [plugin-name] [install|configure|uninstall] instructions`
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Set up babysitter for yourself. Guides you through onboarding — installs dependencies, interviews you about your specialties and preferences, builds your user profile, and configures the best tools for your 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).
8
+
9
+ Before using the process library, resolve the active library root through the SDK CLI. If no binding exists yet, initialize the shared global SDK binding with:
10
+
11
+ ```bash
12
+ babysitter process-library:active --json
13
+ ```
14
+
15
+ Then use the `cradle/user-install` process from the active process library.
16
+
17
+ When the run completes, end with a friendly message that includes a polite and humorous ask to star the repo on GitHub: https://github.com/a5c-ai/babysitter
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Orchestrate a babysitter run. use this command to start babysitting a complex workflow in a non-interactive mode, without any user interaction or breakpoints in the run.
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). but without any user interaction or breakpoints in the run.
@@ -0,0 +1,21 @@
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "sessionStart": [
5
+ {
6
+ "type": "command",
7
+ "bash": "bash \"./hooks/session-start.sh\"",
8
+ "powershell": "powershell -NoProfile -ExecutionPolicy Bypass -File \"./hooks/session-start.ps1\"",
9
+ "timeoutSec": 30
10
+ }
11
+ ],
12
+ "stop": [
13
+ {
14
+ "type": "command",
15
+ "bash": "bash \"./hooks/stop-hook.sh\"",
16
+ "powershell": "powershell -NoProfile -ExecutionPolicy Bypass -File \"./hooks/stop-hook.ps1\"",
17
+ "loop_limit": null
18
+ }
19
+ ]
20
+ }
21
+ }
@@ -0,0 +1,115 @@
1
+ # Babysitter Session Start Hook for Cursor IDE/CLI (PowerShell)
2
+ # Ensures the babysitter SDK CLI is installed (from versions.json sdkVersion),
3
+ # then delegates to the SDK hook handler.
4
+ #
5
+ # Protocol:
6
+ # Input: JSON via stdin (contains session_id, cwd, etc.)
7
+ # Output: JSON via stdout ({} on success)
8
+ # Stderr: debug/log output only
9
+ # Exit 0: success
10
+ # Exit 2: block (fatal error)
11
+
12
+ $ErrorActionPreference = "Stop"
13
+
14
+ $PluginRoot = if ($env:CURSOR_PLUGIN_ROOT) { $env:CURSOR_PLUGIN_ROOT } else { Split-Path -Parent $PSScriptRoot }
15
+ $StateDir = if ($env:BABYSITTER_STATE_DIR) { $env:BABYSITTER_STATE_DIR } else { Join-Path $PWD ".a5c" }
16
+ $MarkerFile = Join-Path $PluginRoot ".babysitter-install-attempted"
17
+
18
+ $env:CURSOR_PLUGIN_ROOT = $PluginRoot
19
+ $env:BABYSITTER_STATE_DIR = $StateDir
20
+
21
+ $LogDir = if ($env:BABYSITTER_LOG_DIR) { $env:BABYSITTER_LOG_DIR } else { Join-Path $PluginRoot ".a5c\logs" }
22
+ $LogFile = Join-Path $LogDir "babysitter-session-start-hook.log"
23
+ New-Item -ItemType Directory -Path $LogDir -Force -ErrorAction SilentlyContinue | Out-Null
24
+
25
+ function Write-Blog {
26
+ param([string]$Message)
27
+ $ts = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
28
+ Add-Content -Path $LogFile -Value "[INFO] $ts $Message" -ErrorAction SilentlyContinue
29
+ if (Get-Command babysitter -ErrorAction SilentlyContinue) {
30
+ & babysitter log --type hook --label "hook:session-start" --message $Message --source shell-hook 2>$null
31
+ }
32
+ }
33
+
34
+ Write-Blog "Hook script invoked"
35
+ Write-Blog "PLUGIN_ROOT=$PluginRoot"
36
+ Write-Blog "STATE_DIR=$StateDir"
37
+
38
+ # Get required SDK version from versions.json
39
+ $versionsFile = Join-Path $PluginRoot "versions.json"
40
+ try {
41
+ $SdkVersion = (Get-Content $versionsFile -Raw | ConvertFrom-Json).sdkVersion
42
+ if (-not $SdkVersion) { $SdkVersion = "latest" }
43
+ } catch {
44
+ $SdkVersion = "latest"
45
+ }
46
+
47
+ function Install-Sdk {
48
+ param([string]$TargetVersion)
49
+ try {
50
+ & npm i -g "@a5c-ai/babysitter-sdk@$TargetVersion" --loglevel=error 2>$null
51
+ if ($LASTEXITCODE -eq 0) {
52
+ Write-Blog "Installed SDK globally ($TargetVersion)"
53
+ return $true
54
+ }
55
+ } catch {}
56
+ try {
57
+ $prefix = Join-Path $env:USERPROFILE ".local"
58
+ & npm i -g "@a5c-ai/babysitter-sdk@$TargetVersion" --prefix $prefix --loglevel=error 2>$null
59
+ if ($LASTEXITCODE -eq 0) {
60
+ $env:PATH = "$prefix\bin;$env:PATH"
61
+ Write-Blog "Installed SDK to user prefix ($TargetVersion)"
62
+ return $true
63
+ }
64
+ } catch {}
65
+ return $false
66
+ }
67
+
68
+ # Check if babysitter CLI exists and if version matches
69
+ $NeedsInstall = $false
70
+ if (Get-Command babysitter -ErrorAction SilentlyContinue) {
71
+ $CurrentVersion = & babysitter --version 2>$null
72
+ if ($CurrentVersion -ne $SdkVersion) {
73
+ Write-Blog "SDK version mismatch: installed=$CurrentVersion, required=$SdkVersion"
74
+ $NeedsInstall = $true
75
+ } else {
76
+ Write-Blog "SDK version OK: $CurrentVersion"
77
+ }
78
+ } else {
79
+ Write-Blog "SDK CLI not found, will install"
80
+ $NeedsInstall = $true
81
+ }
82
+
83
+ # Install/upgrade if needed (only attempt once per plugin version)
84
+ if ($NeedsInstall -and -not (Test-Path $MarkerFile)) {
85
+ Install-Sdk $SdkVersion | Out-Null
86
+ Set-Content -Path $MarkerFile -Value $SdkVersion -ErrorAction SilentlyContinue
87
+ }
88
+
89
+ # If still not available after install attempt, try npx as last resort
90
+ $useFallback = $false
91
+ if (-not (Get-Command babysitter -ErrorAction SilentlyContinue)) {
92
+ Write-Blog "CLI not found after install, using npx fallback"
93
+ $useFallback = $true
94
+ }
95
+
96
+ # Capture stdin
97
+ $InputFile = [System.IO.Path]::GetTempFileName()
98
+ $input | Out-File -FilePath $InputFile -Encoding utf8
99
+
100
+ Write-Blog "Hook input received"
101
+
102
+ $stderrLog = Join-Path $LogDir "babysitter-session-start-hook-stderr.log"
103
+
104
+ if ($useFallback) {
105
+ $Result = Get-Content $InputFile | & npx -y "@a5c-ai/babysitter-sdk@$SdkVersion" hook:run --hook-type session-start --harness cursor --plugin-root $PluginRoot --state-dir $StateDir --json 2>$stderrLog
106
+ } else {
107
+ $Result = Get-Content $InputFile | & babysitter hook:run --hook-type session-start --harness cursor --plugin-root $PluginRoot --state-dir $StateDir --json 2>$stderrLog
108
+ }
109
+ $ExitCode = $LASTEXITCODE
110
+
111
+ Write-Blog "CLI exit code=$ExitCode"
112
+
113
+ Remove-Item $InputFile -Force -ErrorAction SilentlyContinue
114
+ Write-Output $Result
115
+ exit $ExitCode
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env bash
2
+ # Babysitter Session Start Hook for Cursor IDE/CLI
3
+ # Ensures the babysitter SDK CLI is installed (from versions.json sdkVersion),
4
+ # then delegates to the SDK hook handler.
5
+ #
6
+ # Protocol:
7
+ # Input: JSON via stdin (contains session_id, cwd, etc.)
8
+ # Output: JSON via stdout ({} on success)
9
+ # Stderr: debug/log output only
10
+ # Exit 0: success
11
+ # Exit 2: block (fatal error)
12
+
13
+ set -euo pipefail
14
+
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
17
+ STATE_DIR="${BABYSITTER_STATE_DIR:-${PWD}/.a5c}"
18
+ LOG_DIR="${BABYSITTER_LOG_DIR:-$PLUGIN_ROOT/.a5c/logs}"
19
+ LOG_FILE="$LOG_DIR/babysitter-session-start-hook.log"
20
+
21
+ export CURSOR_PLUGIN_ROOT="${CURSOR_PLUGIN_ROOT:-${PLUGIN_ROOT}}"
22
+ export BABYSITTER_STATE_DIR="${STATE_DIR}"
23
+
24
+ mkdir -p "$LOG_DIR" 2>/dev/null
25
+
26
+ blog() {
27
+ local msg="$1"
28
+ local ts
29
+ ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
30
+ echo "[INFO] $ts $msg" >> "$LOG_FILE" 2>/dev/null
31
+ babysitter log --type hook --label "hook:session-start" --message "$msg" --source shell-hook 2>/dev/null || true
32
+ }
33
+
34
+ blog "Hook script invoked"
35
+ blog "PLUGIN_ROOT=$PLUGIN_ROOT"
36
+ blog "STATE_DIR=$STATE_DIR"
37
+
38
+ # Get required SDK version from versions.json
39
+ SDK_VERSION=$(node -e "try{console.log(JSON.parse(require('fs').readFileSync('${PLUGIN_ROOT}/versions.json','utf8')).sdkVersion||'latest')}catch{console.log('latest')}" 2>/dev/null || echo "latest")
40
+
41
+ # Function to install/upgrade SDK
42
+ install_sdk() {
43
+ local target_version="$1"
44
+ if npm i -g "@a5c-ai/babysitter-sdk@${target_version}" --loglevel=error 2>/dev/null; then
45
+ blog "Installed SDK globally (${target_version})"
46
+ return 0
47
+ else
48
+ if npm i -g "@a5c-ai/babysitter-sdk@${target_version}" --prefix "$HOME/.local" --loglevel=error 2>/dev/null; then
49
+ export PATH="$HOME/.local/bin:$PATH"
50
+ blog "Installed SDK to user prefix (${target_version})"
51
+ return 0
52
+ fi
53
+ fi
54
+ return 1
55
+ }
56
+
57
+ # Check if babysitter CLI exists and if version matches
58
+ NEEDS_INSTALL=false
59
+ if command -v babysitter &>/dev/null; then
60
+ CURRENT_VERSION=$(babysitter --version 2>/dev/null || echo "unknown")
61
+ if [ "$CURRENT_VERSION" != "$SDK_VERSION" ]; then
62
+ blog "SDK version mismatch: installed=${CURRENT_VERSION}, required=${SDK_VERSION}"
63
+ NEEDS_INSTALL=true
64
+ else
65
+ blog "SDK version OK: ${CURRENT_VERSION}"
66
+ fi
67
+ else
68
+ blog "SDK CLI not found, will install"
69
+ NEEDS_INSTALL=true
70
+ fi
71
+
72
+ MARKER_FILE="${PLUGIN_ROOT}/.babysitter-install-attempted"
73
+
74
+ # Install/upgrade if needed (only attempt once per plugin version)
75
+ if [ "$NEEDS_INSTALL" = true ] && [ ! -f "$MARKER_FILE" ]; then
76
+ install_sdk "$SDK_VERSION"
77
+ echo "$SDK_VERSION" > "$MARKER_FILE" 2>/dev/null
78
+ fi
79
+
80
+ # If still not available after install attempt, try npx as last resort
81
+ if ! command -v babysitter &>/dev/null; then
82
+ blog "CLI not found after install, using npx fallback"
83
+ babysitter() { npx -y "@a5c-ai/babysitter-sdk@${SDK_VERSION}" "$@"; }
84
+ export -f babysitter
85
+ fi
86
+
87
+ # Capture stdin to a temp file so the CLI receives a clean EOF
88
+ INPUT_FILE=$(mktemp 2>/dev/null || echo "/tmp/cursor-session-start-hook-$$.json")
89
+ cat > "$INPUT_FILE"
90
+
91
+ blog "Hook input received ($(wc -c < "$INPUT_FILE") bytes)"
92
+
93
+ RESULT=$(babysitter hook:run \
94
+ --hook-type session-start \
95
+ --harness cursor \
96
+ --plugin-root "$PLUGIN_ROOT" \
97
+ --state-dir "${BABYSITTER_STATE_DIR}" \
98
+ --json < "$INPUT_FILE" 2>"$LOG_DIR/babysitter-session-start-hook-stderr.log")
99
+ EXIT_CODE=$?
100
+
101
+ blog "CLI exit code=$EXIT_CODE"
102
+
103
+ rm -f "$INPUT_FILE" 2>/dev/null
104
+ printf '%s\n' "$RESULT"
105
+ exit $EXIT_CODE