bluekiwi 0.3.20 → 0.3.22
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/commands/init.js +10 -15
- package/dist/index.js +55 -15
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -41,6 +41,7 @@ export async function initCommand(options = {}) {
|
|
|
41
41
|
// Load existing config for pre-filling prompts
|
|
42
42
|
const existingCfg = loadConfig() ?? createEmptyConfig();
|
|
43
43
|
let existingProfile = getProfile(existingCfg, profileName);
|
|
44
|
+
const activeProfile = getProfile(existingCfg, existingCfg.active_profile);
|
|
44
45
|
let server = normalizeEnvValue(options.server) ??
|
|
45
46
|
normalizeEnvValue(process.env.BLUEKIWI_API_URL) ??
|
|
46
47
|
normalizeEnvValue(process.env.BLUEKIWI_SERVER);
|
|
@@ -58,21 +59,23 @@ export async function initCommand(options = {}) {
|
|
|
58
59
|
existingProfile = getProfile(existingCfg, profileName);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
if (!isNonInteractive
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
questions.push({
|
|
62
|
+
if (!isNonInteractive) {
|
|
63
|
+
if (options.server === undefined) {
|
|
64
|
+
const serverAnswer = await prompts({
|
|
65
65
|
type: "text",
|
|
66
66
|
name: "server",
|
|
67
67
|
message: "BlueKiwi server URL",
|
|
68
|
-
initial: existingProfile?.profile.server_url
|
|
68
|
+
initial: existingProfile?.profile.server_url ??
|
|
69
|
+
activeProfile?.profile.server_url ??
|
|
70
|
+
server,
|
|
69
71
|
});
|
|
72
|
+
server = normalizeEnvValue(serverAnswer.server) ?? server;
|
|
70
73
|
}
|
|
71
74
|
if (apiKey === undefined) {
|
|
72
75
|
const maskedKey = existingProfile?.profile.api_key
|
|
73
76
|
? maskApiKey(existingProfile.profile.api_key)
|
|
74
77
|
: undefined;
|
|
75
|
-
|
|
78
|
+
const apiKeyAnswer = await prompts({
|
|
76
79
|
type: "text",
|
|
77
80
|
name: "apiKey",
|
|
78
81
|
message: maskedKey
|
|
@@ -80,15 +83,7 @@ export async function initCommand(options = {}) {
|
|
|
80
83
|
: "API key (bk_...)",
|
|
81
84
|
initial: maskedKey,
|
|
82
85
|
});
|
|
83
|
-
|
|
84
|
-
const answers = await prompts(questions);
|
|
85
|
-
server ??= answers.server;
|
|
86
|
-
// If user kept the masked key (just pressed Enter), restore original
|
|
87
|
-
if (apiKey === undefined) {
|
|
88
|
-
const entered = answers.apiKey;
|
|
89
|
-
const maskedKey = existingProfile?.profile.api_key
|
|
90
|
-
? maskApiKey(existingProfile.profile.api_key)
|
|
91
|
-
: undefined;
|
|
86
|
+
const entered = apiKeyAnswer.apiKey;
|
|
92
87
|
if (entered && maskedKey && entered === maskedKey) {
|
|
93
88
|
apiKey = existingProfile.profile.api_key;
|
|
94
89
|
}
|
package/dist/index.js
CHANGED
|
@@ -24,48 +24,88 @@ const program = new Command();
|
|
|
24
24
|
program
|
|
25
25
|
.name("bluekiwi")
|
|
26
26
|
.description("BlueKiwi CLI — connect your agent runtime to a BlueKiwi server")
|
|
27
|
-
.
|
|
27
|
+
.helpOption("-h, --help", "display help for command")
|
|
28
|
+
.version(pkg.version, "-v, --version", "display version number");
|
|
28
29
|
program
|
|
29
30
|
.command("accept <token>")
|
|
30
|
-
.requiredOption("--server <url>", "BlueKiwi server URL")
|
|
31
|
-
.option("--profile <name>", "Profile name (default: default)")
|
|
32
|
-
.option("--username <name>", "Username (non-interactive)")
|
|
33
|
-
.option("--password <pass>", "Password (non-interactive)")
|
|
31
|
+
.requiredOption("-s, --server <url>", "BlueKiwi server URL")
|
|
32
|
+
.option("-p, --profile <name>", "Profile name (default: default)")
|
|
33
|
+
.option("-u, --username <name>", "Username (non-interactive)")
|
|
34
|
+
.option("-w, --password <pass>", "Password (non-interactive)")
|
|
34
35
|
.action(acceptCommand);
|
|
35
36
|
program
|
|
36
37
|
.command("init")
|
|
37
|
-
.option("--server <url>", "BlueKiwi server URL")
|
|
38
|
-
.option("--api-key <key>", "API key (bk_...)")
|
|
39
|
-
.option("--
|
|
40
|
-
.option("--
|
|
41
|
-
.option("--
|
|
38
|
+
.option("-s, --server <url>", "BlueKiwi server URL")
|
|
39
|
+
.option("-k, --api-key <key>", "API key (bk_...)")
|
|
40
|
+
.option("--apikey <key>", "Alias for --api-key")
|
|
41
|
+
.option("-p, --profile <name>", "Profile name (default: default)")
|
|
42
|
+
.option("-r, --runtime <name>", "Runtime to install into (repeatable, or comma-separated)", collectRuntimes, [])
|
|
43
|
+
.option("-y, --yes", "Suppress all prompts (non-interactive)")
|
|
42
44
|
.action((opts) => initCommand({
|
|
43
45
|
server: opts.server,
|
|
44
|
-
apiKey: opts.apiKey,
|
|
46
|
+
apiKey: opts.apiKey ?? opts.apikey,
|
|
45
47
|
runtimes: opts.runtime?.length ? opts.runtime : undefined,
|
|
46
48
|
profile: opts.profile,
|
|
47
49
|
yes: opts.yes,
|
|
48
50
|
}));
|
|
49
51
|
program
|
|
50
52
|
.command("status")
|
|
51
|
-
.option("--profile <name>", "Profile name (default: active profile)")
|
|
53
|
+
.option("-p, --profile <name>", "Profile name (default: active profile)")
|
|
52
54
|
.action((opts) => statusCommand(opts.profile));
|
|
53
55
|
program.command("upgrade").action(upgradeCommand);
|
|
54
56
|
program
|
|
55
57
|
.command("logout")
|
|
56
|
-
.option("--profile <name>", "Remove only one profile")
|
|
58
|
+
.option("-p, --profile <name>", "Remove only one profile")
|
|
57
59
|
.action((opts) => logoutCommand(opts.profile));
|
|
58
60
|
program.command("runtimes").action(runtimesCommand.list);
|
|
59
61
|
program
|
|
60
62
|
.command("runtimes:add <name>")
|
|
61
|
-
.option("--profile <name>", "Profile to install into runtimes and set active")
|
|
63
|
+
.option("-p, --profile <name>", "Profile to install into runtimes and set active")
|
|
62
64
|
.action((name, opts) => runtimesCommand.add(name, opts.profile));
|
|
63
65
|
program.command("runtimes:remove <name>").action(runtimesCommand.remove);
|
|
64
|
-
program
|
|
66
|
+
program
|
|
67
|
+
.command("profile [action] [name]")
|
|
68
|
+
.description("List, switch, or remove BlueKiwi profiles")
|
|
69
|
+
.action(async (action, name) => {
|
|
70
|
+
if (!action || action === "list") {
|
|
71
|
+
await profileCommand.list();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (action === "use") {
|
|
75
|
+
if (!name) {
|
|
76
|
+
console.error("Usage: bluekiwi profile use <name>");
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
await profileCommand.use(name);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (action === "remove") {
|
|
83
|
+
if (!name) {
|
|
84
|
+
console.error("Usage: bluekiwi profile remove <name>");
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
await profileCommand.remove(name);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.error(`Unknown profile action '${action}'`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
65
93
|
program.command("profile:list").action(profileCommand.list);
|
|
66
94
|
program.command("profile:use <name>").action(profileCommand.use);
|
|
67
95
|
program.command("profile:remove <name>").action(profileCommand.remove);
|
|
68
96
|
program.command("dev-link").action(devLinkCommand);
|
|
97
|
+
program.command("help [command]").action((command) => {
|
|
98
|
+
if (!command) {
|
|
99
|
+
program.outputHelp();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const target = program.commands.find((cmd) => cmd.name() === command || cmd.aliases().includes(command));
|
|
103
|
+
if (!target) {
|
|
104
|
+
console.error(`Unknown command '${command}'`);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
target.outputHelp();
|
|
108
|
+
});
|
|
69
109
|
program.parseAsync(process.argv).catch((err) => {
|
|
70
110
|
console.error(err.message);
|
|
71
111
|
process.exit(1);
|