benignswarm 0.12.82 → 0.12.84

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.
@@ -0,0 +1,83 @@
1
+ import { existsSync, lstatSync, readFileSync, realpathSync, renameSync, symlinkSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { CliError } from "./errors.js";
5
+ function maybeLstat(path) {
6
+ try {
7
+ return lstatSync(path);
8
+ }
9
+ catch (error) {
10
+ const code = error.code;
11
+ if (code === "ENOENT" || code === "ENOTDIR")
12
+ return null;
13
+ throw error;
14
+ }
15
+ }
16
+ function directory(path) { return maybeLstat(path)?.isDirectory() ?? false; }
17
+ function present(path) { return maybeLstat(path) !== null; }
18
+ /** Resolve a renamed state directory, preserving old paths through a symlink. */
19
+ export function renamedDirectory(parent, currentName, oldName, report = true) {
20
+ const current = join(parent, currentName);
21
+ const old = join(parent, oldName);
22
+ const currentDir = directory(current);
23
+ const oldDir = directory(old);
24
+ const currentExists = present(current);
25
+ const oldExists = present(old);
26
+ if (currentDir && oldDir)
27
+ throw new CliError("directory_conflict", `both ${current} and ${old} are real directories; merge or remove one explicitly before continuing`);
28
+ if (!currentExists && oldDir) {
29
+ renameSync(old, current);
30
+ symlinkSync(currentName, old, "dir");
31
+ if (report)
32
+ process.stderr.write(`[b9s] moved ${old} to ${current}; ${oldName} now links to ${currentName}\n`);
33
+ }
34
+ else if (currentExists && oldDir) {
35
+ throw new CliError("directory_conflict", `${current} and ${old} both exist, but ${current} is not a directory; refusing to move or replace either path`);
36
+ }
37
+ else if (currentExists && !currentDir) {
38
+ throw new CliError("directory_conflict", `${current} exists but is not a directory; refusing to use it as b9s state`);
39
+ }
40
+ else if (oldExists && !currentDir) {
41
+ throw new CliError("directory_conflict", `${old} exists but is not a directory; refusing to replace it with a ${oldName} compatibility link`);
42
+ }
43
+ else if (oldExists && currentDir) {
44
+ try {
45
+ const st = lstatSync(old);
46
+ if (!st.isSymbolicLink())
47
+ throw new Error("not a symbolic link");
48
+ const resolved = realpathSync(old);
49
+ if (resolved !== realpathSync(current))
50
+ throw new Error("points elsewhere");
51
+ }
52
+ catch {
53
+ throw new CliError("directory_conflict", `both ${current} and ${old} exist and ${old} is not a symlink to ${current}; refusing to choose`);
54
+ }
55
+ }
56
+ return current;
57
+ }
58
+ export function configDirectory(env = process.env) {
59
+ if (env.BSCHAT_HOME !== undefined || env.B9S_HOME !== undefined)
60
+ return env.BSCHAT_HOME ?? env.B9S_HOME;
61
+ const home = env.HOME ?? homedir();
62
+ return renamedDirectory(home, ".b9s", ".bschat");
63
+ }
64
+ export function repoDirectory(root) {
65
+ const currentPath = join(root, ".b9s");
66
+ const oldPath = join(root, ".bschat");
67
+ const currentBefore = maybeLstat(currentPath);
68
+ const oldBefore = maybeLstat(oldPath);
69
+ const migration = oldBefore?.isDirectory() === true && currentBefore === null;
70
+ const compatibilityLink = oldBefore?.isSymbolicLink() === true && currentBefore?.isDirectory() === true;
71
+ const current = renamedDirectory(root, ".b9s", ".bschat");
72
+ if ((migration || compatibilityLink) && existsSync(join(root, ".git"))) {
73
+ const ignore = join(root, ".gitignore");
74
+ const contents = existsSync(ignore) ? readFileSync(ignore, "utf8") : "";
75
+ const lines = contents.split("\n");
76
+ const missing = [".b9s/", ".bschat"].filter((entry) => !lines.includes(entry));
77
+ if (missing.length) {
78
+ const prefix = contents && !contents.endsWith("\n") ? `${contents}\n` : contents;
79
+ writeFileSync(ignore, `${prefix}${prefix ? "\n" : ""}# b9s (per-checkout agent state)\n${missing.join("\n")}\n`);
80
+ }
81
+ }
82
+ return current;
83
+ }
@@ -0,0 +1,10 @@
1
+ /** Populate legacy environment names from their B9S_ equivalents when unset. */
2
+ export function applyEnvAliases(env = process.env) {
3
+ for (const [key, value] of Object.entries(env)) {
4
+ if (!key.startsWith("B9S_"))
5
+ continue;
6
+ const legacyKey = `BSCHAT_${key.slice(4)}`;
7
+ if (env[legacyKey] === undefined)
8
+ env[legacyKey] = value;
9
+ }
10
+ }
package/dist/git.js CHANGED
@@ -259,8 +259,8 @@ export function pruneReport(cwd = process.cwd(), closedUnitPaths = new Map(), ac
259
259
  // there (unit worktrees never get one). And a worktree made in the last day is too new to judge:
260
260
  // StickJoy's watcher removed a home checkout two minutes after it was created, before the agent
261
261
  // could bind it, because a fresh branch on main's head looks merged.
262
- if (existsSync(join(w.path, ".bschat", "identity.json"))) {
263
- kept.push({ path: w.path, branch: w.branch, reason: "an agent's home checkout (it has .bschat/identity.json)" });
262
+ if (existsSync(join(w.path, ".b9s", "identity.json")) || existsSync(join(w.path, ".bschat", "identity.json"))) {
263
+ kept.push({ path: w.path, branch: w.branch, reason: "an agent's home checkout (it has a b9s identity file)" });
264
264
  continue;
265
265
  }
266
266
  const made = worktreeCreatedMs(w.path);
package/dist/harness.js CHANGED
@@ -1,7 +1,9 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
1
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { shellPath } from "./install.js";
3
+ import { homedir } from "node:os";
3
4
  import { basename, dirname, join } from "node:path";
4
5
  import { CliError } from "./errors.js";
6
+ import { repoDirectory } from "./directories.js";
5
7
  /** Canonical vendor ids and the aliases people type. */
6
8
  const VENDOR_ALIASES = {
7
9
  "claude-code": "claude-code", claude: "claude-code", anthropic: "claude-code",
@@ -14,12 +16,12 @@ export const HARNESSES = ["claude-code", "codex", "antigravity", "dsh", "gemini-
14
16
  export function normalizeVendor(v) {
15
17
  return VENDOR_ALIASES[v.toLowerCase()] ?? v.toLowerCase();
16
18
  }
17
- export const IDENTITY_FILE = join(".bschat", "identity.json");
19
+ export const IDENTITY_FILE = join(".b9s", "identity.json");
18
20
  /** Walks up from cwd to find the repo-local identity file. */
19
21
  export function findIdentityFile(start = process.cwd()) {
20
22
  let dir = start;
21
23
  for (;;) {
22
- const p = join(dir, IDENTITY_FILE);
24
+ const p = join(repoDirectory(dir), "identity.json");
23
25
  if (existsSync(p))
24
26
  return p;
25
27
  const parent = dirname(dir);
@@ -31,7 +33,7 @@ export function findIdentityFile(start = process.cwd()) {
31
33
  export function readIdentityFile(path) {
32
34
  const raw = JSON.parse(readFileSync(path, "utf8"));
33
35
  if (!raw.agents || typeof raw.agents !== "object")
34
- throw new CliError("bad_identity_file", `${path} is not a bschat identity file`);
36
+ throw new CliError("bad_identity_file", `${path} is not a b9s identity file`);
35
37
  return raw;
36
38
  }
37
39
  /**
@@ -39,7 +41,7 @@ export function readIdentityFile(path) {
39
41
  * existing different name: two agents of one vendor in one worktree must use BSCHAT_AGENT.
40
42
  */
41
43
  export function writeIdentity(root, vendor, name, model, replace, project) {
42
- const p = join(root, IDENTITY_FILE);
44
+ const p = join(repoDirectory(root), "identity.json");
43
45
  let file = { agents: {} };
44
46
  if (existsSync(p))
45
47
  file = readIdentityFile(p);
@@ -52,7 +54,7 @@ export function writeIdentity(root, vendor, name, model, replace, project) {
52
54
  file.agents[vendor] = { name, project, ...(model ? { model } : {}) };
53
55
  mkdirSync(dirname(p), { recursive: true });
54
56
  writeFileSync(p, JSON.stringify(file, null, 2) + "\n");
55
- ensureGitignore(root, [".bschat/", ".claude/settings.local.json"]);
57
+ ensureGitignore(root, [".b9s/", ".bschat/", ".claude/settings.local.json"]);
56
58
  return p;
57
59
  }
58
60
  export function ensureGitignore(root, entries) {
@@ -64,7 +66,7 @@ export function ensureGitignore(root, entries) {
64
66
  const missing = entries.filter((e) => !lines.includes(e));
65
67
  if (!missing.length)
66
68
  return;
67
- writeFileSync(p, (current.endsWith("\n") || current === "" ? current : current + "\n") + "# bschat (per-machine agent identity)\n" + missing.join("\n") + "\n");
69
+ writeFileSync(p, (current.endsWith("\n") || current === "" ? current : current + "\n") + "# b9s (per-machine agent identity)\n" + missing.join("\n") + "\n");
68
70
  }
69
71
  const START = "<!-- bschat:start -->";
70
72
  const END = "<!-- bschat:end -->";
@@ -86,30 +88,31 @@ export function upsertBlock(path, body) {
86
88
  }
87
89
  /**
88
90
  * The section join writes into AGENTS.md / GEMINI.md. Those files are usually committed and read on
89
- * every machine, so it names no path: a Mac's /opt/homebrew/bin/bschat in a committed AGENTS.md
91
+ * every machine, so it names no path: a Mac's /opt/homebrew/bin/b9s in a committed AGENTS.md
90
92
  * pointed agents on a Linux machine at nothing. Each machine records its install in install.json.
91
93
  */
92
- function pointer(_name, apiUrl, _bin) {
94
+ function pointer(_name, apiUrl, bin) {
93
95
  return [
94
- `## bschat: agent chat for this project`,
96
+ `## b9s: agent chat for this project`,
95
97
  ``,
96
- `This repo's agents coordinate on BenignSwarm with the \`bschat\` command, installed once per`,
97
- `machine (if \`bschat\` is not on your PATH, \`~/.bschat/install.json\` names this machine's copy;`,
98
- `do not install another, and do not use npx). Your identity for this repo is recorded in \`.bschat/identity.json\``,
98
+ `This repo's agents coordinate on BenignSwarm with the \`b9s\` command, installed once per`,
99
+ `machine (if \`b9s\` is not on your PATH, use the recorded install at \`${bin}\`;`,
100
+ `do not install another, and do not use npx). Your identity for this repo is recorded in \`.b9s/identity.json\``,
99
101
  `(vendor -> agent name), so it works without env vars. If you are told you are a different agent,`,
100
102
  `export BSCHAT_AGENT=<project>/<name>.`,
101
103
  ``,
102
- `Start of session: \`bschat me\`, \`bschat who\`, \`bschat inbox\`.`,
103
- `Full instructions: \`.bschat/SKILL.md\` in this repo, or ${apiUrl}/skill.`,
104
+ `Start of session: \`b9s me\`, \`b9s who\`, \`b9s inbox\`.`,
105
+ `Full instructions: \`.b9s/SKILL.md\` in this repo, or ${apiUrl}/skill.`,
104
106
  ].join("\n");
105
107
  }
106
108
  /**
107
- * Writes the files a given harness needs to discover bschat in this repo.
109
+ * Writes the files a given harness needs to discover b9s in this repo.
108
110
  * Returns the paths written. Each writer is idempotent.
109
111
  */
110
112
  export function installForHarness(root, harness, files, agentName, apiUrl, bin) {
111
113
  const written = [];
112
- const neutral = join(root, ".bschat");
114
+ const neutral = repoDirectory(root);
115
+ ensureGitignore(root, [".b9s/", ".bschat/"]);
113
116
  mkdirSync(join(neutral, "references"), { recursive: true });
114
117
  writeFileSync(join(neutral, "SKILL.md"), files.skill);
115
118
  writeFileSync(join(neutral, "references", "api.md"), files.api);
@@ -119,7 +122,7 @@ export function installForHarness(root, harness, files, agentName, apiUrl, bin)
119
122
  written.push(join(neutral, "SKILL.md"));
120
123
  switch (harness) {
121
124
  case "claude-code": {
122
- const dir = join(root, ".claude", "skills", "bschat");
125
+ const dir = join(root, ".claude", "skills", "b9s");
123
126
  mkdirSync(join(dir, "references"), { recursive: true });
124
127
  writeFileSync(join(dir, "SKILL.md"), files.skill);
125
128
  writeFileSync(join(dir, "references", "api.md"), files.api);
@@ -127,6 +130,7 @@ export function installForHarness(root, harness, files, agentName, apiUrl, bin)
127
130
  writeFileSync(join(dir, "references", "process.md"), files.process);
128
131
  writeFileSync(join(dir, "references", "continuity.md"), files.continuity);
129
132
  written.push(join(dir, "SKILL.md"));
133
+ rmSync(join(root, ".claude", "skills", "bschat"), { recursive: true, force: true });
130
134
  const sp = join(root, ".claude", "settings.local.json");
131
135
  let settings = {};
132
136
  if (existsSync(sp)) {
@@ -156,7 +160,7 @@ export function installForHarness(root, harness, files, agentName, apiUrl, bin)
156
160
  case "antigravity": {
157
161
  const p = join(root, ".agents", "rules", "bschat.md");
158
162
  mkdirSync(dirname(p), { recursive: true });
159
- writeFileSync(p, `---\ntrigger: always_on\ndescription: "How to use bschat, the agent chat for this project"\n---\n\n${pointer(agentName, apiUrl, bin)}\n`);
163
+ writeFileSync(p, `---\ntrigger: always_on\ndescription: "How to use b9s, the agent chat for this project"\n---\n\n${pointer(agentName, apiUrl, bin)}\n`);
160
164
  written.push(p);
161
165
  const hp = join(root, ".agents", "hooks.json");
162
166
  let hooks = {};
@@ -179,7 +183,49 @@ export function installForHarness(root, harness, files, agentName, apiUrl, bin)
179
183
  break;
180
184
  }
181
185
  default:
182
- throw new CliError("unknown_harness", `no harness integration for "${harness}"`, `Known: ${HARNESSES.join(", ")}. The neutral copy at .bschat/SKILL.md was still written.`);
186
+ throw new CliError("unknown_harness", `no harness integration for "${harness}"`, `Known: ${HARNESSES.join(", ")}. The neutral copy at .b9s/SKILL.md was still written.`);
187
+ }
188
+ return written;
189
+ }
190
+ /** Refresh existing machine hook settings to the current recorded install after `install --latest`. */
191
+ export function refreshInstalledHooks(root, bin) {
192
+ const written = [];
193
+ const claude = join(root, ".claude", "settings.local.json");
194
+ if (existsSync(claude)) {
195
+ let settings;
196
+ try {
197
+ settings = JSON.parse(readFileSync(claude, "utf8"));
198
+ }
199
+ catch {
200
+ throw new CliError("bad_settings", `${claude} is not valid JSON; fix it or remove it`);
201
+ }
202
+ const hooks = withBschatHooks(settings.hooks ?? {}, bin);
203
+ writeFileSync(claude, JSON.stringify({ ...settings, hooks }, null, 2) + "\n");
204
+ written.push(claude);
205
+ }
206
+ const codex = join(process.env.CODEX_HOME ?? join(homedir(), ".codex"), "hooks.json");
207
+ if (existsSync(codex)) {
208
+ let settings;
209
+ try {
210
+ settings = JSON.parse(readFileSync(codex, "utf8"));
211
+ }
212
+ catch {
213
+ throw new CliError("bad_settings", `${codex} is not valid JSON; fix it or remove it`);
214
+ }
215
+ writeFileSync(codex, JSON.stringify(withCodexHooks(settings, bin), null, 2) + "\n");
216
+ written.push(codex);
217
+ }
218
+ const antigravity = join(root, ".agents", "hooks.json");
219
+ if (existsSync(antigravity)) {
220
+ let settings;
221
+ try {
222
+ settings = JSON.parse(readFileSync(antigravity, "utf8"));
223
+ }
224
+ catch {
225
+ throw new CliError("bad_settings", `${antigravity} is not valid JSON; fix it or remove it`);
226
+ }
227
+ writeFileSync(antigravity, JSON.stringify({ ...settings, bschat: antigravityHooks(bin) }, null, 2) + "\n");
228
+ written.push(antigravity);
183
229
  }
184
230
  return written;
185
231
  }
@@ -188,19 +234,25 @@ const HOOK_MARK = "hook claude-code";
188
234
  const hookCommand = (bin, event) => `${shellPath(bin)} ${HOOK_MARK} --event ${event}`;
189
235
  /**
190
236
  * Adds the inbox hook to SessionStart, UserPromptSubmit, PostToolUse and PostModelSwitch without
191
- * touching other hooks. An existing bschat hook (an npx form, an older install's path, or the
192
- * 0.7.x–0.9.0 `npx -y benignswarm bschat hook` that never ran) is rewritten to this install.
237
+ * touching other hooks. An existing b9s hook (an npx form, an older install's path, or the
238
+ * 0.7.x–0.9.0 `npx -y benignswarm b9s hook` that never ran) is rewritten to this install.
193
239
  */
194
240
  export function withBschatHooks(hooks, bin) {
195
241
  const out = { ...hooks };
196
- for (const event of ["SessionStart", "UserPromptSubmit", "PostToolUse", "PostModelSwitch"]) {
242
+ for (const { event, matcher } of [
243
+ { event: "SessionStart", matcher: "" },
244
+ { event: "UserPromptSubmit", matcher: "" },
245
+ { event: "PostToolUse", matcher: "" },
246
+ { event: "PostModelSwitch", matcher: "" },
247
+ { event: "PreToolUse", matcher: "Bash" },
248
+ ]) {
197
249
  const list = (out[event] ?? []).map((g) => ({
198
250
  ...g,
199
251
  hooks: (g.hooks ?? []).map((h) => (typeof h.command === "string" && h.command.includes(HOOK_MARK) ? { ...h, command: hookCommand(bin, event) } : h)),
200
252
  }));
201
253
  const already = list.some((g) => (g.hooks ?? []).some((h) => typeof h.command === "string" && h.command.includes(HOOK_MARK)));
202
254
  if (!already)
203
- list.push({ matcher: "", hooks: [{ type: "command", command: hookCommand(bin, event), timeout: 20 }] });
255
+ list.push({ matcher, hooks: [{ type: "command", command: hookCommand(bin, event), timeout: 20 }] });
204
256
  out[event] = list;
205
257
  }
206
258
  return out;
@@ -238,7 +290,7 @@ export function claudeCheckoutTaken(root, owner, name) {
238
290
  /**
239
291
  * The `bschat` entry of an Antigravity workspace's .agents/hooks.json. The command carries no
240
292
  * identity: several Antigravity agents share a workspace, so the hook finds its agent by the
241
- * conversation (`bschat antigravity bind`, or a watcher installed for that conversation).
293
+ * conversation (`b9s antigravity bind`, or a watcher installed for that conversation).
242
294
  */
243
295
  export function antigravityHooks(bin) {
244
296
  const cmd = (event) => ({ type: "command", command: `${shellPath(bin)} hook antigravity --event ${event}`, timeout: 20 });
@@ -251,8 +303,8 @@ export function antigravityHooks(bin) {
251
303
  }
252
304
  const CODEX_HOOK_MARK = "hook codex";
253
305
  /**
254
- * Merges bschat's hooks into a Codex hooks.json document ({"hooks": {Event: [groups]}}): any
255
- * earlier bschat group is replaced, every other hook is kept. Commands carry no identity.
306
+ * Merges b9s's hooks into a Codex hooks.json document ({"hooks": {Event: [groups]}}): any
307
+ * earlier b9s group is replaced, every other hook is kept. Commands carry no identity.
256
308
  */
257
309
  export function withCodexHooks(doc, bin) {
258
310
  const hooks = { ...(doc.hooks ?? {}) };
@@ -269,11 +321,13 @@ export function withCodexHooks(doc, bin) {
269
321
  }
270
322
  return { ...doc, hooks };
271
323
  }
272
- /** First line of the files `bschat-admin machine add` writes in Codex's administrator layer. */
273
- export const CODEX_MANAGED_MARK = "# bschat managed hooks";
324
+ /** First line of the files `b9s-admin machine add` writes in Codex's administrator layer. */
325
+ export const CODEX_MANAGED_MARK = "# b9s managed hooks";
326
+ const LEGACY_CODEX_MANAGED_MARK = "# bschat managed hooks";
327
+ export const isCodexManagedRequirements = (text) => text.startsWith(CODEX_MANAGED_MARK) || text.startsWith(LEGACY_CODEX_MANAGED_MARK);
274
328
  export const CODEX_MANAGED_DIR = "/etc/codex/hooks";
275
329
  /**
276
- * Codex's administrator layer for a provisioned machine (docs/REMOTE-MACHINES.md): bschat's hooks in
330
+ * Codex's administrator layer for a provisioned machine (docs/REMOTE-MACHINES.md): b9s's hooks in
277
331
  * /etc/codex/requirements.toml, which Codex trusts by policy, calling a wrapper in the managed dir
278
332
  * that runs this machine's recorded install. `allow_managed_hooks_only` is deliberately not set: it
279
333
  * would switch off the machine owner's own hooks. Returns the two files' contents.
@@ -286,7 +340,7 @@ export function codexManagedHooks(bin) {
286
340
  { event: "Stop" },
287
341
  ];
288
342
  const requirements = [
289
- `${CODEX_MANAGED_MARK} (written by bschat-admin machine add; trusted by policy, so headless turns run them)`,
343
+ `${CODEX_MANAGED_MARK} (written by b9s-admin machine add; trusted by policy, so headless turns run them)`,
290
344
  `[hooks]`,
291
345
  `managed_dir = "${CODEX_MANAGED_DIR}"`,
292
346
  ...events.flatMap(({ event, matcher }) => [
@@ -295,12 +349,12 @@ export function codexManagedHooks(bin) {
295
349
  ...(matcher ? [`matcher = "${matcher}"`] : []),
296
350
  `[[hooks.${event}.hooks]]`,
297
351
  `type = "command"`,
298
- `command = "${CODEX_MANAGED_DIR}/bschat ${event}"`,
352
+ `command = "${CODEX_MANAGED_DIR}/b9s ${event}"`,
299
353
  `timeout = 20`,
300
354
  ]),
301
355
  ``,
302
356
  ].join("\n");
303
- // Runs for every user of the machine; one without this install has no bschat agent here.
357
+ // Runs for every user of the machine; one without this install has no b9s agent here.
304
358
  const wrapper = [
305
359
  `#!/bin/sh`,
306
360
  `${CODEX_MANAGED_MARK}: Codex hook entry point for ${bin}`,
@@ -320,8 +374,8 @@ export const BWRAP_APPARMOR_PATH = "/etc/apparmor.d/bschat-bwrap";
320
374
  */
321
375
  export function bwrapAppArmorProfile() {
322
376
  return [
323
- `# bschat: let bubblewrap create the user namespaces sandboxes (Claude Code) need (Ubuntu 24.04+ restricts them).`,
324
- `# Written by bschat machine prepare --bwrap-userns; remove this file and run apparmor_parser -R on it to undo.`,
377
+ `# b9s: let bubblewrap create the user namespaces sandboxes (Claude Code) need (Ubuntu 24.04+ restricts them).`,
378
+ `# Written by b9s machine prepare --bwrap-userns; remove this file and run apparmor_parser -R on it to undo.`,
325
379
  `abi <abi/4.0>,`,
326
380
  `include <tunables/global>`,
327
381
  ``,
@@ -341,8 +395,8 @@ export function bwrapAppArmorProfile() {
341
395
  */
342
396
  export function codexAppArmorProfile() {
343
397
  return [
344
- `# bschat: let Codex create the user namespaces its Linux sandbox needs (Ubuntu 24.04+ restricts them).`,
345
- `# Codex only. Written by bschat machine prepare --codex-userns; remove this file and run`,
398
+ `# b9s: let Codex create the user namespaces its Linux sandbox needs (Ubuntu 24.04+ restricts them).`,
399
+ `# Codex only. Written by b9s machine prepare --codex-userns; remove this file and run`,
346
400
  `# apparmor_parser -R on it to undo.`,
347
401
  `abi <abi/4.0>,`,
348
402
  `include <tunables/global>`,
package/dist/harnesses.js CHANGED
@@ -3,6 +3,7 @@ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { dirname, join } from "node:path";
5
5
  import { CliError } from "./errors.js";
6
+ import { configRoot } from "./config.js";
6
7
  import { codexArchivedRollout, codexRollout } from "./sessions.js";
7
8
  import { codexTurnPhase, usageLimitUntil } from "./turn.js";
8
9
  /**
@@ -61,7 +62,7 @@ export function claudeTranscript(session) {
61
62
  return null;
62
63
  }
63
64
  /** The last turn's output (`claude -p --output-format json`), written by the watcher's turn command. */
64
- export const claudeResultFile = (ref) => join(homedir(), ".bschat", "logs", `turn.${ref.replace("/", ".")}.json`);
65
+ export const claudeResultFile = (ref) => join(configRoot(), "logs", `turn.${ref.replace("/", ".")}.json`);
65
66
  /** The latest timestamp in a transcript, and the latest user prompt's. */
66
67
  export function claudeTranscriptTimes(text) {
67
68
  let lastEventAt = null;
@@ -129,7 +130,7 @@ export function claudeLimitUntil(error, now = Date.now()) {
129
130
  }
130
131
  /**
131
132
  * The command is Claude Code itself (its native binary, or node running its package), not a shell
132
- * wrapping it and not a bschat watcher whose --exec names the session.
133
+ * wrapping it and not a b9s watcher whose --exec names the session.
133
134
  */
134
135
  export function isClaudeCommand(args) {
135
136
  const [first, second = ""] = args.trim().split(/\s+/);
@@ -180,7 +181,7 @@ function claudeProbe(session, ref) {
180
181
  * its working folder, so read-only cannot be honoured and is refused. workspace-write is its sandbox
181
182
  * (refusing to start when the sandbox is unavailable, never running a command outside it), every
182
183
  * domain reachable as with Codex, edits allowed in the checkout and the folders `wu start` and bschat
183
- * write (the checkout's parent, ~/.bschat) plus the machine's writable folders; anything that would
184
+ * write (the checkout's parent, ~/.b9s) plus the machine's writable folders; anything that would
184
185
  * need a prompt is denied, since nobody can answer one. danger-full-access skips permissions.
185
186
  */
186
187
  export function claudeSettings(sandbox, model, effort, cwd, bschatHome, extraWritable = []) {
@@ -188,7 +189,7 @@ export function claudeSettings(sandbox, model, effort, cwd, bschatHome, extraWri
188
189
  if (sandbox === "danger-full-access")
189
190
  return [...common, "--permission-mode", "bypassPermissions"];
190
191
  if (sandbox === "read-only")
191
- throw new CliError("unsupported", "Claude Code has no read-only sandbox: its sandbox always lets the agent write its working folder. Use workspace-write (sandboxed; writes limited to the checkout, its unit worktrees, ~/.bschat and the machine's writable folders) or danger-full-access");
192
+ throw new CliError("unsupported", "Claude Code has no read-only sandbox: its sandbox always lets the agent write its working folder. Use workspace-write (sandboxed; writes limited to the checkout, its unit worktrees, ~/.b9s and the machine's writable folders) or danger-full-access");
192
193
  if (sandbox !== "workspace-write")
193
194
  throw new CliError("usage", `unknown sandbox ${sandbox}`);
194
195
  const dirs = [dirname(cwd), bschatHome, ...extraWritable];