bamboo-agents 0.1.5-dev.36.1aed6b6 → 0.1.5-dev.38.aeaecba
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 +1 -1
- package/dist/index.js +504 -89
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
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.
|
|
3040
|
+
VERSION = "0.1.5-dev.38.aeaecba";
|
|
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
|
-
|
|
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
|
|
|
@@ -12339,17 +12432,115 @@ var init_git = __esm({
|
|
|
12339
12432
|
}
|
|
12340
12433
|
});
|
|
12341
12434
|
|
|
12435
|
+
// src/lib/prompt.ts
|
|
12436
|
+
import { createInterface } from "node:readline";
|
|
12437
|
+
async function promptStdin(question, opts = {}) {
|
|
12438
|
+
const maxRetries = opts.maxRetries ?? 2;
|
|
12439
|
+
const isInteractive2 = process.stdin.isTTY === true;
|
|
12440
|
+
const rl = createInterface({
|
|
12441
|
+
input: process.stdin,
|
|
12442
|
+
output: process.stdout,
|
|
12443
|
+
terminal: isInteractive2
|
|
12444
|
+
});
|
|
12445
|
+
const onSigInt = () => {
|
|
12446
|
+
rl.close();
|
|
12447
|
+
};
|
|
12448
|
+
rl.on("SIGINT", onSigInt);
|
|
12449
|
+
try {
|
|
12450
|
+
let attempts = 0;
|
|
12451
|
+
while (attempts <= maxRetries) {
|
|
12452
|
+
const answer = await readOnce(rl, question);
|
|
12453
|
+
if (answer === null) return null;
|
|
12454
|
+
const trimmed = answer.trim();
|
|
12455
|
+
if (trimmed.length > 0) return trimmed;
|
|
12456
|
+
attempts += 1;
|
|
12457
|
+
if (attempts > maxRetries || !isInteractive2) return null;
|
|
12458
|
+
console.log(" (Press Enter without typing to skip \u2014 or answer Boo's question.)");
|
|
12459
|
+
}
|
|
12460
|
+
return null;
|
|
12461
|
+
} finally {
|
|
12462
|
+
rl.off("SIGINT", onSigInt);
|
|
12463
|
+
rl.close();
|
|
12464
|
+
}
|
|
12465
|
+
}
|
|
12466
|
+
function readOnce(rl, question) {
|
|
12467
|
+
return new Promise((resolve) => {
|
|
12468
|
+
let resolved = false;
|
|
12469
|
+
const settle = (value) => {
|
|
12470
|
+
if (resolved) return;
|
|
12471
|
+
resolved = true;
|
|
12472
|
+
resolve(value);
|
|
12473
|
+
};
|
|
12474
|
+
rl.once("close", () => settle(null));
|
|
12475
|
+
rl.question(question, (answer) => settle(answer));
|
|
12476
|
+
});
|
|
12477
|
+
}
|
|
12478
|
+
var init_prompt = __esm({
|
|
12479
|
+
"src/lib/prompt.ts"() {
|
|
12480
|
+
"use strict";
|
|
12481
|
+
}
|
|
12482
|
+
});
|
|
12483
|
+
|
|
12484
|
+
// src/lib/workspace.ts
|
|
12485
|
+
import { existsSync } from "node:fs";
|
|
12486
|
+
import os4 from "node:os";
|
|
12487
|
+
import { resolve as pathResolve } from "node:path";
|
|
12488
|
+
function defaultClonePath(orgSlug) {
|
|
12489
|
+
const cleanSlug = orgSlug.replace(/^bamboo-?/i, "") || orgSlug;
|
|
12490
|
+
return pathResolve(os4.homedir(), "Bamboo", cleanSlug);
|
|
12491
|
+
}
|
|
12492
|
+
async function resolveWorkspace() {
|
|
12493
|
+
const state = await readState();
|
|
12494
|
+
if (state) {
|
|
12495
|
+
if (!existsSync(state.workspace_path)) {
|
|
12496
|
+
throw new NoWorkspaceError(
|
|
12497
|
+
`Bamboo workspace not found.
|
|
12498
|
+
(State recorded ${state.workspace_path} but it's missing on disk \u2014 run \`bamboo-agents init --reset\` to re-clone.)`
|
|
12499
|
+
);
|
|
12500
|
+
}
|
|
12501
|
+
return { path: state.workspace_path, orgId: state.org_id };
|
|
12502
|
+
}
|
|
12503
|
+
const config = await readConfig();
|
|
12504
|
+
if (config) {
|
|
12505
|
+
if (!existsSync(config.repo_path)) {
|
|
12506
|
+
throw new NoWorkspaceError(
|
|
12507
|
+
`Bamboo workspace not found.
|
|
12508
|
+
(Config recorded ${config.repo_path} but it's missing on disk \u2014 run \`bamboo-agents init --reset\` to re-clone.)`
|
|
12509
|
+
);
|
|
12510
|
+
}
|
|
12511
|
+
return { path: config.repo_path, orgId: config.org_id };
|
|
12512
|
+
}
|
|
12513
|
+
throw new NoWorkspaceError(
|
|
12514
|
+
"No Bamboo workspace yet. Run `bamboo-agents init` first."
|
|
12515
|
+
);
|
|
12516
|
+
}
|
|
12517
|
+
var NoWorkspaceError;
|
|
12518
|
+
var init_workspace = __esm({
|
|
12519
|
+
"src/lib/workspace.ts"() {
|
|
12520
|
+
"use strict";
|
|
12521
|
+
init_state();
|
|
12522
|
+
NoWorkspaceError = class extends Error {
|
|
12523
|
+
constructor(message) {
|
|
12524
|
+
super(message);
|
|
12525
|
+
this.name = "NoWorkspaceError";
|
|
12526
|
+
}
|
|
12527
|
+
};
|
|
12528
|
+
}
|
|
12529
|
+
});
|
|
12530
|
+
|
|
12342
12531
|
// src/commands/init.ts
|
|
12343
12532
|
var init_exports = {};
|
|
12344
12533
|
__export(init_exports, {
|
|
12345
12534
|
WORKSPACE_POLL: () => WORKSPACE_POLL,
|
|
12535
|
+
confirmReset: () => confirmReset,
|
|
12536
|
+
decideInitBranch: () => decideInitBranch,
|
|
12537
|
+
interpretResetAnswer: () => interpretResetAnswer,
|
|
12346
12538
|
pollForWorkspaceReady: () => pollForWorkspaceReady,
|
|
12347
12539
|
preProvisionWorkspace: () => preProvisionWorkspace,
|
|
12348
12540
|
runInit: () => runInit,
|
|
12349
12541
|
slugify: () => slugify
|
|
12350
12542
|
});
|
|
12351
|
-
import { access } from "node:fs/promises";
|
|
12352
|
-
import { resolve as pathResolve } from "node:path";
|
|
12543
|
+
import { access, rm } from "node:fs/promises";
|
|
12353
12544
|
async function pollForWorkspaceReady(bambooSession, initial) {
|
|
12354
12545
|
if (initial.workspace_ready && initial.org.workspace_repo) {
|
|
12355
12546
|
return { ok: true, membership: initial };
|
|
@@ -12389,7 +12580,35 @@ async function preProvisionWorkspace(bambooSession, call = provisionWorkspace) {
|
|
|
12389
12580
|
return { kind: "transient", message: err.message };
|
|
12390
12581
|
}
|
|
12391
12582
|
}
|
|
12392
|
-
async function
|
|
12583
|
+
async function confirmReset(targetPath) {
|
|
12584
|
+
console.log(` ! \`--reset\` will delete: ${targetPath}`);
|
|
12585
|
+
if (process.stdin.isTTY !== true) return true;
|
|
12586
|
+
const answer = await promptStdin(" Continue? [Y/n] ");
|
|
12587
|
+
return interpretResetAnswer(answer);
|
|
12588
|
+
}
|
|
12589
|
+
function interpretResetAnswer(answer) {
|
|
12590
|
+
if (answer === null) return true;
|
|
12591
|
+
const normalized = answer.trim().toLowerCase();
|
|
12592
|
+
if (normalized === "" || normalized === "y" || normalized === "yes") {
|
|
12593
|
+
return true;
|
|
12594
|
+
}
|
|
12595
|
+
return false;
|
|
12596
|
+
}
|
|
12597
|
+
function decideInitBranch(input) {
|
|
12598
|
+
const { hasState, recordedPath, dirExists, canonicalPath, reset } = input;
|
|
12599
|
+
if (reset) {
|
|
12600
|
+
return {
|
|
12601
|
+
kind: "reset_then_clone",
|
|
12602
|
+
path: hasState && recordedPath || canonicalPath
|
|
12603
|
+
};
|
|
12604
|
+
}
|
|
12605
|
+
if (hasState && recordedPath) {
|
|
12606
|
+
if (dirExists) return { kind: "short_circuit", path: recordedPath };
|
|
12607
|
+
return { kind: "reclone_recorded", path: recordedPath };
|
|
12608
|
+
}
|
|
12609
|
+
return { kind: "fresh_clone", path: canonicalPath };
|
|
12610
|
+
}
|
|
12611
|
+
async function runInit(options = {}) {
|
|
12393
12612
|
const creds = await readCredentials();
|
|
12394
12613
|
if (!creds) {
|
|
12395
12614
|
console.error("No credentials found. Run `bamboo-agents login` first.");
|
|
@@ -12509,33 +12728,114 @@ async function runInit() {
|
|
|
12509
12728
|
process.exit(1);
|
|
12510
12729
|
}
|
|
12511
12730
|
const orgSlug = slugify(membership.org.name);
|
|
12512
|
-
const
|
|
12513
|
-
let
|
|
12731
|
+
const canonicalPath = defaultClonePath(orgSlug);
|
|
12732
|
+
let existingState;
|
|
12733
|
+
try {
|
|
12734
|
+
existingState = await readState();
|
|
12735
|
+
} catch (err) {
|
|
12736
|
+
if (err instanceof WorkspaceStateError) {
|
|
12737
|
+
console.error(`
|
|
12738
|
+
${err.message}
|
|
12739
|
+
`);
|
|
12740
|
+
process.exit(2);
|
|
12741
|
+
}
|
|
12742
|
+
throw err;
|
|
12743
|
+
}
|
|
12744
|
+
const targetPath = existingState?.workspace_path ?? canonicalPath;
|
|
12745
|
+
if (options.reset) {
|
|
12746
|
+
const confirmed = await confirmReset(targetPath);
|
|
12747
|
+
if (!confirmed) {
|
|
12748
|
+
console.log(" Aborted \u2014 workspace untouched.");
|
|
12749
|
+
process.exit(2);
|
|
12750
|
+
}
|
|
12751
|
+
const resetSpinner = ora(`Removing ${targetPath}\u2026`).start();
|
|
12752
|
+
try {
|
|
12753
|
+
await rm(targetPath, { recursive: true, force: true });
|
|
12754
|
+
resetSpinner.succeed(`Removed ${targetPath}`);
|
|
12755
|
+
} catch (err) {
|
|
12756
|
+
resetSpinner.fail(`Couldn't remove ${targetPath}: ${err.message}`);
|
|
12757
|
+
process.exit(1);
|
|
12758
|
+
}
|
|
12759
|
+
await cloneAndPersist(targetPath, membership);
|
|
12760
|
+
return;
|
|
12761
|
+
}
|
|
12762
|
+
if (existingState) {
|
|
12763
|
+
let dirExists = false;
|
|
12764
|
+
try {
|
|
12765
|
+
await access(existingState.workspace_path);
|
|
12766
|
+
dirExists = true;
|
|
12767
|
+
} catch {
|
|
12768
|
+
}
|
|
12769
|
+
if (dirExists) {
|
|
12770
|
+
const existingRemote = await getRepoRemoteUrl(existingState.workspace_path);
|
|
12771
|
+
const matches = existingRemote != null && remoteUrlMatchesRepo(existingRemote, membership.org.workspace_repo);
|
|
12772
|
+
if (matches) {
|
|
12773
|
+
await writeConfig({
|
|
12774
|
+
org_id: membership.org.id,
|
|
12775
|
+
org_name: membership.org.name,
|
|
12776
|
+
workspace_repo: membership.org.workspace_repo,
|
|
12777
|
+
repo_path: existingState.workspace_path,
|
|
12778
|
+
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
12779
|
+
});
|
|
12780
|
+
console.log("");
|
|
12781
|
+
console.log(` \u2713 Workspace already at ${existingState.workspace_path}`);
|
|
12782
|
+
console.log(" (init is idempotent \u2014 re-run with --reset to start over)");
|
|
12783
|
+
console.log("");
|
|
12784
|
+
return;
|
|
12785
|
+
}
|
|
12786
|
+
console.error(
|
|
12787
|
+
`
|
|
12788
|
+
${existingState.workspace_path} exists but its origin doesn't match your workspace repo.
|
|
12789
|
+
|
|
12790
|
+
` + (existingRemote ? ` Found origin: ${existingRemote}
|
|
12791
|
+
Expected: github.com/${membership.org.workspace_repo}
|
|
12792
|
+
|
|
12793
|
+
` : ` It's not a git repo (no origin remote).
|
|
12794
|
+
|
|
12795
|
+
`) + " Re-run with `bamboo-agents init --reset` to start over, or move the directory aside.\n"
|
|
12796
|
+
);
|
|
12797
|
+
process.exit(2);
|
|
12798
|
+
}
|
|
12799
|
+
console.log(` State points at ${existingState.workspace_path}, but the directory is missing \u2014 re-cloning there.`);
|
|
12800
|
+
await cloneAndPersist(existingState.workspace_path, membership);
|
|
12801
|
+
return;
|
|
12802
|
+
}
|
|
12803
|
+
let canonicalExists = false;
|
|
12514
12804
|
try {
|
|
12515
|
-
await access(
|
|
12516
|
-
|
|
12805
|
+
await access(canonicalPath);
|
|
12806
|
+
canonicalExists = true;
|
|
12517
12807
|
} catch {
|
|
12518
12808
|
}
|
|
12519
|
-
if (
|
|
12520
|
-
const existingRemote = await getRepoRemoteUrl(
|
|
12809
|
+
if (canonicalExists) {
|
|
12810
|
+
const existingRemote = await getRepoRemoteUrl(canonicalPath);
|
|
12521
12811
|
const matches = existingRemote != null && remoteUrlMatchesRepo(existingRemote, membership.org.workspace_repo);
|
|
12522
12812
|
if (matches) {
|
|
12523
12813
|
await writeConfig({
|
|
12524
12814
|
org_id: membership.org.id,
|
|
12525
12815
|
org_name: membership.org.name,
|
|
12526
12816
|
workspace_repo: membership.org.workspace_repo,
|
|
12527
|
-
repo_path:
|
|
12817
|
+
repo_path: canonicalPath,
|
|
12528
12818
|
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
12529
12819
|
});
|
|
12820
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12821
|
+
await writeState({
|
|
12822
|
+
$schema_version: STATE_SCHEMA_VERSION,
|
|
12823
|
+
workspace_path: canonicalPath,
|
|
12824
|
+
org_id: membership.org.id,
|
|
12825
|
+
org_slug: orgSlug,
|
|
12826
|
+
cloned_at: now,
|
|
12827
|
+
last_sync: now,
|
|
12828
|
+
remote_url: `https://github.com/${membership.org.workspace_repo}`
|
|
12829
|
+
});
|
|
12530
12830
|
console.log("");
|
|
12531
|
-
console.log(` \u2713
|
|
12532
|
-
console.log(" (
|
|
12831
|
+
console.log(` \u2713 Adopted existing workspace at ${canonicalPath}`);
|
|
12832
|
+
console.log(" (origin matches \u2014 registered in state.json)");
|
|
12533
12833
|
console.log("");
|
|
12534
12834
|
return;
|
|
12535
12835
|
}
|
|
12536
12836
|
console.error(
|
|
12537
12837
|
`
|
|
12538
|
-
${
|
|
12838
|
+
${canonicalPath} already exists and is NOT the right repo.
|
|
12539
12839
|
|
|
12540
12840
|
` + (existingRemote ? ` Found origin: ${existingRemote}
|
|
12541
12841
|
Expected: github.com/${membership.org.workspace_repo}
|
|
@@ -12546,7 +12846,12 @@ async function runInit() {
|
|
|
12546
12846
|
);
|
|
12547
12847
|
process.exit(2);
|
|
12548
12848
|
}
|
|
12549
|
-
|
|
12849
|
+
await cloneAndPersist(canonicalPath, membership);
|
|
12850
|
+
}
|
|
12851
|
+
async function cloneAndPersist(repoPath, membership) {
|
|
12852
|
+
const cloneSpinner = ora(
|
|
12853
|
+
`Cloning ${membership.org.workspace_repo} \u2192 ${repoPath}\u2026`
|
|
12854
|
+
).start();
|
|
12550
12855
|
try {
|
|
12551
12856
|
await cloneRepo(membership.org.workspace_repo, repoPath);
|
|
12552
12857
|
cloneSpinner.succeed(`Cloned to ${repoPath}`);
|
|
@@ -12561,6 +12866,16 @@ async function runInit() {
|
|
|
12561
12866
|
repo_path: repoPath,
|
|
12562
12867
|
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
12563
12868
|
});
|
|
12869
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12870
|
+
await writeState({
|
|
12871
|
+
$schema_version: 1,
|
|
12872
|
+
workspace_path: repoPath,
|
|
12873
|
+
org_id: membership.org.id,
|
|
12874
|
+
org_slug: slugify(membership.org.name),
|
|
12875
|
+
cloned_at: now,
|
|
12876
|
+
last_sync: now,
|
|
12877
|
+
remote_url: `https://github.com/${membership.org.workspace_repo}`
|
|
12878
|
+
});
|
|
12564
12879
|
console.log("");
|
|
12565
12880
|
console.log(` \u2713 Workspace ready at ${repoPath}`);
|
|
12566
12881
|
console.log(" Next: `bamboo-agents open` to launch Claude Code there.");
|
|
@@ -12574,8 +12889,10 @@ var init_init = __esm({
|
|
|
12574
12889
|
init_api();
|
|
12575
12890
|
init_credentials();
|
|
12576
12891
|
init_git();
|
|
12892
|
+
init_prompt();
|
|
12577
12893
|
init_state();
|
|
12578
12894
|
init_util2();
|
|
12895
|
+
init_workspace();
|
|
12579
12896
|
WORKSPACE_POLL = {
|
|
12580
12897
|
intervalMs: 2e3,
|
|
12581
12898
|
timeoutMs: 5 * 60 * 1e3
|
|
@@ -12839,55 +13156,6 @@ var init_clone_or_adopt_phase = __esm({
|
|
|
12839
13156
|
}
|
|
12840
13157
|
});
|
|
12841
13158
|
|
|
12842
|
-
// src/lib/prompt.ts
|
|
12843
|
-
import { createInterface } from "node:readline";
|
|
12844
|
-
async function promptStdin(question, opts = {}) {
|
|
12845
|
-
const maxRetries = opts.maxRetries ?? 2;
|
|
12846
|
-
const isInteractive2 = process.stdin.isTTY === true;
|
|
12847
|
-
const rl = createInterface({
|
|
12848
|
-
input: process.stdin,
|
|
12849
|
-
output: process.stdout,
|
|
12850
|
-
terminal: isInteractive2
|
|
12851
|
-
});
|
|
12852
|
-
const onSigInt = () => {
|
|
12853
|
-
rl.close();
|
|
12854
|
-
};
|
|
12855
|
-
rl.on("SIGINT", onSigInt);
|
|
12856
|
-
try {
|
|
12857
|
-
let attempts = 0;
|
|
12858
|
-
while (attempts <= maxRetries) {
|
|
12859
|
-
const answer = await readOnce(rl, question);
|
|
12860
|
-
if (answer === null) return null;
|
|
12861
|
-
const trimmed = answer.trim();
|
|
12862
|
-
if (trimmed.length > 0) return trimmed;
|
|
12863
|
-
attempts += 1;
|
|
12864
|
-
if (attempts > maxRetries || !isInteractive2) return null;
|
|
12865
|
-
console.log(" (Press Enter without typing to skip \u2014 or answer Boo's question.)");
|
|
12866
|
-
}
|
|
12867
|
-
return null;
|
|
12868
|
-
} finally {
|
|
12869
|
-
rl.off("SIGINT", onSigInt);
|
|
12870
|
-
rl.close();
|
|
12871
|
-
}
|
|
12872
|
-
}
|
|
12873
|
-
function readOnce(rl, question) {
|
|
12874
|
-
return new Promise((resolve) => {
|
|
12875
|
-
let resolved = false;
|
|
12876
|
-
const settle = (value) => {
|
|
12877
|
-
if (resolved) return;
|
|
12878
|
-
resolved = true;
|
|
12879
|
-
resolve(value);
|
|
12880
|
-
};
|
|
12881
|
-
rl.once("close", () => settle(null));
|
|
12882
|
-
rl.question(question, (answer) => settle(answer));
|
|
12883
|
-
});
|
|
12884
|
-
}
|
|
12885
|
-
var init_prompt = __esm({
|
|
12886
|
-
"src/lib/prompt.ts"() {
|
|
12887
|
-
"use strict";
|
|
12888
|
-
}
|
|
12889
|
-
});
|
|
12890
|
-
|
|
12891
13159
|
// src/lib/phases-impl/pick-first-user-agent-phase.ts
|
|
12892
13160
|
import { readdir, readFile as readFile3, stat } from "node:fs/promises";
|
|
12893
13161
|
import { dirname, join as pathJoin, resolve as pathResolve3 } from "node:path";
|
|
@@ -13641,29 +13909,34 @@ __export(open_exports, {
|
|
|
13641
13909
|
runOpen: () => runOpen
|
|
13642
13910
|
});
|
|
13643
13911
|
async function runOpen() {
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13912
|
+
let workspacePath;
|
|
13913
|
+
try {
|
|
13914
|
+
workspacePath = (await resolveWorkspace()).path;
|
|
13915
|
+
} catch (err) {
|
|
13916
|
+
if (err instanceof NoWorkspaceError) {
|
|
13917
|
+
console.error(err.message);
|
|
13918
|
+
process.exit(2);
|
|
13919
|
+
}
|
|
13920
|
+
throw err;
|
|
13648
13921
|
}
|
|
13649
13922
|
const status = await detectClaudeDesktop();
|
|
13650
13923
|
if (status.kind === "missing") {
|
|
13651
13924
|
console.error(
|
|
13652
13925
|
`Claude Desktop isn't installed. Get it at ${DOWNLOAD_URL}, then re-run \`bamboo-agents open\`.`
|
|
13653
13926
|
);
|
|
13654
|
-
console.error(`(Your workspace is cloned at ${
|
|
13927
|
+
console.error(`(Your workspace is cloned at ${workspacePath}.)`);
|
|
13655
13928
|
process.exit(1);
|
|
13656
13929
|
}
|
|
13657
13930
|
if (status.kind === "unsupported_platform") {
|
|
13658
13931
|
console.log("");
|
|
13659
13932
|
console.log(" Claude Desktop isn't available on Linux yet.");
|
|
13660
|
-
console.log(` Your workspace is cloned at: ${
|
|
13933
|
+
console.log(` Your workspace is cloned at: ${workspacePath}`);
|
|
13661
13934
|
console.log("");
|
|
13662
13935
|
return;
|
|
13663
13936
|
}
|
|
13664
|
-
const url = `claude://code/new?folder=${encodeURIComponent(
|
|
13937
|
+
const url = `claude://code/new?folder=${encodeURIComponent(workspacePath)}`;
|
|
13665
13938
|
await open_default(url);
|
|
13666
|
-
console.log(`Opening Claude Code at ${
|
|
13939
|
+
console.log(`Opening Claude Code at ${workspacePath}\u2026`);
|
|
13667
13940
|
console.log("(Claude Desktop will ask you to trust the folder the first time.)");
|
|
13668
13941
|
}
|
|
13669
13942
|
var DOWNLOAD_URL;
|
|
@@ -13672,7 +13945,7 @@ var init_open2 = __esm({
|
|
|
13672
13945
|
"use strict";
|
|
13673
13946
|
init_open();
|
|
13674
13947
|
init_claude_desktop();
|
|
13675
|
-
|
|
13948
|
+
init_workspace();
|
|
13676
13949
|
DOWNLOAD_URL = "https://claude.com/download";
|
|
13677
13950
|
}
|
|
13678
13951
|
});
|
|
@@ -13700,6 +13973,7 @@ function formatSubscriptionLine(billing) {
|
|
|
13700
13973
|
}
|
|
13701
13974
|
async function runStatus() {
|
|
13702
13975
|
const creds = await readCredentials();
|
|
13976
|
+
const state = await readState().catch(() => null);
|
|
13703
13977
|
const cfg = await readConfig();
|
|
13704
13978
|
console.log("");
|
|
13705
13979
|
console.log(" Bamboo CLI status");
|
|
@@ -13715,13 +13989,18 @@ async function runStatus() {
|
|
|
13715
13989
|
console.log(` GitHub expires: ${creds.github_token_expires_at}`);
|
|
13716
13990
|
}
|
|
13717
13991
|
}
|
|
13718
|
-
|
|
13992
|
+
const workspacePath = state?.workspace_path ?? cfg?.repo_path ?? null;
|
|
13993
|
+
if (!workspacePath) {
|
|
13719
13994
|
console.log(" Workspace: not configured (run `bamboo-agents init`)");
|
|
13720
13995
|
} else {
|
|
13721
|
-
|
|
13722
|
-
console.log(`
|
|
13723
|
-
console.log(`
|
|
13724
|
-
console.log(`
|
|
13996
|
+
const repoLabel = cfg?.workspace_repo ?? state?.remote_url?.replace(/^https?:\/\/github\.com\//, "") ?? "(unknown)";
|
|
13997
|
+
console.log(` Workspace: ${repoLabel}`);
|
|
13998
|
+
console.log(` Repo path: ${workspacePath}`);
|
|
13999
|
+
console.log(` Org: ${cfg?.org_name ?? state?.org_slug ?? "(unknown)"}`);
|
|
14000
|
+
console.log(` Installed: ${cfg?.installed_at ?? state?.cloned_at ?? "(unknown)"}`);
|
|
14001
|
+
if (state?.last_sync) {
|
|
14002
|
+
console.log(` Last sync: ${state.last_sync}`);
|
|
14003
|
+
}
|
|
13725
14004
|
}
|
|
13726
14005
|
if (creds?.bamboo_session) {
|
|
13727
14006
|
try {
|
|
@@ -13882,6 +14161,130 @@ var init_doctor = __esm({
|
|
|
13882
14161
|
}
|
|
13883
14162
|
});
|
|
13884
14163
|
|
|
14164
|
+
// src/commands/save.ts
|
|
14165
|
+
var save_exports = {};
|
|
14166
|
+
__export(save_exports, {
|
|
14167
|
+
runSave: () => runSave
|
|
14168
|
+
});
|
|
14169
|
+
import { execFile as execFile8 } from "node:child_process";
|
|
14170
|
+
import { promisify as promisify8 } from "node:util";
|
|
14171
|
+
async function gitC(repoPath, args) {
|
|
14172
|
+
const { stdout, stderr } = await execFileP3("git", ["-C", repoPath, ...args], {
|
|
14173
|
+
encoding: "utf8"
|
|
14174
|
+
});
|
|
14175
|
+
return { stdout, stderr };
|
|
14176
|
+
}
|
|
14177
|
+
async function runSave(message) {
|
|
14178
|
+
if (!message || !message.trim()) {
|
|
14179
|
+
console.error("bamboo-agents save: commit message is required.");
|
|
14180
|
+
console.error('Example: bamboo-agents save "tightened the brand voice doc"');
|
|
14181
|
+
process.exit(2);
|
|
14182
|
+
}
|
|
14183
|
+
let workspacePath;
|
|
14184
|
+
try {
|
|
14185
|
+
workspacePath = (await resolveWorkspace()).path;
|
|
14186
|
+
} catch (err) {
|
|
14187
|
+
if (err instanceof NoWorkspaceError) {
|
|
14188
|
+
console.error(`bamboo-agents save: ${err.message}`);
|
|
14189
|
+
process.exit(2);
|
|
14190
|
+
}
|
|
14191
|
+
throw err;
|
|
14192
|
+
}
|
|
14193
|
+
try {
|
|
14194
|
+
await gitC(workspacePath, ["add", "-A"]);
|
|
14195
|
+
let hasStagedChanges = false;
|
|
14196
|
+
try {
|
|
14197
|
+
await gitC(workspacePath, ["diff", "--cached", "--quiet"]);
|
|
14198
|
+
} catch {
|
|
14199
|
+
hasStagedChanges = true;
|
|
14200
|
+
}
|
|
14201
|
+
if (!hasStagedChanges) {
|
|
14202
|
+
console.log("");
|
|
14203
|
+
console.log(" Nothing to save \u2014 your workspace is already up to date.");
|
|
14204
|
+
console.log("");
|
|
14205
|
+
return;
|
|
14206
|
+
}
|
|
14207
|
+
await gitC(workspacePath, ["commit", "-m", message.trim()]);
|
|
14208
|
+
await gitC(workspacePath, ["push"]);
|
|
14209
|
+
console.log("");
|
|
14210
|
+
console.log(` Saved: ${message.trim()}`);
|
|
14211
|
+
console.log(` (pushed from ${workspacePath})`);
|
|
14212
|
+
console.log("");
|
|
14213
|
+
} catch (err) {
|
|
14214
|
+
const e = err;
|
|
14215
|
+
console.error("bamboo-agents save: git failed.");
|
|
14216
|
+
if (e.stderr?.trim()) console.error(e.stderr.trim());
|
|
14217
|
+
else console.error(e.message);
|
|
14218
|
+
process.exit(1);
|
|
14219
|
+
}
|
|
14220
|
+
}
|
|
14221
|
+
var execFileP3;
|
|
14222
|
+
var init_save = __esm({
|
|
14223
|
+
"src/commands/save.ts"() {
|
|
14224
|
+
"use strict";
|
|
14225
|
+
init_workspace();
|
|
14226
|
+
execFileP3 = promisify8(execFile8);
|
|
14227
|
+
}
|
|
14228
|
+
});
|
|
14229
|
+
|
|
14230
|
+
// src/commands/sync.ts
|
|
14231
|
+
var sync_exports = {};
|
|
14232
|
+
__export(sync_exports, {
|
|
14233
|
+
runSync: () => runSync
|
|
14234
|
+
});
|
|
14235
|
+
import { execFile as execFile9 } from "node:child_process";
|
|
14236
|
+
import { promisify as promisify9 } from "node:util";
|
|
14237
|
+
async function runSync() {
|
|
14238
|
+
let workspacePath;
|
|
14239
|
+
try {
|
|
14240
|
+
workspacePath = (await resolveWorkspace()).path;
|
|
14241
|
+
} catch (err) {
|
|
14242
|
+
if (err instanceof NoWorkspaceError) {
|
|
14243
|
+
console.error(`bamboo-agents sync: ${err.message}`);
|
|
14244
|
+
process.exit(2);
|
|
14245
|
+
}
|
|
14246
|
+
throw err;
|
|
14247
|
+
}
|
|
14248
|
+
try {
|
|
14249
|
+
const { stdout } = await execFileP4(
|
|
14250
|
+
"git",
|
|
14251
|
+
["-C", workspacePath, "pull", "--ff-only"],
|
|
14252
|
+
{ encoding: "utf8" }
|
|
14253
|
+
);
|
|
14254
|
+
console.log("");
|
|
14255
|
+
console.log(" Synced your workspace with the remote.");
|
|
14256
|
+
if (stdout.trim()) {
|
|
14257
|
+
console.log(` ${stdout.trim().split("\n").pop()}`);
|
|
14258
|
+
}
|
|
14259
|
+
console.log(` (workspace: ${workspacePath})`);
|
|
14260
|
+
console.log("");
|
|
14261
|
+
} catch (err) {
|
|
14262
|
+
const e = err;
|
|
14263
|
+
console.error("bamboo-agents sync: git failed.");
|
|
14264
|
+
if (e.stderr?.trim()) console.error(e.stderr.trim());
|
|
14265
|
+
else console.error(e.message);
|
|
14266
|
+
process.exit(1);
|
|
14267
|
+
}
|
|
14268
|
+
try {
|
|
14269
|
+
const state = await readState();
|
|
14270
|
+
if (state) await updateLastSync(/* @__PURE__ */ new Date());
|
|
14271
|
+
} catch (err) {
|
|
14272
|
+
if (err instanceof WorkspaceStateError) {
|
|
14273
|
+
return;
|
|
14274
|
+
}
|
|
14275
|
+
throw err;
|
|
14276
|
+
}
|
|
14277
|
+
}
|
|
14278
|
+
var execFileP4;
|
|
14279
|
+
var init_sync = __esm({
|
|
14280
|
+
"src/commands/sync.ts"() {
|
|
14281
|
+
"use strict";
|
|
14282
|
+
init_state();
|
|
14283
|
+
init_workspace();
|
|
14284
|
+
execFileP4 = promisify9(execFile9);
|
|
14285
|
+
}
|
|
14286
|
+
});
|
|
14287
|
+
|
|
13885
14288
|
// src/lib/skills-local.ts
|
|
13886
14289
|
import { readdir as readdir2, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
13887
14290
|
import { join as join2 } from "node:path";
|
|
@@ -14061,14 +14464,15 @@ __export(skills_exports, {
|
|
|
14061
14464
|
runSkillsUpdate: () => runSkillsUpdate
|
|
14062
14465
|
});
|
|
14063
14466
|
async function resolveWorkspacePath() {
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14467
|
+
try {
|
|
14468
|
+
return (await resolveWorkspace()).path;
|
|
14469
|
+
} catch (err) {
|
|
14470
|
+
if (err instanceof NoWorkspaceError) {
|
|
14471
|
+
console.error(`bamboo-agents: ${err.message}`);
|
|
14472
|
+
process.exit(1);
|
|
14473
|
+
}
|
|
14474
|
+
throw err;
|
|
14070
14475
|
}
|
|
14071
|
-
return cfg.repo_path;
|
|
14072
14476
|
}
|
|
14073
14477
|
function summarize(description, max = 80) {
|
|
14074
14478
|
const oneLine = description.replace(/\s+/g, " ").trim();
|
|
@@ -14375,8 +14779,8 @@ async function runSkillsUpdate(agentIdentifier, skillName) {
|
|
|
14375
14779
|
var init_skills = __esm({
|
|
14376
14780
|
"src/commands/skills.ts"() {
|
|
14377
14781
|
"use strict";
|
|
14378
|
-
init_state();
|
|
14379
14782
|
init_credentials();
|
|
14783
|
+
init_workspace();
|
|
14380
14784
|
init_skills_local();
|
|
14381
14785
|
init_api();
|
|
14382
14786
|
}
|
|
@@ -14411,9 +14815,12 @@ program2.command("login").description("Sign in to Bamboo via your browser").acti
|
|
|
14411
14815
|
const { runLogin: runLogin2 } = await Promise.resolve().then(() => (init_login(), login_exports));
|
|
14412
14816
|
await runLogin2();
|
|
14413
14817
|
});
|
|
14414
|
-
program2.command("init").description("Clone your workspace + set up git credentials").
|
|
14818
|
+
program2.command("init").description("Clone your workspace + set up git credentials").option(
|
|
14819
|
+
"--reset",
|
|
14820
|
+
"Delete the existing workspace clone and start over (prompts for confirmation)"
|
|
14821
|
+
).action(async (options) => {
|
|
14415
14822
|
const { runInit: runInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
14416
|
-
await runInit2();
|
|
14823
|
+
await runInit2({ reset: options.reset });
|
|
14417
14824
|
});
|
|
14418
14825
|
program2.command("open").description("Launch Claude Code at your workspace").action(async () => {
|
|
14419
14826
|
const { runOpen: runOpen2 } = await Promise.resolve().then(() => (init_open2(), open_exports));
|
|
@@ -14427,6 +14834,14 @@ program2.command("doctor").description("Verify your local setup is ready").actio
|
|
|
14427
14834
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
|
|
14428
14835
|
await runDoctor2();
|
|
14429
14836
|
});
|
|
14837
|
+
program2.command("save <message>").description("Commit + push everything in your workspace (cwd-agnostic)").action(async (message) => {
|
|
14838
|
+
const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save(), save_exports));
|
|
14839
|
+
await runSave2(message);
|
|
14840
|
+
});
|
|
14841
|
+
program2.command("sync").description("Pull your workspace clone up to remote (cwd-agnostic)").action(async () => {
|
|
14842
|
+
const { runSync: runSync2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
|
|
14843
|
+
await runSync2();
|
|
14844
|
+
});
|
|
14430
14845
|
var skills = program2.command("skills").description("Read workspace skills from your local clone");
|
|
14431
14846
|
skills.command("list").description("List every skill in the workspace").option(
|
|
14432
14847
|
"--agent <slug>",
|