bitfab-cli 0.2.171 → 0.2.172
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/index.js +108 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30790,13 +30790,23 @@ function skipFlags(skip, flag) {
|
|
|
30790
30790
|
return skip ? [flag] : [];
|
|
30791
30791
|
}
|
|
30792
30792
|
function runCli(bin, args) {
|
|
30793
|
-
const result =
|
|
30794
|
-
if (result.status !== 0) {
|
|
30793
|
+
const result = runCliResult(bin, args);
|
|
30794
|
+
if (result.status !== 0 || result.error) {
|
|
30795
|
+
const output = result.output.trim();
|
|
30795
30796
|
throw new Error(
|
|
30796
|
-
`${bin} ${args.join(" ")} failed${result.status === null ? "" : ` with status ${result.status}`}`
|
|
30797
|
+
`${bin} ${args.join(" ")} failed${result.status === null ? "" : ` with status ${result.status}`}${output ? `
|
|
30798
|
+
${output}` : ""}`
|
|
30797
30799
|
);
|
|
30798
30800
|
}
|
|
30799
|
-
return
|
|
30801
|
+
return result.output;
|
|
30802
|
+
}
|
|
30803
|
+
function runCliResult(bin, args) {
|
|
30804
|
+
const result = spawnSync(bin, [...args], { stdio: "pipe", ...SHELL_OPTS });
|
|
30805
|
+
return {
|
|
30806
|
+
status: result.status,
|
|
30807
|
+
output: (result.stdout?.toString() ?? "") + (result.stderr?.toString() ?? ""),
|
|
30808
|
+
error: result.error
|
|
30809
|
+
};
|
|
30800
30810
|
}
|
|
30801
30811
|
function launchCli(bin, args) {
|
|
30802
30812
|
spawnSync(bin, [...args], { stdio: "inherit", ...SHELL_OPTS });
|
|
@@ -30835,7 +30845,44 @@ function ensureLatestPlugin(pull) {
|
|
|
30835
30845
|
}
|
|
30836
30846
|
|
|
30837
30847
|
// src/cliEditor.ts
|
|
30848
|
+
function makeCliAuthCheck({
|
|
30849
|
+
cli,
|
|
30850
|
+
args,
|
|
30851
|
+
label,
|
|
30852
|
+
loginCommand,
|
|
30853
|
+
parseAuthenticated
|
|
30854
|
+
}) {
|
|
30855
|
+
return () => {
|
|
30856
|
+
const result = runCliResult(cli, args);
|
|
30857
|
+
if (result.error) {
|
|
30858
|
+
return {
|
|
30859
|
+
ok: false,
|
|
30860
|
+
message: `Failed to run ${cli}: ${result.error.message}`
|
|
30861
|
+
};
|
|
30862
|
+
}
|
|
30863
|
+
if (result.status === 0 && parseAuthenticated(result.output)) {
|
|
30864
|
+
return { ok: true };
|
|
30865
|
+
}
|
|
30866
|
+
const output = result.output.trim();
|
|
30867
|
+
return {
|
|
30868
|
+
ok: false,
|
|
30869
|
+
message: [
|
|
30870
|
+
`${label} is not logged in. Run \`${loginCommand}\` and try again before launching the Bitfab agent.`,
|
|
30871
|
+
output ? `
|
|
30872
|
+
${label} said:
|
|
30873
|
+
${output}` : ""
|
|
30874
|
+
].join("")
|
|
30875
|
+
};
|
|
30876
|
+
};
|
|
30877
|
+
}
|
|
30878
|
+
function ensureCliAuthenticated(cfg) {
|
|
30879
|
+
const result = cfg.authCheck?.();
|
|
30880
|
+
if (result?.ok === false) {
|
|
30881
|
+
throw new Error(result.message);
|
|
30882
|
+
}
|
|
30883
|
+
}
|
|
30838
30884
|
function cliSetup(cfg, skipPermissions) {
|
|
30885
|
+
ensureCliAuthenticated(cfg);
|
|
30839
30886
|
p2.log.info(`Launching ${cfg.setupCommand}...
|
|
30840
30887
|
`);
|
|
30841
30888
|
launchCli(cfg.cli, [
|
|
@@ -30844,6 +30891,7 @@ function cliSetup(cfg, skipPermissions) {
|
|
|
30844
30891
|
]);
|
|
30845
30892
|
}
|
|
30846
30893
|
function cliAssistant(cfg, args, skipPermissions) {
|
|
30894
|
+
ensureCliAuthenticated(cfg);
|
|
30847
30895
|
const cmd = [cfg.assistantCommand, ...args].join(" ");
|
|
30848
30896
|
p2.log.info(`Launching ${cmd}...
|
|
30849
30897
|
`);
|
|
@@ -30868,6 +30916,7 @@ function cliUpdate(cfg, args, skipPermissions) {
|
|
|
30868
30916
|
s.stop(formatPluginRefreshResult(out));
|
|
30869
30917
|
}
|
|
30870
30918
|
if (mode === "sdk" || mode === "all") {
|
|
30919
|
+
ensureCliAuthenticated(cfg);
|
|
30871
30920
|
p2.log.info(`Launching ${cfg.updateCommand} sdk...
|
|
30872
30921
|
`);
|
|
30873
30922
|
launchCli(cfg.cli, [
|
|
@@ -30888,6 +30937,21 @@ var SETUP_COMMAND = "/bitfab:setup";
|
|
|
30888
30937
|
var ANALYZE_REPO_COMMAND = "/bitfab:setup analyze-repo";
|
|
30889
30938
|
var ASSISTANT_COMMAND = "/bitfab:assistant";
|
|
30890
30939
|
var UPDATE_COMMAND = "/bitfab:update";
|
|
30940
|
+
function isClaudeAuthStatusLoggedIn(output) {
|
|
30941
|
+
try {
|
|
30942
|
+
const status = JSON.parse(output);
|
|
30943
|
+
return status.loggedIn === true;
|
|
30944
|
+
} catch {
|
|
30945
|
+
return false;
|
|
30946
|
+
}
|
|
30947
|
+
}
|
|
30948
|
+
var checkClaudeAuth = makeCliAuthCheck({
|
|
30949
|
+
cli: CLI,
|
|
30950
|
+
args: ["auth", "status"],
|
|
30951
|
+
label: "Claude Code",
|
|
30952
|
+
loginCommand: "claude auth login",
|
|
30953
|
+
parseAuthenticated: isClaudeAuthStatusLoggedIn
|
|
30954
|
+
});
|
|
30891
30955
|
function runClaudeInstall() {
|
|
30892
30956
|
const s = p3.spinner();
|
|
30893
30957
|
s.start("Adding bitfab marketplace");
|
|
@@ -30928,6 +30992,10 @@ function ensureLatestClaudePlugin() {
|
|
|
30928
30992
|
ensureLatestPlugin(pullLatestClaudePlugin);
|
|
30929
30993
|
}
|
|
30930
30994
|
async function runClaudeAnalyzeRepo(captureOverride, limit) {
|
|
30995
|
+
const auth = checkClaudeAuth();
|
|
30996
|
+
if (!auth.ok) {
|
|
30997
|
+
throw new Error(auth.message);
|
|
30998
|
+
}
|
|
30931
30999
|
const logPath = analyzeRepoLogPath();
|
|
30932
31000
|
const env = { ...process.env };
|
|
30933
31001
|
if (captureOverride !== void 0) {
|
|
@@ -31128,6 +31196,7 @@ var config2 = {
|
|
|
31128
31196
|
setupCommand: SETUP_COMMAND,
|
|
31129
31197
|
assistantCommand: ASSISTANT_COMMAND,
|
|
31130
31198
|
updateCommand: UPDATE_COMMAND,
|
|
31199
|
+
authCheck: checkClaudeAuth,
|
|
31131
31200
|
pullLatest: pullLatestClaudePlugin
|
|
31132
31201
|
};
|
|
31133
31202
|
var claudeAdapter = {
|
|
@@ -31153,6 +31222,16 @@ var PLUGIN_KEY2 = "bitfab@bitfab";
|
|
|
31153
31222
|
var SETUP_COMMAND2 = "$bitfab:setup";
|
|
31154
31223
|
var ASSISTANT_COMMAND2 = "$bitfab:assistant";
|
|
31155
31224
|
var UPDATE_COMMAND2 = "$bitfab:update";
|
|
31225
|
+
function isCodexLoginStatusLoggedIn(output) {
|
|
31226
|
+
return /logged in/i.test(output) && !/not logged in/i.test(output);
|
|
31227
|
+
}
|
|
31228
|
+
var checkCodexAuth = makeCliAuthCheck({
|
|
31229
|
+
cli: CLI2,
|
|
31230
|
+
args: ["login", "status"],
|
|
31231
|
+
label: "Codex",
|
|
31232
|
+
loginCommand: "codex login",
|
|
31233
|
+
parseAuthenticated: isCodexLoginStatusLoggedIn
|
|
31234
|
+
});
|
|
31156
31235
|
function pullLatestCodexPlugin() {
|
|
31157
31236
|
return runCli(CLI2, ["plugin", "marketplace", "upgrade", MARKETPLACE2]);
|
|
31158
31237
|
}
|
|
@@ -31230,6 +31309,7 @@ var config3 = {
|
|
|
31230
31309
|
setupCommand: SETUP_COMMAND2,
|
|
31231
31310
|
assistantCommand: ASSISTANT_COMMAND2,
|
|
31232
31311
|
updateCommand: UPDATE_COMMAND2,
|
|
31312
|
+
authCheck: checkCodexAuth,
|
|
31233
31313
|
pullLatest: pullLatestCodexPlugin
|
|
31234
31314
|
};
|
|
31235
31315
|
var codexAdapter = {
|
|
@@ -31251,6 +31331,27 @@ var ADD_PLUGIN_CMD = `/add-plugin ${REPO3}`;
|
|
|
31251
31331
|
var SETUP_COMMAND3 = "/bitfab-setup";
|
|
31252
31332
|
var ASSISTANT_COMMAND3 = "/bitfab-assistant";
|
|
31253
31333
|
var UPDATE_COMMAND3 = "/bitfab-update";
|
|
31334
|
+
function isCursorAgentStatusAuthenticated(output) {
|
|
31335
|
+
try {
|
|
31336
|
+
const status = JSON.parse(output);
|
|
31337
|
+
return status.isAuthenticated === true || status.status === "authenticated";
|
|
31338
|
+
} catch {
|
|
31339
|
+
return false;
|
|
31340
|
+
}
|
|
31341
|
+
}
|
|
31342
|
+
var checkCursorAuth = makeCliAuthCheck({
|
|
31343
|
+
cli: "cursor",
|
|
31344
|
+
args: ["agent", "status", "--format", "json"],
|
|
31345
|
+
label: "Cursor Agent",
|
|
31346
|
+
loginCommand: "cursor agent login",
|
|
31347
|
+
parseAuthenticated: isCursorAgentStatusAuthenticated
|
|
31348
|
+
});
|
|
31349
|
+
function ensureCursorAuthenticated() {
|
|
31350
|
+
const result = checkCursorAuth();
|
|
31351
|
+
if (result.ok === false) {
|
|
31352
|
+
throw new Error(result.message);
|
|
31353
|
+
}
|
|
31354
|
+
}
|
|
31254
31355
|
function runCursorInstall() {
|
|
31255
31356
|
const copied = copyToClipboard(ADD_PLUGIN_CMD);
|
|
31256
31357
|
if (copied) {
|
|
@@ -31279,6 +31380,7 @@ function runCursorInstall() {
|
|
|
31279
31380
|
function ensureLatestCursorPlugin() {
|
|
31280
31381
|
}
|
|
31281
31382
|
function runCursorSetup(skipPermissions) {
|
|
31383
|
+
ensureCursorAuthenticated();
|
|
31282
31384
|
if (skipPermissions) {
|
|
31283
31385
|
p5.log.warn("--skip-permissions is not supported for Cursor");
|
|
31284
31386
|
}
|
|
@@ -31291,6 +31393,7 @@ function runCursorAnalyzeRepo() {
|
|
|
31291
31393
|
p5.log.info(`To run it in Cursor, run ${SETUP_COMMAND3} analyze-repo manually.`);
|
|
31292
31394
|
}
|
|
31293
31395
|
function runCursorAssistant(args, skipPermissions) {
|
|
31396
|
+
ensureCursorAuthenticated();
|
|
31294
31397
|
if (skipPermissions) {
|
|
31295
31398
|
p5.log.warn("--skip-permissions is not supported for Cursor");
|
|
31296
31399
|
}
|
|
@@ -31298,6 +31401,7 @@ function runCursorAssistant(args, skipPermissions) {
|
|
|
31298
31401
|
p5.log.info(`To start the assistant, run ${cmd} in Cursor.`);
|
|
31299
31402
|
}
|
|
31300
31403
|
function runCursorUpdate(args, skipPermissions) {
|
|
31404
|
+
ensureCursorAuthenticated();
|
|
31301
31405
|
if (skipPermissions) {
|
|
31302
31406
|
p5.log.warn("--skip-permissions is not supported for Cursor");
|
|
31303
31407
|
}
|