@generativereality/browser-automation 0.4.14 → 0.4.16
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/.claude-plugin/plugin.json +3 -2
- package/LICENSE +21 -0
- package/README.md +10 -4
- package/dist/index.js +88 -3
- package/package.json +2 -2
- package/scripts/release.sh +189 -0
- package/scripts/sync-plugin.sh +37 -5
- package/skills/browser/SKILL.md +67 -356
- package/skills/browser/references/contributing.md +36 -0
- package/skills/browser/references/input-and-forms.md +137 -0
- package/skills/browser/references/renderer-health.md +213 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-automation",
|
|
3
3
|
"description": "Daemonless, per-tab-isolated browser automation for Claude Code via the `browser-automation` CLI. Drives one shared headed Chrome (persistent profile + extensions) over per-target CDP — many parallel sessions, no focus stealing, nothing long-lived to crash.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.16",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "generativereality"
|
|
7
7
|
},
|
|
8
|
-
"homepage": "https://github.com/generativereality/browser-automation"
|
|
8
|
+
"homepage": "https://github.com/generativereality/browser-automation",
|
|
9
|
+
"license": "MIT"
|
|
9
10
|
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 generativereality
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -42,11 +42,16 @@ browser-automation doctor # verify (incl. renderer capacity)
|
|
|
42
42
|
Claude Code skill (so the agent knows how to use it):
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
mkdir -p .claude/skills/browser
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
mkdir -p .claude/skills/browser/references
|
|
46
|
+
base=https://raw.githubusercontent.com/generativereality/browser-automation/master/skills/browser
|
|
47
|
+
for f in SKILL.md references/input-and-forms.md references/renderer-health.md references/contributing.md; do
|
|
48
|
+
curl -fsSL "$base/$f" -o ".claude/skills/browser/$f"
|
|
49
|
+
done
|
|
48
50
|
```
|
|
49
51
|
|
|
52
|
+
The skill is `SKILL.md` plus the `references/` files it points to for the long
|
|
53
|
+
troubleshooting and hard cases; copy all of them.
|
|
54
|
+
|
|
50
55
|
…or install the plugin from the marketplace:
|
|
51
56
|
|
|
52
57
|
```bash
|
|
@@ -181,8 +186,9 @@ same one-action-per-snapshot rule as Playwright refs.
|
|
|
181
186
|
`doctor` prints it too, and warns if another user holds it.
|
|
182
187
|
- `BROWSER_AUTOMATION_CDP` — full CDP host, overriding the port entirely.
|
|
183
188
|
- `BROWSER_AUTOMATION_PROFILE` — Chrome profile dir for `launch`. Default `~/.browser-automation/chrome-profile`; a profile still at the old location inside Chrome's own folder is moved there on launch (`browser-automation profile --migrate` to do it by hand).
|
|
189
|
+
- `BAC_SHOW_TAB=1` — `--show` on every `goto`/`new`: select the tab in its window when the automation Chrome is already in front (never raises Chrome over another app).
|
|
184
190
|
- `BAC_SESSION` — default session name for page commands.
|
|
185
191
|
|
|
186
192
|
## License
|
|
187
193
|
|
|
188
|
-
MIT
|
|
194
|
+
MIT — see [`LICENSE`](LICENSE).
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { execFileSync, spawnSync } from "node:child_process";
|
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
//#region package.json
|
|
11
11
|
var name = "@generativereality/browser-automation";
|
|
12
|
-
var version = "0.4.
|
|
12
|
+
var version = "0.4.16";
|
|
13
13
|
var description = "Daemonless, per-tab-isolated browser automation CLI for Claude Code. Drives one shared headed Chrome (persistent profile + extensions) over per-target CDP — many parallel sessions, no focus stealing, nothing long-lived to crash.";
|
|
14
14
|
var package_default = {
|
|
15
15
|
name,
|
|
@@ -29,7 +29,7 @@ var package_default = {
|
|
|
29
29
|
"typecheck": "tsc --noEmit",
|
|
30
30
|
"check": "npm run typecheck && bash scripts/check-one-port.sh && npm run build && npm test",
|
|
31
31
|
"test": "node --test \"test/**/*.test.mjs\"",
|
|
32
|
-
"release": "
|
|
32
|
+
"release": "bash scripts/release.sh",
|
|
33
33
|
"sync-plugin": "bash scripts/sync-plugin.sh",
|
|
34
34
|
"prepack": "npm run build"
|
|
35
35
|
},
|
|
@@ -918,6 +918,10 @@ function chromeProcesses() {
|
|
|
918
918
|
renderers
|
|
919
919
|
};
|
|
920
920
|
}
|
|
921
|
+
/** The pid of the browser process serving the port we are driving, if visible. */
|
|
922
|
+
function browserPid() {
|
|
923
|
+
return chromeProcesses().browser;
|
|
924
|
+
}
|
|
921
925
|
/**
|
|
922
926
|
* macOS only: is the browser's Mach port rendezvous service still registered?
|
|
923
927
|
*
|
|
@@ -1094,6 +1098,68 @@ async function withRendererDiagnosis(fn) {
|
|
|
1094
1098
|
}
|
|
1095
1099
|
}
|
|
1096
1100
|
//#endregion
|
|
1101
|
+
//#region src/core/show.ts
|
|
1102
|
+
/** On for this command: `--show`, or `BAC_SHOW_TAB=1` set once by a skill. */
|
|
1103
|
+
function wantsShow(flag) {
|
|
1104
|
+
return flag === true || /^(1|true|yes|on)$/i.test(process.env.BAC_SHOW_TAB ?? "");
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Is the Chrome we drive the frontmost app? `null` when this platform cannot
|
|
1108
|
+
* say — which must not be treated as "yes".
|
|
1109
|
+
*
|
|
1110
|
+
* `lsappinfo`, not AppleScript: it needs no Accessibility or Automation grant,
|
|
1111
|
+
* and a permission dialog mid-command is worse than the problem.
|
|
1112
|
+
*/
|
|
1113
|
+
function ourChromeIsFrontmost() {
|
|
1114
|
+
const injected = process.env.BROWSER_AUTOMATION_TEST_FRONTMOST;
|
|
1115
|
+
if (injected) return injected === "chrome";
|
|
1116
|
+
if (process.platform !== "darwin") return null;
|
|
1117
|
+
try {
|
|
1118
|
+
const asn = execFileSync("lsappinfo", ["front"], {
|
|
1119
|
+
encoding: "utf8",
|
|
1120
|
+
stdio: [
|
|
1121
|
+
"ignore",
|
|
1122
|
+
"pipe",
|
|
1123
|
+
"ignore"
|
|
1124
|
+
]
|
|
1125
|
+
}).trim();
|
|
1126
|
+
if (!asn) return null;
|
|
1127
|
+
const info = execFileSync("lsappinfo", [
|
|
1128
|
+
"info",
|
|
1129
|
+
"-only",
|
|
1130
|
+
"pid",
|
|
1131
|
+
asn
|
|
1132
|
+
], {
|
|
1133
|
+
encoding: "utf8",
|
|
1134
|
+
stdio: [
|
|
1135
|
+
"ignore",
|
|
1136
|
+
"pipe",
|
|
1137
|
+
"ignore"
|
|
1138
|
+
]
|
|
1139
|
+
});
|
|
1140
|
+
const front = Number(/pid\s*=\s*(\d+)/.exec(info)?.[1]);
|
|
1141
|
+
const ours = browserPid();
|
|
1142
|
+
if (!front || !ours) return null;
|
|
1143
|
+
return front === ours;
|
|
1144
|
+
} catch {
|
|
1145
|
+
return null;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
/** Select `targetId` in its window if, and only if, that raises nothing. */
|
|
1149
|
+
async function showTab(targetId) {
|
|
1150
|
+
const front = ourChromeIsFrontmost();
|
|
1151
|
+
if (front === null) return "unsupported";
|
|
1152
|
+
if (!front) return "not-frontmost";
|
|
1153
|
+
await activateTab(targetId);
|
|
1154
|
+
return "shown";
|
|
1155
|
+
}
|
|
1156
|
+
/** One line for the agent when it asked and did not get it — never silent, never loud. */
|
|
1157
|
+
function describeNotShown(outcome) {
|
|
1158
|
+
if (outcome === "not-frontmost") return "Tab not shown: another app (or another Chrome) is in front, and --show never brings this Chrome over it. It selects the tab once the automation Chrome is in front.";
|
|
1159
|
+
if (outcome === "unsupported") return "Tab not shown: cannot tell which app is in front here (macOS only), so --show did nothing rather than risk taking the screen.";
|
|
1160
|
+
return null;
|
|
1161
|
+
}
|
|
1162
|
+
//#endregion
|
|
1097
1163
|
//#region src/commands/new.ts
|
|
1098
1164
|
const newCommand = define({
|
|
1099
1165
|
name: "new",
|
|
@@ -1108,6 +1174,10 @@ const newCommand = define({
|
|
|
1108
1174
|
type: "boolean",
|
|
1109
1175
|
short: "f",
|
|
1110
1176
|
description: "Open a new tab even if the session already has one"
|
|
1177
|
+
},
|
|
1178
|
+
show: {
|
|
1179
|
+
type: "boolean",
|
|
1180
|
+
description: "Make this the SELECTED tab in its Chrome window, so someone watching Chrome sees it — only when the automation Chrome is already the frontmost app, so it never brings Chrome over another app. Default on with BAC_SHOW_TAB=1."
|
|
1111
1181
|
}
|
|
1112
1182
|
},
|
|
1113
1183
|
async run(ctx) {
|
|
@@ -1131,7 +1201,14 @@ const newCommand = define({
|
|
|
1131
1201
|
}
|
|
1132
1202
|
consola$1.warn(`[${name}] tab ${targetId.slice(0, 12)}… did not answer yet (${r.reason ?? r.outcome}). Chrome can still create renderers, so this is likely transient — retry the next command.`);
|
|
1133
1203
|
}
|
|
1134
|
-
|
|
1204
|
+
let shown = false;
|
|
1205
|
+
if (wantsShow(ctx.values.show)) {
|
|
1206
|
+
const outcome = await showTab(targetId).catch(() => "unsupported");
|
|
1207
|
+
shown = outcome === "shown";
|
|
1208
|
+
const note = describeNotShown(outcome);
|
|
1209
|
+
if (note) consola$1.info(note);
|
|
1210
|
+
}
|
|
1211
|
+
consola$1.success(`[${name}] opened ${shown ? "and showed" : "background"} tab ${targetId.slice(0, 12)}… → ${url}`);
|
|
1135
1212
|
}
|
|
1136
1213
|
});
|
|
1137
1214
|
//#endregion
|
|
@@ -1236,6 +1313,10 @@ const gotoCommand = define({
|
|
|
1236
1313
|
url: {
|
|
1237
1314
|
type: "positional",
|
|
1238
1315
|
description: "URL to navigate to"
|
|
1316
|
+
},
|
|
1317
|
+
show: {
|
|
1318
|
+
type: "boolean",
|
|
1319
|
+
description: "Make this the SELECTED tab in its Chrome window, so someone watching Chrome sees it — only when the automation Chrome is already the frontmost app, so it never brings Chrome over another app. Default on with BAC_SHOW_TAB=1."
|
|
1239
1320
|
}
|
|
1240
1321
|
},
|
|
1241
1322
|
async run(ctx) {
|
|
@@ -1251,6 +1332,10 @@ const gotoCommand = define({
|
|
|
1251
1332
|
if ((await ensureRenderer(targetId)).woke) consola$1.warn("The new tab's renderer did not start on its own, so the tab was activated briefly to force one. The Chrome window was raised and handed straight back.");
|
|
1252
1333
|
}
|
|
1253
1334
|
if (!(await withRendererDiagnosis(() => navigate(targetId, target))).loaded) consola$1.warn("No load event arrived, so the page may still be loading. The navigation itself was accepted; this is a statement about what could not be confirmed.");
|
|
1335
|
+
if (wantsShow(ctx.values.show)) {
|
|
1336
|
+
const note = describeNotShown(await showTab(targetId).catch(() => "unsupported"));
|
|
1337
|
+
if (note) consola$1.info(note);
|
|
1338
|
+
}
|
|
1254
1339
|
if (!opts.match && !opts.target) {
|
|
1255
1340
|
const name = opts.session || defaultSessionName();
|
|
1256
1341
|
saveSession({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@generativereality/browser-automation",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.16",
|
|
4
4
|
"description": "Daemonless, per-tab-isolated browser automation CLI for Claude Code. Drives one shared headed Chrome (persistent profile + extensions) over per-target CDP — many parallel sessions, no focus stealing, nothing long-lived to crash.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"typecheck": "tsc --noEmit",
|
|
19
19
|
"check": "npm run typecheck && bash scripts/check-one-port.sh && npm run build && npm test",
|
|
20
20
|
"test": "node --test \"test/**/*.test.mjs\"",
|
|
21
|
-
"release": "
|
|
21
|
+
"release": "bash scripts/release.sh",
|
|
22
22
|
"sync-plugin": "bash scripts/sync-plugin.sh",
|
|
23
23
|
"prepack": "npm run build"
|
|
24
24
|
},
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Cut a release. Two halves, with the human approval gate between them.
|
|
3
|
+
#
|
|
4
|
+
# scripts/release.sh plan # what would ship since the last tag; changes nothing
|
|
5
|
+
# scripts/release.sh cut <patch|minor|X.Y.Z> [--dry-run]
|
|
6
|
+
# # bump, check, commit onto master, tag, push the tag
|
|
7
|
+
# scripts/release.sh finish # after the run is APPROVED: wait for npm, sync the
|
|
8
|
+
# # plugin, update this machine's install
|
|
9
|
+
#
|
|
10
|
+
# Why a script: every release in September 2026 was improvised from CLAUDE.md
|
|
11
|
+
# prose, and each one hit something the prose did not say — local master
|
|
12
|
+
# checked out in another worktree, a plugin sync rejected because another plugin
|
|
13
|
+
# had synced first, `npm view` reporting the old version for minutes after a
|
|
14
|
+
# successful publish. The steps are mechanical; the JUDGEMENT (which version,
|
|
15
|
+
# whether to approve) is not, so the script does the first and refuses to do
|
|
16
|
+
# the second.
|
|
17
|
+
#
|
|
18
|
+
# It never approves the gated CI run. Approval belongs to the maintainer, and
|
|
19
|
+
# `gh api .../pending_deployments` CAN do it from here — which is exactly why
|
|
20
|
+
# a script must not: see CLAUDE.md, "Releasing".
|
|
21
|
+
set -euo pipefail
|
|
22
|
+
|
|
23
|
+
cd "$(dirname "$0")/.."
|
|
24
|
+
ROOT="$(pwd)"
|
|
25
|
+
# What gets released. Only ever origin/master for real; overridable so a dry run
|
|
26
|
+
# can be tested against a branch that has something unreleased on it.
|
|
27
|
+
BASE="${BA_RELEASE_BASE:-origin/master}"
|
|
28
|
+
REPO=generativereality/browser-automation
|
|
29
|
+
PKG=@generativereality/browser-automation
|
|
30
|
+
|
|
31
|
+
die() { echo "Error: $*" >&2; exit 1; }
|
|
32
|
+
say() { printf '\n== %s\n' "$*"; }
|
|
33
|
+
|
|
34
|
+
last_tag() { git -C "$ROOT" describe --tags --abbrev=0 "$BASE" 2>/dev/null || true; }
|
|
35
|
+
|
|
36
|
+
plan() {
|
|
37
|
+
git fetch -q origin --tags
|
|
38
|
+
local tag; tag="$(last_tag)"
|
|
39
|
+
[ -n "$tag" ] || die "no release tag reachable from origin/master"
|
|
40
|
+
say "Unreleased on $BASE since $tag"
|
|
41
|
+
git log --format=' %h %s' "$tag..$BASE"
|
|
42
|
+
[ -n "$(git log --format=%h "$tag..$BASE")" ] || { echo " (nothing)"; return 0; }
|
|
43
|
+
say "Files touched"
|
|
44
|
+
git diff --stat "$tag..$BASE" | tail -n 25
|
|
45
|
+
say "Decide the version (CLAUDE.md, Versioning policy)"
|
|
46
|
+
cat <<'TXT'
|
|
47
|
+
minor if ANY of these shipped, even inside a "fix":
|
|
48
|
+
- where the CLI keeps or reads user data (profile, sessions, downloads), or a migration of it
|
|
49
|
+
- a changed default, flag meaning, exit code, or output a script might parse
|
|
50
|
+
- anything a user may need to act on after upgrading
|
|
51
|
+
otherwise patch (fixes, and commands that complete the CLI).
|
|
52
|
+
Name it to the maintainer with the reason, and get a yes, before `cut`.
|
|
53
|
+
TXT
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
cut() {
|
|
57
|
+
local want="${1:-}" dry="${2:-}"
|
|
58
|
+
[ -n "$want" ] || die "cut needs patch, minor or X.Y.Z — the version is a decision, not a default"
|
|
59
|
+
git fetch -q origin --tags
|
|
60
|
+
|
|
61
|
+
# Build the release from origin/master exactly, in a throwaway worktree:
|
|
62
|
+
# this checkout is shared with other sessions and local master usually lives
|
|
63
|
+
# in another worktree, so neither "the current branch" nor "master" is safe
|
|
64
|
+
# to assume.
|
|
65
|
+
# Global, not `local`: the EXIT trap runs after this function has returned.
|
|
66
|
+
RELEASE_WT="$(mktemp -d "${TMPDIR:-/tmp}/ba-release.XXXXXX")"
|
|
67
|
+
git worktree add -q --detach "$RELEASE_WT" "$BASE"
|
|
68
|
+
trap 'cd "$ROOT"; git worktree remove --force "$RELEASE_WT" >/dev/null 2>&1 || true' EXIT
|
|
69
|
+
cd "$RELEASE_WT"
|
|
70
|
+
|
|
71
|
+
local cur; cur="$(node -p "require('./package.json').version")"
|
|
72
|
+
local plug; plug="$(node -p "require('./.claude-plugin/plugin.json').version")"
|
|
73
|
+
[ "$cur" = "$plug" ] || die "package.json ($cur) and plugin.json ($plug) disagree on origin/master"
|
|
74
|
+
local next
|
|
75
|
+
case "$want" in
|
|
76
|
+
patch) next="$(node -p "v='$cur'.split('.').map(Number);v[2]++;v.join('.')")" ;;
|
|
77
|
+
minor) next="$(node -p "v='$cur'.split('.').map(Number);v[1]++;v[2]=0;v.join('.')")" ;;
|
|
78
|
+
[0-9]*.[0-9]*.[0-9]*) next="$want" ;;
|
|
79
|
+
*) die "unknown version '$want'" ;;
|
|
80
|
+
esac
|
|
81
|
+
git rev-parse -q --verify "refs/tags/v$next" >/dev/null && die "v$next already exists"
|
|
82
|
+
[ -z "$(git log --format=%h "$(last_tag)..HEAD")" ] && die "nothing unreleased since $(last_tag)"
|
|
83
|
+
|
|
84
|
+
say "Releasing $cur -> $next"
|
|
85
|
+
git log --format=' %h %s' "$(last_tag)..HEAD"
|
|
86
|
+
|
|
87
|
+
node -e "
|
|
88
|
+
const fs=require('fs');
|
|
89
|
+
for (const f of ['package.json','.claude-plugin/plugin.json']) {
|
|
90
|
+
const s=fs.readFileSync(f,'utf8'), t=s.replace(/(\"version\":\s*\")$cur(\")/, '\$1$next\$2');
|
|
91
|
+
if (s===t) { console.error('no version to bump in '+f); process.exit(1) }
|
|
92
|
+
fs.writeFileSync(f,t)
|
|
93
|
+
}"
|
|
94
|
+
npm install --package-lock-only --silent >/dev/null 2>&1 || true
|
|
95
|
+
|
|
96
|
+
say "npm ci + npm run check"
|
|
97
|
+
npm ci --silent >/dev/null
|
|
98
|
+
local log; log="$(mktemp "${TMPDIR:-/tmp}/ba-check.XXXXXX")"
|
|
99
|
+
npm run check >"$log" 2>&1 || {
|
|
100
|
+
tail -n 30 "$log" >&2
|
|
101
|
+
echo "" >&2
|
|
102
|
+
echo "npm run check failed (full log: $log). If it is the renderer-health tests, a busy" >&2
|
|
103
|
+
echo "Chrome on this user's port can fail them locally (CLAUDE.md, Dev gotchas) — compare" >&2
|
|
104
|
+
echo "against master under the same conditions before believing it." >&2
|
|
105
|
+
exit 1
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
git add package.json .claude-plugin/plugin.json package-lock.json
|
|
109
|
+
git commit -q -m "release: v$next"
|
|
110
|
+
git tag -a "v$next" -m "v$next"
|
|
111
|
+
|
|
112
|
+
if [ "$dry" = "--dry-run" ]; then
|
|
113
|
+
# Tags are shared by every worktree of this repo — leave none behind.
|
|
114
|
+
git tag -d "v$next" >/dev/null
|
|
115
|
+
say "Dry run: would push $(git rev-parse --short HEAD) to master and tag v$next. Nothing pushed, no tag kept."
|
|
116
|
+
return 0
|
|
117
|
+
fi
|
|
118
|
+
[ "$BASE" = "origin/master" ] || die "BA_RELEASE_BASE is for --dry-run only"
|
|
119
|
+
# Fast-forward only: if master moved while this ran, stop and re-plan rather
|
|
120
|
+
# than release something nobody looked at.
|
|
121
|
+
git push -q origin "HEAD:refs/heads/master" || die "master moved (push was not a fast-forward). Run plan again."
|
|
122
|
+
git push -q origin "v$next"
|
|
123
|
+
|
|
124
|
+
say "Tag v$next pushed. The release run is now WAITING FOR APPROVAL:"
|
|
125
|
+
sleep 5
|
|
126
|
+
gh run list --repo "$REPO" --workflow release.yml --limit 1 --json url,status --jq '.[0] | " \(.url) (\(.status))"' || true
|
|
127
|
+
cat <<TXT
|
|
128
|
+
|
|
129
|
+
Approving is the maintainer's call. Ask them to approve it there — or approve it
|
|
130
|
+
yourself only if they told you to for THIS release. Then: scripts/release.sh finish
|
|
131
|
+
TXT
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
finish() {
|
|
135
|
+
git fetch -q origin --tags
|
|
136
|
+
local tag; tag="$(last_tag)"; local v="${tag#v}"
|
|
137
|
+
local run; run="$(gh run list --repo "$REPO" --workflow release.yml --branch "$tag" --limit 1 --json databaseId --jq '.[0].databaseId')"
|
|
138
|
+
[ -n "$run" ] || die "no release run for $tag"
|
|
139
|
+
|
|
140
|
+
say "Waiting for the release run of $tag"
|
|
141
|
+
local s
|
|
142
|
+
for _ in $(seq 1 90); do
|
|
143
|
+
s="$(gh run view "$run" --repo "$REPO" --json status,conclusion --jq '.status+" "+.conclusion')"
|
|
144
|
+
case "$s" in
|
|
145
|
+
"completed success") break ;;
|
|
146
|
+
completed*) die "release run $run finished: $s — $(gh run view "$run" --repo "$REPO" --json url --jq .url)" ;;
|
|
147
|
+
waiting*) echo " still waiting for approval…" ;;
|
|
148
|
+
esac
|
|
149
|
+
sleep 10
|
|
150
|
+
done
|
|
151
|
+
[ "$s" = "completed success" ] || die "release run did not finish in 15 minutes"
|
|
152
|
+
|
|
153
|
+
# The registry, not `npm view`: publishing reports success minutes before
|
|
154
|
+
# the version is served (3.5 min for 0.4.13), and `npm view` also caches.
|
|
155
|
+
say "Waiting for $v on the registry"
|
|
156
|
+
local name="${PKG/\//%2F}"
|
|
157
|
+
for _ in $(seq 1 60); do
|
|
158
|
+
[ "$(curl -s -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/$name/$v")" = 200 ] && break
|
|
159
|
+
sleep 10
|
|
160
|
+
done
|
|
161
|
+
[ "$(curl -s -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/$name/$v")" = 200 ] || die "$v not on the registry after 10 minutes"
|
|
162
|
+
echo " $PKG@$v is live"
|
|
163
|
+
|
|
164
|
+
say "Plugin marketplace"
|
|
165
|
+
# Sync from the released tag, not from whatever this checkout has.
|
|
166
|
+
RELEASE_WT="$(mktemp -d "${TMPDIR:-/tmp}/ba-finish.XXXXXX")"
|
|
167
|
+
git worktree add -q --detach "$RELEASE_WT" "$tag"
|
|
168
|
+
trap 'cd "$ROOT"; git worktree remove --force "$RELEASE_WT" >/dev/null 2>&1 || true' EXIT
|
|
169
|
+
# This checkout's script (an old tag's copy lacks its fixes), the tag's files.
|
|
170
|
+
BA_PLUGIN_SOURCE="$RELEASE_WT" bash "$ROOT/scripts/sync-plugin.sh"
|
|
171
|
+
|
|
172
|
+
say "This machine"
|
|
173
|
+
npm install -g "$PKG@$v" >/dev/null 2>&1 && echo " installed $(browser-automation --version)"
|
|
174
|
+
|
|
175
|
+
say "Downstream — not done by this script"
|
|
176
|
+
cat <<TXT
|
|
177
|
+
- rememberthis.ai vendors the skill: python3 scripts/sync-vendored-skills.py --update
|
|
178
|
+
there, re-read its LOCAL block, commit that one file (other sessions work in that
|
|
179
|
+
repo — do not sweep up their changes).
|
|
180
|
+
- Tell the maintainer anything a user must act on (a moved profile, a changed default).
|
|
181
|
+
TXT
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
case "${1:-}" in
|
|
185
|
+
plan) plan ;;
|
|
186
|
+
cut) shift; cut "$@" ;;
|
|
187
|
+
finish) finish ;;
|
|
188
|
+
*) sed -n '2,8p' "$0"; exit 1 ;;
|
|
189
|
+
esac
|
package/scripts/sync-plugin.sh
CHANGED
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
set -euo pipefail
|
|
10
10
|
|
|
11
11
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
# Where the payload is copied FROM. Defaults to this checkout; `release.sh
|
|
13
|
+
# finish` points it at the released tag, so what ships is what was tagged —
|
|
14
|
+
# while still running THIS copy of the script (an old tag's copy lacks fixes).
|
|
15
|
+
REPO_ROOT="${BA_PLUGIN_SOURCE:-$(dirname "$SCRIPT_DIR")}"
|
|
16
|
+
PLUGINS_DIR="${BA_PLUGINS_DIR:-$(dirname "$SCRIPT_DIR")/../plugins}" # override for tests
|
|
14
17
|
CHECK_ONLY=false
|
|
15
18
|
[ "${1:-}" = "--check" ] && CHECK_ONLY=true
|
|
16
19
|
|
|
@@ -27,7 +30,13 @@ PAYLOAD_FILES=(
|
|
|
27
30
|
"skills/browser/SKILL.md"
|
|
28
31
|
".claude-plugin/plugin.json"
|
|
29
32
|
"scripts/launch-chrome.sh"
|
|
33
|
+
"LICENSE"
|
|
30
34
|
)
|
|
35
|
+
# SKILL.md links to these for its long reference material; a payload without
|
|
36
|
+
# them leaves the skill pointing at files that are not there.
|
|
37
|
+
for f in "$REPO_ROOT"/skills/browser/references/*.md; do
|
|
38
|
+
[ -e "$f" ] && PAYLOAD_FILES+=("skills/browser/references/$(basename "$f")")
|
|
39
|
+
done
|
|
31
40
|
|
|
32
41
|
for rel in "${PAYLOAD_FILES[@]}"; do
|
|
33
42
|
if ! diff -q "$REPO_ROOT/$rel" "$PLUGINS_DIR/plugins/browser-automation/$rel" >/dev/null 2>&1; then
|
|
@@ -56,13 +65,36 @@ done
|
|
|
56
65
|
rm -f "$PLUGINS_DIR/plugins/browser-automation/.mcp.json"
|
|
57
66
|
|
|
58
67
|
cd "$PLUGINS_DIR"
|
|
59
|
-
if git diff --quiet; then
|
|
68
|
+
if git diff --quiet -- plugins/browser-automation && [ -z "$(git ls-files --others --exclude-standard -- plugins/browser-automation)" ]; then
|
|
60
69
|
echo "Plugins repo already up to date"
|
|
61
70
|
exit 0
|
|
62
71
|
fi
|
|
63
72
|
|
|
73
|
+
# **Other plugins publish to this repo too.** The 0.4.14 sync was rejected
|
|
74
|
+
# because a cctabs sync had landed on origin/main in between — the marketplace
|
|
75
|
+
# is shared, so "behind origin" is the normal state, not an error. Commit ONLY
|
|
76
|
+
# our directory, then replay it on top of whatever arrived and push; our
|
|
77
|
+
# commit touches nothing outside plugins/browser-automation, so the rebase
|
|
78
|
+
# cannot conflict with another plugin's sync. It can conflict with a sync of
|
|
79
|
+
# THIS plugin from another checkout — then stop rather than guess.
|
|
80
|
+
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
|
81
|
+
if [ "$BRANCH" != "main" ]; then
|
|
82
|
+
echo "Error: plugins repo is on '$BRANCH', not main. Not syncing into a branch." >&2
|
|
83
|
+
exit 1
|
|
84
|
+
fi
|
|
85
|
+
VERSION="$(node -p "require('$REPO_ROOT/package.json').version" 2>/dev/null || echo '?')"
|
|
64
86
|
git add plugins/browser-automation
|
|
65
|
-
git commit -m "chore: sync browser-automation plugin"
|
|
66
|
-
|
|
87
|
+
git commit -q -m "chore: sync browser-automation plugin to $VERSION"
|
|
88
|
+
for attempt in 1 2 3; do
|
|
89
|
+
git fetch -q origin main
|
|
90
|
+
if ! git rebase -q origin/main; then
|
|
91
|
+
git rebase --abort
|
|
92
|
+
echo "Error: rebasing the sync onto origin/main conflicted — something else changed" >&2
|
|
93
|
+
echo " plugins/browser-automation. Resolve in $PLUGINS_DIR, then push." >&2
|
|
94
|
+
exit 1
|
|
95
|
+
fi
|
|
96
|
+
git push -q origin main && break
|
|
97
|
+
[ "$attempt" = 3 ] && { echo "Error: push kept being rejected; see $PLUGINS_DIR." >&2; exit 1; }
|
|
98
|
+
done
|
|
67
99
|
|
|
68
100
|
echo "Synced browser-automation to plugins repo"
|