bamboo-agents 0.1.5-dev.36.1aed6b6 → 0.1.5-dev.37.e3cb3a7

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5-dev.36.1aed6b6
1
+ 0.1.5-dev.37.e3cb3a7
package/dist/index.js CHANGED
@@ -3037,7 +3037,7 @@ var VERSION;
3037
3037
  var init_version = __esm({
3038
3038
  "src/version.ts"() {
3039
3039
  "use strict";
3040
- VERSION = "0.1.5-dev.36.1aed6b6";
3040
+ VERSION = "0.1.5-dev.37.e3cb3a7";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -7159,6 +7159,15 @@ function configPath() {
7159
7159
  function credentialsPath() {
7160
7160
  return join(bambooDir(), "credentials.json");
7161
7161
  }
7162
+ function bambooStateDir() {
7163
+ if (process.env.BAMBOO_STATE_HOME) return process.env.BAMBOO_STATE_HOME;
7164
+ if (process.env.XDG_STATE_HOME)
7165
+ return join(process.env.XDG_STATE_HOME, "bamboo-agents");
7166
+ return join(homedir(), ".config", "bamboo-agents");
7167
+ }
7168
+ function statePath() {
7169
+ return join(bambooStateDir(), "state.json");
7170
+ }
7162
7171
  var init_paths = __esm({
7163
7172
  "src/lib/paths.ts"() {
7164
7173
  "use strict";
@@ -7227,7 +7236,81 @@ async function writeConfig(cfg) {
7227
7236
  mode: 420
7228
7237
  });
7229
7238
  }
7230
- var ConfigSchema, STATE_SCHEMA_VERSION, WorkspaceStateSchema;
7239
+ async function readState() {
7240
+ const file = statePath();
7241
+ let raw;
7242
+ try {
7243
+ raw = await readFile2(file, "utf8");
7244
+ } catch (err) {
7245
+ if (err.code === "ENOENT") return null;
7246
+ throw new WorkspaceStateError(
7247
+ "io",
7248
+ file,
7249
+ `Couldn't read ${file}: ${err.message}. Run \`bamboo-agents init\` to rebuild.`
7250
+ );
7251
+ }
7252
+ let parsed;
7253
+ try {
7254
+ parsed = JSON.parse(raw);
7255
+ } catch (err) {
7256
+ throw new WorkspaceStateError(
7257
+ "corrupt_json",
7258
+ file,
7259
+ `${file} is not valid JSON: ${err.message}. Delete it and re-run \`bamboo-agents init\` to rebuild.`
7260
+ );
7261
+ }
7262
+ const version = parsed && typeof parsed === "object" && "$schema_version" in parsed ? parsed.$schema_version : void 0;
7263
+ if (typeof version === "number" && version !== STATE_SCHEMA_VERSION) {
7264
+ throw new WorkspaceStateError(
7265
+ "schema_mismatch",
7266
+ file,
7267
+ `${file} uses schema version ${version}, but this CLI expects version ${STATE_SCHEMA_VERSION}. Run \`bamboo-agents init --reset\` to rebuild.`
7268
+ );
7269
+ }
7270
+ const result = WorkspaceStateSchema.safeParse(parsed);
7271
+ if (!result.success) {
7272
+ throw new WorkspaceStateError(
7273
+ "schema_mismatch",
7274
+ file,
7275
+ `${file} doesn't match the expected schema: ${result.error.message}. Run \`bamboo-agents init --reset\` to rebuild.`
7276
+ );
7277
+ }
7278
+ return result.data;
7279
+ }
7280
+ async function writeState(state) {
7281
+ WorkspaceStateSchema.parse(state);
7282
+ const dir = bambooStateDir();
7283
+ const target = statePath();
7284
+ await mkdir2(dir, { recursive: true, mode: 448 });
7285
+ await chmod2(dir, 448);
7286
+ const tmp = `${target}.${randomBytes(6).toString("hex")}.tmp`;
7287
+ await writeFile2(tmp, JSON.stringify(state, null, 2) + "\n", {
7288
+ encoding: "utf8",
7289
+ mode: 384
7290
+ });
7291
+ try {
7292
+ await rename(tmp, target);
7293
+ } catch (err) {
7294
+ try {
7295
+ await unlink(tmp);
7296
+ } catch {
7297
+ }
7298
+ throw err;
7299
+ }
7300
+ await chmod2(target, 384);
7301
+ }
7302
+ async function updateLastSync(when) {
7303
+ const current = await readState();
7304
+ if (!current) {
7305
+ throw new WorkspaceStateError(
7306
+ "io",
7307
+ statePath(),
7308
+ `Cannot update last_sync \u2014 no workspace state at ${statePath()}. Run \`bamboo-agents init\` first.`
7309
+ );
7310
+ }
7311
+ await writeState({ ...current, last_sync: when.toISOString() });
7312
+ }
7313
+ var ConfigSchema, STATE_SCHEMA_VERSION, WorkspaceStateSchema, WorkspaceStateError;
7231
7314
  var init_state = __esm({
7232
7315
  "src/lib/state.ts"() {
7233
7316
  "use strict";
@@ -7255,6 +7338,16 @@ var init_state = __esm({
7255
7338
  // ISO-8601
7256
7339
  remote_url: external_exports.string().url()
7257
7340
  });
7341
+ WorkspaceStateError = class extends Error {
7342
+ kind;
7343
+ path;
7344
+ constructor(kind, path2, message) {
7345
+ super(message);
7346
+ this.name = "WorkspaceStateError";
7347
+ this.kind = kind;
7348
+ this.path = path2;
7349
+ }
7350
+ };
7258
7351
  }
7259
7352
  });
7260
7353
 
@@ -13635,35 +13728,81 @@ var init_claude_desktop = __esm({
13635
13728
  }
13636
13729
  });
13637
13730
 
13731
+ // src/lib/workspace.ts
13732
+ import { existsSync } from "node:fs";
13733
+ async function resolveWorkspace() {
13734
+ const state = await readState();
13735
+ if (state) {
13736
+ if (!existsSync(state.workspace_path)) {
13737
+ throw new NoWorkspaceError(
13738
+ `Bamboo workspace not found.
13739
+ (State recorded ${state.workspace_path} but it's missing on disk \u2014 run \`bamboo-agents init --reset\` to re-clone.)`
13740
+ );
13741
+ }
13742
+ return { path: state.workspace_path, orgId: state.org_id };
13743
+ }
13744
+ const config = await readConfig();
13745
+ if (config) {
13746
+ if (!existsSync(config.repo_path)) {
13747
+ throw new NoWorkspaceError(
13748
+ `Bamboo workspace not found.
13749
+ (Config recorded ${config.repo_path} but it's missing on disk \u2014 run \`bamboo-agents init --reset\` to re-clone.)`
13750
+ );
13751
+ }
13752
+ return { path: config.repo_path, orgId: config.org_id };
13753
+ }
13754
+ throw new NoWorkspaceError(
13755
+ "No Bamboo workspace yet. Run `bamboo-agents init` first."
13756
+ );
13757
+ }
13758
+ var NoWorkspaceError;
13759
+ var init_workspace = __esm({
13760
+ "src/lib/workspace.ts"() {
13761
+ "use strict";
13762
+ init_state();
13763
+ NoWorkspaceError = class extends Error {
13764
+ constructor(message) {
13765
+ super(message);
13766
+ this.name = "NoWorkspaceError";
13767
+ }
13768
+ };
13769
+ }
13770
+ });
13771
+
13638
13772
  // src/commands/open.ts
13639
13773
  var open_exports = {};
13640
13774
  __export(open_exports, {
13641
13775
  runOpen: () => runOpen
13642
13776
  });
13643
13777
  async function runOpen() {
13644
- const cfg = await readConfig();
13645
- if (!cfg) {
13646
- console.error("No workspace configured. Run `bamboo-agents init` first.");
13647
- process.exit(2);
13778
+ let workspacePath;
13779
+ try {
13780
+ workspacePath = (await resolveWorkspace()).path;
13781
+ } catch (err) {
13782
+ if (err instanceof NoWorkspaceError) {
13783
+ console.error(err.message);
13784
+ process.exit(2);
13785
+ }
13786
+ throw err;
13648
13787
  }
13649
13788
  const status = await detectClaudeDesktop();
13650
13789
  if (status.kind === "missing") {
13651
13790
  console.error(
13652
13791
  `Claude Desktop isn't installed. Get it at ${DOWNLOAD_URL}, then re-run \`bamboo-agents open\`.`
13653
13792
  );
13654
- console.error(`(Your workspace is cloned at ${cfg.repo_path}.)`);
13793
+ console.error(`(Your workspace is cloned at ${workspacePath}.)`);
13655
13794
  process.exit(1);
13656
13795
  }
13657
13796
  if (status.kind === "unsupported_platform") {
13658
13797
  console.log("");
13659
13798
  console.log(" Claude Desktop isn't available on Linux yet.");
13660
- console.log(` Your workspace is cloned at: ${cfg.repo_path}`);
13799
+ console.log(` Your workspace is cloned at: ${workspacePath}`);
13661
13800
  console.log("");
13662
13801
  return;
13663
13802
  }
13664
- const url = `claude://code/new?folder=${encodeURIComponent(cfg.repo_path)}`;
13803
+ const url = `claude://code/new?folder=${encodeURIComponent(workspacePath)}`;
13665
13804
  await open_default(url);
13666
- console.log(`Opening Claude Code at ${cfg.repo_path}\u2026`);
13805
+ console.log(`Opening Claude Code at ${workspacePath}\u2026`);
13667
13806
  console.log("(Claude Desktop will ask you to trust the folder the first time.)");
13668
13807
  }
13669
13808
  var DOWNLOAD_URL;
@@ -13672,7 +13811,7 @@ var init_open2 = __esm({
13672
13811
  "use strict";
13673
13812
  init_open();
13674
13813
  init_claude_desktop();
13675
- init_state();
13814
+ init_workspace();
13676
13815
  DOWNLOAD_URL = "https://claude.com/download";
13677
13816
  }
13678
13817
  });
@@ -13700,6 +13839,7 @@ function formatSubscriptionLine(billing) {
13700
13839
  }
13701
13840
  async function runStatus() {
13702
13841
  const creds = await readCredentials();
13842
+ const state = await readState().catch(() => null);
13703
13843
  const cfg = await readConfig();
13704
13844
  console.log("");
13705
13845
  console.log(" Bamboo CLI status");
@@ -13715,13 +13855,18 @@ async function runStatus() {
13715
13855
  console.log(` GitHub expires: ${creds.github_token_expires_at}`);
13716
13856
  }
13717
13857
  }
13718
- if (!cfg) {
13858
+ const workspacePath = state?.workspace_path ?? cfg?.repo_path ?? null;
13859
+ if (!workspacePath) {
13719
13860
  console.log(" Workspace: not configured (run `bamboo-agents init`)");
13720
13861
  } else {
13721
- console.log(` Workspace: ${cfg.workspace_repo}`);
13722
- console.log(` Repo path: ${cfg.repo_path}`);
13723
- console.log(` Org: ${cfg.org_name}`);
13724
- console.log(` Installed: ${cfg.installed_at}`);
13862
+ const repoLabel = cfg?.workspace_repo ?? state?.remote_url?.replace(/^https?:\/\/github\.com\//, "") ?? "(unknown)";
13863
+ console.log(` Workspace: ${repoLabel}`);
13864
+ console.log(` Repo path: ${workspacePath}`);
13865
+ console.log(` Org: ${cfg?.org_name ?? state?.org_slug ?? "(unknown)"}`);
13866
+ console.log(` Installed: ${cfg?.installed_at ?? state?.cloned_at ?? "(unknown)"}`);
13867
+ if (state?.last_sync) {
13868
+ console.log(` Last sync: ${state.last_sync}`);
13869
+ }
13725
13870
  }
13726
13871
  if (creds?.bamboo_session) {
13727
13872
  try {
@@ -13882,6 +14027,130 @@ var init_doctor = __esm({
13882
14027
  }
13883
14028
  });
13884
14029
 
14030
+ // src/commands/save.ts
14031
+ var save_exports = {};
14032
+ __export(save_exports, {
14033
+ runSave: () => runSave
14034
+ });
14035
+ import { execFile as execFile8 } from "node:child_process";
14036
+ import { promisify as promisify8 } from "node:util";
14037
+ async function gitC(repoPath, args) {
14038
+ const { stdout, stderr } = await execFileP3("git", ["-C", repoPath, ...args], {
14039
+ encoding: "utf8"
14040
+ });
14041
+ return { stdout, stderr };
14042
+ }
14043
+ async function runSave(message) {
14044
+ if (!message || !message.trim()) {
14045
+ console.error("bamboo-agents save: commit message is required.");
14046
+ console.error('Example: bamboo-agents save "tightened the brand voice doc"');
14047
+ process.exit(2);
14048
+ }
14049
+ let workspacePath;
14050
+ try {
14051
+ workspacePath = (await resolveWorkspace()).path;
14052
+ } catch (err) {
14053
+ if (err instanceof NoWorkspaceError) {
14054
+ console.error(`bamboo-agents save: ${err.message}`);
14055
+ process.exit(2);
14056
+ }
14057
+ throw err;
14058
+ }
14059
+ try {
14060
+ await gitC(workspacePath, ["add", "-A"]);
14061
+ let hasStagedChanges = false;
14062
+ try {
14063
+ await gitC(workspacePath, ["diff", "--cached", "--quiet"]);
14064
+ } catch {
14065
+ hasStagedChanges = true;
14066
+ }
14067
+ if (!hasStagedChanges) {
14068
+ console.log("");
14069
+ console.log(" Nothing to save \u2014 your workspace is already up to date.");
14070
+ console.log("");
14071
+ return;
14072
+ }
14073
+ await gitC(workspacePath, ["commit", "-m", message.trim()]);
14074
+ await gitC(workspacePath, ["push"]);
14075
+ console.log("");
14076
+ console.log(` Saved: ${message.trim()}`);
14077
+ console.log(` (pushed from ${workspacePath})`);
14078
+ console.log("");
14079
+ } catch (err) {
14080
+ const e = err;
14081
+ console.error("bamboo-agents save: git failed.");
14082
+ if (e.stderr?.trim()) console.error(e.stderr.trim());
14083
+ else console.error(e.message);
14084
+ process.exit(1);
14085
+ }
14086
+ }
14087
+ var execFileP3;
14088
+ var init_save = __esm({
14089
+ "src/commands/save.ts"() {
14090
+ "use strict";
14091
+ init_workspace();
14092
+ execFileP3 = promisify8(execFile8);
14093
+ }
14094
+ });
14095
+
14096
+ // src/commands/sync.ts
14097
+ var sync_exports = {};
14098
+ __export(sync_exports, {
14099
+ runSync: () => runSync
14100
+ });
14101
+ import { execFile as execFile9 } from "node:child_process";
14102
+ import { promisify as promisify9 } from "node:util";
14103
+ async function runSync() {
14104
+ let workspacePath;
14105
+ try {
14106
+ workspacePath = (await resolveWorkspace()).path;
14107
+ } catch (err) {
14108
+ if (err instanceof NoWorkspaceError) {
14109
+ console.error(`bamboo-agents sync: ${err.message}`);
14110
+ process.exit(2);
14111
+ }
14112
+ throw err;
14113
+ }
14114
+ try {
14115
+ const { stdout } = await execFileP4(
14116
+ "git",
14117
+ ["-C", workspacePath, "pull", "--ff-only"],
14118
+ { encoding: "utf8" }
14119
+ );
14120
+ console.log("");
14121
+ console.log(" Synced your workspace with the remote.");
14122
+ if (stdout.trim()) {
14123
+ console.log(` ${stdout.trim().split("\n").pop()}`);
14124
+ }
14125
+ console.log(` (workspace: ${workspacePath})`);
14126
+ console.log("");
14127
+ } catch (err) {
14128
+ const e = err;
14129
+ console.error("bamboo-agents sync: git failed.");
14130
+ if (e.stderr?.trim()) console.error(e.stderr.trim());
14131
+ else console.error(e.message);
14132
+ process.exit(1);
14133
+ }
14134
+ try {
14135
+ const state = await readState();
14136
+ if (state) await updateLastSync(/* @__PURE__ */ new Date());
14137
+ } catch (err) {
14138
+ if (err instanceof WorkspaceStateError) {
14139
+ return;
14140
+ }
14141
+ throw err;
14142
+ }
14143
+ }
14144
+ var execFileP4;
14145
+ var init_sync = __esm({
14146
+ "src/commands/sync.ts"() {
14147
+ "use strict";
14148
+ init_state();
14149
+ init_workspace();
14150
+ execFileP4 = promisify9(execFile9);
14151
+ }
14152
+ });
14153
+
13885
14154
  // src/lib/skills-local.ts
13886
14155
  import { readdir as readdir2, readFile as readFile4, stat as stat2 } from "node:fs/promises";
13887
14156
  import { join as join2 } from "node:path";
@@ -14061,14 +14330,15 @@ __export(skills_exports, {
14061
14330
  runSkillsUpdate: () => runSkillsUpdate
14062
14331
  });
14063
14332
  async function resolveWorkspacePath() {
14064
- const cfg = await readConfig();
14065
- if (!cfg) {
14066
- console.error(
14067
- "bamboo-agents: no workspace configured. Run `bamboo-agents init` first."
14068
- );
14069
- process.exit(1);
14333
+ try {
14334
+ return (await resolveWorkspace()).path;
14335
+ } catch (err) {
14336
+ if (err instanceof NoWorkspaceError) {
14337
+ console.error(`bamboo-agents: ${err.message}`);
14338
+ process.exit(1);
14339
+ }
14340
+ throw err;
14070
14341
  }
14071
- return cfg.repo_path;
14072
14342
  }
14073
14343
  function summarize(description, max = 80) {
14074
14344
  const oneLine = description.replace(/\s+/g, " ").trim();
@@ -14375,8 +14645,8 @@ async function runSkillsUpdate(agentIdentifier, skillName) {
14375
14645
  var init_skills = __esm({
14376
14646
  "src/commands/skills.ts"() {
14377
14647
  "use strict";
14378
- init_state();
14379
14648
  init_credentials();
14649
+ init_workspace();
14380
14650
  init_skills_local();
14381
14651
  init_api();
14382
14652
  }
@@ -14427,6 +14697,14 @@ program2.command("doctor").description("Verify your local setup is ready").actio
14427
14697
  const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
14428
14698
  await runDoctor2();
14429
14699
  });
14700
+ program2.command("save <message>").description("Commit + push everything in your workspace (cwd-agnostic)").action(async (message) => {
14701
+ const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save(), save_exports));
14702
+ await runSave2(message);
14703
+ });
14704
+ program2.command("sync").description("Pull your workspace clone up to remote (cwd-agnostic)").action(async () => {
14705
+ const { runSync: runSync2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
14706
+ await runSync2();
14707
+ });
14430
14708
  var skills = program2.command("skills").description("Read workspace skills from your local clone");
14431
14709
  skills.command("list").description("List every skill in the workspace").option(
14432
14710
  "--agent <slug>",