bamboo-agents 0.1.5-dev.28 → 0.1.5-dev.30

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.28
1
+ 0.1.5-dev.30
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.28";
3040
+ VERSION = "0.1.5-dev.30";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -12784,8 +12784,8 @@ var init_prompt = __esm({
12784
12784
  });
12785
12785
 
12786
12786
  // src/lib/phases-impl/pick-first-user-agent-phase.ts
12787
- import { readFile as readFile3, stat } from "node:fs/promises";
12788
- import { join as pathJoin, resolve as pathResolve3 } from "node:path";
12787
+ import { readdir, readFile as readFile3, stat } from "node:fs/promises";
12788
+ import { dirname, join as pathJoin, resolve as pathResolve3 } from "node:path";
12789
12789
  async function runCaseA(ctx) {
12790
12790
  console.log(" Let's set up YOUR first agent. How would you like to start?");
12791
12791
  console.log("");
@@ -12874,49 +12874,9 @@ async function runCreateFlow(ctx) {
12874
12874
  }
12875
12875
  async function runUploadFlow(ctx) {
12876
12876
  if (!ctx.credentials) return null;
12877
- console.log("");
12878
- const defaultsHint = UPLOAD_DEFAULT_PATHS.join(" or ");
12879
- const filePathInput = await promptStdin(
12880
- ` Path to the CLAUDE.md/AGENTS.md file (default: ${defaultsHint}): `
12881
- );
12882
- const filePath = filePathInput ?? UPLOAD_DEFAULT_PATHS[0];
12883
- const requestedPath = pathResolve3(ctx.cwd, filePath);
12884
- let absPath = requestedPath;
12885
- try {
12886
- const s = await stat(requestedPath);
12887
- if (s.isDirectory()) {
12888
- let resolved = null;
12889
- for (const name2 of UPLOAD_DEFAULT_PATHS) {
12890
- const candidate = pathJoin(requestedPath, name2);
12891
- try {
12892
- const cs = await stat(candidate);
12893
- if (cs.isFile()) {
12894
- resolved = candidate;
12895
- break;
12896
- }
12897
- } catch {
12898
- }
12899
- }
12900
- if (!resolved) {
12901
- console.log("");
12902
- console.log(
12903
- ` ${requestedPath} is a directory and doesn't contain a ${UPLOAD_DEFAULT_PATHS.join(" or ")}.`
12904
- );
12905
- return null;
12906
- }
12907
- absPath = resolved;
12908
- }
12909
- } catch {
12910
- }
12911
- let content;
12912
- try {
12913
- content = await readFile3(absPath, "utf8");
12914
- } catch (err) {
12915
- const message = err instanceof Error ? err.message : String(err);
12916
- console.log("");
12917
- console.log(` Couldn't read ${absPath}: ${message}`);
12918
- return null;
12919
- }
12877
+ const resolved = await resolveUploadFile(ctx);
12878
+ if (!resolved) return null;
12879
+ const { absPath, content } = resolved;
12920
12880
  const bytes = Buffer.byteLength(content, "utf8");
12921
12881
  if (bytes > MAX_UPLOAD_BYTES) {
12922
12882
  console.log("");
@@ -12974,6 +12934,99 @@ async function runUploadFlow(ctx) {
12974
12934
  return null;
12975
12935
  }
12976
12936
  }
12937
+ async function resolveUploadFile(ctx) {
12938
+ const defaultsHint = UPLOAD_DEFAULT_PATHS.join(" or ");
12939
+ let isFirstPrompt = true;
12940
+ for (let attempt = 0; attempt < 5; attempt += 1) {
12941
+ console.log("");
12942
+ const question = isFirstPrompt ? ` Path to the CLAUDE.md/AGENTS.md file (default: ${defaultsHint}): ` : " Try a different path (or hit enter to cancel): ";
12943
+ const filePathInput = await promptStdin(question, { maxRetries: 0 });
12944
+ let filePath;
12945
+ if (filePathInput === null) {
12946
+ if (!isFirstPrompt) {
12947
+ return null;
12948
+ }
12949
+ filePath = UPLOAD_DEFAULT_PATHS[0];
12950
+ } else {
12951
+ filePath = filePathInput;
12952
+ }
12953
+ isFirstPrompt = false;
12954
+ const requestedPath = pathResolve3(ctx.cwd, filePath);
12955
+ let absPath = requestedPath;
12956
+ try {
12957
+ const s = await stat(requestedPath);
12958
+ if (s.isDirectory()) {
12959
+ let resolvedInside = null;
12960
+ for (const name of UPLOAD_DEFAULT_PATHS) {
12961
+ const candidate = pathJoin(requestedPath, name);
12962
+ try {
12963
+ const cs = await stat(candidate);
12964
+ if (cs.isFile()) {
12965
+ resolvedInside = candidate;
12966
+ break;
12967
+ }
12968
+ } catch {
12969
+ }
12970
+ }
12971
+ if (!resolvedInside) {
12972
+ console.log("");
12973
+ console.log(
12974
+ ` ${requestedPath} is a directory and doesn't contain a ${UPLOAD_DEFAULT_PATHS.join(" or ")}.`
12975
+ );
12976
+ await printDirectorySneakPeek(ctx.cwd, pathJoin(requestedPath, UPLOAD_DEFAULT_PATHS[0]));
12977
+ continue;
12978
+ }
12979
+ absPath = resolvedInside;
12980
+ }
12981
+ } catch {
12982
+ }
12983
+ try {
12984
+ const content = await readFile3(absPath, "utf8");
12985
+ return { absPath, content };
12986
+ } catch (err) {
12987
+ await handleReadFailure(ctx, absPath, err);
12988
+ }
12989
+ }
12990
+ console.log("");
12991
+ console.log(
12992
+ " Couldn't find a file to upload after several tries \u2014 cancelling. Re-run `bamboo-agents` when ready."
12993
+ );
12994
+ return null;
12995
+ }
12996
+ async function handleReadFailure(ctx, absPath, err) {
12997
+ const code = err.code ?? (err instanceof Error ? err.message : String(err));
12998
+ const message = err instanceof Error ? err.message : String(err);
12999
+ console.log("");
13000
+ console.log(` Couldn't read ${absPath}: ${message}`);
13001
+ if (code === "ENOENT" || code === "EACCES" || code === "EISDIR" || code === "ENOTDIR") {
13002
+ await printDirectorySneakPeek(ctx.cwd, absPath);
13003
+ }
13004
+ }
13005
+ async function printDirectorySneakPeek(cwd, failedAbsPath) {
13006
+ const parent = dirname(failedAbsPath);
13007
+ const targets = [parent, cwd];
13008
+ const seen = /* @__PURE__ */ new Set();
13009
+ for (const target of targets) {
13010
+ if (seen.has(target)) continue;
13011
+ seen.add(target);
13012
+ let entries;
13013
+ try {
13014
+ const s = await stat(target);
13015
+ if (!s.isDirectory()) continue;
13016
+ entries = await readdir(target);
13017
+ } catch {
13018
+ continue;
13019
+ }
13020
+ if (entries.length === 0) {
13021
+ console.log(` (${target} is empty)`);
13022
+ return;
13023
+ }
13024
+ const sample = entries.slice(0, 5).join(", ");
13025
+ const more = entries.length > 5 ? ` (and ${entries.length - 5} more)` : "";
13026
+ console.log(` ${target} contains: ${sample}${more}`);
13027
+ return;
13028
+ }
13029
+ }
12977
13030
  async function resolveBrand(ctx) {
12978
13031
  if (!ctx.credentials) return null;
12979
13032
  let brands;
@@ -13323,8 +13376,13 @@ var init_open_phase = __esm({
13323
13376
  await open_default(url);
13324
13377
  console.log(`Opening Claude Code at ${ctx.config.repo_path}\u2026`);
13325
13378
  console.log("(Claude Desktop will ask you to trust the folder the first time.)");
13379
+ const dashboardUrl = `${apiBase()}/app`;
13326
13380
  console.log("");
13327
- console.log(` \u2192 Continue setup at ${apiBase()}/app`);
13381
+ console.log(` \u2192 Continue setup at ${dashboardUrl}`);
13382
+ try {
13383
+ await open_default(dashboardUrl);
13384
+ } catch {
13385
+ }
13328
13386
  return {
13329
13387
  kind: "advanced",
13330
13388
  summary: `Launching Claude Code at ${ctx.config.repo_path}`
@@ -13336,22 +13394,32 @@ var init_open_phase = __esm({
13336
13394
 
13337
13395
  // src/lib/orchestrator-steps/health-line.ts
13338
13396
  async function printHealthLine(ctx) {
13397
+ if (!ctx.credentials?.bamboo_session) return;
13398
+ if (!ctx.agentId) return;
13399
+ console.log("");
13400
+ console.log(" Computing health score\u2026");
13401
+ let health;
13339
13402
  try {
13340
- if (!ctx.credentials?.bamboo_session) return;
13341
- if (!ctx.agentId) return;
13342
- const health = await getAgentHealth(
13403
+ health = await getAgentHealth(
13343
13404
  ctx.credentials.bamboo_session,
13344
13405
  ctx.agentId
13345
13406
  );
13346
- if (!health) return;
13347
- const score = Math.round(health.score);
13348
- const max = health.max;
13349
- const gap = health.top_gap_slot;
13350
- const line = gap ? ` Health: ${score} / ${max} \u2014 top gap: ${gap}` : ` Health: ${score} / ${max}`;
13351
- console.log("");
13352
- console.log(line);
13353
- } catch {
13407
+ } catch (err) {
13408
+ const code = err && typeof err === "object" && "errorCode" in err && err.errorCode ? String(err.errorCode) : err instanceof Error ? err.message : String(err);
13409
+ console.log(
13410
+ ` Couldn't compute health: ${code} \u2014 re-run with --debug for details, or check \`bamboo-agents doctor\`.`
13411
+ );
13412
+ return;
13413
+ }
13414
+ if (!health) {
13415
+ console.log(" (this agent doesn't have a health rubric yet \u2014 skipping)");
13416
+ return;
13354
13417
  }
13418
+ const score = Math.round(health.score);
13419
+ const max = health.max;
13420
+ const gap = health.top_gap_slot;
13421
+ const line = gap ? ` Health: ${score} / ${max} \u2014 top gap: ${gap}` : ` Health: ${score} / ${max}`;
13422
+ console.log(line);
13355
13423
  }
13356
13424
  var init_health_line = __esm({
13357
13425
  "src/lib/orchestrator-steps/health-line.ts"() {