bitfab-cli 0.2.171 → 0.2.173
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 +121 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8816,7 +8816,8 @@ var require_dist = __commonJS({
|
|
|
8816
8816
|
});
|
|
8817
8817
|
|
|
8818
8818
|
// src/index.ts
|
|
8819
|
-
import {
|
|
8819
|
+
import { realpathSync } from "fs";
|
|
8820
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
8820
8821
|
import { cancel as cancel2 } from "@clack/prompts";
|
|
8821
8822
|
|
|
8822
8823
|
// src/init.ts
|
|
@@ -30790,13 +30791,23 @@ function skipFlags(skip, flag) {
|
|
|
30790
30791
|
return skip ? [flag] : [];
|
|
30791
30792
|
}
|
|
30792
30793
|
function runCli(bin, args) {
|
|
30793
|
-
const result =
|
|
30794
|
-
if (result.status !== 0) {
|
|
30794
|
+
const result = runCliResult(bin, args);
|
|
30795
|
+
if (result.status !== 0 || result.error) {
|
|
30796
|
+
const output = result.output.trim();
|
|
30795
30797
|
throw new Error(
|
|
30796
|
-
`${bin} ${args.join(" ")} failed${result.status === null ? "" : ` with status ${result.status}`}`
|
|
30798
|
+
`${bin} ${args.join(" ")} failed${result.status === null ? "" : ` with status ${result.status}`}${output ? `
|
|
30799
|
+
${output}` : ""}`
|
|
30797
30800
|
);
|
|
30798
30801
|
}
|
|
30799
|
-
return
|
|
30802
|
+
return result.output;
|
|
30803
|
+
}
|
|
30804
|
+
function runCliResult(bin, args) {
|
|
30805
|
+
const result = spawnSync(bin, [...args], { stdio: "pipe", ...SHELL_OPTS });
|
|
30806
|
+
return {
|
|
30807
|
+
status: result.status,
|
|
30808
|
+
output: (result.stdout?.toString() ?? "") + (result.stderr?.toString() ?? ""),
|
|
30809
|
+
error: result.error
|
|
30810
|
+
};
|
|
30800
30811
|
}
|
|
30801
30812
|
function launchCli(bin, args) {
|
|
30802
30813
|
spawnSync(bin, [...args], { stdio: "inherit", ...SHELL_OPTS });
|
|
@@ -30835,7 +30846,44 @@ function ensureLatestPlugin(pull) {
|
|
|
30835
30846
|
}
|
|
30836
30847
|
|
|
30837
30848
|
// src/cliEditor.ts
|
|
30849
|
+
function makeCliAuthCheck({
|
|
30850
|
+
cli,
|
|
30851
|
+
args,
|
|
30852
|
+
label,
|
|
30853
|
+
loginCommand,
|
|
30854
|
+
parseAuthenticated
|
|
30855
|
+
}) {
|
|
30856
|
+
return () => {
|
|
30857
|
+
const result = runCliResult(cli, args);
|
|
30858
|
+
if (result.error) {
|
|
30859
|
+
return {
|
|
30860
|
+
ok: false,
|
|
30861
|
+
message: `Failed to run ${cli}: ${result.error.message}`
|
|
30862
|
+
};
|
|
30863
|
+
}
|
|
30864
|
+
if (result.status === 0 && parseAuthenticated(result.output)) {
|
|
30865
|
+
return { ok: true };
|
|
30866
|
+
}
|
|
30867
|
+
const output = result.output.trim();
|
|
30868
|
+
return {
|
|
30869
|
+
ok: false,
|
|
30870
|
+
message: [
|
|
30871
|
+
`${label} is not logged in. Run \`${loginCommand}\` and try again before launching the Bitfab agent.`,
|
|
30872
|
+
output ? `
|
|
30873
|
+
${label} said:
|
|
30874
|
+
${output}` : ""
|
|
30875
|
+
].join("")
|
|
30876
|
+
};
|
|
30877
|
+
};
|
|
30878
|
+
}
|
|
30879
|
+
function ensureCliAuthenticated(cfg) {
|
|
30880
|
+
const result = cfg.authCheck?.();
|
|
30881
|
+
if (result?.ok === false) {
|
|
30882
|
+
throw new Error(result.message);
|
|
30883
|
+
}
|
|
30884
|
+
}
|
|
30838
30885
|
function cliSetup(cfg, skipPermissions) {
|
|
30886
|
+
ensureCliAuthenticated(cfg);
|
|
30839
30887
|
p2.log.info(`Launching ${cfg.setupCommand}...
|
|
30840
30888
|
`);
|
|
30841
30889
|
launchCli(cfg.cli, [
|
|
@@ -30844,6 +30892,7 @@ function cliSetup(cfg, skipPermissions) {
|
|
|
30844
30892
|
]);
|
|
30845
30893
|
}
|
|
30846
30894
|
function cliAssistant(cfg, args, skipPermissions) {
|
|
30895
|
+
ensureCliAuthenticated(cfg);
|
|
30847
30896
|
const cmd = [cfg.assistantCommand, ...args].join(" ");
|
|
30848
30897
|
p2.log.info(`Launching ${cmd}...
|
|
30849
30898
|
`);
|
|
@@ -30868,6 +30917,7 @@ function cliUpdate(cfg, args, skipPermissions) {
|
|
|
30868
30917
|
s.stop(formatPluginRefreshResult(out));
|
|
30869
30918
|
}
|
|
30870
30919
|
if (mode === "sdk" || mode === "all") {
|
|
30920
|
+
ensureCliAuthenticated(cfg);
|
|
30871
30921
|
p2.log.info(`Launching ${cfg.updateCommand} sdk...
|
|
30872
30922
|
`);
|
|
30873
30923
|
launchCli(cfg.cli, [
|
|
@@ -30888,6 +30938,21 @@ var SETUP_COMMAND = "/bitfab:setup";
|
|
|
30888
30938
|
var ANALYZE_REPO_COMMAND = "/bitfab:setup analyze-repo";
|
|
30889
30939
|
var ASSISTANT_COMMAND = "/bitfab:assistant";
|
|
30890
30940
|
var UPDATE_COMMAND = "/bitfab:update";
|
|
30941
|
+
function isClaudeAuthStatusLoggedIn(output) {
|
|
30942
|
+
try {
|
|
30943
|
+
const status = JSON.parse(output);
|
|
30944
|
+
return status.loggedIn === true;
|
|
30945
|
+
} catch {
|
|
30946
|
+
return false;
|
|
30947
|
+
}
|
|
30948
|
+
}
|
|
30949
|
+
var checkClaudeAuth = makeCliAuthCheck({
|
|
30950
|
+
cli: CLI,
|
|
30951
|
+
args: ["auth", "status"],
|
|
30952
|
+
label: "Claude Code",
|
|
30953
|
+
loginCommand: "claude auth login",
|
|
30954
|
+
parseAuthenticated: isClaudeAuthStatusLoggedIn
|
|
30955
|
+
});
|
|
30891
30956
|
function runClaudeInstall() {
|
|
30892
30957
|
const s = p3.spinner();
|
|
30893
30958
|
s.start("Adding bitfab marketplace");
|
|
@@ -30928,6 +30993,10 @@ function ensureLatestClaudePlugin() {
|
|
|
30928
30993
|
ensureLatestPlugin(pullLatestClaudePlugin);
|
|
30929
30994
|
}
|
|
30930
30995
|
async function runClaudeAnalyzeRepo(captureOverride, limit) {
|
|
30996
|
+
const auth = checkClaudeAuth();
|
|
30997
|
+
if (!auth.ok) {
|
|
30998
|
+
throw new Error(auth.message);
|
|
30999
|
+
}
|
|
30931
31000
|
const logPath = analyzeRepoLogPath();
|
|
30932
31001
|
const env = { ...process.env };
|
|
30933
31002
|
if (captureOverride !== void 0) {
|
|
@@ -31128,6 +31197,7 @@ var config2 = {
|
|
|
31128
31197
|
setupCommand: SETUP_COMMAND,
|
|
31129
31198
|
assistantCommand: ASSISTANT_COMMAND,
|
|
31130
31199
|
updateCommand: UPDATE_COMMAND,
|
|
31200
|
+
authCheck: checkClaudeAuth,
|
|
31131
31201
|
pullLatest: pullLatestClaudePlugin
|
|
31132
31202
|
};
|
|
31133
31203
|
var claudeAdapter = {
|
|
@@ -31153,6 +31223,16 @@ var PLUGIN_KEY2 = "bitfab@bitfab";
|
|
|
31153
31223
|
var SETUP_COMMAND2 = "$bitfab:setup";
|
|
31154
31224
|
var ASSISTANT_COMMAND2 = "$bitfab:assistant";
|
|
31155
31225
|
var UPDATE_COMMAND2 = "$bitfab:update";
|
|
31226
|
+
function isCodexLoginStatusLoggedIn(output) {
|
|
31227
|
+
return /logged in/i.test(output) && !/not logged in/i.test(output);
|
|
31228
|
+
}
|
|
31229
|
+
var checkCodexAuth = makeCliAuthCheck({
|
|
31230
|
+
cli: CLI2,
|
|
31231
|
+
args: ["login", "status"],
|
|
31232
|
+
label: "Codex",
|
|
31233
|
+
loginCommand: "codex login",
|
|
31234
|
+
parseAuthenticated: isCodexLoginStatusLoggedIn
|
|
31235
|
+
});
|
|
31156
31236
|
function pullLatestCodexPlugin() {
|
|
31157
31237
|
return runCli(CLI2, ["plugin", "marketplace", "upgrade", MARKETPLACE2]);
|
|
31158
31238
|
}
|
|
@@ -31230,6 +31310,7 @@ var config3 = {
|
|
|
31230
31310
|
setupCommand: SETUP_COMMAND2,
|
|
31231
31311
|
assistantCommand: ASSISTANT_COMMAND2,
|
|
31232
31312
|
updateCommand: UPDATE_COMMAND2,
|
|
31313
|
+
authCheck: checkCodexAuth,
|
|
31233
31314
|
pullLatest: pullLatestCodexPlugin
|
|
31234
31315
|
};
|
|
31235
31316
|
var codexAdapter = {
|
|
@@ -31251,6 +31332,27 @@ var ADD_PLUGIN_CMD = `/add-plugin ${REPO3}`;
|
|
|
31251
31332
|
var SETUP_COMMAND3 = "/bitfab-setup";
|
|
31252
31333
|
var ASSISTANT_COMMAND3 = "/bitfab-assistant";
|
|
31253
31334
|
var UPDATE_COMMAND3 = "/bitfab-update";
|
|
31335
|
+
function isCursorAgentStatusAuthenticated(output) {
|
|
31336
|
+
try {
|
|
31337
|
+
const status = JSON.parse(output);
|
|
31338
|
+
return status.isAuthenticated === true || status.status === "authenticated";
|
|
31339
|
+
} catch {
|
|
31340
|
+
return false;
|
|
31341
|
+
}
|
|
31342
|
+
}
|
|
31343
|
+
var checkCursorAuth = makeCliAuthCheck({
|
|
31344
|
+
cli: "cursor",
|
|
31345
|
+
args: ["agent", "status", "--format", "json"],
|
|
31346
|
+
label: "Cursor Agent",
|
|
31347
|
+
loginCommand: "cursor agent login",
|
|
31348
|
+
parseAuthenticated: isCursorAgentStatusAuthenticated
|
|
31349
|
+
});
|
|
31350
|
+
function ensureCursorAuthenticated() {
|
|
31351
|
+
const result = checkCursorAuth();
|
|
31352
|
+
if (result.ok === false) {
|
|
31353
|
+
throw new Error(result.message);
|
|
31354
|
+
}
|
|
31355
|
+
}
|
|
31254
31356
|
function runCursorInstall() {
|
|
31255
31357
|
const copied = copyToClipboard(ADD_PLUGIN_CMD);
|
|
31256
31358
|
if (copied) {
|
|
@@ -31279,6 +31381,7 @@ function runCursorInstall() {
|
|
|
31279
31381
|
function ensureLatestCursorPlugin() {
|
|
31280
31382
|
}
|
|
31281
31383
|
function runCursorSetup(skipPermissions) {
|
|
31384
|
+
ensureCursorAuthenticated();
|
|
31282
31385
|
if (skipPermissions) {
|
|
31283
31386
|
p5.log.warn("--skip-permissions is not supported for Cursor");
|
|
31284
31387
|
}
|
|
@@ -31291,6 +31394,7 @@ function runCursorAnalyzeRepo() {
|
|
|
31291
31394
|
p5.log.info(`To run it in Cursor, run ${SETUP_COMMAND3} analyze-repo manually.`);
|
|
31292
31395
|
}
|
|
31293
31396
|
function runCursorAssistant(args, skipPermissions) {
|
|
31397
|
+
ensureCursorAuthenticated();
|
|
31294
31398
|
if (skipPermissions) {
|
|
31295
31399
|
p5.log.warn("--skip-permissions is not supported for Cursor");
|
|
31296
31400
|
}
|
|
@@ -31298,6 +31402,7 @@ function runCursorAssistant(args, skipPermissions) {
|
|
|
31298
31402
|
p5.log.info(`To start the assistant, run ${cmd} in Cursor.`);
|
|
31299
31403
|
}
|
|
31300
31404
|
function runCursorUpdate(args, skipPermissions) {
|
|
31405
|
+
ensureCursorAuthenticated();
|
|
31301
31406
|
if (skipPermissions) {
|
|
31302
31407
|
p5.log.warn("--skip-permissions is not supported for Cursor");
|
|
31303
31408
|
}
|
|
@@ -31987,11 +32092,17 @@ ${GLOBAL_HELP_TEXT}`);
|
|
|
31987
32092
|
abortUpdateCheck();
|
|
31988
32093
|
process.exit(1);
|
|
31989
32094
|
}
|
|
31990
|
-
function
|
|
31991
|
-
|
|
31992
|
-
|
|
32095
|
+
function isEntrypoint(entrypoint, moduleUrl) {
|
|
32096
|
+
if (entrypoint === void 0) {
|
|
32097
|
+
return false;
|
|
32098
|
+
}
|
|
32099
|
+
try {
|
|
32100
|
+
return realpathSync(entrypoint) === realpathSync(fileURLToPath5(moduleUrl));
|
|
32101
|
+
} catch {
|
|
32102
|
+
return false;
|
|
32103
|
+
}
|
|
31993
32104
|
}
|
|
31994
|
-
if (
|
|
32105
|
+
if (isEntrypoint(process.argv[1], import.meta.url)) {
|
|
31995
32106
|
main().catch((err) => {
|
|
31996
32107
|
const message = err instanceof Error ? err.message : String(err);
|
|
31997
32108
|
cancel2(message);
|
|
@@ -32001,6 +32112,7 @@ if (isDirectRun()) {
|
|
|
32001
32112
|
export {
|
|
32002
32113
|
getHelpText,
|
|
32003
32114
|
getHelpTopic,
|
|
32115
|
+
isEntrypoint,
|
|
32004
32116
|
parseArgs2 as parseArgs,
|
|
32005
32117
|
wantsHelp
|
|
32006
32118
|
};
|