@a5c-ai/babysitter-cursor 0.1.5-staging.aaae75fb → 0.1.5-staging.b2dcdbb3

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.
@@ -4,9 +4,9 @@ argument-hint: "[run-id] Optional run ID to diagnose. If omitted, uses the most
4
4
  allowed-tools: Read, Grep, Write, Task, Bash, Edit, Grep, Glob, WebFetch, WebSearch, Search, AskUserQuestion, TodoWrite, TodoRead, Skill, BashOutput, KillShell, MultiEdit, LS
5
5
  ---
6
6
 
7
- 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.
7
+ You are a diagnostic agent for the babysitter runtime. Your job is to perform a comprehensive health check across 14 areas and produce a structured diagnostic report. Follow each section methodically. Track results as you go and produce the final summary at the end.
8
8
 
9
- Initialize a results tracker with these 10 checks, all starting as PENDING:
9
+ Initialize a results tracker with these 14 checks, all starting as PENDING:
10
10
  1. Run Discovery
11
11
  2. Journal Integrity
12
12
  3. State Cache Consistency
@@ -17,6 +17,10 @@ Initialize a results tracker with these 10 checks, all starting as PENDING:
17
17
  8. Disk Usage
18
18
  9. Process Validation
19
19
  10. Hook Execution Health
20
+ 11. Session-ID Provenance
21
+ 12. Ancestor Liveness
22
+ 13. Concurrent Session Detection
23
+ 14. Windows Ancestor-Walk Strategy
20
24
 
21
25
  ---
22
26
 
@@ -350,9 +354,65 @@ Mark as FAIL if:
350
354
 
351
355
  ---
352
356
 
357
+ ## 11. Session-ID Provenance
358
+
359
+ **Goal:** Verify how the current babysitter session ID was resolved and flag stale or shadowed values.
360
+
361
+ - Invoke: `npx babysitter session:whoami --json`
362
+ - Parse the output and inspect the `resolvedFrom` field. Classify as follows:
363
+ - `resolvedFrom: "pid-marker"` → mark as PASS ("Session ID derives from the live Claude Code ancestor process -- authoritative").
364
+ - `resolvedFrom: "env-file"` → mark as PASS with a note ("CLAUDE_ENV_FILE was used; typically healthy").
365
+ - `resolvedFrom: "env-var"` → mark as WARN ("`BABYSITTER_SESSION_ID` is set without a corroborating PID marker. Likely stale from a prior Claude Code session -- see GitHub issue #130").
366
+ - Remediation: run `babysitter session:cleanup` and start a fresh Claude Code session, or `unset BABYSITTER_SESSION_ID` before invoking babysitter.
367
+ - `resolvedFrom: "none"` → mark as ERROR ("No session ID resolvable. Either no session-start hook fired, or the ancestor walk failed").
368
+
369
+ **Env-var shadow check:**
370
+ - Independently inspect `envVarPresent` and `envVarMatches` in the output.
371
+ - If `envVarPresent && !envVarMatches`, mark as WARN ("`BABYSITTER_SESSION_ID` in env does not match the resolved session ID; a stale value is shadowing the authoritative one. Unset the env var").
372
+
373
+ ---
374
+
375
+ ## 12. Ancestor Liveness
376
+
377
+ **Goal:** Confirm the PID marker references a live Claude Code process.
378
+
379
+ - Reuse the `session:whoami --json` output from check 11.
380
+ - Inspect the `ancestorAlive` field.
381
+ - If `ancestorAlive === false`, mark as ERROR ("The PID marker references a dead Claude Code process").
382
+ - Remediation: `babysitter session:cleanup`.
383
+ - Otherwise mark as PASS.
384
+
385
+ ---
386
+
387
+ ## 13. Concurrent Session Detection
388
+
389
+ **Goal:** Surface multiple live harness sessions that may compete for the same session ID.
390
+
391
+ - Enumerate files in `~/.a5c/` matching the pattern `current-session-*-pid-*`.
392
+ - Count markers per harness (derived from the filename).
393
+ - If more than one live marker exists for the same harness, mark as INFO ("Multiple live Claude Code / harness sessions detected; ensure each shell scopes `BABYSITTER_SESSION_ID` appropriately -- the PID marker handles this automatically").
394
+ - Otherwise mark as PASS.
395
+
396
+ ---
397
+
398
+ ## 14. Windows Ancestor-Walk Strategy
399
+
400
+ **Goal:** Verify the ancestor-walk strategy works on Windows, where `wmic` is no longer guaranteed to be present.
401
+
402
+ - Only run this check when `process.platform === 'win32'`. On other platforms, mark as PASS ("Not applicable -- non-Windows platform").
403
+ - Attempt the ancestor walk by invoking `npx babysitter session:whoami --json` (reuse output from check 11 if available).
404
+ - If resolution succeeded (any `resolvedFrom` other than `none`), mark as PASS.
405
+ - If `resolvedFrom: "none"` on Windows:
406
+ - Test `wmic` availability: `where wmic` via shell.
407
+ - If absent, document that Windows 11 24H2 removed `wmic`; the fallback PowerShell CIM path should handle this.
408
+ - If the PowerShell ancestor walk also failed, mark as ERROR with remediation: ensure PowerShell is available (`powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter ProcessId=$PID"` should work).
409
+ - If the cascade works but is slow (>5s on first probe), add an INFO note on first-probe latency.
410
+
411
+ ---
412
+
353
413
  ## Final Report
354
414
 
355
- After completing all 10 checks, produce the diagnostic report in this format:
415
+ After completing all 14 checks, produce the diagnostic report in this format:
356
416
 
357
417
  ```
358
418
  ============================================
@@ -379,6 +439,10 @@ OVERALL HEALTH: <HEALTHY | WARNING | CRITICAL>
379
439
  | 8 | Disk Usage | <status> |
380
440
  | 9 | Process Validation | <status> |
381
441
  | 10 | Hook Execution Health | <status> |
442
+ | 11 | Session-ID Provenance | <status> |
443
+ | 12 | Ancestor Liveness | <status> |
444
+ | 13 | Concurrent Session Detection | <status> |
445
+ | 14 | Windows Ancestor-Walk Strategy | <status> |
382
446
 
383
447
  --------------------------------------------
384
448
  ISSUES & RECOMMENDATIONS
@@ -392,9 +456,9 @@ OVERALL HEALTH: <HEALTHY | WARNING | CRITICAL>
392
456
  ```
393
457
 
394
458
  **Overall health determination:**
395
- - **HEALTHY**: All 10 checks are PASS.
396
- - **WARNING**: At least one check is WARN but none are FAIL.
397
- - **CRITICAL**: At least one check is FAIL.
459
+ - **HEALTHY**: All 14 checks are PASS (INFO notes are acceptable).
460
+ - **WARNING**: At least one check is WARN but none are FAIL or ERROR.
461
+ - **CRITICAL**: At least one check is FAIL or ERROR.
398
462
 
399
463
  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.
400
464
 
@@ -424,3 +488,25 @@ After diagnosing issues, prompt the user to report or fix what was found -- they
424
488
  Example prompt after diagnosis:
425
489
 
426
490
  > "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."
491
+
492
+ ---
493
+
494
+ ## Self-Heal Suggestions
495
+
496
+ If any of checks 11-14 surface issues (stale env vars, dead ancestor PIDs, shadowed session IDs, or Windows ancestor-walk failures), suggest the following remediation sequence, in order. Present it as an actionable block:
497
+
498
+ ```bash
499
+ # 1. Cleanup dead markers and orphaned state files
500
+ babysitter session:cleanup --dry-run # preview
501
+ babysitter session:cleanup # apply
502
+
503
+ # 2. Unset a stale env var
504
+ unset BABYSITTER_SESSION_ID
505
+
506
+ # 3. Re-bind a run explicitly if needed
507
+ babysitter session:resume --session-id <fresh-id> --state-dir ~/.a5c --run-id <runId> --runs-dir .a5c/runs
508
+
509
+ # 4. Start a fresh Claude Code session (closes and reopens the session)
510
+ ```
511
+
512
+ Run steps 1 and 2 first; re-run `/babysitter:doctor` after each step to confirm the session-provenance checks return to PASS. Step 3 is only needed when a specific run must be re-bound to the fresh session. If the issue persists after step 4, escalate via `/debug` or `/babysitter:contrib`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a5c-ai/babysitter-cursor",
3
- "version": "0.1.5-staging.aaae75fb",
3
+ "version": "0.1.5-staging.b2dcdbb3",
4
4
  "description": "Babysitter orchestration plugin for Cursor IDE with SDK-managed process-library bootstrapping and in-turn iteration model",
5
5
  "scripts": {
6
6
  "test": "node scripts/sync-command-surfaces.js --check",
@@ -44,6 +44,6 @@
44
44
  },
45
45
  "homepage": "https://github.com/a5c-ai/babysitter/tree/main/plugins/babysitter-cursor#readme",
46
46
  "dependencies": {
47
- "@a5c-ai/babysitter-sdk": "0.0.188-staging.aaae75fb"
47
+ "@a5c-ai/babysitter-sdk": "0.0.188-staging.b2dcdbb3"
48
48
  }
49
49
  }
@@ -5,9 +5,9 @@ description: Diagnose babysitter run health - journal integrity, state cache, ef
5
5
 
6
6
  # doctor
7
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.
8
+ You are a diagnostic agent for the babysitter runtime. Your job is to perform a comprehensive health check across 14 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
9
 
10
- Initialize a results tracker with these 10 checks, all starting as PENDING:
10
+ Initialize a results tracker with these 14 checks, all starting as PENDING:
11
11
  1. Run Discovery
12
12
  2. Journal Integrity
13
13
  3. State Cache Consistency
@@ -18,6 +18,10 @@ Initialize a results tracker with these 10 checks, all starting as PENDING:
18
18
  8. Disk Usage
19
19
  9. Process Validation
20
20
  10. Hook Execution Health
21
+ 11. Session-ID Provenance
22
+ 12. Ancestor Liveness
23
+ 13. Concurrent Session Detection
24
+ 14. Windows Ancestor-Walk Strategy
21
25
 
22
26
  ---
23
27
 
@@ -351,9 +355,65 @@ Mark as FAIL if:
351
355
 
352
356
  ---
353
357
 
358
+ ## 11. Session-ID Provenance
359
+
360
+ **Goal:** Verify how the current babysitter session ID was resolved and flag stale or shadowed values.
361
+
362
+ - Invoke: `npx babysitter session:whoami --json`
363
+ - Parse the output and inspect the `resolvedFrom` field. Classify as follows:
364
+ - `resolvedFrom: "pid-marker"` → mark as PASS ("Session ID derives from the live Claude Code ancestor process -- authoritative").
365
+ - `resolvedFrom: "env-file"` → mark as PASS with a note ("CLAUDE_ENV_FILE was used; typically healthy").
366
+ - `resolvedFrom: "env-var"` → mark as WARN ("`BABYSITTER_SESSION_ID` is set without a corroborating PID marker. Likely stale from a prior Claude Code session -- see GitHub issue #130").
367
+ - Remediation: run `babysitter session:cleanup` and start a fresh Claude Code session, or `unset BABYSITTER_SESSION_ID` before invoking babysitter.
368
+ - `resolvedFrom: "none"` → mark as ERROR ("No session ID resolvable. Either no session-start hook fired, or the ancestor walk failed").
369
+
370
+ **Env-var shadow check:**
371
+ - Independently inspect `envVarPresent` and `envVarMatches` in the output.
372
+ - If `envVarPresent && !envVarMatches`, mark as WARN ("`BABYSITTER_SESSION_ID` in env does not match the resolved session ID; a stale value is shadowing the authoritative one. Unset the env var").
373
+
374
+ ---
375
+
376
+ ## 12. Ancestor Liveness
377
+
378
+ **Goal:** Confirm the PID marker references a live Claude Code process.
379
+
380
+ - Reuse the `session:whoami --json` output from check 11.
381
+ - Inspect the `ancestorAlive` field.
382
+ - If `ancestorAlive === false`, mark as ERROR ("The PID marker references a dead Claude Code process").
383
+ - Remediation: `babysitter session:cleanup`.
384
+ - Otherwise mark as PASS.
385
+
386
+ ---
387
+
388
+ ## 13. Concurrent Session Detection
389
+
390
+ **Goal:** Surface multiple live harness sessions that may compete for the same session ID.
391
+
392
+ - Enumerate files in `~/.a5c/` matching the pattern `current-session-*-pid-*`.
393
+ - Count markers per harness (derived from the filename).
394
+ - If more than one live marker exists for the same harness, mark as INFO ("Multiple live Claude Code / harness sessions detected; ensure each shell scopes `BABYSITTER_SESSION_ID` appropriately -- the PID marker handles this automatically").
395
+ - Otherwise mark as PASS.
396
+
397
+ ---
398
+
399
+ ## 14. Windows Ancestor-Walk Strategy
400
+
401
+ **Goal:** Verify the ancestor-walk strategy works on Windows, where `wmic` is no longer guaranteed to be present.
402
+
403
+ - Only run this check when `process.platform === 'win32'`. On other platforms, mark as PASS ("Not applicable -- non-Windows platform").
404
+ - Attempt the ancestor walk by invoking `npx babysitter session:whoami --json` (reuse output from check 11 if available).
405
+ - If resolution succeeded (any `resolvedFrom` other than `none`), mark as PASS.
406
+ - If `resolvedFrom: "none"` on Windows:
407
+ - Test `wmic` availability: `where wmic` via shell.
408
+ - If absent, document that Windows 11 24H2 removed `wmic`; the fallback PowerShell CIM path should handle this.
409
+ - If the PowerShell ancestor walk also failed, mark as ERROR with remediation: ensure PowerShell is available (`powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter ProcessId=$PID"` should work).
410
+ - If the cascade works but is slow (>5s on first probe), add an INFO note on first-probe latency.
411
+
412
+ ---
413
+
354
414
  ## Final Report
355
415
 
356
- After completing all 10 checks, produce the diagnostic report in this format:
416
+ After completing all 14 checks, produce the diagnostic report in this format:
357
417
 
358
418
  ```
359
419
  ============================================
@@ -380,6 +440,10 @@ OVERALL HEALTH: <HEALTHY | WARNING | CRITICAL>
380
440
  | 8 | Disk Usage | <status> |
381
441
  | 9 | Process Validation | <status> |
382
442
  | 10 | Hook Execution Health | <status> |
443
+ | 11 | Session-ID Provenance | <status> |
444
+ | 12 | Ancestor Liveness | <status> |
445
+ | 13 | Concurrent Session Detection | <status> |
446
+ | 14 | Windows Ancestor-Walk Strategy | <status> |
383
447
 
384
448
  --------------------------------------------
385
449
  ISSUES & RECOMMENDATIONS
@@ -393,9 +457,9 @@ OVERALL HEALTH: <HEALTHY | WARNING | CRITICAL>
393
457
  ```
394
458
 
395
459
  **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.
460
+ - **HEALTHY**: All 14 checks are PASS (INFO notes are acceptable).
461
+ - **WARNING**: At least one check is WARN but none are FAIL or ERROR.
462
+ - **CRITICAL**: At least one check is FAIL or ERROR.
399
463
 
400
464
  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
465
 
@@ -425,3 +489,25 @@ After diagnosing issues, prompt the user to report or fix what was found -- they
425
489
  Example prompt after diagnosis:
426
490
 
427
491
  > "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."
492
+
493
+ ---
494
+
495
+ ## Self-Heal Suggestions
496
+
497
+ If any of checks 11-14 surface issues (stale env vars, dead ancestor PIDs, shadowed session IDs, or Windows ancestor-walk failures), suggest the following remediation sequence, in order. Present it as an actionable block:
498
+
499
+ ```bash
500
+ # 1. Cleanup dead markers and orphaned state files
501
+ babysitter session:cleanup --dry-run # preview
502
+ babysitter session:cleanup # apply
503
+
504
+ # 2. Unset a stale env var
505
+ unset BABYSITTER_SESSION_ID
506
+
507
+ # 3. Re-bind a run explicitly if needed
508
+ babysitter session:resume --session-id <fresh-id> --state-dir ~/.a5c --run-id <runId> --runs-dir .a5c/runs
509
+
510
+ # 4. Start a fresh Claude Code session (closes and reopens the session)
511
+ ```
512
+
513
+ Run steps 1 and 2 first; re-run `/babysitter:doctor` after each step to confirm the session-provenance checks return to PASS. Step 3 is only needed when a specific run must be re-bound to the fresh session. If the issue persists after step 4, escalate via `/debug` or `/babysitter:contrib`.
package/versions.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "sdkVersion": "0.0.188-staging.aaae75fb"
2
+ "sdkVersion": "0.0.188-staging.b2dcdbb3"
3
3
  }