@lesscap/baton-cli 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/dist/baton.mjs +23 -13
  2. package/package.json +1 -1
package/dist/baton.mjs CHANGED
@@ -1655,14 +1655,22 @@ function getBaseURL() {
1655
1655
 
1656
1656
  // src/session/runner.ts
1657
1657
  import { spawnSync } from "node:child_process";
1658
- import { query as query2 } from "@anthropic-ai/claude-agent-sdk";
1658
+ import { query } from "@anthropic-ai/claude-agent-sdk";
1659
1659
 
1660
1660
  // src/session/runner/log.ts
1661
1661
  var maskedEnvKeys = (env) => env ? Object.keys(env).sort().join(", ") : "(none)";
1662
1662
 
1663
1663
  // src/session/runner/sdk-env.ts
1664
+ import { existsSync as existsSync3 } from "node:fs";
1665
+ import { isAbsolute } from "node:path";
1664
1666
  var buildSdkEnv = (overlay) => overlay ? { ...process.env, ...overlay } : void 0;
1665
1667
  var claudeExecutable = () => process.env.BATON_CLAUDE_BIN;
1668
+ var additionalDirs = () => {
1669
+ const raw = process.env.BATON_ADD_DIRS;
1670
+ if (!raw) return void 0;
1671
+ const dirs = raw.split(":").map((s) => s.trim()).filter((s) => s !== "" && isAbsolute(s) && existsSync3(s));
1672
+ return dirs.length > 0 ? dirs : void 0;
1673
+ };
1666
1674
 
1667
1675
  // src/session/runner/transcript.ts
1668
1676
  import { readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
@@ -1787,10 +1795,11 @@ ${text}` : header;
1787
1795
  };
1788
1796
 
1789
1797
  // src/session/runner/query.ts
1790
- import "@anthropic-ai/claude-agent-sdk";
1791
1798
  var startQuery = (config, text, resuming, queryFn, abortController, log, envOverlay) => {
1792
1799
  const env = buildSdkEnv(envOverlay);
1793
1800
  const exe = claudeExecutable();
1801
+ const addDirs = additionalDirs();
1802
+ if (addDirs) log(`[add-dir] ${addDirs.join(", ")}`);
1794
1803
  const options = {
1795
1804
  cwd: config.worktreePath,
1796
1805
  permissionMode: "bypassPermissions",
@@ -1799,7 +1808,8 @@ var startQuery = (config, text, resuming, queryFn, abortController, log, envOver
1799
1808
  stderr: (line) => log(`[claude] ${line.trimEnd()}`),
1800
1809
  ...resuming ? { resume: config.agentSessionId } : { sessionId: config.agentSessionId },
1801
1810
  ...env ? { env } : {},
1802
- ...exe ? { pathToClaudeCodeExecutable: exe } : {}
1811
+ ...exe ? { pathToClaudeCodeExecutable: exe } : {},
1812
+ ...addDirs ? { additionalDirectories: addDirs } : {}
1803
1813
  };
1804
1814
  return queryFn({ prompt: text, options });
1805
1815
  };
@@ -1945,7 +1955,7 @@ var restoreTty = () => {
1945
1955
  };
1946
1956
  var runDaemon = async (config, deps, signal) => {
1947
1957
  const log = deps.log ?? ((m) => console.log(`[#${config.sessionId} ${config.name}] ${m}`));
1948
- const qf = deps.queryFn ?? query2;
1958
+ const qf = deps.queryFn ?? query;
1949
1959
  const ESCtor = deps.eventSourceImpl ?? EventSource;
1950
1960
  log(`bin: ${claudeExecutable() ?? "(sdk bundled)"} cwd: ${config.worktreePath}`);
1951
1961
  log(`runtime env keys: ${maskedEnvKeys(deps.env)}`);
@@ -2341,10 +2351,10 @@ import { hostname as osHostname } from "node:os";
2341
2351
  // src/worker/daemon.ts
2342
2352
  import { spawn } from "node:child_process";
2343
2353
  import { randomUUID } from "node:crypto";
2344
- import { existsSync as existsSync4 } from "node:fs";
2354
+ import { existsSync as existsSync5 } from "node:fs";
2345
2355
  import { dirname as dirname2, join as join5 } from "node:path";
2346
2356
  import { fileURLToPath } from "node:url";
2347
- import { query as query3 } from "@anthropic-ai/claude-agent-sdk";
2357
+ import { query as query2 } from "@anthropic-ai/claude-agent-sdk";
2348
2358
 
2349
2359
  // src/session/runner/title.ts
2350
2360
  var clip = (s, max) => s.length > max ? s.slice(0, max) : s;
@@ -2391,10 +2401,10 @@ ${exchange}`;
2391
2401
 
2392
2402
  // src/session/worktree.ts
2393
2403
  import { execFileSync, spawnSync as spawnSync2 } from "node:child_process";
2394
- import { existsSync as existsSync3, mkdirSync } from "node:fs";
2404
+ import { existsSync as existsSync4, mkdirSync } from "node:fs";
2395
2405
  import { dirname } from "node:path";
2396
2406
  var createWorktree = (input) => {
2397
- if (existsSync3(input.worktreePath))
2407
+ if (existsSync4(input.worktreePath))
2398
2408
  throw new Error(`worktree path already exists: ${input.worktreePath}`);
2399
2409
  mkdirSync(dirname(input.worktreePath), { recursive: true });
2400
2410
  const branch = `baton/${input.sessionCode}`;
@@ -2416,7 +2426,7 @@ var repoHeadBranch = (repo) => {
2416
2426
  return branch || "main";
2417
2427
  };
2418
2428
  var removeWorktree = (repo, worktreePath) => {
2419
- if (!existsSync3(worktreePath)) return;
2429
+ if (!existsSync4(worktreePath)) return;
2420
2430
  try {
2421
2431
  execFileSync("git", ["-C", repo, "worktree", "remove", "--force", worktreePath], {
2422
2432
  stdio: "pipe"
@@ -2429,7 +2439,7 @@ var removeWorktree = (repo, worktreePath) => {
2429
2439
  var binPath = () => {
2430
2440
  const here = dirname2(fileURLToPath(import.meta.url));
2431
2441
  const devShim = join5(here, "..", "..", "bin", "baton.mjs");
2432
- return existsSync4(devShim) ? devShim : fileURLToPath(import.meta.url);
2442
+ return existsSync5(devShim) ? devShim : fileURLToPath(import.meta.url);
2433
2443
  };
2434
2444
  var runWorkerDaemon = async (cfg, client, signal) => {
2435
2445
  const repo = process.cwd();
@@ -2510,7 +2520,7 @@ var runWorkerDaemon = async (cfg, client, signal) => {
2510
2520
  worktreePath,
2511
2521
  userText: exchange.userText,
2512
2522
  assistantText: exchange.assistantText,
2513
- queryFn: query3
2523
+ queryFn: query2
2514
2524
  });
2515
2525
  if (!title) return log(`title #${sessionId}: not enough to title yet, skipping`);
2516
2526
  await client.sessions.setName(sessionId, title, cfg.apiToken);
@@ -2566,12 +2576,12 @@ var runWorkerDaemon = async (cfg, client, signal) => {
2566
2576
 
2567
2577
  // src/worker/machine-id.ts
2568
2578
  import { randomUUID as randomUUID2 } from "node:crypto";
2569
- import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
2579
+ import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
2570
2580
  import { homedir as homedir3 } from "node:os";
2571
2581
  import { dirname as dirname3, join as join6 } from "node:path";
2572
2582
  var machineIdPath = (env = process.env) => join6(env.XDG_DATA_HOME ?? join6(env.HOME ?? homedir3(), ".local/share"), "baton", "machine-id");
2573
2583
  var readOrCreateMachineId = (path = machineIdPath()) => {
2574
- if (existsSync5(path)) {
2584
+ if (existsSync6(path)) {
2575
2585
  const s = readFileSync3(path, "utf8").trim();
2576
2586
  if (s) return s;
2577
2587
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesscap/baton-cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "baton CLI — register/run a worker, manage projects/requirements/tasks/sessions",
6
6
  "bin": {