niahere 0.2.87 → 0.2.88
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
package/skills/qa/playwright.md
CHANGED
|
@@ -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 "$
|
|
449
|
-
bash "$
|
|
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 "$
|
|
458
|
+
bash "$script_path" cleanup --run-id "$run_id" >>"$log_file" 2>&1
|
|
452
459
|
fi
|
|
453
|
-
|
|
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 "$@" ;;
|