@botbuddy/cli 1.123.2 → 1.123.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.123.3
4
+
5
+ - BOT-3667: a new Claude session in a reused worktree connects to BB at once. Claude Desktop reuses worktree folders, and the previous session's BB identity was treated as live for 30 minutes after its transcript was last written, so the new session's band showed "BB identity belongs to another session" and the SessionStart hook did not register it. `bb status-band read` and `bb bootstrap --type claude` now ask Claude's running-session registry (`~/.claude/sessions/<pid>.json`, kept only while a session's process runs): a holder with no entry for a live process has exited, and its cache is set aside at once. A holder that is still running is never taken over. A host with no readable registry, and a holder with no Claude transcript (another harness), keep the previous rules. The band (1.12.2) also retries recoverable identity failures (`session_mismatch`, `session_missing`, `session_bind_failed`, `session_renewal_failed`, `session_changed`) by itself on the same 30 s to 5 min backoff, so it binds once the other session exits. Configuration failures still wait for a fix.
6
+
3
7
  ## 1.123.2
4
8
 
5
9
  - BOT-3660: when staging is red, the bb-status band's `Open staging ↗` opens `/release-readiness/staging/sha/<red commit>?tenant=<tenant>`, the failing release in the tenant whose staging is red, instead of `/release-readiness/staging/latest` in whichever tenant the browser had active. `bb status-band read` passes the new `staging.red_sha` from `get_session_status` (a full SHA only); without one the link is `/release-readiness/staging/latest?tenant=<tenant>`. The plugin version moves to 1.12.1, so `bb update` installs it.
@@ -11,7 +11,7 @@
11
11
  "name": "bb-status",
12
12
  "source": "./bb-status",
13
13
  "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, for BotBuddy and Supply Guard sessions",
14
- "version": "1.12.1"
14
+ "version": "1.12.2"
15
15
  },
16
16
  {
17
17
  "name": "bb-session",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bb-status",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, live only while the session is on screen.",
5
5
  "author": {
6
6
  "name": "BotBuddy"
@@ -22,6 +22,11 @@ let relayFault = null;
22
22
  // BOT-3644 AC-4/5: a transient read failure keeps the last good snapshot on
23
23
  // screen (marked STALE with its code) and retries by itself with backoff.
24
24
  const TRANSIENT = new Set(["source_unreachable", "source_unavailable", "invalid_response", "status_unavailable"]);
25
+ // BOT-3667 AC-4: identity failures that clear on their own (another live session
26
+ // holds the worktree until it exits; a bind, renewal or read that raced) clear
27
+ // the drawn status, as any identity failure must, and retry on the same backoff.
28
+ const RECOVERABLE = new Set(["session_mismatch", "session_missing", "session_bind_failed", "session_renewal_failed", "session_changed"]);
29
+ const retries = (code) => TRANSIENT.has(code) || RECOVERABLE.has(code);
25
30
  const READ_RETRY_FIRST_MS = 30000;
26
31
  const READ_RETRY_MAX_MS = 300000;
27
32
  let readFault = null;
@@ -572,7 +577,7 @@ async function refresh($, { wake = false, keep = false } = {}) {
572
577
  snapshot = null;
573
578
  readFault = null;
574
579
  }
575
- if (TRANSIENT.has(errorCode)) retryRead($, request);
580
+ if (retries(errorCode)) retryRead($, request);
576
581
  else readBackoffMs = 0;
577
582
  // BOT-3222: the hook is still registering this session; read once more
578
583
  // when the adapter says, unless another read has started since.
@@ -607,7 +612,7 @@ function retryRead($, request) {
607
612
  const after = readBackoffMs;
608
613
  void (async () => {
609
614
  await delay($, after + 500);
610
- if (request !== generation || mode !== "live" || !TRANSIENT.has(errorCode)) return;
615
+ if (request !== generation || mode !== "live" || !retries(errorCode)) return;
611
616
  if (parked || !(await onScreen($))) {
612
617
  parked = true;
613
618
  return;
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.123.2",
3
- "source_commit": "d25543415cd188cd3ea7aa872a8d04501efa78af",
4
- "source_sha256": "5252d27b5e5d47d0f3ad937532c13d12f117a6b9f1b99e5746d3cdb84a74a8bf",
2
+ "release_version": "1.123.3",
3
+ "source_commit": "81598ae767d6a28ec5615319c87b45a56292c6ab",
4
+ "source_sha256": "dfda001e9197f3e42cc30d57a182f8b4d39adbc1cd21e3ffd4bef5764345f61d",
5
5
  "target": "darwin-arm64",
6
- "sha256": "e4ec497e30b860d9e3d3f470a066657e7d37d3196b47ed744d2b4e1b0dc34f49"
6
+ "sha256": "efddc5acb85b5f35ca797c9119dceb918ba618e14e445c62a4079db5a95abdc8"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.123.2",
3
- "source_commit": "d25543415cd188cd3ea7aa872a8d04501efa78af",
4
- "source_sha256": "5252d27b5e5d47d0f3ad937532c13d12f117a6b9f1b99e5746d3cdb84a74a8bf",
2
+ "release_version": "1.123.3",
3
+ "source_commit": "81598ae767d6a28ec5615319c87b45a56292c6ab",
4
+ "source_sha256": "dfda001e9197f3e42cc30d57a182f8b4d39adbc1cd21e3ffd4bef5764345f61d",
5
5
  "target": "linux-x64",
6
- "sha256": "9cb3ba6e0bb6a5c3b584942c8a0d5a6c98aebe88b4f3257ee34c3b8f8f2183b4"
6
+ "sha256": "e789286cb13b8220cf074c412d7f00c93d3d4795107f6ee89ba87b1723fb997f"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.123.2",
4
- "source_commit": "d25543415cd188cd3ea7aa872a8d04501efa78af",
5
- "source_sha256": "5252d27b5e5d47d0f3ad937532c13d12f117a6b9f1b99e5746d3cdb84a74a8bf",
3
+ "release_version": "1.123.3",
4
+ "source_commit": "81598ae767d6a28ec5615319c87b45a56292c6ab",
5
+ "source_sha256": "dfda001e9197f3e42cc30d57a182f8b4d39adbc1cd21e3ffd4bef5764345f61d",
6
6
  "targets": {
7
7
  "darwin-arm64": {
8
8
  "goos": "darwin",
9
9
  "goarch": "arm64",
10
10
  "binary": "daemon/bin/darwin-arm64/botbuddy-daemon",
11
- "sha256": "e4ec497e30b860d9e3d3f470a066657e7d37d3196b47ed744d2b4e1b0dc34f49",
11
+ "sha256": "efddc5acb85b5f35ca797c9119dceb918ba618e14e445c62a4079db5a95abdc8",
12
12
  "mode": "0755"
13
13
  },
14
14
  "linux-x64": {
15
15
  "goos": "linux",
16
16
  "goarch": "amd64",
17
17
  "binary": "daemon/bin/linux-x64/botbuddy-daemon",
18
- "sha256": "9cb3ba6e0bb6a5c3b584942c8a0d5a6c98aebe88b4f3257ee34c3b8f8f2183b4",
18
+ "sha256": "e789286cb13b8220cf074c412d7f00c93d3d4795107f6ee89ba87b1723fb997f",
19
19
  "mode": "0755"
20
20
  }
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbuddy/cli",
3
- "version": "1.123.2",
3
+ "version": "1.123.3",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -39,9 +39,64 @@ export async function worktreeHarnessSessionId(cwd, env = process.env) {
39
39
  }
40
40
  }
41
41
 
42
- // true: the holder's transcript was written within HOLDER_IDLE_MS; false: it
43
- // exists and has been silent longer; null: no transcript found (unknown).
44
- export async function claudeHolderActive(holder, worktree, { env = process.env, now = () => Date.now() } = {}) {
42
+ // BOT-3667: is the process still there? `kill(pid, 0)` sends nothing. Only
43
+ // ESRCH proves it gone; EPERM (someone else's process) or any other doubt
44
+ // counts as running, so a session that might be live is never taken over.
45
+ function processAlive(pid) {
46
+ try {
47
+ process.kill(pid, 0);
48
+ return true;
49
+ } catch (error) {
50
+ return error?.code !== "ESRCH";
51
+ }
52
+ }
53
+ // BOT-3667: Claude Code keeps <config>/sessions/<pid>.json ({ pid, sessionId,
54
+ // … }) for each running session and removes it on exit. true/false when the
55
+ // registry is readable and maintained (at least one well-formed entry, which
56
+ // the session running this command always has); null when it cannot tell.
57
+ async function claudeHolderRunning(id, env, alive) {
58
+ const dir = join(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"), "sessions");
59
+ let names;
60
+ try {
61
+ names = (await readdir(dir)).filter((name) => /^[0-9]{1,10}\.json$/.test(name));
62
+ } catch {
63
+ return null;
64
+ }
65
+ let maintained = false;
66
+ // Codex P2 on #2042: an entry that cannot be read (written mid-read, corrupt,
67
+ // missing its pid or sessionId) could be the holder's own, so "no entry for
68
+ // the holder" is no longer proof that it exited.
69
+ let unreadable = false;
70
+ for (const name of names) {
71
+ let entry;
72
+ try {
73
+ entry = JSON.parse(await readFile(join(dir, name), "utf8"));
74
+ } catch (error) {
75
+ if (error?.code !== "ENOENT") unreadable = true; // removed since readdir: its process exited
76
+ continue;
77
+ }
78
+ if (!Number.isSafeInteger(entry?.pid) || entry.pid <= 0 || typeof entry?.sessionId !== "string") {
79
+ unreadable = true;
80
+ continue;
81
+ }
82
+ maintained = true;
83
+ if (entry.sessionId.toLowerCase() !== id) continue;
84
+ let running;
85
+ try {
86
+ running = alive(entry.pid) !== false;
87
+ } catch (error) {
88
+ running = error?.code !== "ESRCH";
89
+ }
90
+ if (running) return true;
91
+ }
92
+ return maintained && !unreadable ? false : null;
93
+ }
94
+
95
+ // true: the holder is running (its registry entry names a live process) or,
96
+ // with no usable registry, its transcript was written within HOLDER_IDLE_MS;
97
+ // false: it has exited, or its transcript has been silent longer; null: no
98
+ // transcript found, so it is not known to be a Claude session (unknown).
99
+ export async function claudeHolderActive(holder, worktree, { env = process.env, now = () => Date.now(), alive = processAlive } = {}) {
45
100
  const id = String(holder || "").toLowerCase();
46
101
  if (!UUID_ONLY.test(id)) return null;
47
102
  const projects = claudeProjects(env);
@@ -66,6 +121,9 @@ export async function claudeHolderActive(holder, worktree, { env = process.env,
66
121
  }
67
122
  }
68
123
  if (at == null) return null;
124
+ // A known Claude session: the running-session registry decides when it can.
125
+ const running = await claudeHolderRunning(id, env, alive);
126
+ if (running !== null) return running;
69
127
  return now() - at < HOLDER_IDLE_MS;
70
128
  }
71
129
  // Returns false (never bind), true (bootstrap as is), or { aside } — another