@bunshin-cc/bunshin 0.3.0 → 0.3.1

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/bin.js +53 -6
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -2489,19 +2489,49 @@ import { createHash } from "node:crypto";
2489
2489
  import fs5 from "node:fs";
2490
2490
  import os from "node:os";
2491
2491
  import path4 from "node:path";
2492
+ function deployWorkspace(env = process.env) {
2493
+ if (env.BUNSHIN_DEPLOY_WORKSPACE) return path4.resolve(env.BUNSHIN_DEPLOY_WORKSPACE);
2494
+ try {
2495
+ const ws = JSON.parse(fs5.readFileSync(settingsFile(env.BUNSHIN_DEPLOY_HOME || os.homedir()), "utf8")).workspace;
2496
+ return typeof ws === "string" && ws ? ws : null;
2497
+ } catch {
2498
+ return null;
2499
+ }
2500
+ }
2492
2501
  function deployPaths(env = process.env) {
2493
2502
  const home = env.BUNSHIN_DEPLOY_HOME || os.homedir();
2503
+ const ws = deployWorkspace(env);
2494
2504
  return {
2495
2505
  home,
2496
- claudeSkills: path4.join(home, ".claude", "skills"),
2497
- codexSkills: path4.join(home, ".codex", "skills"),
2498
- claudeMd: path4.join(home, ".claude", "CLAUDE.md"),
2499
- agentsMd: path4.join(home, ".codex", "AGENTS.md"),
2506
+ claudeSkills: path4.join(ws ?? home, ".claude", "skills"),
2507
+ codexSkills: path4.join(ws ?? home, ".codex", "skills"),
2508
+ claudeMd: ws ? path4.join(ws, "CLAUDE.md") : path4.join(home, ".claude", "CLAUDE.md"),
2509
+ agentsMd: ws ? path4.join(ws, "AGENTS.md") : path4.join(home, ".codex", "AGENTS.md"),
2500
2510
  library: path4.join(home, ".bunshin", "library"),
2501
2511
  bin: path4.join(home, ".bunshin", "bin"),
2502
2512
  state: path4.join(home, ".bunshin", "deploy")
2503
2513
  };
2504
2514
  }
2515
+ function setDeployWorkspace(dir, env = process.env) {
2516
+ const home = env.BUNSHIN_DEPLOY_HOME || os.homedir();
2517
+ const ws = dir ? path4.resolve(dir.replace(/^~(?=$|\/)/, home)) : null;
2518
+ if (ws && !fs5.statSync(ws, { throwIfNoEntry: false })?.isDirectory()) throw new Error(`${ws} is not a folder`);
2519
+ const stateDir = path4.join(home, ".bunshin", "deploy");
2520
+ const deployed = fs5.existsSync(stateDir) && fs5.readdirSync(stateDir).some((f) => {
2521
+ if (f === "settings.json" || !f.endsWith(".json")) return false;
2522
+ try {
2523
+ return Object.keys(JSON.parse(fs5.readFileSync(path4.join(stateDir, f), "utf8")).docs ?? {}).length > 0;
2524
+ } catch {
2525
+ return false;
2526
+ }
2527
+ });
2528
+ if (deployed && ws !== deployWorkspace({ ...env, BUNSHIN_DEPLOY_WORKSPACE: "" })) {
2529
+ throw new Error("The library is already deployed to the current location. Set the workspace before the first sync on this machine.");
2530
+ }
2531
+ fs5.mkdirSync(path4.dirname(settingsFile(home)), { recursive: true });
2532
+ fs5.writeFileSync(settingsFile(home), JSON.stringify(ws ? { workspace: ws } : {}, null, 2) + "\n");
2533
+ return ws;
2534
+ }
2505
2535
  function statePath(p, orgId) {
2506
2536
  return path4.join(p.state, `${orgId.replace(/[^A-Za-z0-9._-]/g, "_") || "org"}.json`);
2507
2537
  }
@@ -3037,13 +3067,14 @@ function materialize(sections, dir) {
3037
3067
  }
3038
3068
  return { files };
3039
3069
  }
3040
- var sha, BLOCK_BEGIN, BLOCK_END, MANIFEST, MAX_FILE, isExecutable, LAYER_RANK, docMarker;
3070
+ var settingsFile, sha, BLOCK_BEGIN, BLOCK_END, MANIFEST, MAX_FILE, isExecutable, LAYER_RANK, docMarker;
3041
3071
  var init_deploy = __esm({
3042
3072
  "src/v2/deploy.ts"() {
3043
3073
  "use strict";
3044
3074
  init_v22();
3045
3075
  init_util();
3046
3076
  init_store2();
3077
+ settingsFile = (home) => path4.join(home, ".bunshin", "deploy", "settings.json");
3047
3078
  sha = (text2) => createHash("sha256").update(text2).digest("hex");
3048
3079
  BLOCK_BEGIN = "<!-- bunshin:begin -->";
3049
3080
  BLOCK_END = "<!-- bunshin:end -->";
@@ -7270,6 +7301,19 @@ async function cmdLibrary(store, args, cwd, out, err) {
7270
7301
  files: ${p.library}
7271
7302
  `);
7272
7303
  for (const x of pending) out(` edited here, awaiting the nightly: ${x.name}
7304
+ `);
7305
+ return 0;
7306
+ }
7307
+ case "workspace": {
7308
+ const target = args._[2];
7309
+ if (bool3(args.flags.clear)) setDeployWorkspace(null);
7310
+ else if (target) setDeployWorkspace(target);
7311
+ const ws = deployWorkspace();
7312
+ const p = deployPaths();
7313
+ out(ws ? `workspace: ${ws}
7314
+ ` : "workspace: none (skills and instructions are user-wide)\n");
7315
+ out(` skills: ${p.claudeSkills}, ${p.codexSkills}
7316
+ instructions: ${p.claudeMd}, ${p.agentsMd}
7273
7317
  `);
7274
7318
  return 0;
7275
7319
  }
@@ -8202,7 +8246,7 @@ init_util();
8202
8246
  init_project_hooks();
8203
8247
  function parseArgs(argv) {
8204
8248
  const out = { _: [], flags: {} };
8205
- const valueless = /* @__PURE__ */ new Set(["json", "quiet", "force", "sync", "global", "help", "version", "dry-run", "offline", "apply", "no-hooks", "remove-hooks", "key-stdin", "debug", "verbose", "robot", "fork", "upload", "index", "all", "legacy", "depth", "local", "skip-github", "propose-rewrites"]);
8249
+ const valueless = /* @__PURE__ */ new Set(["json", "quiet", "force", "sync", "global", "help", "version", "dry-run", "offline", "apply", "no-hooks", "remove-hooks", "key-stdin", "debug", "verbose", "robot", "fork", "upload", "index", "all", "legacy", "depth", "local", "skip-github", "propose-rewrites", "clear"]);
8206
8250
  for (let i = 0; i < argv.length; i++) {
8207
8251
  const a = argv[i];
8208
8252
  if (a === "--") {
@@ -8290,6 +8334,9 @@ Usage: bunshin <command> [options]
8290
8334
  the deployed skills; push proposes local edits / a new skill now
8291
8335
  library version|log|status|pin [--write [file]]|checkout <lib@N> --to <dir> [--git <sha>] [--pin <file>]
8292
8336
  library versions (lib@N), history, and exact reproductions
8337
+ library workspace [<dir>|--clear]
8338
+ deploy skills and instructions into a workspace folder (e.g.
8339
+ ~/Documents/dev) instead of ~/.claude and ~/.codex; set it before the first sync
8293
8340
  questions [list|answer <id> "<choice>"] open questions for your team
8294
8341
  suggest --code <harness path> [--file <local file>] [--rationale "<text>"]
8295
8342
  queue a robot harness code change (save_skill) for the release pipeline
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunshin-cc/bunshin",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Shared memory for company AI agents. Connect Codex, Claude Code, or Pi to Bunshin.",
5
5
  "type": "module",
6
6
  "bin": {