Skip to content

Commit a1d34a3

Browse files
committed
feat: ✨ CLI: Add aws credentials onboarding
1 parent 4b7af07 commit a1d34a3

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

extensions/cli/spec/onboarding.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ When a user first runs `cn` in interactive mode, they will be taken through "onb
77
**The onboarding flow runs when the user hasn't completed onboarding before, regardless of whether they have a valid config.yaml file.**
88

99
1. If the --config flag is provided, load this config
10-
2. Otherwise, we will present the user with two options:
11-
10+
2. Otherwise, check if AWS credentials are available through the standard AWS credential chain
11+
3. Present the user with available options:
1212
- Log in with Continue: log them in, which will automatically create their assistant and then we can load the first assistant from the first org
1313
- Enter your Anthropic API key: let them enter the key, and then either create a ~/.continue/config.yaml with the following contents OR update the existing config.yaml to add the model
14+
- Use AWS credentials: (only shown if AWS credentials are available) automatically create a config using AWS Bedrock Claude and skip further onboarding
1415

1516
```yaml
1617
name: Local Config
@@ -23,6 +24,19 @@ When a user first runs `cn` in interactive mode, they will be taken through "onb
2324
ANTHROPIC_API_KEY: <THEIR_ANTHROPIC_API_KEY>
2425
```
2526
27+
For the AWS option, it will create/update the config with:
28+
29+
```yaml
30+
name: Local Config
31+
version: 1.0.0
32+
schema: v1
33+
34+
models:
35+
- uses: bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0
36+
with:
37+
region: us-east-1
38+
```
39+
2640
When something in the onboarding flow is done automatically, we should tell the user what happened.
2741
2842
## Normal flow

extensions/cli/src/onboarding.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import {
1616
getApiKeyValidationError,
1717
isValidAnthropicApiKey,
1818
} from "./util/apiKeyValidation.js";
19-
import { updateAnthropicModelInYaml } from "./util/yamlConfigUpdater.js";
19+
import {
20+
updateAnthropicModelInYaml,
21+
} from "./util/yamlConfigUpdater.js";
2022

2123
const CONFIG_PATH = path.join(env.continueHome, "config.yaml");
2224

@@ -92,14 +94,18 @@ async function runOnboardingFlow(
9294
return { ...result, wasOnboarded: false };
9395
}
9496

95-
// Step 3: Present user with two options
97+
// Step 3: Present user with three options
9698
console.log(chalk.yellow("How do you want to get started?"));
9799
console.log(chalk.white("1. ⏩ Log in with Continue"));
98100
console.log(chalk.white("2. 🔑 Enter your Anthropic API key"));
101+
console.log(chalk.white("3. ☁️ Use AWS credentials"));
99102

103+
const validChoices = ["1", "2", "3", ""];
100104
const choice = readlineSync.question(chalk.yellow("\nEnter choice (1): "), {
101-
limit: ["1", "2", ""],
102-
limitMessage: chalk.dim("Please enter 1 or 2"),
105+
limit: validChoices,
106+
limitMessage: chalk.dim(
107+
"Please enter 1, 2, or 3",
108+
),
103109
});
104110

105111
if (choice === "1" || choice === "") {
@@ -124,10 +130,17 @@ async function runOnboardingFlow(
124130
chalk.green(`✓ Config file updated successfully at ${CONFIG_PATH}`),
125131
);
126132

133+
const result = await initialize(authConfig, CONFIG_PATH);
134+
return { ...result, wasOnboarded: true };
135+
} else if (choice === "3") {
136+
console.log(chalk.blue("✓ Using AWS credentials"));
137+
127138
const result = await initialize(authConfig, CONFIG_PATH);
128139
return { ...result, wasOnboarded: true };
129140
} else {
130-
throw new Error("Invalid choice. Please select 1 or 2.");
141+
throw new Error(
142+
`Invalid choice. Please select "1, 2, or 3"`,
143+
);
131144
}
132145
}
133146

0 commit comments

Comments
 (0)