@a5c-ai/babysitter-cursor 5.0.1-staging.71bb37a4 → 5.0.1-staging.75c8fb21

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 (39) hide show
  1. package/bin/cli.js +8 -16
  2. package/bin/install-shared.js +236 -120
  3. package/bin/install.js +12 -28
  4. package/bin/uninstall.js +11 -27
  5. package/commands/doctor.md +5 -5
  6. package/commands/help.md +245 -244
  7. package/commands/observe.md +12 -12
  8. package/hooks/babysitter-proxied-session-start.ps1 +10 -194
  9. package/hooks/babysitter-proxied-session-start.sh +7 -170
  10. package/hooks/babysitter-proxied-stop.ps1 +12 -0
  11. package/hooks/babysitter-proxied-stop.sh +3 -0
  12. package/hooks/hooks-cursor.json +2 -2
  13. package/hooks.json +2 -2
  14. package/package.json +20 -20
  15. package/plugin.json +7 -5
  16. package/scripts/team-install.js +14 -72
  17. package/skills/cleanup/SKILL.md +21 -0
  18. package/skills/contrib/SKILL.md +34 -0
  19. package/skills/doctor/SKILL.md +5 -5
  20. package/skills/forever/SKILL.md +8 -0
  21. package/skills/help/SKILL.md +3 -2
  22. package/skills/observe/SKILL.md +1 -1
  23. package/skills/plugins/SKILL.md +257 -0
  24. package/skills/project-install/SKILL.md +18 -0
  25. package/skills/resume/SKILL.md +1 -1
  26. package/skills/retrospect/SKILL.md +48 -48
  27. package/skills/user-install/SKILL.md +3 -3
  28. package/skills/yolo/SKILL.md +8 -0
  29. package/versions.json +2 -1
  30. package/.cursor-plugin/plugin.json +0 -22
  31. package/.cursorrules +0 -55
  32. package/hooks/babysitter-proxied-stop-hook.ps1 +0 -125
  33. package/hooks/babysitter-proxied-stop-hook.sh +0 -112
  34. package/hooks/hooks-cursor.json.legacy +0 -21
  35. package/hooks/proxied-hooks.json +0 -22
  36. package/hooks/session-start.ps1 +0 -116
  37. package/hooks/session-start.sh +0 -106
  38. package/hooks/stop-hook.ps1 +0 -73
  39. package/hooks/stop-hook.sh +0 -61
@@ -1,125 +0,0 @@
1
- # Unified Stop Hook for Cursor IDE/CLI (PowerShell)
2
- # Routes through hooks-proxy for all hook execution.
3
- #
4
- # Drives the orchestration loop by checking run state on session stop.
5
- #
6
- # Protocol:
7
- # Input: JSON via stdin (session context)
8
- # Output: JSON via stdout (with optional continue/stop signal)
9
- # Stderr: debug/log output only
10
- # Exit 0: success
11
-
12
- $ErrorActionPreference = "Stop"
13
-
14
- $PluginRoot = if ($env:CURSOR_PLUGIN_ROOT) { $env:CURSOR_PLUGIN_ROOT } else { Split-Path -Parent $PSScriptRoot }
15
- $GlobalRoot = if ($env:BABYSITTER_GLOBAL_STATE_DIR) { $env:BABYSITTER_GLOBAL_STATE_DIR } else { Join-Path $HOME ".a5c" }
16
- $StateDir = if ($env:BABYSITTER_STATE_DIR) { $env:BABYSITTER_STATE_DIR } else { Join-Path $GlobalRoot "state" }
17
- $ProxyMarkerFile = Join-Path $PluginRoot ".hooks-proxy-install-attempted"
18
-
19
- $env:CURSOR_PLUGIN_ROOT = $PluginRoot
20
- $env:BABYSITTER_STATE_DIR = $StateDir
21
-
22
- $LogDir = if ($env:BABYSITTER_LOG_DIR) { $env:BABYSITTER_LOG_DIR } else { Join-Path $GlobalRoot "logs" }
23
- $LogFile = Join-Path $LogDir "babysitter-stop-hook.log"
24
- New-Item -ItemType Directory -Path $LogDir -Force -ErrorAction SilentlyContinue | Out-Null
25
-
26
- function Write-Blog {
27
- param([string]$Message)
28
- $ts = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
29
- Add-Content -Path $LogFile -Value "[INFO] $ts $Message" -ErrorAction SilentlyContinue
30
- if (Get-Command babysitter -ErrorAction SilentlyContinue) {
31
- & babysitter log --type hook --label "hook:stop" --message $Message --source shell-hook 2>$null
32
- }
33
- }
34
-
35
- Write-Blog "Unified hook script invoked"
36
- Write-Blog "PLUGIN_ROOT=$PluginRoot"
37
- Write-Blog "STATE_DIR=$StateDir"
38
-
39
- # Get required version from versions.json (used for hooks-proxy)
40
- $versionsFile = Join-Path $PluginRoot "versions.json"
41
- try {
42
- $SdkVersion = (Get-Content $versionsFile -Raw | ConvertFrom-Json).sdkVersion
43
- if (-not $SdkVersion) { $SdkVersion = "latest" }
44
- } catch {
45
- $SdkVersion = "latest"
46
- }
47
-
48
- # ---------------------------------------------------------------------------
49
- # Hooks-proxy install (same pattern as SDK install in session-start)
50
- # ---------------------------------------------------------------------------
51
-
52
- function Install-HooksProxy {
53
- param([string]$TargetVersion)
54
- try {
55
- & npm i -g "@a5c-ai/hooks-proxy-cli@$TargetVersion" --loglevel=error 2>$null
56
- if ($LASTEXITCODE -eq 0) {
57
- Write-Blog "Installed hooks-proxy globally ($TargetVersion)"
58
- return $true
59
- }
60
- } catch {}
61
- try {
62
- $prefix = Join-Path $env:USERPROFILE ".local"
63
- & npm i -g "@a5c-ai/hooks-proxy-cli@$TargetVersion" --prefix $prefix --loglevel=error 2>$null
64
- if ($LASTEXITCODE -eq 0) {
65
- $env:PATH = "$prefix\bin;$env:PATH"
66
- Write-Blog "Installed hooks-proxy to user prefix ($TargetVersion)"
67
- return $true
68
- }
69
- } catch {}
70
- return $false
71
- }
72
-
73
- # Resolve hooks-proxy binary
74
- $Proxy = $null
75
- if (Get-Command a5c-hooks-proxy -ErrorAction SilentlyContinue) {
76
- $Proxy = "a5c-hooks-proxy"
77
- } else {
78
- $localProxy = Join-Path $env:USERPROFILE ".local\bin\a5c-hooks-proxy.exe"
79
- if (Test-Path $localProxy) {
80
- $Proxy = $localProxy
81
- }
82
- }
83
-
84
- # Install if not found (only attempt once per plugin version)
85
- if (-not $Proxy -and -not (Test-Path $ProxyMarkerFile)) {
86
- Write-Blog "hooks-proxy not found, attempting install"
87
- Install-HooksProxy $SdkVersion | Out-Null
88
- Set-Content -Path $ProxyMarkerFile -Value $SdkVersion -ErrorAction SilentlyContinue
89
- # Re-resolve after install
90
- if (Get-Command a5c-hooks-proxy -ErrorAction SilentlyContinue) {
91
- $Proxy = "a5c-hooks-proxy"
92
- } else {
93
- $localProxy = Join-Path $env:USERPROFILE ".local\bin\a5c-hooks-proxy.exe"
94
- if (Test-Path $localProxy) {
95
- $Proxy = $localProxy
96
- }
97
- }
98
- }
99
-
100
- # ---------------------------------------------------------------------------
101
- # Capture stdin and delegate to hooks-proxy
102
- # ---------------------------------------------------------------------------
103
-
104
- $InputFile = [System.IO.Path]::GetTempFileName()
105
- $input | Out-File -FilePath $InputFile -Encoding utf8
106
-
107
- Write-Blog "Hook input received"
108
-
109
- $stderrLog = Join-Path $LogDir "babysitter-stop-hook-stderr.log"
110
-
111
- if ($Proxy) {
112
- Write-Blog "Using hooks-proxy: $Proxy"
113
- $Result = Get-Content $InputFile | & $Proxy invoke --adapter cursor --handler "babysitter hook:run --harness unified --hook-type stop --plugin-root $PluginRoot --state-dir $StateDir --json" --json 2>$stderrLog
114
- $ExitCode = $LASTEXITCODE
115
- } else {
116
- Write-Blog "hooks-proxy not found after install, using npx fallback"
117
- $Result = Get-Content $InputFile | & npx -y "@a5c-ai/hooks-proxy-cli@$SdkVersion" invoke --adapter cursor --handler "babysitter hook:run --harness unified --hook-type stop --plugin-root $PluginRoot --state-dir $StateDir --json" --json 2>$stderrLog
118
- $ExitCode = $LASTEXITCODE
119
- }
120
-
121
- Write-Blog "CLI exit code=$ExitCode"
122
-
123
- Remove-Item $InputFile -Force -ErrorAction SilentlyContinue
124
- Write-Output $Result
125
- exit $ExitCode
@@ -1,112 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Unified Stop Hook - routes through hooks-proxy for all hook execution.
3
- #
4
- # Drives the orchestration loop by checking run state on session stop.
5
- #
6
- # Protocol:
7
- # Input: JSON via stdin (session context)
8
- # Output: JSON via stdout (with optional continue/stop signal)
9
- # Stderr: debug/log output only
10
- # Exit 0: success
11
-
12
- set -euo pipefail
13
-
14
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
- PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
16
- GLOBAL_ROOT="${BABYSITTER_GLOBAL_STATE_DIR:-$HOME/.a5c}"
17
- STATE_DIR="${BABYSITTER_STATE_DIR:-${GLOBAL_ROOT}/state}"
18
- LOG_DIR="${BABYSITTER_LOG_DIR:-${GLOBAL_ROOT}/logs}"
19
- LOG_FILE="$LOG_DIR/babysitter-stop-hook.log"
20
- PROXY_MARKER_FILE="${PLUGIN_ROOT}/.hooks-proxy-install-attempted"
21
-
22
- export CURSOR_PLUGIN_ROOT="${CURSOR_PLUGIN_ROOT:-${PLUGIN_ROOT}}"
23
- export BABYSITTER_STATE_DIR="${STATE_DIR}"
24
-
25
- mkdir -p "$LOG_DIR" 2>/dev/null
26
-
27
- blog() {
28
- local msg="$1"
29
- local ts
30
- ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
31
- echo "[INFO] $ts $msg" >> "$LOG_FILE" 2>/dev/null
32
- if command -v babysitter &>/dev/null; then
33
- babysitter log --type hook --label "hook:stop" --message "$msg" --source shell-hook 2>/dev/null || true
34
- fi
35
- }
36
-
37
- blog "Unified hook script invoked"
38
- blog "PLUGIN_ROOT=$PLUGIN_ROOT"
39
- blog "STATE_DIR=$STATE_DIR"
40
-
41
- # Get required version from versions.json (used for hooks-proxy)
42
- 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")
43
-
44
- # ---------------------------------------------------------------------------
45
- # Hooks-proxy install (same pattern as SDK install in session-start)
46
- # ---------------------------------------------------------------------------
47
-
48
- install_hooks_proxy() {
49
- local target_version="$1"
50
- if npm i -g "@a5c-ai/hooks-proxy-cli@${target_version}" --loglevel=error 2>/dev/null; then
51
- blog "Installed hooks-proxy globally (${target_version})"
52
- return 0
53
- else
54
- if npm i -g "@a5c-ai/hooks-proxy-cli@${target_version}" --prefix "$HOME/.local" --loglevel=error 2>/dev/null; then
55
- export PATH="$HOME/.local/bin:$PATH"
56
- blog "Installed hooks-proxy to user prefix (${target_version})"
57
- return 0
58
- fi
59
- fi
60
- return 1
61
- }
62
-
63
- # Resolve hooks-proxy binary
64
- PROXY=""
65
- if command -v a5c-hooks-proxy &>/dev/null; then
66
- PROXY="a5c-hooks-proxy"
67
- elif [ -f "$HOME/.local/bin/a5c-hooks-proxy" ]; then
68
- PROXY="$HOME/.local/bin/a5c-hooks-proxy"
69
- fi
70
-
71
- # Install if not found (only attempt once per plugin version)
72
- if [ -z "$PROXY" ] && [ ! -f "$PROXY_MARKER_FILE" ]; then
73
- blog "hooks-proxy not found, attempting install"
74
- install_hooks_proxy "$SDK_VERSION"
75
- echo "$SDK_VERSION" > "$PROXY_MARKER_FILE" 2>/dev/null
76
- if command -v a5c-hooks-proxy &>/dev/null; then
77
- PROXY="a5c-hooks-proxy"
78
- elif [ -f "$HOME/.local/bin/a5c-hooks-proxy" ]; then
79
- PROXY="$HOME/.local/bin/a5c-hooks-proxy"
80
- fi
81
- fi
82
-
83
- # npx fallback if still not found
84
- if [ -z "$PROXY" ]; then
85
- blog "hooks-proxy not found after install, using npx fallback"
86
- PROXY="npx -y @a5c-ai/hooks-proxy-cli@${SDK_VERSION} "
87
- fi
88
-
89
- # ---------------------------------------------------------------------------
90
- # Capture stdin and delegate to hooks-proxy
91
- # ---------------------------------------------------------------------------
92
-
93
- INPUT_FILE=$(mktemp 2>/dev/null || echo "/tmp/cursor-stop-hook-$$.json")
94
- cat > "$INPUT_FILE"
95
-
96
- blog "Hook input received ($(wc -c < "$INPUT_FILE") bytes)"
97
-
98
- STDERR_LOG="$LOG_DIR/babysitter-stop-hook-stderr.log"
99
-
100
- blog "Using hooks-proxy: $PROXY"
101
- RESULT=$($PROXY invoke \
102
- --adapter cursor \
103
- --handler "babysitter hook:run --harness unified --hook-type stop --plugin-root ${CURSOR_PLUGIN_ROOT} --state-dir ${BABYSITTER_STATE_DIR} --json" \
104
- --json \
105
- < "$INPUT_FILE" 2>"$STDERR_LOG")
106
- EXIT_CODE=$?
107
-
108
- blog "CLI exit code=$EXIT_CODE"
109
-
110
- rm -f "$INPUT_FILE" 2>/dev/null
111
- printf '%s\n' "$RESULT"
112
- exit $EXIT_CODE
@@ -1,21 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
1
- {
2
- "_comment": "NOT ACTIVE — Alternative hooks-cursor.json using per-hook unified scripts with hooks-proxy support. To activate, replace hooks-cursor.json with this file.",
3
- "version": 1,
4
- "hooks": {
5
- "sessionStart": [
6
- {
7
- "type": "command",
8
- "bash": "bash \"./hooks/babysitter-proxied-session-start.sh\"",
9
- "powershell": "powershell -NoProfile -ExecutionPolicy Bypass -File \"./hooks/babysitter-proxied-session-start.ps1\"",
10
- "timeoutSec": 30
11
- }
12
- ],
13
- "stop": [
14
- {
15
- "type": "command",
16
- "bash": "bash \"./hooks/babysitter-proxied-stop-hook.sh\"",
17
- "powershell": "powershell -NoProfile -ExecutionPolicy Bypass -File \"./hooks/babysitter-proxied-stop-hook.ps1\"",
18
- "loop_limit": null
19
- }
20
- ]
21
- }
22
- }
@@ -1,116 +0,0 @@
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
- $GlobalRoot = if ($env:BABYSITTER_GLOBAL_STATE_DIR) { $env:BABYSITTER_GLOBAL_STATE_DIR } else { Join-Path $HOME ".a5c" }
16
- $StateDir = if ($env:BABYSITTER_STATE_DIR) { $env:BABYSITTER_STATE_DIR } else { Join-Path $GlobalRoot "state" }
17
- $MarkerFile = Join-Path $PluginRoot ".babysitter-install-attempted"
18
-
19
- $env:CURSOR_PLUGIN_ROOT = $PluginRoot
20
- $env:BABYSITTER_STATE_DIR = $StateDir
21
-
22
- $LogDir = if ($env:BABYSITTER_LOG_DIR) { $env:BABYSITTER_LOG_DIR } else { Join-Path $GlobalRoot "logs" }
23
- $LogFile = Join-Path $LogDir "babysitter-session-start-hook.log"
24
- New-Item -ItemType Directory -Path $LogDir -Force -ErrorAction SilentlyContinue | Out-Null
25
-
26
- function Write-Blog {
27
- param([string]$Message)
28
- $ts = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
29
- Add-Content -Path $LogFile -Value "[INFO] $ts $Message" -ErrorAction SilentlyContinue
30
- if (Get-Command babysitter -ErrorAction SilentlyContinue) {
31
- & babysitter log --type hook --label "hook:session-start" --message $Message --source shell-hook 2>$null
32
- }
33
- }
34
-
35
- Write-Blog "Hook script invoked"
36
- Write-Blog "PLUGIN_ROOT=$PluginRoot"
37
- Write-Blog "STATE_DIR=$StateDir"
38
-
39
- # Get required SDK version from versions.json
40
- $versionsFile = Join-Path $PluginRoot "versions.json"
41
- try {
42
- $SdkVersion = (Get-Content $versionsFile -Raw | ConvertFrom-Json).sdkVersion
43
- if (-not $SdkVersion) { $SdkVersion = "latest" }
44
- } catch {
45
- $SdkVersion = "latest"
46
- }
47
-
48
- function Install-Sdk {
49
- param([string]$TargetVersion)
50
- try {
51
- & npm i -g "@a5c-ai/babysitter-sdk@$TargetVersion" --loglevel=error 2>$null
52
- if ($LASTEXITCODE -eq 0) {
53
- Write-Blog "Installed SDK globally ($TargetVersion)"
54
- return $true
55
- }
56
- } catch {}
57
- try {
58
- $prefix = Join-Path $env:USERPROFILE ".local"
59
- & npm i -g "@a5c-ai/babysitter-sdk@$TargetVersion" --prefix $prefix --loglevel=error 2>$null
60
- if ($LASTEXITCODE -eq 0) {
61
- $env:PATH = "$prefix\bin;$env:PATH"
62
- Write-Blog "Installed SDK to user prefix ($TargetVersion)"
63
- return $true
64
- }
65
- } catch {}
66
- return $false
67
- }
68
-
69
- # Check if babysitter CLI exists and if version matches
70
- $NeedsInstall = $false
71
- if (Get-Command babysitter -ErrorAction SilentlyContinue) {
72
- $CurrentVersion = & babysitter --version 2>$null
73
- if ($CurrentVersion -ne $SdkVersion) {
74
- Write-Blog "SDK version mismatch: installed=$CurrentVersion, required=$SdkVersion"
75
- $NeedsInstall = $true
76
- } else {
77
- Write-Blog "SDK version OK: $CurrentVersion"
78
- }
79
- } else {
80
- Write-Blog "SDK CLI not found, will install"
81
- $NeedsInstall = $true
82
- }
83
-
84
- # Install/upgrade if needed (only attempt once per plugin version)
85
- if ($NeedsInstall -and -not (Test-Path $MarkerFile)) {
86
- Install-Sdk $SdkVersion | Out-Null
87
- Set-Content -Path $MarkerFile -Value $SdkVersion -ErrorAction SilentlyContinue
88
- }
89
-
90
- # If still not available after install attempt, try npx as last resort
91
- $useFallback = $false
92
- if (-not (Get-Command babysitter -ErrorAction SilentlyContinue)) {
93
- Write-Blog "CLI not found after install, using npx fallback"
94
- $useFallback = $true
95
- }
96
-
97
- # Capture stdin
98
- $InputFile = [System.IO.Path]::GetTempFileName()
99
- $input | Out-File -FilePath $InputFile -Encoding utf8
100
-
101
- Write-Blog "Hook input received"
102
-
103
- $stderrLog = Join-Path $LogDir "babysitter-session-start-hook-stderr.log"
104
-
105
- if ($useFallback) {
106
- $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
107
- } else {
108
- $Result = Get-Content $InputFile | & babysitter hook:run --hook-type session-start --harness cursor --plugin-root $PluginRoot --state-dir $StateDir --json 2>$stderrLog
109
- }
110
- $ExitCode = $LASTEXITCODE
111
-
112
- Write-Blog "CLI exit code=$ExitCode"
113
-
114
- Remove-Item $InputFile -Force -ErrorAction SilentlyContinue
115
- Write-Output $Result
116
- exit $ExitCode
@@ -1,106 +0,0 @@
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
- GLOBAL_ROOT="${BABYSITTER_GLOBAL_STATE_DIR:-$HOME/.a5c}"
18
- STATE_DIR="${BABYSITTER_STATE_DIR:-${GLOBAL_ROOT}/state}"
19
- LOG_DIR="${BABYSITTER_LOG_DIR:-${GLOBAL_ROOT}/logs}"
20
- LOG_FILE="$LOG_DIR/babysitter-session-start-hook.log"
21
-
22
- export CURSOR_PLUGIN_ROOT="${CURSOR_PLUGIN_ROOT:-${PLUGIN_ROOT}}"
23
- export BABYSITTER_STATE_DIR="${STATE_DIR}"
24
-
25
- mkdir -p "$LOG_DIR" 2>/dev/null
26
-
27
- blog() {
28
- local msg="$1"
29
- local ts
30
- ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
31
- echo "[INFO] $ts $msg" >> "$LOG_FILE" 2>/dev/null
32
- babysitter log --type hook --label "hook:session-start" --message "$msg" --source shell-hook 2>/dev/null || true
33
- }
34
-
35
- blog "Hook script invoked"
36
- blog "PLUGIN_ROOT=$PLUGIN_ROOT"
37
- blog "STATE_DIR=$STATE_DIR"
38
-
39
- # Get required SDK version from versions.json
40
- 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")
41
-
42
- # Function to install/upgrade SDK
43
- install_sdk() {
44
- local target_version="$1"
45
- if npm i -g "@a5c-ai/babysitter-sdk@${target_version}" --loglevel=error 2>/dev/null; then
46
- blog "Installed SDK globally (${target_version})"
47
- return 0
48
- else
49
- if npm i -g "@a5c-ai/babysitter-sdk@${target_version}" --prefix "$HOME/.local" --loglevel=error 2>/dev/null; then
50
- export PATH="$HOME/.local/bin:$PATH"
51
- blog "Installed SDK to user prefix (${target_version})"
52
- return 0
53
- fi
54
- fi
55
- return 1
56
- }
57
-
58
- # Check if babysitter CLI exists and if version matches
59
- NEEDS_INSTALL=false
60
- if command -v babysitter &>/dev/null; then
61
- CURRENT_VERSION=$(babysitter --version 2>/dev/null || echo "unknown")
62
- if [ "$CURRENT_VERSION" != "$SDK_VERSION" ]; then
63
- blog "SDK version mismatch: installed=${CURRENT_VERSION}, required=${SDK_VERSION}"
64
- NEEDS_INSTALL=true
65
- else
66
- blog "SDK version OK: ${CURRENT_VERSION}"
67
- fi
68
- else
69
- blog "SDK CLI not found, will install"
70
- NEEDS_INSTALL=true
71
- fi
72
-
73
- MARKER_FILE="${PLUGIN_ROOT}/.babysitter-install-attempted"
74
-
75
- # Install/upgrade if needed (only attempt once per plugin version)
76
- if [ "$NEEDS_INSTALL" = true ] && [ ! -f "$MARKER_FILE" ]; then
77
- install_sdk "$SDK_VERSION"
78
- echo "$SDK_VERSION" > "$MARKER_FILE" 2>/dev/null
79
- fi
80
-
81
- # If still not available after install attempt, try npx as last resort
82
- if ! command -v babysitter &>/dev/null; then
83
- blog "CLI not found after install, using npx fallback"
84
- babysitter() { npx -y "@a5c-ai/babysitter-sdk@${SDK_VERSION}" "$@"; }
85
- export -f babysitter
86
- fi
87
-
88
- # Capture stdin to a temp file so the CLI receives a clean EOF
89
- INPUT_FILE=$(mktemp 2>/dev/null || echo "/tmp/cursor-session-start-hook-$$.json")
90
- cat > "$INPUT_FILE"
91
-
92
- blog "Hook input received ($(wc -c < "$INPUT_FILE") bytes)"
93
-
94
- RESULT=$(babysitter hook:run \
95
- --hook-type session-start \
96
- --harness cursor \
97
- --plugin-root "$PLUGIN_ROOT" \
98
- --state-dir "${BABYSITTER_STATE_DIR}" \
99
- --json < "$INPUT_FILE" 2>"$LOG_DIR/babysitter-session-start-hook-stderr.log")
100
- EXIT_CODE=$?
101
-
102
- blog "CLI exit code=$EXIT_CODE"
103
-
104
- rm -f "$INPUT_FILE" 2>/dev/null
105
- printf '%s\n' "$RESULT"
106
- exit $EXIT_CODE
@@ -1,73 +0,0 @@
1
- # Babysitter Stop Hook for Cursor IDE/CLI (PowerShell)
2
- # Drives the orchestration loop by checking run state on session stop.
3
- #
4
- # Protocol:
5
- # Input: JSON via stdin (session context)
6
- # Output: JSON via stdout (with optional continue/stop signal)
7
- # Stderr: debug/log output only
8
- # Exit 0: success
9
-
10
- $ErrorActionPreference = "Stop"
11
-
12
- $PluginRoot = if ($env:CURSOR_PLUGIN_ROOT) { $env:CURSOR_PLUGIN_ROOT } else { Split-Path -Parent $PSScriptRoot }
13
- $GlobalRoot = if ($env:BABYSITTER_GLOBAL_STATE_DIR) { $env:BABYSITTER_GLOBAL_STATE_DIR } else { Join-Path $HOME ".a5c" }
14
- $StateDir = if ($env:BABYSITTER_STATE_DIR) { $env:BABYSITTER_STATE_DIR } else { Join-Path $GlobalRoot "state" }
15
-
16
- $env:CURSOR_PLUGIN_ROOT = $PluginRoot
17
- $env:BABYSITTER_STATE_DIR = $StateDir
18
-
19
- $LogDir = if ($env:BABYSITTER_LOG_DIR) { $env:BABYSITTER_LOG_DIR } else { Join-Path $GlobalRoot "logs" }
20
- $LogFile = Join-Path $LogDir "babysitter-stop-hook.log"
21
- New-Item -ItemType Directory -Path $LogDir -Force -ErrorAction SilentlyContinue | Out-Null
22
-
23
- function Write-Blog {
24
- param([string]$Message)
25
- $ts = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
26
- Add-Content -Path $LogFile -Value "[INFO] $ts $Message" -ErrorAction SilentlyContinue
27
- if (Get-Command babysitter -ErrorAction SilentlyContinue) {
28
- & babysitter log --type hook --label "hook:stop" --message $Message --source shell-hook 2>$null
29
- }
30
- }
31
-
32
- Write-Blog "Hook script invoked"
33
- Write-Blog "PLUGIN_ROOT=$PluginRoot"
34
- Write-Blog "STATE_DIR=$StateDir"
35
-
36
- # Resolve babysitter CLI
37
- $useFallback = $false
38
- if (-not (Get-Command babysitter -ErrorAction SilentlyContinue)) {
39
- $localBin = Join-Path $env:USERPROFILE ".local\bin\babysitter.cmd"
40
- if (Test-Path $localBin) {
41
- $env:PATH = "$(Split-Path $localBin);$env:PATH"
42
- } else {
43
- $versionsFile = Join-Path $PluginRoot "versions.json"
44
- try {
45
- $script:SdkVersion = (Get-Content $versionsFile -Raw | ConvertFrom-Json).sdkVersion
46
- if (-not $script:SdkVersion) { $script:SdkVersion = "latest" }
47
- } catch {
48
- $script:SdkVersion = "latest"
49
- }
50
- $useFallback = $true
51
- }
52
- }
53
-
54
- # Capture stdin
55
- $InputFile = [System.IO.Path]::GetTempFileName()
56
- $input | Out-File -FilePath $InputFile -Encoding utf8
57
-
58
- Write-Blog "Hook input received"
59
-
60
- $stderrLog = Join-Path $LogDir "babysitter-stop-hook-stderr.log"
61
-
62
- if ($useFallback) {
63
- $Result = Get-Content $InputFile | & npx -y "@a5c-ai/babysitter-sdk@$script:SdkVersion" hook:run --hook-type stop --harness cursor --plugin-root $PluginRoot --state-dir $StateDir --json 2>$stderrLog
64
- } else {
65
- $Result = Get-Content $InputFile | & babysitter hook:run --hook-type stop --harness cursor --plugin-root $PluginRoot --state-dir $StateDir --json 2>$stderrLog
66
- }
67
- $ExitCode = $LASTEXITCODE
68
-
69
- Write-Blog "CLI exit code=$ExitCode"
70
-
71
- Remove-Item $InputFile -Force -ErrorAction SilentlyContinue
72
- Write-Output $Result
73
- exit $ExitCode
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Babysitter Stop Hook for Cursor IDE/CLI
3
- # Drives the orchestration loop by checking run state on session stop.
4
- #
5
- # Protocol:
6
- # Input: JSON via stdin (session context)
7
- # Output: JSON via stdout (with optional continue/stop signal)
8
- # Stderr: debug/log output only
9
- # Exit 0: success
10
-
11
- set -euo pipefail
12
-
13
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
- PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
15
- GLOBAL_ROOT="${BABYSITTER_GLOBAL_STATE_DIR:-$HOME/.a5c}"
16
- STATE_DIR="${BABYSITTER_STATE_DIR:-${GLOBAL_ROOT}/state}"
17
- LOG_DIR="${BABYSITTER_LOG_DIR:-${GLOBAL_ROOT}/logs}"
18
- LOG_FILE="$LOG_DIR/babysitter-stop-hook.log"
19
-
20
- export CURSOR_PLUGIN_ROOT="${CURSOR_PLUGIN_ROOT:-${PLUGIN_ROOT}}"
21
- export BABYSITTER_STATE_DIR="${STATE_DIR}"
22
-
23
- if ! command -v babysitter &>/dev/null; then
24
- # No CLI available — exit 0 (no-op, proceed with original command)
25
- exit 0
26
- fi
27
-
28
- mkdir -p "$LOG_DIR" 2>/dev/null
29
-
30
- blog() {
31
- local msg="$1"
32
- local ts
33
- ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
34
- echo "[INFO] $ts $msg" >> "$LOG_FILE" 2>/dev/null
35
- babysitter log --type hook --label "hook:stop" --message "$msg" --source shell-hook 2>/dev/null || true
36
- }
37
-
38
- blog "Hook script invoked"
39
- blog "PLUGIN_ROOT=$PLUGIN_ROOT"
40
- blog "STATE_DIR=$STATE_DIR"
41
-
42
-
43
-
44
- INPUT_FILE=$(mktemp 2>/dev/null || echo "/tmp/cursor-stop-hook-$$.json")
45
- cat > "$INPUT_FILE"
46
-
47
- blog "Hook input received ($(wc -c < "$INPUT_FILE") bytes)"
48
-
49
- RESULT=$(babysitter hook:run \
50
- --hook-type stop \
51
- --harness cursor \
52
- --plugin-root "$PLUGIN_ROOT" \
53
- --state-dir "${BABYSITTER_STATE_DIR}" \
54
- --json < "$INPUT_FILE" 2>"$LOG_DIR/babysitter-stop-hook-stderr.log")
55
- EXIT_CODE=$?
56
-
57
- blog "CLI exit code=$EXIT_CODE"
58
-
59
- rm -f "$INPUT_FILE" 2>/dev/null
60
- printf '%s\n' "$RESULT"
61
- exit $EXIT_CODE