benignswarm 0.12.55 → 0.12.57

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/dist/args.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { CliError } from "./errors.js";
3
- export const STRING_FLAGS = ["as", "admin", "key", "url", "label", "model", "since", "limit", "after", "topic", "goal", "task", "state", "blocked-on", "tags", "custom", "vendor", "role", "description", "permissions", "cardinality", "machine", "dir", "confirm", "type", "name", "out", "token", "prefix", "uses", "expires-hours", "skill-dir", "harness", "reply-to", "event", "project", "projects", "post", "title", "body", "body-file", "handoff-to", "evidence", "agent", "parent", "parent-item", "channel", "statuses", "assign", "if-status", "status", "exec", "interval", "requeue-after", "unacked-after", "category", "command", "follow-delay", "env", "scope", "pr", "note", "add", "remove", "merged", "tag", "activity", "max-unanswered", "to", "replay-of", "branch", "effort", "by", "target", "milestone", "file", "exit", "depends-on", "source", "by", "on", "question", "ruling", "gaps", "unit", "units", "blocks", "sla", "takeover", "max-open", "max-in-progress", "require-scope", "require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit", "require-pushed", "quiet", "summary", "meaning", "expert-role", "reviews", "works", "trials", "email", "repeat", "summary-minutes", "churn", "unmet", "require-cited-changes", "checks-every", "propose", "waits-on", "sandbox", "thread", "turn-timeout", "ssh", "variant", "count", "needs", "min-ram"];
3
+ export const STRING_FLAGS = ["as", "admin", "key", "url", "label", "model", "since", "limit", "after", "topic", "goal", "task", "state", "blocked-on", "tags", "custom", "vendor", "role", "description", "permissions", "cardinality", "machine", "dir", "confirm", "type", "name", "out", "token", "prefix", "uses", "expires-hours", "skill-dir", "harness", "reply-to", "event", "project", "projects", "post", "title", "body", "body-file", "handoff-to", "evidence", "agent", "parent", "parent-item", "channel", "statuses", "assign", "if-status", "status", "exec", "interval", "requeue-after", "unacked-after", "category", "command", "follow-delay", "env", "scope", "pr", "note", "add", "remove", "merged", "tag", "activity", "max-unanswered", "to", "replay-of", "branch", "effort", "by", "target", "milestone", "file", "exit", "depends-on", "source", "by", "on", "question", "ruling", "gaps", "unit", "units", "blocks", "sla", "takeover", "max-open", "max-in-progress", "require-scope", "require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit", "require-pushed", "quiet", "summary", "meaning", "expert-role", "reviews", "works", "trials", "email", "repeat", "summary-minutes", "churn", "unmet", "require-cited-changes", "checks-every", "propose", "waits-on", "sandbox", "thread", "turn-timeout", "ssh", "variant", "count", "needs", "min-ram", "exclude"];
4
4
  export const BOOL_FLAGS = ["latest", "no-restart", "json", "follow", "account", "help", "version", "broadcast", "create-channels", "read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "unread", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full", "no-bind", "all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "clear", "met", "shared", "archive", "approve", "turn", "service", "print-hooks", "create", "rotate"];
5
5
  export function parse(argv) {
6
6
  const options = {};
@@ -7,7 +7,7 @@ import { spawnSync } from "node:child_process";
7
7
  import { CliError } from "../errors.js";
8
8
  import { table } from "../output.js";
9
9
  import { milestoneWith, milestonesWith } from "./wu.js";
10
- import { machineAdmin, poolAdmin, projectRepoAdmin } from "./machine-admin.js";
10
+ import { machineAdmin, poolAdmin, projectCheckoutAdmin, projectRepoAdmin } from "./machine-admin.js";
11
11
  import { accountAdmin, answerAdmin, keysAdmin, needsAdmin, notifierAdmin, processAdmin, skillAdmin, tagList, worktreeAdmin } from "./operator.js";
12
12
  function adminClient(p) {
13
13
  return Client.forAdmin(loadAdmin(resolveAdminName(str(p.flags, "admin"))));
@@ -57,6 +57,8 @@ export async function admin(p, out) {
57
57
  case "project":
58
58
  if (action === "repo")
59
59
  return projectRepoAdmin(rest, p, out);
60
+ if (action === "checkout")
61
+ return projectCheckoutAdmin(rest, p, out);
60
62
  return project(action, rest, p, out);
61
63
  case "agent":
62
64
  return agent(action, rest, p, out);
@@ -1,9 +1,9 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
2
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
- import { join as joinPath } from "node:path";
4
+ import { dirname, join as joinPath } from "node:path";
5
5
  import { bool, str } from "../args.js";
6
- import { agentRef, loadAgent } from "../config.js";
6
+ import { agentRef, configRoot, loadAgent } from "../config.js";
7
7
  import { CliError } from "../errors.js";
8
8
  import { requireInstall } from "../install.js";
9
9
  import { bindSession, codexArchivedRollout, codexRollout } from "../sessions.js";
@@ -57,12 +57,7 @@ export async function codexStart(p, out) {
57
57
  const ref = agentRef(creds);
58
58
  requireInstall();
59
59
  // 2. Its thread: adopt one, or start one headless with an onboarding turn.
60
- const settings = [
61
- ...(model ? ["-m", model] : []),
62
- ...(effort ? ["-c", `model_reasoning_effort="${effort}"`] : []),
63
- "-c", `sandbox_mode="${sandbox}"`,
64
- "-c", `approval_policy="never"`,
65
- ];
60
+ const settings = codexSettings(sandbox, model, effort, process.cwd(), configRoot());
66
61
  let thread;
67
62
  let firstTurnLog = null;
68
63
  if (adopt) {
@@ -103,6 +98,22 @@ export async function codexStart(p, out) {
103
98
  lines.push(`If the Codex account hits its usage limit, the watcher pauses turns until the time Codex gives; after switching to an account with quota, resume at once: bschat codex unpause --as ${ref}`);
104
99
  out.print(lines.join("\n"), { agent: ref, thread, sandbox, model: model ?? null, effort: effort ?? null, exec, first_turn_log: firstTurnLog, untrusted_hooks: missing });
105
100
  }
101
+ /**
102
+ * The Codex settings a headless turn runs with. Under workspace-write the agent still has to reach
103
+ * the API and write its own bschat state (~/.bschat), and `wu start` puts unit worktrees beside the
104
+ * checkout, so those two places are writable and the network is on; nothing else is.
105
+ */
106
+ export function codexSettings(sandbox, model, effort, cwd, bschatHome) {
107
+ return [
108
+ ...(model ? ["-m", model] : []),
109
+ ...(effort ? ["-c", `model_reasoning_effort="${effort}"`] : []),
110
+ "-c", `sandbox_mode="${sandbox}"`,
111
+ "-c", `approval_policy="never"`,
112
+ ...(sandbox === "workspace-write"
113
+ ? ["-c", "sandbox_workspace_write.network_access=true", "-c", `sandbox_workspace_write.writable_roots=${JSON.stringify([bschatHome, dirname(cwd)])}`]
114
+ : []),
115
+ ];
116
+ }
106
117
  /** Starts a headless Codex session in its own process group and returns its thread id from the JSON event stream. */
107
118
  async function startThread(codexBin, args, logPath, agent) {
108
119
  const fd = openSync(logPath, "a");
@@ -123,12 +123,19 @@ export async function machineAdmin(action, rest, p, out) {
123
123
  const m = r.machine;
124
124
  const rep = m.report ?? {};
125
125
  const head = [
126
- `${m.name}: last report ${m.last_report_at ?? "never"}; labels ${(m.labels ?? []).join(", ") || "(none)"}; slots ${m.slots ?? "auto"}`,
126
+ `${m.name}: last report ${m.last_report_at ?? "never"}; labels ${(m.labels ?? []).join(", ") || "(none)"}; slots ${m.slots ?? "auto"}; workdir ${rep.workdir ?? m.workdir ?? "~/bschat"}${rep.workdir_free_bytes ? ` (${Math.round(rep.workdir_free_bytes / 1e9)} GB free)` : ""}`,
127
127
  rep.os ? ` ${rep.os}/${rep.arch} ${rep.hostname} as ${rep.user}; ${rep.cpus ?? "?"} CPUs, ${rep.mem_total_bytes ? `${Math.round(rep.mem_total_bytes / 1024 ** 3)} GB RAM` : "? RAM"}; bschat ${rep.bschat?.version}; codex ${rep.codex ? `${rep.codex.version}, ${rep.codex.logged_in ? "logged in" : "NOT logged in"}` : "missing"}; hooks ${rep.managed_hooks ? "managed by policy" : "user-level"}; linger ${rep.linger ?? "n/a"}; disk free ${rep.disk_free_bytes ? `${Math.round(rep.disk_free_bytes / 1e9)} GB` : "?"}` : " (no report yet: is its daemon running?)",
128
128
  ];
129
129
  const rows = m.sessions.map((s) => ({ agent: s.agent, pool: s.pool ?? "-", desired: s.desired, state: s.reported?.state ?? "-", thread: s.thread ?? "-", sandbox: s.sandbox, model: s.model ?? "-", dir: s.dir || s.reported?.dir || "(auto)", error: s.reported?.error ?? s.reported?.detail ?? "", last_turn: (s.reported?.last_turn ?? "").replace(/^\S+ bschat watch\[[^\]]+\]: /, "") }));
130
130
  return out.print([...head, rows.length ? table(rows, ["agent", "pool", "desired", "state", "thread", "sandbox", "model", "dir", "error", "last_turn"]) : " no sessions"].join("\n"), r);
131
131
  }
132
+ if (action === "workdir") {
133
+ const [name, path] = rest;
134
+ if (!name || !path)
135
+ throw new CliError("usage", "machine workdir <name> <absolute path | default> (where its daemon clones projects and makes agent worktrees; default ~/bschat)");
136
+ const r = await c.call("PATCH", `/machines/${name}`, { workdir: path === "default" ? null : path });
137
+ return out.print(`${name}: pool checkouts go to ${r.machine.workdir ?? "~/bschat"} from its next pass (existing checkouts stay where they are).`, r);
138
+ }
132
139
  if (action === "label" || action === "slots") {
133
140
  const name = rest[0];
134
141
  if (!name)
@@ -241,6 +248,15 @@ export async function poolAdmin(action, rest, p, out, argv) {
241
248
  }
242
249
  throw new CliError("usage", "pool set <project>/<name> ... | list [project] | show <project>/<name> | remove <project>/<name>");
243
250
  }
251
+ /** project checkout <project> --exclude logs/,docs/big | none: paths new worktrees leave out. */
252
+ export async function projectCheckoutAdmin(rest, p, out) {
253
+ const project = rest[0];
254
+ const ex = str(p.flags, "exclude");
255
+ if (!project || ex === undefined)
256
+ throw new CliError("usage", "project checkout <project> --exclude <path,path | none> (new worktrees leave these out: wu start everywhere and pool sessions; commits still carry them)");
257
+ const r = await adminClient(p).call("PUT", `/projects/${project}/checkout`, { exclude: ex === "none" ? [] : ex.split(",").map((x) => x.trim()).filter(Boolean) });
258
+ out.print(`${project}: new worktrees ${r.checkout.exclude.length ? `leave out ${r.checkout.exclude.join(", ")}` : "check out everything"}. Existing worktrees are unchanged; read a left-out file with git show HEAD:<path>.`, r);
259
+ }
244
260
  /** project repo <project> <git url | none>: what daemons clone for the project's pool sessions. */
245
261
  export async function projectRepoAdmin(rest, p, out) {
246
262
  const [project, url] = rest;
@@ -7,6 +7,7 @@ import { Client } from "../client.js";
7
7
  import { configRoot, loadAgent, saveAgent } from "../config.js";
8
8
  import { CliError } from "../errors.js";
9
9
  import { CODEX_MANAGED_DIR, CODEX_MANAGED_MARK, codexManagedHooks } from "../harness.js";
10
+ import { applySparse } from "../git.js";
10
11
  import { installService, lingerEnabled, MACHINE_LABEL, removeService, requireInstall, restartWatcher, serviceActive, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
11
12
  import { CLI_VERSION } from "../version.js";
12
13
  export const machineFile = () => join(configRoot(), "machine.json");
@@ -38,7 +39,9 @@ const KEY_CHECK_MS = 10 * 60_000;
38
39
  /** One pass: make what runs here match what the operator declared, then report. */
39
40
  export async function reconcile(m, log) {
40
41
  const client = Client.raw(m.url, m.key);
41
- const desired = (await client.call("GET", "/machines/me")).sessions;
42
+ const me = await client.call("GET", "/machines/me");
43
+ const desired = me.sessions;
44
+ const workdir = me.machine?.workdir ?? null;
42
45
  const state = readMachineState();
43
46
  const bin = requireInstall().bin;
44
47
  const out = [];
@@ -60,7 +63,7 @@ export async function reconcile(m, log) {
60
63
  throw new Error(`harness ${s.harness} is not supported by this bschat ${CLI_VERSION}`);
61
64
  if (!s.dir) {
62
65
  // A pool session: the daemon makes the checkout (clone once per machine, a worktree per agent).
63
- const c = ensureCheckout(s, log);
66
+ const c = ensureCheckout(s, log, workdir);
64
67
  if ("preparing" in c) {
65
68
  out.push({ id: s.id, state: "preparing", detail: c.preparing });
66
69
  continue;
@@ -111,7 +114,7 @@ export async function reconcile(m, log) {
111
114
  delete state.sessions[id];
112
115
  }
113
116
  writeMachineState(state);
114
- const report = machineFacts();
117
+ const report = { ...machineFacts(), workdir: workdir ?? join(homedir(), "bschat"), workdir_free_bytes: freeBytes(workdir ?? homedir()) };
115
118
  await client.call("POST", "/machines/me/report", { report, sessions: out });
116
119
  return { sessions: out, report };
117
120
  }
@@ -123,12 +126,14 @@ const git = (args, cwd) => spawnSync("git", args, { cwd, encoding: "utf8", timeo
123
126
  * target with wu start). An identity file makes plain `bschat` there the agent; `.bschat/` is ignored
124
127
  * through the clone's info/exclude, so no tracked file changes.
125
128
  */
126
- export function ensureCheckout(s, log) {
129
+ export function ensureCheckout(s, log, workdir = null) {
127
130
  if (!s.project)
128
131
  throw new Error("an automatic checkout needs a project agent");
129
132
  if (!s.repo_url)
130
133
  throw new Error(`project ${s.project} has no repository URL: bschat-admin project repo ${s.project} <git url>`);
131
- const root = join(homedir(), "bschat", s.project);
134
+ if (workdir && !existsSync(workdir))
135
+ mkdirSync(workdir, { recursive: true });
136
+ const root = join(workdir ?? join(homedir(), "bschat"), s.project);
132
137
  const base = join(root, "main");
133
138
  const marker = join(root, ".cloning");
134
139
  if (!existsSync(join(base, ".git"))) {
@@ -159,10 +164,13 @@ export function ensureCheckout(s, log) {
159
164
  if (f.status !== 0)
160
165
  throw new Error(`git fetch in ${base} failed: ${(f.stderr ?? "").trim().slice(-300)}`);
161
166
  const head = (git(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], base).stdout ?? "").trim() || "origin/main";
162
- const w = git(["worktree", "add", "--detach", dir, head], base);
167
+ const exclude = s.checkout_exclude ?? [];
168
+ const w = git(["worktree", "add", "--detach", ...(exclude.length ? ["--no-checkout"] : []), dir, head], base);
163
169
  if (w.status !== 0)
164
170
  throw new Error(`git worktree add ${dir} failed: ${(w.stderr ?? "").trim().slice(-300)}`);
165
- log(`${s.agent}: worktree ${dir} at ${head}`);
171
+ if (exclude.length)
172
+ applySparse(dir, exclude);
173
+ log(`${s.agent}: worktree ${dir} at ${head}${exclude.length ? `, leaving out ${exclude.join(", ")}` : ""}`);
166
174
  }
167
175
  const common = (git(["rev-parse", "--path-format=absolute", "--git-common-dir"], base).stdout ?? "").trim();
168
176
  const exclude = join(common, "info", "exclude");
@@ -224,6 +232,15 @@ function lastTurnLine(ref) {
224
232
  const lines = readFileSync(f, "utf8").split("\n").filter((l) => /bschat watch\[/.test(l) && /turn #|TURN #|usage limit|pause lifted/.test(l));
225
233
  return lines.length ? lines[lines.length - 1].slice(0, 300) : null;
226
234
  }
235
+ function freeBytes(path) {
236
+ try {
237
+ const st = statfsSync(existsSync(path) ? path : dirname(path));
238
+ return st.bavail * st.bsize;
239
+ }
240
+ catch {
241
+ return null;
242
+ }
243
+ }
227
244
  /** What the operator needs to know about this machine, reported with every pass. */
228
245
  export function machineFacts() {
229
246
  const codex = spawnSync("codex", ["--version"], { encoding: "utf8" });
@@ -72,6 +72,8 @@ export async function wu(p, out) {
72
72
  ].filter(Boolean).join("\n");
73
73
  };
74
74
  const processDef = async () => (await client.call("GET", `/projects/${project}/process`)).process.definition;
75
+ // The project's sparse-checkout exclusions (bschat-admin project checkout), for new worktrees.
76
+ const checkoutExclude = async () => (await client.call("GET", `/projects/${project}/process`)).checkout?.exclude ?? [];
75
77
  switch (sub) {
76
78
  case "open": {
77
79
  const title = p.positionals.slice(2).join(" ").trim();
@@ -81,7 +83,7 @@ export async function wu(p, out) {
81
83
  // and recorded exactly as `wu start` would; --here keeps the current checkout.
82
84
  const r = await client.call("POST", base, { title, scope: str(p.flags, "scope") ?? "", tags: list("tags"), evidence: list("evidence"), ...branchAndHead(), worktree: process.cwd(), target: str(p.flags, "target") ?? null, milestone: str(p.flags, "milestone") ?? null });
83
85
  const n = r.unit.number;
84
- const { path, branch, mode } = prepareWorktree(n, r.unit, await processDef(), p);
86
+ const { path, branch, mode } = prepareWorktree(n, r.unit, await processDef(), p, await checkoutExclude());
85
87
  const where = branchAndHead(path);
86
88
  const s = await client.call("POST", `${base}/${n}/start`, { branch: branch ?? where.branch, head: where.head, worktree: path, mode });
87
89
  out.print(`${fmt(s.unit)}\n${mode === "here" ? "Working in this checkout." : `Your worktree: ${path} (branch ${branch})\n cd ${path}\nWork there.`}\nSubmit for review when ready: bschat wu submit ${n} --evidence <id>`, { ...s, worktree: path, branch, mode });
@@ -119,7 +121,7 @@ export async function wu(p, out) {
119
121
  const unit = (await client.call("GET", `${base}/${n}`)).unit;
120
122
  const def = await processDef();
121
123
  const target = unit.target ?? def.merge.target_branch;
122
- const { path, branch, mode } = prepareWorktree(n, unit, def, p);
124
+ const { path, branch, mode } = prepareWorktree(n, unit, def, p, await checkoutExclude());
123
125
  const where = branchAndHead(path);
124
126
  const r = await client.call("POST", `${base}/${n}/start`, { branch: branch ?? where.branch, head: where.head, worktree: path, mode });
125
127
  out.print(`${fmt(r.unit)}\nYour worktree: ${path}${mode === "fresh" ? ` (new branch ${branch} from ${target}${unit.replay ? " as of the original" : ""})` : mode === "branch" ? ` (branch ${branch})` : " (this checkout)"}\n cd ${path}\nWork there. Submit when ready: bschat wu submit ${n} --evidence <id>`, { ...r, worktree: path, branch, mode });
@@ -412,7 +414,7 @@ function cleanupUnitWorktree(wt, def, keep) {
412
414
  * One worktree per unit, made (or repaired) here. Exceptions are explicit and recorded: --branch
413
415
  * continues existing work in its own worktree; --here uses the current checkout (single-agent repos).
414
416
  */
415
- function prepareWorktree(n, unit, def, p) {
417
+ function prepareWorktree(n, unit, def, p, exclude = []) {
416
418
  // The unit's own target when it has one: a lane or release branch the work lands in.
417
419
  const target = unit.target ?? def.merge.target_branch;
418
420
  const log = (line) => process.stderr.write(`bschat: ${line}\n`);
@@ -449,7 +451,7 @@ function prepareWorktree(n, unit, def, p) {
449
451
  log(`created ${pinned} from origin/${pinned}`);
450
452
  }
451
453
  if (!existing)
452
- ensureWorktree(path, pinned, baseRef, process.cwd(), log);
454
+ ensureWorktree(path, pinned, baseRef, process.cwd(), log, exclude);
453
455
  return { mode: "branch", path, branch: pinned };
454
456
  }
455
457
  const slug = String(unit.title).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
@@ -462,7 +464,7 @@ function prepareWorktree(n, unit, def, p) {
462
464
  throw new CliError("no_base", `cannot find ${target} as of ${unit.replay.created_at} for the replay`, `git fetch origin ${target}:${target} then try again`);
463
465
  baseRef = at;
464
466
  }
465
- ensureWorktree(path, branch, baseRef, process.cwd(), log);
467
+ ensureWorktree(path, branch, baseRef, process.cwd(), log, exclude);
466
468
  return { mode: "fresh", path, branch };
467
469
  }
468
470
  /** The plan's slices: readiness, dependencies, unit counts. */
package/dist/git.js CHANGED
@@ -115,12 +115,28 @@ export function commitAtTime(ref, iso, cwd = process.cwd()) {
115
115
  * which case it is checked out as is. Returns the path. Fails loudly: a half-made worktree is
116
116
  * worse than none.
117
117
  */
118
- export function createWorktree(path, branch, base, cwd = process.cwd()) {
118
+ export function createWorktree(path, branch, base, cwd = process.cwd(), exclude = []) {
119
119
  const exists = git(["rev-parse", "--verify", "-q", `refs/heads/${branch}`], cwd) !== null;
120
- const args = exists ? ["worktree", "add", path, branch] : ["worktree", "add", "-b", branch, path, base];
120
+ const sparse = exclude.length > 0;
121
+ const args = ["worktree", "add", ...(sparse ? ["--no-checkout"] : []), ...(exists ? [path, branch] : ["-b", branch, path, base])];
121
122
  const r = spawnSync("git", args, { cwd, encoding: "utf8" });
122
123
  if (r.status !== 0)
123
124
  throw new Error(`git ${args.join(" ")}: ${(r.stderr || r.stdout).trim()}`);
125
+ if (sparse)
126
+ applySparse(path, exclude);
127
+ }
128
+ /**
129
+ * Non-cone sparse checkout patterns that keep everything except `exclude` (repository paths such as
130
+ * "logs/"): ester's logs/ is 18 GB of a 21 GB checkout. Commits still carry the paths.
131
+ */
132
+ export const sparsePatterns = (exclude) => ["/*", ...exclude.map((x) => `!/${x.replace(/^\/+/, "")}`)];
133
+ /** Sets a fresh `--no-checkout` worktree's sparse patterns (its own; git turns on per-worktree config) and fills it. */
134
+ export function applySparse(path, exclude) {
135
+ for (const args of [["sparse-checkout", "set", "--no-cone", ...sparsePatterns(exclude)], ["reset", "-q", "--hard", "HEAD"]]) {
136
+ const r = spawnSync("git", args, { cwd: path, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
137
+ if (r.status !== 0)
138
+ throw new Error(`git ${args.join(" ")} in ${path}: ${(r.stderr || r.stdout).trim()}`);
139
+ }
124
140
  }
125
141
  /** What git says about the worktree at `path`, from `git worktree list` plus a status probe. */
126
142
  export function worktreeState(path, cwd = process.cwd()) {
@@ -166,7 +182,7 @@ function realpathOrSelf(p) {
166
182
  * `git worktree add` (a harness timeout on a large repo) is removed and created again rather than
167
183
  * failing on "already exists"; an existing complete worktree on the right branch is reused.
168
184
  */
169
- export function ensureWorktree(path, branch, base, cwd = process.cwd(), log = () => { }) {
185
+ export function ensureWorktree(path, branch, base, cwd = process.cwd(), log = () => { }, exclude = []) {
170
186
  const st = worktreeState(path, cwd);
171
187
  if (st.state === "foreign")
172
188
  throw new Error(`${path} exists but is not a worktree of this repository; move it aside or pass --here`);
@@ -188,8 +204,8 @@ export function ensureWorktree(path, branch, base, cwd = process.cwd(), log = ()
188
204
  }
189
205
  const files = (git(["ls-files"], cwd) ?? "").split("\n").length;
190
206
  if (files > 20_000)
191
- log(`creating ${path} (${files.toLocaleString()} tracked files; this can take a minute or more)`);
192
- createWorktree(path, branch, base, cwd);
207
+ log(`creating ${path} (${files.toLocaleString()} tracked files${exclude.length ? `, leaving out ${exclude.join(", ")}` : "; this can take a minute or more"})`);
208
+ createWorktree(path, branch, base, cwd, exclude);
193
209
  return { created: true, repaired };
194
210
  }
195
211
  /**
package/dist/help.js CHANGED
@@ -206,9 +206,11 @@ Machines (provisioned over your own ssh; a daemon on each runs the agent session
206
206
  bschat-admin machine session stop|start|remove <machine> <project>/<agent>
207
207
  bschat-admin machine label <name> <label...> [--remove a,b] what cannot be measured (lab-lan, builds); pools' --needs match it
208
208
  bschat-admin machine slots <name> <n | auto> how many sessions it takes (auto: one per 4 GB of RAM)
209
+ bschat-admin machine workdir <name> <path | default> where its daemon clones projects for pool sessions (default ~/bschat)
209
210
 
210
211
  Pools (a role, variants and a count; the server names the agents and places them on machines)
211
212
  bschat-admin project repo <project> <git url | none> what machines clone for the project's pool sessions
213
+ bschat-admin project checkout <project> --exclude <path,path | none> paths new worktrees leave out (sparse checkout), e.g. logs/
212
214
  bschat-admin pool set <project>/<name> --role <role> --variant [tag=]harness:model[:effort][*weight] [--variant ...]
213
215
  --count <n> --sandbox <mode> [--needs label,label] [--min-ram GB] [--turn-timeout min]
214
216
  slots are agents named <name>-<tag>-<n>; fewer retires the extra ones
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.55";
1
+ export const CLI_VERSION = "0.12.57";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.55",
3
+ "version": "0.12.57",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {