-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavigation.ts
More file actions
136 lines (125 loc) · 4.65 KB
/
Copy pathnavigation.ts
File metadata and controls
136 lines (125 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { TerminalSession } from './terminal/index.js';
import { simulateAuthCallback } from './utils.js';
/**
* Advances the wizard past the Welcome and SystemCheck screens.
*
* Waits for the welcome CTA, presses Enter, then waits for the system
* check to pass. The session is left at the Authenticate screen.
*
* @param session - An active terminal session showing the Welcome screen.
*/
export async function navigatePastWelcome(session: TerminalSession): Promise<void> {
await session.waitForText('Start setup');
await session.press('Enter');
await session.waitForText('All checks passed');
}
/**
* Completes the full authentication flow via browser-simulated OAuth.
*
* Initiates sign-in, triggers {@link simulateAuthCallback}, and waits
* for the "Authenticated" confirmation. The session is left at the
* InstallPlugins screen.
*
* @param session - An active terminal session showing the Authenticate screen.
*/
export async function navigatePastAuth(session: TerminalSession): Promise<void> {
await session.waitForText('Sign in to Confidence');
await session.waitForText('Sign in to a Confidence account');
await session.press('Enter');
await session.waitForText('Waiting for browser');
await simulateAuthCallback();
await session.waitForText('Authenticated');
}
/**
* Navigates from the start through Welcome, SystemCheck, and Auth,
* landing on the InstallPlugins screen with a fresh checkpoint.
*
* @param session - An active terminal session at the Welcome screen.
*/
export async function navigateToPlugins(session: TerminalSession): Promise<void> {
await navigatePastWelcome(session);
await navigatePastAuth(session);
session.checkpoint();
await session.waitForText('Which CLI agent would you like to use?');
}
/**
* Navigates from the start through to the ConnectTools screen,
* selecting the default (first) IDE plugin and setting a checkpoint.
*
* @param session - An active terminal session at the Welcome screen.
*/
export async function navigateToConnectTools(session: TerminalSession): Promise<void> {
await navigateToPlugins(session);
session.checkpoint();
await session.press('Enter');
await session.waitForText('Plugin installed successfully');
await session.waitForText('Teach your AI Confidence');
}
/**
* Navigates from the start through to the SelectGoal screen,
* accepting default tools connection and setting a checkpoint.
*
* @param session - An active terminal session at the Welcome screen.
*/
export async function navigateToGoalSelection(session: TerminalSession): Promise<void> {
await navigateToConnectTools(session);
session.checkpoint();
await session.press('Enter');
await session.waitForText("Select the features you'd like to set up");
}
/**
* Navigates from the start through to the OnboardProject screen,
* selecting "Feature Flags" as the goal and setting a checkpoint.
*
* @param session - An active terminal session at the Welcome screen.
*/
export async function navigateToOnboarding(session: TerminalSession): Promise<void> {
await navigateToGoalSelection(session);
session.checkpoint();
await session.press('Space');
await session.press('Enter');
await session.waitForText('Start onboarding?');
}
/**
* Selects an IDE from the InstallPlugins list and runs through the
* remaining wizard screens (ConnectTools + OnboardProject) until
* onboarding completes.
*
* Handles the case where ConnectTools may auto-advance when MCP
* servers are already registered globally.
*
* @param session - An active terminal session at the InstallPlugins screen.
* @param downPresses - How many times to press ArrowDown to reach the
* desired IDE option (0 = first item, 1 = second, etc.).
*
* @example
* ```ts
* await navigateToPlugins(session);
* await selectIdeAndOnboard(session, 1); // select Cursor (2nd item)
* ```
*/
export async function selectIdeAndOnboard(
session: TerminalSession,
downPresses: number,
): Promise<void> {
await session.pressRepeat('ArrowDown', downPresses);
await session.press('Enter');
const matched = await session.waitForText([
'Start onboarding?',
'Connect Confidence tools?',
"Select the features you'd like to set up",
]);
if (matched === 'Connect Confidence tools?') {
await session.press('Enter');
await session.waitForText('Connected successfully');
await session.waitForText("Select the features you'd like to set up");
}
if (matched !== 'Start onboarding?') {
// SelectGoal — toggle Feature Flags and submit
await session.press('Space');
await session.press('Enter');
await session.waitForText('Start onboarding?');
}
await session.press('Enter');
await session.waitForText('onboarding complete');
}