niahere 0.2.87 → 0.2.89

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "niahere",
3
- "version": "0.2.87",
3
+ "version": "0.2.89",
4
4
  "description": "A personal AI assistant daemon — chat, scheduled jobs, persona system, extensible via skills.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -4,7 +4,7 @@ description: >
4
4
  Persistent task management via Beads CLI (bd). Use when user mentions tasks, todos, issues, or tracking work.
5
5
  Check `which bd` first — if missing, offer: `npm install -g @beads/bd`.
6
6
  All commands: run from `$BEATS_DIR` (for example `~/.niahere/beads`) and use `bd <command>`. Always label: `--label project:<project-name>`.
7
- Run `bd help-all` for available commands. Not for ephemeral in-conversation tracking.
7
+ Run `bd --help` or `bd help --all` for available commands. Not for ephemeral in-conversation tracking.
8
8
  ---
9
9
 
10
10
  ## Overview
@@ -19,7 +19,7 @@ Global task manager powered by [Beads](https://github.com/steveyegge/beads). Sto
19
19
  3. Set `BEATS_DIR` to your Beads workspace (for example `~/.niahere/beads`).
20
20
  4. All commands: `cd "$BEATS_DIR" && bd <command>`.
21
21
  5. Always label with `--label project:<name>`.
22
- 6. Run `cd "$BEATS_DIR" && bd help-all` for available commands.
22
+ 6. Run `cd "$BEATS_DIR" && bd --help` or `bd help --all` for available commands.
23
23
 
24
24
  ## Core Commands
25
25
 
@@ -53,6 +53,8 @@ bd update <id> --status in_progress # Start work
53
53
  bd update <id> --description "..." # Add/replace description
54
54
  bd update <id> --add-label personal # Add label
55
55
  bd update <id> --set-labels bug,urgent # Replace all labels
56
+ bd update <id> --claim # Atomically claim work
57
+ bd update <id> --set-metadata team=platform # Set task-scoped metadata
56
58
  ```
57
59
 
58
60
  Chain multiple updates: `bd update <id> --priority P1 --type bug --parent <parent-id>`
@@ -63,7 +65,11 @@ Chain multiple updates: `bd update <id> --priority P1 --type bug --parent <paren
63
65
  bd list # Open tasks (tree view)
64
66
  bd list --all # Include closed/deferred tasks
65
67
  bd list --label project:<name> # Filter by project
68
+ bd ready # Ready work with blocker-aware semantics
69
+ bd ready --claim # Atomically claim the first matching ready issue
66
70
  bd show <id> # Full details of a task
71
+ bd show <id> --long # Full details, including extended metadata
72
+ bd show --current --long # Current/last touched issue with metadata
67
73
  bd children <id> # List children of a parent
68
74
  ```
69
75
 
@@ -88,6 +94,57 @@ bd reopen <id> # Reopen if closed prematurely
88
94
  - Ephemeral/conversation-only tracking → use conversation context, not beads
89
95
  - `bd set-state ... state=...` is for operational metadata only; it does not change the task status shown in list.
90
96
 
97
+ ## Agent Session Tracking
98
+
99
+ When a Beads task is worked in Claude Code, Codex, or another agent CLI, store the active session on the task as metadata. Do not invent session IDs yourself; let the tool create the session, then attach the discovered session ID to the bead.
100
+
101
+ Use one shared metadata schema for all tools:
102
+
103
+ ```bash
104
+ session_tool=codex|claude
105
+ session_id=<tool-created-session-id>
106
+ session_cwd=<absolute repo/worktree path>
107
+ session_resume_cmd=<exact resume command>
108
+ session_attached_at=<ISO timestamp>
109
+ ```
110
+
111
+ Attach a session after starting or identifying it:
112
+
113
+ ```bash
114
+ cd "$BEATS_DIR"
115
+ bd update <id> --claim
116
+ bd update <id> \
117
+ --set-metadata session_tool=codex \
118
+ --set-metadata session_id="$sid" \
119
+ --set-metadata session_cwd="$PWD" \
120
+ --set-metadata session_resume_cmd="cd $PWD && codex resume $sid" \
121
+ --set-metadata session_attached_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
122
+ bd note <id> "Attached codex session $sid"
123
+ ```
124
+
125
+ For Claude, use the same keys and a Claude resume command:
126
+
127
+ ```bash
128
+ bd update <id> \
129
+ --set-metadata session_tool=claude \
130
+ --set-metadata session_id="$sid" \
131
+ --set-metadata session_cwd="$PWD" \
132
+ --set-metadata session_resume_cmd="cd $PWD && claude --resume $sid" \
133
+ --set-metadata session_attached_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
134
+ ```
135
+
136
+ Find session-backed tasks:
137
+
138
+ ```bash
139
+ bd list --has-metadata-key session_id --all --long
140
+ bd list --metadata-field session_tool=codex --all --long
141
+ bd list --metadata-field session_tool=claude --all --long
142
+ bd show <id> --long
143
+ bd show --current --long
144
+ ```
145
+
146
+ Use task metadata as the source of truth. `bd kv` is global and not task-scoped, so do not use it for task sessions. `bd audit` is append-only history, not a jump table. Notes/comments are useful human breadcrumbs, but the resume command and session ID should live in metadata.
147
+
91
148
  ## Hierarchy & Organization
92
149
 
93
150
  ### When to use parent-child vs labels
@@ -49,6 +49,7 @@ This:
49
49
  - watches the Chrome process; when Chrome exits, commits the run profile back to the canonical profile and removes the run clone
50
50
 
51
51
  Each concurrent `open` gets its own user-data dir and CDP URL.
52
+ The Chrome process is detached from the invoking shell, so it stays open across agent turn boundaries, Slack replies, and manual verification-code pauses. Reconnect later with the printed `PW_CDP_URL` or retrieve it with `status --run-id <run-id>`.
52
53
 
53
54
  Attach with Playwright when needed:
54
55
 
@@ -86,6 +87,7 @@ skills/qa/scripts/playwright-profile-clone.sh prepare
86
87
  skills/qa/scripts/playwright-profile-clone.sh open
87
88
  skills/qa/scripts/playwright-profile-clone.sh open --discard-on-close
88
89
  skills/qa/scripts/playwright-profile-clone.sh open --keep
90
+ skills/qa/scripts/playwright-profile-clone.sh close --run-id <run-id> --wait
89
91
  skills/qa/scripts/playwright-profile-clone.sh status --run-id <run-id>
90
92
  skills/qa/scripts/playwright-profile-clone.sh commit --run-id <run-id>
91
93
  skills/qa/scripts/playwright-profile-clone.sh cleanup --run-id <run-id>
@@ -93,6 +95,7 @@ skills/qa/scripts/playwright-profile-clone.sh prune --keep 100
93
95
  ```
94
96
 
95
97
  The helper auto-prunes old run profiles after `prepare`/`open`. Default cap is `100` run dirs. Override it with `PLAYWRIGHT_PROFILE_MAX_RUNS=<count>`, or disable automatic pruning with `PLAYWRIGHT_PROFILE_MAX_RUNS=0` or `PLAYWRIGHT_PROFILE_MAX_RUNS=off`. Pruning skips the current run and any run with a tracked live Chrome PID.
98
+ When browser work is complete, call `close --run-id <run-id> --wait`; this terminates the tracked Chrome process and lets the configured close behavior commit or discard the run.
96
99
 
97
100
  ## Quickstart: Open a Browser
98
101
 
@@ -15,6 +15,7 @@ usage() {
15
15
  Usage:
16
16
  playwright-profile-clone.sh prepare [--run-id <hex>] [--primary <path>]
17
17
  playwright-profile-clone.sh open [--run-id <hex>] [--primary <path>] [--commit-on-close|--discard-on-close|--keep]
18
+ playwright-profile-clone.sh close [--run-id <hex>] [--wait]
18
19
  playwright-profile-clone.sh commit [--run-id <hex>]
19
20
  playwright-profile-clone.sh cleanup [--run-id <hex>]
20
21
  playwright-profile-clone.sh prune [--keep <count>|--off]
@@ -384,7 +385,7 @@ cmd_open() {
384
385
  chrome="$(chrome_path)"
385
386
  log_file="$RUNS_DIR/$run_id.chrome.log"
386
387
 
387
- "$chrome" \
388
+ nohup "$chrome" \
388
389
  --user-data-dir="$run_dir" \
389
390
  --remote-debugging-port="$port" \
390
391
  --no-first-run \
@@ -439,18 +440,24 @@ start_close_watchdog() {
439
440
 
440
441
  [ "$close_action" != "keep" ] || return 0
441
442
 
442
- (
443
+ nohup bash -c '
444
+ script_path="$1"
445
+ run_id="$2"
446
+ chrome_pid="$3"
447
+ close_action="$4"
448
+ log_file="$5"
449
+
443
450
  while kill -0 "$chrome_pid" 2>/dev/null; do
444
451
  sleep 0.2
445
452
  done
446
453
 
447
454
  if [ "$close_action" = "commit" ]; then
448
- bash "$SCRIPT_PATH" commit --run-id "$run_id" --assume-closed >>"$log_file" 2>&1 &&
449
- bash "$SCRIPT_PATH" cleanup --run-id "$run_id" >>"$log_file" 2>&1
455
+ bash "$script_path" commit --run-id "$run_id" --assume-closed >>"$log_file" 2>&1 &&
456
+ bash "$script_path" cleanup --run-id "$run_id" >>"$log_file" 2>&1
450
457
  elif [ "$close_action" = "discard" ]; then
451
- bash "$SCRIPT_PATH" cleanup --run-id "$run_id" >>"$log_file" 2>&1
458
+ bash "$script_path" cleanup --run-id "$run_id" >>"$log_file" 2>&1
452
459
  fi
453
- ) >/dev/null 2>&1 &
460
+ ' _ "$SCRIPT_PATH" "$run_id" "$chrome_pid" "$close_action" "$log_file" >/dev/null 2>&1 &
454
461
  }
455
462
 
456
463
  cmd_commit() {
@@ -470,6 +477,49 @@ cmd_commit() {
470
477
  commit_profile "$run_id" "$allow_running"
471
478
  }
472
479
 
480
+ cmd_close() {
481
+ local run_id_arg=""
482
+ local wait_for_cleanup="false"
483
+ while [ "$#" -gt 0 ]; do
484
+ case "$1" in
485
+ --run-id) run_id_arg="${2:-}"; shift 2 ;;
486
+ --wait) wait_for_cleanup="true"; shift ;;
487
+ -h|--help) usage; exit 0 ;;
488
+ *) die "unknown close arg: $1" ;;
489
+ esac
490
+ done
491
+
492
+ local run_id
493
+ run_id="$(resolve_run_id_arg "$run_id_arg")"
494
+ load_state "$run_id"
495
+
496
+ [ -n "${PW_CHROME_PID:-}" ] || die "run id $run_id has no tracked Chrome PID"
497
+
498
+ if kill -0 "$PW_CHROME_PID" 2>/dev/null; then
499
+ kill "$PW_CHROME_PID" 2>/dev/null || true
500
+ echo "status=closing"
501
+ else
502
+ echo "status=already_closed"
503
+ fi
504
+ echo "run_id=$run_id"
505
+
506
+ if [ "$wait_for_cleanup" = "true" ]; then
507
+ local deadline=$((SECONDS + 30))
508
+ if [ "${PW_PROFILE_CLOSE_ACTION:-manual}" = "keep" ]; then
509
+ while kill -0 "$PW_CHROME_PID" 2>/dev/null && [ "$SECONDS" -lt "$deadline" ]; do
510
+ sleep 0.2
511
+ done
512
+ kill -0 "$PW_CHROME_PID" 2>/dev/null && die "timed out waiting for browser to close for run id $run_id"
513
+ else
514
+ while [ -e "$(state_file "$run_id")" ] && [ "$SECONDS" -lt "$deadline" ]; do
515
+ sleep 0.2
516
+ done
517
+ [ ! -e "$(state_file "$run_id")" ] || die "timed out waiting for close handling for run id $run_id"
518
+ fi
519
+ echo "status=closed"
520
+ fi
521
+ }
522
+
473
523
  cmd_cleanup() {
474
524
  local run_id_arg=""
475
525
  while [ "$#" -gt 0 ]; do
@@ -523,6 +573,7 @@ main() {
523
573
  case "$command" in
524
574
  prepare) cmd_prepare "$@" ;;
525
575
  open) cmd_open "$@" ;;
576
+ close) cmd_close "$@" ;;
526
577
  commit) cmd_commit "$@" ;;
527
578
  cleanup) cmd_cleanup "$@" ;;
528
579
  prune) cmd_prune "$@" ;;