bamboo-agents 0.1.5-dev.38.aeaecba → 0.1.5-dev.39.69fcffd
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 +667 -45
- 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.39.69fcffd";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -7854,14 +7854,14 @@ var init_open = __esm({
|
|
|
7854
7854
|
}
|
|
7855
7855
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
7856
7856
|
if (options.wait) {
|
|
7857
|
-
return new Promise((
|
|
7857
|
+
return new Promise((resolve2, reject) => {
|
|
7858
7858
|
subprocess.once("error", reject);
|
|
7859
7859
|
subprocess.once("close", (exitCode) => {
|
|
7860
7860
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
7861
7861
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
7862
7862
|
return;
|
|
7863
7863
|
}
|
|
7864
|
-
|
|
7864
|
+
resolve2(subprocess);
|
|
7865
7865
|
});
|
|
7866
7866
|
});
|
|
7867
7867
|
}
|
|
@@ -12049,7 +12049,7 @@ var init_api = __esm({
|
|
|
12049
12049
|
|
|
12050
12050
|
// src/lib/util.ts
|
|
12051
12051
|
function sleep(ms) {
|
|
12052
|
-
return new Promise((
|
|
12052
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
12053
12053
|
}
|
|
12054
12054
|
var init_util2 = __esm({
|
|
12055
12055
|
"src/lib/util.ts"() {
|
|
@@ -12117,8 +12117,8 @@ async function handleMissingGithubToken(bambooSession) {
|
|
|
12117
12117
|
async function startCallbackServer(expectedState) {
|
|
12118
12118
|
let resolveSession;
|
|
12119
12119
|
let rejectSession;
|
|
12120
|
-
const session = new Promise((
|
|
12121
|
-
resolveSession =
|
|
12120
|
+
const session = new Promise((resolve2, reject) => {
|
|
12121
|
+
resolveSession = resolve2;
|
|
12122
12122
|
rejectSession = reject;
|
|
12123
12123
|
});
|
|
12124
12124
|
const server = createServer((req, res) => {
|
|
@@ -12176,10 +12176,10 @@ async function startCallbackServer(expectedState) {
|
|
|
12176
12176
|
server.close();
|
|
12177
12177
|
}, LOGIN_TIMEOUT_MS);
|
|
12178
12178
|
timer.unref();
|
|
12179
|
-
const port = await new Promise((
|
|
12179
|
+
const port = await new Promise((resolve2, reject) => {
|
|
12180
12180
|
server.once("listening", () => {
|
|
12181
12181
|
const addr = server.address();
|
|
12182
|
-
if (addr && typeof addr === "object")
|
|
12182
|
+
if (addr && typeof addr === "object") resolve2(addr.port);
|
|
12183
12183
|
else reject(new Error("Couldn't bind localhost port"));
|
|
12184
12184
|
});
|
|
12185
12185
|
server.once("error", reject);
|
|
@@ -12312,6 +12312,18 @@ var init_login_phase = __esm({
|
|
|
12312
12312
|
});
|
|
12313
12313
|
|
|
12314
12314
|
// src/lib/git.ts
|
|
12315
|
+
var git_exports = {};
|
|
12316
|
+
__export(git_exports, {
|
|
12317
|
+
GitError: () => GitError,
|
|
12318
|
+
checkGitCredentialForGitHub: () => checkGitCredentialForGitHub,
|
|
12319
|
+
cloneRepo: () => cloneRepo,
|
|
12320
|
+
getGitConfig: () => getGitConfig,
|
|
12321
|
+
getRepoRemoteUrl: () => getRepoRemoteUrl,
|
|
12322
|
+
gitVersion: () => gitVersion,
|
|
12323
|
+
installGithubCredential: () => installGithubCredential,
|
|
12324
|
+
isGitRecentEnough: () => isGitRecentEnough,
|
|
12325
|
+
remoteUrlMatchesRepo: () => remoteUrlMatchesRepo
|
|
12326
|
+
});
|
|
12315
12327
|
import { execFile as execFile6 } from "node:child_process";
|
|
12316
12328
|
import { promisify as promisify6 } from "node:util";
|
|
12317
12329
|
async function gitVersion() {
|
|
@@ -12340,9 +12352,9 @@ password=${token}
|
|
|
12340
12352
|
const proc = child;
|
|
12341
12353
|
proc.stdin?.write(input);
|
|
12342
12354
|
proc.stdin?.end();
|
|
12343
|
-
await new Promise((
|
|
12355
|
+
await new Promise((resolve2, reject) => {
|
|
12344
12356
|
proc.on("exit", (code) => {
|
|
12345
|
-
if (code === 0)
|
|
12357
|
+
if (code === 0) resolve2();
|
|
12346
12358
|
else reject(new GitError(`git credential approve exited with code ${code}`));
|
|
12347
12359
|
});
|
|
12348
12360
|
proc.on("error", reject);
|
|
@@ -12362,7 +12374,7 @@ async function cloneRepo(repoFullName, targetDir) {
|
|
|
12362
12374
|
}
|
|
12363
12375
|
}
|
|
12364
12376
|
async function checkGitCredentialForGitHub() {
|
|
12365
|
-
return new Promise((
|
|
12377
|
+
return new Promise((resolve2) => {
|
|
12366
12378
|
const proc = execFile6(
|
|
12367
12379
|
"git",
|
|
12368
12380
|
["credential", "fill"],
|
|
@@ -12372,12 +12384,12 @@ async function checkGitCredentialForGitHub() {
|
|
|
12372
12384
|
},
|
|
12373
12385
|
(err, stdout) => {
|
|
12374
12386
|
if (err) {
|
|
12375
|
-
|
|
12387
|
+
resolve2(false);
|
|
12376
12388
|
return;
|
|
12377
12389
|
}
|
|
12378
12390
|
const hasOurUsername = /^username=x-access-token\s*$/m.test(stdout);
|
|
12379
12391
|
const hasPassword = /^password=\S+/m.test(stdout);
|
|
12380
|
-
|
|
12392
|
+
resolve2(hasOurUsername && hasPassword);
|
|
12381
12393
|
}
|
|
12382
12394
|
);
|
|
12383
12395
|
proc.stdin?.write("protocol=https\nhost=github.com\n\n");
|
|
@@ -12464,12 +12476,12 @@ async function promptStdin(question, opts = {}) {
|
|
|
12464
12476
|
}
|
|
12465
12477
|
}
|
|
12466
12478
|
function readOnce(rl, question) {
|
|
12467
|
-
return new Promise((
|
|
12479
|
+
return new Promise((resolve2) => {
|
|
12468
12480
|
let resolved = false;
|
|
12469
12481
|
const settle = (value) => {
|
|
12470
12482
|
if (resolved) return;
|
|
12471
12483
|
resolved = true;
|
|
12472
|
-
|
|
12484
|
+
resolve2(value);
|
|
12473
12485
|
};
|
|
12474
12486
|
rl.once("close", () => settle(null));
|
|
12475
12487
|
rl.question(question, (answer) => settle(answer));
|
|
@@ -13274,11 +13286,11 @@ async function runUploadFlow(ctx) {
|
|
|
13274
13286
|
console.log(" \u2026");
|
|
13275
13287
|
}
|
|
13276
13288
|
console.log("");
|
|
13277
|
-
const
|
|
13289
|
+
const confirm2 = await promptChoice(
|
|
13278
13290
|
" Upload this? [y/n]: ",
|
|
13279
13291
|
["y", "n", "Y", "N"]
|
|
13280
13292
|
);
|
|
13281
|
-
if (
|
|
13293
|
+
if (confirm2 === null || confirm2.toLowerCase() !== "y") return null;
|
|
13282
13294
|
console.log("");
|
|
13283
13295
|
const name = await promptStdin(
|
|
13284
13296
|
" Name this agent (e.g. My Existing Agent): "
|
|
@@ -14020,14 +14032,317 @@ var init_status = __esm({
|
|
|
14020
14032
|
}
|
|
14021
14033
|
});
|
|
14022
14034
|
|
|
14035
|
+
// src/lib/workspace-health.ts
|
|
14036
|
+
import { execFile as execFile8 } from "node:child_process";
|
|
14037
|
+
import { promisify as promisify8 } from "node:util";
|
|
14038
|
+
import { lstat, readlink, readdir as readdir2, mkdir as mkdir3, symlink, rm as rm2, access as access3 } from "node:fs/promises";
|
|
14039
|
+
import { join as join2, dirname as dirname2, resolve } from "node:path";
|
|
14040
|
+
import { homedir as homedir2 } from "node:os";
|
|
14041
|
+
function getStaleSyncHours() {
|
|
14042
|
+
const raw = process.env.BAMBOO_STALE_SYNC_HOURS;
|
|
14043
|
+
if (!raw) return DEFAULT_STALE_SYNC_HOURS;
|
|
14044
|
+
const n = Number(raw);
|
|
14045
|
+
if (!Number.isFinite(n) || n <= 0) return DEFAULT_STALE_SYNC_HOURS;
|
|
14046
|
+
return n;
|
|
14047
|
+
}
|
|
14048
|
+
function cloneSearchRoots(cwd) {
|
|
14049
|
+
const overridden = process.env.BAMBOO_CLONE_SEARCH_DIRS;
|
|
14050
|
+
const home = homedir2();
|
|
14051
|
+
const base = overridden ? overridden.split(":").filter(Boolean) : [home, join2(home, "Documents"), join2(home, "Downloads"), join2(home, "Desktop")];
|
|
14052
|
+
const walk = [];
|
|
14053
|
+
let cur = cwd ?? process.cwd();
|
|
14054
|
+
for (let i = 0; i < 20; i++) {
|
|
14055
|
+
walk.push(cur);
|
|
14056
|
+
const parent = dirname2(cur);
|
|
14057
|
+
if (parent === cur) break;
|
|
14058
|
+
if (parent === home) {
|
|
14059
|
+
walk.push(home);
|
|
14060
|
+
break;
|
|
14061
|
+
}
|
|
14062
|
+
cur = parent;
|
|
14063
|
+
}
|
|
14064
|
+
const seen = /* @__PURE__ */ new Set();
|
|
14065
|
+
const out = [];
|
|
14066
|
+
for (const p of [...base, ...walk]) {
|
|
14067
|
+
const norm = resolve(p);
|
|
14068
|
+
if (seen.has(norm)) continue;
|
|
14069
|
+
seen.add(norm);
|
|
14070
|
+
out.push(norm);
|
|
14071
|
+
}
|
|
14072
|
+
return out;
|
|
14073
|
+
}
|
|
14074
|
+
async function findClones(remoteUrl, roots, maxDepth = 4) {
|
|
14075
|
+
const found = /* @__PURE__ */ new Set();
|
|
14076
|
+
let scanned = 0;
|
|
14077
|
+
async function visit(dir, depth) {
|
|
14078
|
+
if (scanned >= MAX_DIRS_SCANNED) return;
|
|
14079
|
+
if (depth < 0) return;
|
|
14080
|
+
scanned += 1;
|
|
14081
|
+
const gitDir = join2(dir, ".git");
|
|
14082
|
+
let isRepo = false;
|
|
14083
|
+
try {
|
|
14084
|
+
const s = await lstat(gitDir);
|
|
14085
|
+
isRepo = s.isDirectory() || s.isFile();
|
|
14086
|
+
} catch {
|
|
14087
|
+
isRepo = false;
|
|
14088
|
+
}
|
|
14089
|
+
if (isRepo) {
|
|
14090
|
+
const url = await getRepoRemoteUrl(dir);
|
|
14091
|
+
if (url && matchesRemote(url, remoteUrl)) {
|
|
14092
|
+
found.add(resolve(dir));
|
|
14093
|
+
}
|
|
14094
|
+
return;
|
|
14095
|
+
}
|
|
14096
|
+
let entries = [];
|
|
14097
|
+
try {
|
|
14098
|
+
entries = await readdir2(dir, { withFileTypes: true });
|
|
14099
|
+
} catch {
|
|
14100
|
+
return;
|
|
14101
|
+
}
|
|
14102
|
+
for (const entry of entries) {
|
|
14103
|
+
if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
|
|
14104
|
+
if (entry.name.startsWith(".")) {
|
|
14105
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
14106
|
+
}
|
|
14107
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
14108
|
+
await visit(join2(dir, entry.name), depth - 1);
|
|
14109
|
+
}
|
|
14110
|
+
}
|
|
14111
|
+
for (const root of roots) {
|
|
14112
|
+
try {
|
|
14113
|
+
await access3(root);
|
|
14114
|
+
} catch {
|
|
14115
|
+
continue;
|
|
14116
|
+
}
|
|
14117
|
+
await visit(root, maxDepth);
|
|
14118
|
+
}
|
|
14119
|
+
return [...found];
|
|
14120
|
+
}
|
|
14121
|
+
function matchesRemote(a, b) {
|
|
14122
|
+
const slugA = remoteUrlSlug(a);
|
|
14123
|
+
const slugB = remoteUrlSlug(b);
|
|
14124
|
+
if (!slugA || !slugB) return false;
|
|
14125
|
+
return slugA.toLowerCase() === slugB.toLowerCase();
|
|
14126
|
+
}
|
|
14127
|
+
function remoteUrlSlug(url) {
|
|
14128
|
+
const cleaned = url.trim().replace(/\.git$/i, "");
|
|
14129
|
+
const https = cleaned.match(/^https?:\/\/[^/]*github\.com\/(.+)$/i);
|
|
14130
|
+
if (https && https[1]) return https[1];
|
|
14131
|
+
const ssh = cleaned.match(/^[^@]+@github\.com:(.+)$/i);
|
|
14132
|
+
if (ssh && ssh[1]) return ssh[1];
|
|
14133
|
+
if (/^[^/]+\/[^/]+$/.test(cleaned)) return cleaned;
|
|
14134
|
+
return null;
|
|
14135
|
+
}
|
|
14136
|
+
async function checkAdapters(workspacePath) {
|
|
14137
|
+
const out = [];
|
|
14138
|
+
for (const { path: path2, target } of CROSS_TOOL_ADAPTERS) {
|
|
14139
|
+
const full = join2(workspacePath, path2);
|
|
14140
|
+
let s;
|
|
14141
|
+
try {
|
|
14142
|
+
s = await lstat(full);
|
|
14143
|
+
} catch {
|
|
14144
|
+
out.push({ path: path2, expectedTarget: target, ok: false, state: "missing", actualTarget: null });
|
|
14145
|
+
continue;
|
|
14146
|
+
}
|
|
14147
|
+
if (!s.isSymbolicLink()) {
|
|
14148
|
+
out.push({
|
|
14149
|
+
path: path2,
|
|
14150
|
+
expectedTarget: target,
|
|
14151
|
+
ok: false,
|
|
14152
|
+
state: "not_symlink",
|
|
14153
|
+
actualTarget: null
|
|
14154
|
+
});
|
|
14155
|
+
continue;
|
|
14156
|
+
}
|
|
14157
|
+
let actual;
|
|
14158
|
+
try {
|
|
14159
|
+
actual = await readlink(full);
|
|
14160
|
+
} catch {
|
|
14161
|
+
out.push({ path: path2, expectedTarget: target, ok: false, state: "missing", actualTarget: null });
|
|
14162
|
+
continue;
|
|
14163
|
+
}
|
|
14164
|
+
if (actual === target) {
|
|
14165
|
+
out.push({ path: path2, expectedTarget: target, ok: true, state: "ok", actualTarget: actual });
|
|
14166
|
+
} else {
|
|
14167
|
+
out.push({
|
|
14168
|
+
path: path2,
|
|
14169
|
+
expectedTarget: target,
|
|
14170
|
+
ok: false,
|
|
14171
|
+
state: "wrong_target",
|
|
14172
|
+
actualTarget: actual
|
|
14173
|
+
});
|
|
14174
|
+
}
|
|
14175
|
+
}
|
|
14176
|
+
return out;
|
|
14177
|
+
}
|
|
14178
|
+
async function healAdapters(workspacePath) {
|
|
14179
|
+
const fixed = [];
|
|
14180
|
+
const current = await checkAdapters(workspacePath);
|
|
14181
|
+
for (const status of current) {
|
|
14182
|
+
if (status.ok) continue;
|
|
14183
|
+
const full = join2(workspacePath, status.path);
|
|
14184
|
+
if (status.state === "wrong_target" || status.state === "not_symlink") {
|
|
14185
|
+
try {
|
|
14186
|
+
await rm2(full, { recursive: true, force: true });
|
|
14187
|
+
} catch {
|
|
14188
|
+
}
|
|
14189
|
+
}
|
|
14190
|
+
await mkdir3(dirname2(full), { recursive: true });
|
|
14191
|
+
await symlink(status.expectedTarget, full);
|
|
14192
|
+
fixed.push(status.path);
|
|
14193
|
+
}
|
|
14194
|
+
return fixed;
|
|
14195
|
+
}
|
|
14196
|
+
function isStaleSync(lastSync, hours = getStaleSyncHours()) {
|
|
14197
|
+
const parsed = Date.parse(lastSync);
|
|
14198
|
+
if (Number.isNaN(parsed)) return true;
|
|
14199
|
+
return Date.now() - parsed > hours * 60 * 60 * 1e3;
|
|
14200
|
+
}
|
|
14201
|
+
function describeAge(lastSync) {
|
|
14202
|
+
const parsed = Date.parse(lastSync);
|
|
14203
|
+
if (Number.isNaN(parsed)) return "unknown";
|
|
14204
|
+
const ms = Date.now() - parsed;
|
|
14205
|
+
const hours = Math.floor(ms / (60 * 60 * 1e3));
|
|
14206
|
+
if (hours < 1) return "<1h";
|
|
14207
|
+
if (hours < 48) return `${hours}h`;
|
|
14208
|
+
const days = Math.floor(hours / 24);
|
|
14209
|
+
return `${days}d`;
|
|
14210
|
+
}
|
|
14211
|
+
async function gitPullFfOnly(workspacePath) {
|
|
14212
|
+
try {
|
|
14213
|
+
const { stderr } = await execFileP3("git", ["-C", workspacePath, "pull", "--ff-only"], {
|
|
14214
|
+
encoding: "utf8"
|
|
14215
|
+
});
|
|
14216
|
+
return { ok: true, stderr };
|
|
14217
|
+
} catch (err) {
|
|
14218
|
+
const e = err;
|
|
14219
|
+
return { ok: false, stderr: e.stderr ?? e.message };
|
|
14220
|
+
}
|
|
14221
|
+
}
|
|
14222
|
+
async function pathExists(p) {
|
|
14223
|
+
try {
|
|
14224
|
+
await access3(p);
|
|
14225
|
+
return true;
|
|
14226
|
+
} catch {
|
|
14227
|
+
return false;
|
|
14228
|
+
}
|
|
14229
|
+
}
|
|
14230
|
+
var execFileP3, CROSS_TOOL_ADAPTERS, DEFAULT_STALE_SYNC_HOURS, MAX_DIRS_SCANNED, SKIP_DIRS;
|
|
14231
|
+
var init_workspace_health = __esm({
|
|
14232
|
+
"src/lib/workspace-health.ts"() {
|
|
14233
|
+
"use strict";
|
|
14234
|
+
init_git();
|
|
14235
|
+
execFileP3 = promisify8(execFile8);
|
|
14236
|
+
CROSS_TOOL_ADAPTERS = [
|
|
14237
|
+
{ path: ".claude/skills", target: "../skills" },
|
|
14238
|
+
{ path: ".cursor/skills", target: "../skills" },
|
|
14239
|
+
{ path: ".agents/skills", target: "../skills" }
|
|
14240
|
+
];
|
|
14241
|
+
DEFAULT_STALE_SYNC_HOURS = 24;
|
|
14242
|
+
MAX_DIRS_SCANNED = 2e3;
|
|
14243
|
+
SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
14244
|
+
"node_modules",
|
|
14245
|
+
".git",
|
|
14246
|
+
".cache",
|
|
14247
|
+
".npm",
|
|
14248
|
+
".pnpm",
|
|
14249
|
+
".pnpm-store",
|
|
14250
|
+
".turbo",
|
|
14251
|
+
".next",
|
|
14252
|
+
".vercel",
|
|
14253
|
+
"dist",
|
|
14254
|
+
"build",
|
|
14255
|
+
"out",
|
|
14256
|
+
"Library",
|
|
14257
|
+
// macOS — never anything interesting for our purposes
|
|
14258
|
+
"Pictures",
|
|
14259
|
+
"Movies",
|
|
14260
|
+
"Music"
|
|
14261
|
+
]);
|
|
14262
|
+
}
|
|
14263
|
+
});
|
|
14264
|
+
|
|
14265
|
+
// src/lib/heal-prompt.ts
|
|
14266
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
14267
|
+
async function confirm(question, defaultValue = true) {
|
|
14268
|
+
if (!process.stdin.isTTY) return defaultValue;
|
|
14269
|
+
const hint = defaultValue ? "[Y/n]" : "[y/N]";
|
|
14270
|
+
const ask = `${question} ${hint} `;
|
|
14271
|
+
const rl = createInterface2({
|
|
14272
|
+
input: process.stdin,
|
|
14273
|
+
output: process.stdout,
|
|
14274
|
+
terminal: true
|
|
14275
|
+
});
|
|
14276
|
+
try {
|
|
14277
|
+
const answer = await readOnce2(rl, ask);
|
|
14278
|
+
if (answer === null) return null;
|
|
14279
|
+
const trimmed = answer.trim().toLowerCase();
|
|
14280
|
+
if (trimmed === "") return defaultValue;
|
|
14281
|
+
if (trimmed === "y" || trimmed === "yes") return true;
|
|
14282
|
+
if (trimmed === "n" || trimmed === "no") return false;
|
|
14283
|
+
return defaultValue;
|
|
14284
|
+
} finally {
|
|
14285
|
+
rl.close();
|
|
14286
|
+
}
|
|
14287
|
+
}
|
|
14288
|
+
async function choose(question, choices, defaultIndex = 0) {
|
|
14289
|
+
if (!process.stdin.isTTY) return defaultIndex;
|
|
14290
|
+
if (choices.length === 0) return null;
|
|
14291
|
+
console.log(question);
|
|
14292
|
+
for (let i = 0; i < choices.length; i++) {
|
|
14293
|
+
const letter = String.fromCharCode(65 + i);
|
|
14294
|
+
const marker = i === defaultIndex ? "\u203A" : " ";
|
|
14295
|
+
console.log(` ${marker} ${letter}. ${choices[i]}`);
|
|
14296
|
+
}
|
|
14297
|
+
const defaultLetter = String.fromCharCode(65 + defaultIndex);
|
|
14298
|
+
const ask = ` Pick [${defaultLetter}]: `;
|
|
14299
|
+
const rl = createInterface2({
|
|
14300
|
+
input: process.stdin,
|
|
14301
|
+
output: process.stdout,
|
|
14302
|
+
terminal: true
|
|
14303
|
+
});
|
|
14304
|
+
try {
|
|
14305
|
+
const answer = await readOnce2(rl, ask);
|
|
14306
|
+
if (answer === null) return null;
|
|
14307
|
+
const trimmed = answer.trim().toUpperCase();
|
|
14308
|
+
if (trimmed === "") return defaultIndex;
|
|
14309
|
+
if (trimmed.length === 1) {
|
|
14310
|
+
const idx = trimmed.charCodeAt(0) - 65;
|
|
14311
|
+
if (idx >= 0 && idx < choices.length) return idx;
|
|
14312
|
+
}
|
|
14313
|
+
return defaultIndex;
|
|
14314
|
+
} finally {
|
|
14315
|
+
rl.close();
|
|
14316
|
+
}
|
|
14317
|
+
}
|
|
14318
|
+
function readOnce2(rl, question) {
|
|
14319
|
+
return new Promise((resolve2) => {
|
|
14320
|
+
let resolved = false;
|
|
14321
|
+
const settle = (value) => {
|
|
14322
|
+
if (resolved) return;
|
|
14323
|
+
resolved = true;
|
|
14324
|
+
resolve2(value);
|
|
14325
|
+
};
|
|
14326
|
+
rl.once("close", () => settle(null));
|
|
14327
|
+
rl.question(question, (answer) => settle(answer));
|
|
14328
|
+
});
|
|
14329
|
+
}
|
|
14330
|
+
var init_heal_prompt = __esm({
|
|
14331
|
+
"src/lib/heal-prompt.ts"() {
|
|
14332
|
+
"use strict";
|
|
14333
|
+
}
|
|
14334
|
+
});
|
|
14335
|
+
|
|
14023
14336
|
// src/commands/doctor.ts
|
|
14024
14337
|
var doctor_exports = {};
|
|
14025
14338
|
__export(doctor_exports, {
|
|
14026
14339
|
checkBambooSession: () => checkBambooSession,
|
|
14027
14340
|
checkGitCredential: () => checkGitCredential,
|
|
14341
|
+
collectDriftFindings: () => collectDriftFindings,
|
|
14028
14342
|
runDoctor: () => runDoctor
|
|
14029
14343
|
});
|
|
14030
|
-
import { access as
|
|
14344
|
+
import { access as access4 } from "node:fs/promises";
|
|
14345
|
+
import { rm as rm3 } from "node:fs/promises";
|
|
14031
14346
|
async function checkGit() {
|
|
14032
14347
|
const v = await gitVersion();
|
|
14033
14348
|
if (!v) {
|
|
@@ -14120,7 +14435,7 @@ async function checkRepoPath() {
|
|
|
14120
14435
|
};
|
|
14121
14436
|
}
|
|
14122
14437
|
try {
|
|
14123
|
-
await
|
|
14438
|
+
await access4(cfg.repo_path);
|
|
14124
14439
|
return { name: "Repo cloned", ok: true, detail: cfg.repo_path };
|
|
14125
14440
|
} catch {
|
|
14126
14441
|
return {
|
|
@@ -14130,26 +14445,331 @@ async function checkRepoPath() {
|
|
|
14130
14445
|
};
|
|
14131
14446
|
}
|
|
14132
14447
|
}
|
|
14133
|
-
async function
|
|
14134
|
-
const
|
|
14448
|
+
async function collectDriftFindings(state, cwd) {
|
|
14449
|
+
const stateExists = await pathExists(state.workspace_path);
|
|
14450
|
+
const staleStateFinding = stateExists ? {
|
|
14451
|
+
kind: "stale_state",
|
|
14452
|
+
ok: true,
|
|
14453
|
+
summary: state.workspace_path
|
|
14454
|
+
} : {
|
|
14455
|
+
kind: "stale_state",
|
|
14456
|
+
ok: false,
|
|
14457
|
+
summary: `recorded workspace ${state.workspace_path} doesn't exist`,
|
|
14458
|
+
data: { workspace_path: state.workspace_path }
|
|
14459
|
+
};
|
|
14460
|
+
const found = await findClones(state.remote_url, cloneSearchRoots(cwd));
|
|
14461
|
+
const candidates = new Set(found);
|
|
14462
|
+
if (stateExists) {
|
|
14463
|
+
const { getRepoRemoteUrl: getRepoRemoteUrl2 } = await Promise.resolve().then(() => (init_git(), git_exports));
|
|
14464
|
+
const url = await getRepoRemoteUrl2(state.workspace_path);
|
|
14465
|
+
if (url && slugMatch(url, state.remote_url)) {
|
|
14466
|
+
candidates.add(state.workspace_path);
|
|
14467
|
+
}
|
|
14468
|
+
}
|
|
14469
|
+
const cloneList = [...candidates];
|
|
14470
|
+
const multiCloneFinding = cloneList.length > 1 ? {
|
|
14471
|
+
kind: "multi_clone",
|
|
14472
|
+
ok: false,
|
|
14473
|
+
summary: `found ${cloneList.length} clones of ${state.remote_url}`,
|
|
14474
|
+
data: { clones: cloneList, canonical: state.workspace_path }
|
|
14475
|
+
} : {
|
|
14476
|
+
kind: "multi_clone",
|
|
14477
|
+
ok: true,
|
|
14478
|
+
summary: cloneList.length === 1 ? "single clone" : "no extra clones found",
|
|
14479
|
+
data: { clones: cloneList }
|
|
14480
|
+
};
|
|
14481
|
+
const wrongStateFinding = await (async () => {
|
|
14482
|
+
if (stateExists) {
|
|
14483
|
+
const { getRepoRemoteUrl: getRepoRemoteUrl2 } = await Promise.resolve().then(() => (init_git(), git_exports));
|
|
14484
|
+
const url = await getRepoRemoteUrl2(state.workspace_path);
|
|
14485
|
+
if (!url || !slugMatch(url, state.remote_url)) {
|
|
14486
|
+
const better2 = cloneList.find((p) => p !== state.workspace_path);
|
|
14487
|
+
if (better2) {
|
|
14488
|
+
return {
|
|
14489
|
+
kind: "wrong_state",
|
|
14490
|
+
ok: false,
|
|
14491
|
+
summary: `${state.workspace_path} doesn't match remote ${state.remote_url}`,
|
|
14492
|
+
data: {
|
|
14493
|
+
recorded: state.workspace_path,
|
|
14494
|
+
actual: better2,
|
|
14495
|
+
recorded_origin: url ?? null
|
|
14496
|
+
}
|
|
14497
|
+
};
|
|
14498
|
+
}
|
|
14499
|
+
}
|
|
14500
|
+
return { kind: "wrong_state", ok: true, summary: "state matches workspace" };
|
|
14501
|
+
}
|
|
14502
|
+
const better = cloneList.find((p) => p !== state.workspace_path);
|
|
14503
|
+
if (better) {
|
|
14504
|
+
return {
|
|
14505
|
+
kind: "wrong_state",
|
|
14506
|
+
ok: false,
|
|
14507
|
+
summary: `recorded path missing, but a clone exists at ${better}`,
|
|
14508
|
+
data: { recorded: state.workspace_path, actual: better }
|
|
14509
|
+
};
|
|
14510
|
+
}
|
|
14511
|
+
return { kind: "wrong_state", ok: true, summary: "no alternate clone to switch to" };
|
|
14512
|
+
})();
|
|
14513
|
+
const adapterFinding = await (async () => {
|
|
14514
|
+
if (!stateExists) {
|
|
14515
|
+
return {
|
|
14516
|
+
kind: "missing_adapters",
|
|
14517
|
+
ok: true,
|
|
14518
|
+
summary: "skipped (workspace path missing)"
|
|
14519
|
+
};
|
|
14520
|
+
}
|
|
14521
|
+
const adapters = await checkAdapters(state.workspace_path);
|
|
14522
|
+
const broken = adapters.filter((a) => !a.ok);
|
|
14523
|
+
if (broken.length === 0) {
|
|
14524
|
+
return { kind: "missing_adapters", ok: true, summary: "all adapter symlinks present" };
|
|
14525
|
+
}
|
|
14526
|
+
return {
|
|
14527
|
+
kind: "missing_adapters",
|
|
14528
|
+
ok: false,
|
|
14529
|
+
summary: `${broken.length}/${adapters.length} adapter symlinks missing or wrong`,
|
|
14530
|
+
data: { adapters, broken: broken.map((b) => b.path) }
|
|
14531
|
+
};
|
|
14532
|
+
})();
|
|
14533
|
+
const staleSyncFinding = isStaleSync(state.last_sync) ? {
|
|
14534
|
+
kind: "stale_sync",
|
|
14535
|
+
ok: false,
|
|
14536
|
+
summary: `last sync was ${describeAge(state.last_sync)} ago (threshold: ${getStaleSyncHours()}h)`,
|
|
14537
|
+
data: { last_sync: state.last_sync }
|
|
14538
|
+
} : {
|
|
14539
|
+
kind: "stale_sync",
|
|
14540
|
+
ok: true,
|
|
14541
|
+
summary: `synced ${describeAge(state.last_sync)} ago`
|
|
14542
|
+
};
|
|
14543
|
+
return [
|
|
14544
|
+
staleStateFinding,
|
|
14545
|
+
multiCloneFinding,
|
|
14546
|
+
wrongStateFinding,
|
|
14547
|
+
adapterFinding,
|
|
14548
|
+
staleSyncFinding
|
|
14549
|
+
];
|
|
14550
|
+
}
|
|
14551
|
+
function slugMatch(a, b) {
|
|
14552
|
+
const slug = (u) => {
|
|
14553
|
+
const cleaned = u.trim().replace(/\.git$/i, "");
|
|
14554
|
+
const https = cleaned.match(/^https?:\/\/[^/]*github\.com\/(.+)$/i);
|
|
14555
|
+
if (https && https[1]) return https[1].toLowerCase();
|
|
14556
|
+
const ssh = cleaned.match(/^[^@]+@github\.com:(.+)$/i);
|
|
14557
|
+
if (ssh && ssh[1]) return ssh[1].toLowerCase();
|
|
14558
|
+
if (/^[^/]+\/[^/]+$/.test(cleaned)) return cleaned.toLowerCase();
|
|
14559
|
+
return null;
|
|
14560
|
+
};
|
|
14561
|
+
const sa = slug(a);
|
|
14562
|
+
const sb = slug(b);
|
|
14563
|
+
return sa !== null && sb !== null && sa === sb;
|
|
14564
|
+
}
|
|
14565
|
+
async function healStaleState(finding, state, opts) {
|
|
14566
|
+
console.log("");
|
|
14567
|
+
console.log(` \u2717 Recorded workspace path missing: ${finding.data?.workspace_path}`);
|
|
14568
|
+
if (opts.quiet) return state;
|
|
14569
|
+
const want = await confirm(" Re-run init to re-clone?", true);
|
|
14570
|
+
if (!want) {
|
|
14571
|
+
console.log(" Skipped. Run `bamboo-agents init` manually when ready.");
|
|
14572
|
+
return state;
|
|
14573
|
+
}
|
|
14574
|
+
console.log(" Launching `bamboo-agents init` flow\u2026");
|
|
14575
|
+
const { runInit: runInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
14576
|
+
await runInit2();
|
|
14577
|
+
const fresh = await readState();
|
|
14578
|
+
return fresh ?? state;
|
|
14579
|
+
}
|
|
14580
|
+
async function healMultiClone(finding, state, opts) {
|
|
14581
|
+
const clones = finding.data?.clones ?? [];
|
|
14582
|
+
console.log("");
|
|
14583
|
+
console.log(` \u2717 Found ${clones.length} clones of ${state.remote_url}:`);
|
|
14584
|
+
for (const p of clones) console.log(` \u2022 ${p}`);
|
|
14585
|
+
if (opts.quiet) return state;
|
|
14586
|
+
const choices = [...clones, "Skip (leave both)"];
|
|
14587
|
+
const defaultIdx = clones.findIndex((p) => p === state.workspace_path);
|
|
14588
|
+
const idx = await choose(
|
|
14589
|
+
" Which clone should be canonical?",
|
|
14590
|
+
choices,
|
|
14591
|
+
defaultIdx >= 0 ? defaultIdx : 0
|
|
14592
|
+
);
|
|
14593
|
+
if (idx === null || idx === choices.length - 1) {
|
|
14594
|
+
console.log(" Skipped. Multi-clone left as-is.");
|
|
14595
|
+
return state;
|
|
14596
|
+
}
|
|
14597
|
+
const canonical = clones[idx];
|
|
14598
|
+
const nonCanonical = clones.filter((p) => p !== canonical);
|
|
14599
|
+
let next = state;
|
|
14600
|
+
if (canonical !== state.workspace_path) {
|
|
14601
|
+
next = { ...state, workspace_path: canonical };
|
|
14602
|
+
await writeState(next);
|
|
14603
|
+
console.log(` Updated state.json \u2192 ${canonical}`);
|
|
14604
|
+
}
|
|
14605
|
+
if (nonCanonical.length > 0) {
|
|
14606
|
+
console.log(" Other clones:");
|
|
14607
|
+
for (const p of nonCanonical) console.log(` \u2022 ${p}`);
|
|
14608
|
+
const wantDelete = await confirm(" Delete the non-canonical clones?", false);
|
|
14609
|
+
if (wantDelete) {
|
|
14610
|
+
for (const p of nonCanonical) {
|
|
14611
|
+
try {
|
|
14612
|
+
await rm3(p, { recursive: true, force: true });
|
|
14613
|
+
console.log(` \u2713 removed ${p}`);
|
|
14614
|
+
} catch (err) {
|
|
14615
|
+
console.log(` \u2717 couldn't remove ${p}: ${err.message}`);
|
|
14616
|
+
}
|
|
14617
|
+
}
|
|
14618
|
+
} else {
|
|
14619
|
+
console.log(" Left non-canonical clones in place.");
|
|
14620
|
+
}
|
|
14621
|
+
}
|
|
14622
|
+
return next;
|
|
14623
|
+
}
|
|
14624
|
+
async function healWrongState(finding, state, opts) {
|
|
14625
|
+
const actual = finding.data?.actual;
|
|
14626
|
+
const recorded = finding.data?.recorded;
|
|
14627
|
+
if (!actual || !recorded) return state;
|
|
14628
|
+
console.log("");
|
|
14629
|
+
console.log(` \u2717 state.workspace_path = ${recorded}, but workspace lives at ${actual}`);
|
|
14630
|
+
if (opts.quiet) return state;
|
|
14631
|
+
const useActual = opts.autoHeal ? true : await confirm(` Update state.json \u2192 ${actual}?`, true);
|
|
14632
|
+
if (useActual === null || !useActual) {
|
|
14633
|
+
console.log(" Skipped. state.json still points at the recorded path.");
|
|
14634
|
+
return state;
|
|
14635
|
+
}
|
|
14636
|
+
const next = { ...state, workspace_path: actual };
|
|
14637
|
+
await writeState(next);
|
|
14638
|
+
console.log(` Updated state.json \u2192 ${actual}`);
|
|
14639
|
+
return next;
|
|
14640
|
+
}
|
|
14641
|
+
async function healMissingAdapters(finding, state, opts) {
|
|
14642
|
+
const broken = finding.data?.broken ?? [];
|
|
14643
|
+
console.log("");
|
|
14644
|
+
console.log(` \u2717 Missing/wrong adapter symlinks: ${broken.join(", ")}`);
|
|
14645
|
+
if (opts.quiet) return state;
|
|
14646
|
+
const want = opts.autoHeal ? true : await confirm(" Add the missing adapter symlinks?", true);
|
|
14647
|
+
if (!want) {
|
|
14648
|
+
console.log(" Skipped. Add manually with `ln -s ../skills <path>` from your workspace root.");
|
|
14649
|
+
return state;
|
|
14650
|
+
}
|
|
14651
|
+
try {
|
|
14652
|
+
const fixed = await healAdapters(state.workspace_path);
|
|
14653
|
+
for (const p of fixed) console.log(` \u2713 created ${p} \u2192 ../skills`);
|
|
14654
|
+
} catch (err) {
|
|
14655
|
+
console.log(` \u2717 couldn't create symlinks: ${err.message}`);
|
|
14656
|
+
}
|
|
14657
|
+
return state;
|
|
14658
|
+
}
|
|
14659
|
+
async function healStaleSync(_finding, state, opts) {
|
|
14660
|
+
console.log("");
|
|
14661
|
+
console.log(` \u2717 Last sync was ${describeAge(state.last_sync)} ago.`);
|
|
14662
|
+
if (opts.quiet) return state;
|
|
14663
|
+
const want = opts.autoHeal ? true : await confirm(" Pull now (ff-only)?", true);
|
|
14664
|
+
if (!want) {
|
|
14665
|
+
console.log(" Skipped. Run `git pull` in your workspace when ready.");
|
|
14666
|
+
return state;
|
|
14667
|
+
}
|
|
14668
|
+
const result = await gitPullFfOnly(state.workspace_path);
|
|
14669
|
+
if (result.ok) {
|
|
14670
|
+
const next = { ...state, last_sync: (/* @__PURE__ */ new Date()).toISOString() };
|
|
14671
|
+
await writeState(next);
|
|
14672
|
+
console.log(" \u2713 pulled cleanly");
|
|
14673
|
+
return next;
|
|
14674
|
+
}
|
|
14675
|
+
console.log(` \u2717 pull failed: ${result.stderr.trim().split("\n")[0]}`);
|
|
14676
|
+
console.log(" Run `git pull` manually to diagnose.");
|
|
14677
|
+
return state;
|
|
14678
|
+
}
|
|
14679
|
+
async function runDoctor(options = {}) {
|
|
14680
|
+
const opts = {
|
|
14681
|
+
quiet: options.quiet === true,
|
|
14682
|
+
autoHeal: options.autoHeal === true
|
|
14683
|
+
};
|
|
14684
|
+
const baseChecks = await Promise.all([
|
|
14135
14685
|
checkGit(),
|
|
14136
14686
|
checkBambooSession(),
|
|
14137
14687
|
checkGitCredential(),
|
|
14138
14688
|
checkConfig(),
|
|
14139
14689
|
checkRepoPath()
|
|
14140
14690
|
]);
|
|
14691
|
+
const state = await readState().catch(() => null);
|
|
14692
|
+
const drift = state ? await collectDriftFindings(state) : null;
|
|
14693
|
+
if (opts.quiet) {
|
|
14694
|
+
const payload = {
|
|
14695
|
+
ok: baseChecks.every((c) => c.ok) && (drift ?? []).every((d) => d.ok),
|
|
14696
|
+
checks: baseChecks.map((c) => ({ name: c.name, ok: c.ok, detail: c.detail })),
|
|
14697
|
+
drift: drift ?? []
|
|
14698
|
+
};
|
|
14699
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
14700
|
+
process.exit(payload.ok ? 0 : 1);
|
|
14701
|
+
return;
|
|
14702
|
+
}
|
|
14141
14703
|
console.log("");
|
|
14142
|
-
for (const c of
|
|
14704
|
+
for (const c of baseChecks) {
|
|
14143
14705
|
const mark = c.ok ? "\u2713" : "\u2717";
|
|
14144
14706
|
console.log(` ${mark} ${c.name.padEnd(28)} ${c.detail}`);
|
|
14145
14707
|
}
|
|
14708
|
+
if (drift) {
|
|
14709
|
+
console.log("");
|
|
14710
|
+
const labels = {
|
|
14711
|
+
stale_state: "Workspace path on disk",
|
|
14712
|
+
multi_clone: "Single clone",
|
|
14713
|
+
wrong_state: "State matches workspace",
|
|
14714
|
+
missing_adapters: "Cross-tool adapters",
|
|
14715
|
+
stale_sync: "Recent sync"
|
|
14716
|
+
};
|
|
14717
|
+
for (const f of drift) {
|
|
14718
|
+
const mark = f.ok ? "\u2713" : "\u2717";
|
|
14719
|
+
console.log(` ${mark} ${labels[f.kind].padEnd(28)} ${f.summary}`);
|
|
14720
|
+
}
|
|
14721
|
+
}
|
|
14146
14722
|
console.log("");
|
|
14147
|
-
const
|
|
14148
|
-
if (
|
|
14149
|
-
|
|
14150
|
-
|
|
14723
|
+
const remaining = (drift ?? []).filter((f) => !f.ok);
|
|
14724
|
+
if (remaining.length === 0) {
|
|
14725
|
+
const baseFailures = baseChecks.filter((c) => !c.ok).length;
|
|
14726
|
+
if (baseFailures > 0) {
|
|
14727
|
+
console.log(` ${baseFailures} check(s) failing.`);
|
|
14728
|
+
process.exit(1);
|
|
14729
|
+
}
|
|
14730
|
+
console.log(" All checks passing.");
|
|
14731
|
+
return;
|
|
14151
14732
|
}
|
|
14152
|
-
console.log(
|
|
14733
|
+
console.log(` ${remaining.length} drift issue(s) detected \u2014 let's fix them.`);
|
|
14734
|
+
let cur = state;
|
|
14735
|
+
const order = [
|
|
14736
|
+
"stale_state",
|
|
14737
|
+
"wrong_state",
|
|
14738
|
+
"multi_clone",
|
|
14739
|
+
"missing_adapters",
|
|
14740
|
+
"stale_sync"
|
|
14741
|
+
];
|
|
14742
|
+
for (const kind of order) {
|
|
14743
|
+
const f = remaining.find((r) => r.kind === kind);
|
|
14744
|
+
if (!f) continue;
|
|
14745
|
+
switch (kind) {
|
|
14746
|
+
case "stale_state":
|
|
14747
|
+
cur = await healStaleState(f, cur, opts);
|
|
14748
|
+
break;
|
|
14749
|
+
case "multi_clone":
|
|
14750
|
+
cur = await healMultiClone(f, cur, opts);
|
|
14751
|
+
break;
|
|
14752
|
+
case "wrong_state":
|
|
14753
|
+
cur = await healWrongState(f, cur, opts);
|
|
14754
|
+
break;
|
|
14755
|
+
case "missing_adapters":
|
|
14756
|
+
cur = await healMissingAdapters(f, cur, opts);
|
|
14757
|
+
break;
|
|
14758
|
+
case "stale_sync":
|
|
14759
|
+
cur = await healStaleSync(f, cur, opts);
|
|
14760
|
+
break;
|
|
14761
|
+
}
|
|
14762
|
+
}
|
|
14763
|
+
const post = await readState().catch(() => null);
|
|
14764
|
+
const postDrift = post ? await collectDriftFindings(post) : drift;
|
|
14765
|
+
const stillBroken = (postDrift ?? []).filter((d) => !d.ok);
|
|
14766
|
+
console.log("");
|
|
14767
|
+
if (stillBroken.length === 0) {
|
|
14768
|
+
console.log(" \u2713 Workspace healthy.");
|
|
14769
|
+
return;
|
|
14770
|
+
}
|
|
14771
|
+
console.log(` ${stillBroken.length} issue(s) remain \u2014 re-run \`bamboo-agents doctor\` after addressing.`);
|
|
14772
|
+
process.exit(1);
|
|
14153
14773
|
}
|
|
14154
14774
|
var init_doctor = __esm({
|
|
14155
14775
|
"src/commands/doctor.ts"() {
|
|
@@ -14158,6 +14778,8 @@ var init_doctor = __esm({
|
|
|
14158
14778
|
init_git();
|
|
14159
14779
|
init_state();
|
|
14160
14780
|
init_credentials();
|
|
14781
|
+
init_workspace_health();
|
|
14782
|
+
init_heal_prompt();
|
|
14161
14783
|
}
|
|
14162
14784
|
});
|
|
14163
14785
|
|
|
@@ -14166,10 +14788,10 @@ var save_exports = {};
|
|
|
14166
14788
|
__export(save_exports, {
|
|
14167
14789
|
runSave: () => runSave
|
|
14168
14790
|
});
|
|
14169
|
-
import { execFile as
|
|
14170
|
-
import { promisify as
|
|
14791
|
+
import { execFile as execFile9 } from "node:child_process";
|
|
14792
|
+
import { promisify as promisify9 } from "node:util";
|
|
14171
14793
|
async function gitC(repoPath, args) {
|
|
14172
|
-
const { stdout, stderr } = await
|
|
14794
|
+
const { stdout, stderr } = await execFileP4("git", ["-C", repoPath, ...args], {
|
|
14173
14795
|
encoding: "utf8"
|
|
14174
14796
|
});
|
|
14175
14797
|
return { stdout, stderr };
|
|
@@ -14218,12 +14840,12 @@ async function runSave(message) {
|
|
|
14218
14840
|
process.exit(1);
|
|
14219
14841
|
}
|
|
14220
14842
|
}
|
|
14221
|
-
var
|
|
14843
|
+
var execFileP4;
|
|
14222
14844
|
var init_save = __esm({
|
|
14223
14845
|
"src/commands/save.ts"() {
|
|
14224
14846
|
"use strict";
|
|
14225
14847
|
init_workspace();
|
|
14226
|
-
|
|
14848
|
+
execFileP4 = promisify9(execFile9);
|
|
14227
14849
|
}
|
|
14228
14850
|
});
|
|
14229
14851
|
|
|
@@ -14232,8 +14854,8 @@ var sync_exports = {};
|
|
|
14232
14854
|
__export(sync_exports, {
|
|
14233
14855
|
runSync: () => runSync
|
|
14234
14856
|
});
|
|
14235
|
-
import { execFile as
|
|
14236
|
-
import { promisify as
|
|
14857
|
+
import { execFile as execFile10 } from "node:child_process";
|
|
14858
|
+
import { promisify as promisify10 } from "node:util";
|
|
14237
14859
|
async function runSync() {
|
|
14238
14860
|
let workspacePath;
|
|
14239
14861
|
try {
|
|
@@ -14246,7 +14868,7 @@ async function runSync() {
|
|
|
14246
14868
|
throw err;
|
|
14247
14869
|
}
|
|
14248
14870
|
try {
|
|
14249
|
-
const { stdout } = await
|
|
14871
|
+
const { stdout } = await execFileP5(
|
|
14250
14872
|
"git",
|
|
14251
14873
|
["-C", workspacePath, "pull", "--ff-only"],
|
|
14252
14874
|
{ encoding: "utf8" }
|
|
@@ -14275,19 +14897,19 @@ async function runSync() {
|
|
|
14275
14897
|
throw err;
|
|
14276
14898
|
}
|
|
14277
14899
|
}
|
|
14278
|
-
var
|
|
14900
|
+
var execFileP5;
|
|
14279
14901
|
var init_sync = __esm({
|
|
14280
14902
|
"src/commands/sync.ts"() {
|
|
14281
14903
|
"use strict";
|
|
14282
14904
|
init_state();
|
|
14283
14905
|
init_workspace();
|
|
14284
|
-
|
|
14906
|
+
execFileP5 = promisify10(execFile10);
|
|
14285
14907
|
}
|
|
14286
14908
|
});
|
|
14287
14909
|
|
|
14288
14910
|
// src/lib/skills-local.ts
|
|
14289
|
-
import { readdir as
|
|
14290
|
-
import { join as
|
|
14911
|
+
import { readdir as readdir3, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
14912
|
+
import { join as join3 } from "node:path";
|
|
14291
14913
|
function parseSimpleFrontmatter(raw) {
|
|
14292
14914
|
const text = raw.replace(/\r\n/g, "\n");
|
|
14293
14915
|
const m = text.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
@@ -14402,7 +15024,7 @@ function parseSkillContent(raw, sourcePath) {
|
|
|
14402
15024
|
};
|
|
14403
15025
|
}
|
|
14404
15026
|
async function resolveSkillsDir(repoPath) {
|
|
14405
|
-
const dir =
|
|
15027
|
+
const dir = join3(repoPath, "skills");
|
|
14406
15028
|
try {
|
|
14407
15029
|
const s = await stat2(dir);
|
|
14408
15030
|
return s.isDirectory() ? dir : null;
|
|
@@ -14413,11 +15035,11 @@ async function resolveSkillsDir(repoPath) {
|
|
|
14413
15035
|
async function listLocalSkills(repoPath) {
|
|
14414
15036
|
const dir = await resolveSkillsDir(repoPath);
|
|
14415
15037
|
if (!dir) return [];
|
|
14416
|
-
const entries = await
|
|
15038
|
+
const entries = await readdir3(dir, { withFileTypes: true });
|
|
14417
15039
|
const skillDirs = entries.filter((e) => e.isDirectory());
|
|
14418
15040
|
const skills2 = [];
|
|
14419
15041
|
for (const entry of skillDirs) {
|
|
14420
|
-
const full =
|
|
15042
|
+
const full = join3(dir, entry.name, "SKILL.md");
|
|
14421
15043
|
let raw;
|
|
14422
15044
|
try {
|
|
14423
15045
|
raw = await readFile4(full, "utf8");
|
|
@@ -14438,7 +15060,7 @@ async function listLocalSkills(repoPath) {
|
|
|
14438
15060
|
async function getLocalSkill(repoPath, name) {
|
|
14439
15061
|
const dir = await resolveSkillsDir(repoPath);
|
|
14440
15062
|
if (!dir) return null;
|
|
14441
|
-
const full =
|
|
15063
|
+
const full = join3(dir, name, "SKILL.md");
|
|
14442
15064
|
let raw;
|
|
14443
15065
|
try {
|
|
14444
15066
|
raw = await readFile4(full, "utf8");
|
|
@@ -14830,9 +15452,9 @@ program2.command("status").description("Show current Bamboo CLI state").action(a
|
|
|
14830
15452
|
const { runStatus: runStatus2 } = await Promise.resolve().then(() => (init_status(), status_exports));
|
|
14831
15453
|
await runStatus2();
|
|
14832
15454
|
});
|
|
14833
|
-
program2.command("doctor").description("Verify your local setup is ready").action(async () => {
|
|
15455
|
+
program2.command("doctor").description("Verify your local setup is ready + heal workspace drift").option("--quiet", "Emit JSON without prompting (CI / scripts)").option("--auto-heal", "Apply non-destructive fixes silently").action(async (options) => {
|
|
14834
15456
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
|
|
14835
|
-
await runDoctor2();
|
|
15457
|
+
await runDoctor2({ quiet: options.quiet, autoHeal: options.autoHeal });
|
|
14836
15458
|
});
|
|
14837
15459
|
program2.command("save <message>").description("Commit + push everything in your workspace (cwd-agnostic)").action(async (message) => {
|
|
14838
15460
|
const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save(), save_exports));
|