@botbuddy/cli 1.123.2 → 1.123.4

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.123.4
4
+
5
+ - BOT-3678: a checkout whose `.botbuddy-agent.json` predates the `tenant` field (the pre-BOT-1608 `{"schema_version":1,"profile":…}` shape, found on old branches) no longer shows "This repo is bound to a tenant BB status does not support". `bb status-band read` refuses a new `repo_binding_stale` code, and the band (1.12.3) says the checkout's `.botbuddy-agent.json` predates tenant binding and to update this branch from main. A binding that names an unknown tenant still refuses `tenant_mismatch`. No tenant is ever inferred from `profile`.
6
+
7
+ ## 1.123.3
8
+
9
+ - 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.
10
+
3
11
  ## 1.123.2
4
12
 
5
13
  - 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.3"
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.3",
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;
@@ -81,6 +86,9 @@ const ERRORS = {
81
86
  session_renewal_failed: "BB session renewal failed. Refresh to retry, or run `bb doctor --fix`.",
82
87
  session_file_unsafe: "BB session file must be private (mode 0600).",
83
88
  tenant_mismatch: "This repo is bound to a tenant BB status does not support.",
89
+ // BOT-3678: an old branch's .botbuddy-agent.json has no tenant field.
90
+ repo_binding_stale:
91
+ "This checkout's .botbuddy-agent.json predates tenant binding: update this branch from main, then Refresh.",
84
92
  agent_mismatch:
85
93
  "BB returned a different agent. Reconnect BB for this session.",
86
94
  worktree_mismatch: "BB identity belongs to a different worktree.",
@@ -572,7 +580,7 @@ async function refresh($, { wake = false, keep = false } = {}) {
572
580
  snapshot = null;
573
581
  readFault = null;
574
582
  }
575
- if (TRANSIENT.has(errorCode)) retryRead($, request);
583
+ if (retries(errorCode)) retryRead($, request);
576
584
  else readBackoffMs = 0;
577
585
  // BOT-3222: the hook is still registering this session; read once more
578
586
  // when the adapter says, unless another read has started since.
@@ -607,7 +615,7 @@ function retryRead($, request) {
607
615
  const after = readBackoffMs;
608
616
  void (async () => {
609
617
  await delay($, after + 500);
610
- if (request !== generation || mode !== "live" || !TRANSIENT.has(errorCode)) return;
618
+ if (request !== generation || mode !== "live" || !retries(errorCode)) return;
611
619
  if (parked || !(await onScreen($))) {
612
620
  parked = true;
613
621
  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.4",
3
+ "source_commit": "881e5fac314ea16fb8f874cacecd0f63d705448e",
4
+ "source_sha256": "784ce44ebb2d26fbe80bca2f7aa142dbc674873d6a4a9f4835f78c8a603fd805",
5
5
  "target": "darwin-arm64",
6
- "sha256": "e4ec497e30b860d9e3d3f470a066657e7d37d3196b47ed744d2b4e1b0dc34f49"
6
+ "sha256": "2fc8827fc9c706acb06442b9c470e6a1b29ee999be561ecc615c68cf513c69e1"
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.4",
3
+ "source_commit": "881e5fac314ea16fb8f874cacecd0f63d705448e",
4
+ "source_sha256": "784ce44ebb2d26fbe80bca2f7aa142dbc674873d6a4a9f4835f78c8a603fd805",
5
5
  "target": "linux-x64",
6
- "sha256": "9cb3ba6e0bb6a5c3b584942c8a0d5a6c98aebe88b4f3257ee34c3b8f8f2183b4"
6
+ "sha256": "517b35fe605efa61dbf8ff9def5a6c2aeae2076a0c277361f33cbf02e1adc718"
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.4",
4
+ "source_commit": "881e5fac314ea16fb8f874cacecd0f63d705448e",
5
+ "source_sha256": "784ce44ebb2d26fbe80bca2f7aa142dbc674873d6a4a9f4835f78c8a603fd805",
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": "2fc8827fc9c706acb06442b9c470e6a1b29ee999be561ecc615c68cf513c69e1",
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": "517b35fe605efa61dbf8ff9def5a6c2aeae2076a0c277361f33cbf02e1adc718",
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.4",
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
@@ -298,7 +298,12 @@ export async function readStatus({
298
298
  } catch {
299
299
  refuse("repo_binding_missing");
300
300
  }
301
- if (binding.schema_version !== 1 || !Object.hasOwn(TENANTS, binding.tenant))
301
+ // BOT-3678: a v1 binding with no tenant field predates BOT-1608 (the legacy
302
+ // `profile` shape on an old branch); it is stale, not foreign. No tenant is
303
+ // ever inferred from `profile`.
304
+ if (binding?.schema_version === 1 && !Object.hasOwn(binding, "tenant"))
305
+ refuse("repo_binding_stale");
306
+ if (binding?.schema_version !== 1 || !Object.hasOwn(TENANTS, binding.tenant))
302
307
  refuse("tenant_mismatch");
303
308
  const tenant = binding.tenant;
304
309
  const prefix = TENANTS[tenant];