Elffuss BraidHub

kikocis/continue public

Merge pull request #7621 from continuedev/dallin/con-3089-info-diagnostics

feat: CLI: add diagnostics to /info screen
Changesetd84bb2249dcdb2b7da61131dee08a59f5a14f9c4ad0c884214c0acdd51ae2020
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-09-08 21:11 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-08 21:11 -07:00
Parentsbc0caa2e953a, c6df8e8aeb09

Browse the files at this changeset

3 files changed

added extensions/cli/src/infoScreen.ts +136 −0
@@ -0,0 +1,136 @@
1+import { execSync } from "child_process";
2+
3+import chalk from "chalk";
4+
5+import {
6+ isAuthenticated,
7+ isAuthenticatedConfig,
8+ loadAuthConfig,
9+} from "./auth/workos.js";
10+import { services } from "./services/index.js";
11+import { getCurrentSession, getSessionFilePath } from "./session.js";
12+import { posthogService } from "./telemetry/posthogService.js";
13+import { logger } from "./util/logger.js";
14+import { getVersion } from "./version.js";
15+
16+export async function handleInfoSlashCommand() {
17+ posthogService.capture("useSlashCommand", { name: "info" });
18+
19+ const infoLines = [];
20+
21+ // Version and working directory info
22+ const version = getVersion();
23+ const cwd = process.cwd();
24+
25+ infoLines.push(
26+ chalk.white("CLI Information:"),
27+ ` Version: ${chalk.green(version)}`,
28+ ` Working Directory: ${chalk.blue(cwd)}`,
29+ );
30+
31+ // Auth info
32+ if (isAuthenticated()) {
33+ const config = loadAuthConfig();
34+ if (config && isAuthenticatedConfig(config)) {
35+ const email = config.userEmail || config.userId;
36+ const orgId = config.organizationId;
37+ infoLines.push(
38+ "",
39+ chalk.white("Authentication:"),
40+ ` Email: ${chalk.green(email)}`,
41+ ` Org ID: ${chalk.cyan(orgId)}`,
42+ );
43+ } else {
44+ infoLines.push(
45+ "",
46+ chalk.white("Authentication:"),
47+ ` ${chalk.yellow("Authenticated via environment variable")}`,
48+ );
49+ }
50+ } else {
51+ infoLines.push(
52+ "",
53+ chalk.white("Authentication:"),
54+ ` ${chalk.red("Not logged in")}`,
55+ );
56+ }
57+
58+ // Config info
59+ try {
60+ const configState = services.config.getState();
61+ infoLines.push("", chalk.white("Configuration:"));
62+ if (configState.config) {
63+ infoLines.push(` ${chalk.gray(`Using ${configState.config?.name}`)}`);
64+ } else {
65+ infoLines.push(` ${chalk.red(`Config not found`)}`);
66+ }
67+ if (configState.configPath) {
68+ infoLines.push(` Path: ${chalk.blue(configState.configPath)}`);
69+ }
70+
71+ // Add current model info
72+ try {
73+ const modelInfo = services.model?.getModelInfo();
74+ if (modelInfo) {
75+ infoLines.push(` Model: ${chalk.cyan(modelInfo.name)}`);
76+ } else {
77+ infoLines.push(` Model: ${chalk.red("Not available")}`);
78+ }
79+ } catch {
80+ infoLines.push(` Model: ${chalk.red("Error retrieving model info")}`);
81+ }
82+ } catch {
83+ infoLines.push(
84+ "",
85+ chalk.white("Configuration:"),
86+ ` ${chalk.red("Configuration service not available")}`,
87+ );
88+ }
89+
90+ // Session info
91+ infoLines.push("", chalk.white("Session:"));
92+ try {
93+ const currentSession = getCurrentSession();
94+ const sessionFilePath = getSessionFilePath();
95+ infoLines.push(
96+ ` Title: ${chalk.green(currentSession.title)}`,
97+ ` ID: ${chalk.gray(currentSession.sessionId)}`,
98+ ` File: ${chalk.blue(sessionFilePath)}`,
99+ );
100+ } catch {
101+ infoLines.push(` ${chalk.red("Session not available")}`);
102+ }
103+
104+ // Runtime diagnostic info
105+ const nodePath = process.execPath;
106+ const invokedPath = process.argv[1];
107+
108+ // Get npm version
109+ let npmVersion = "unknown";
110+ try {
111+ npmVersion = execSync("npm --version", {
112+ encoding: "utf8",
113+ timeout: 5000,
114+ stdio: ["pipe", "pipe", "ignore"],
115+ }).trim();
116+ } catch (error) {
117+ // If npm command fails, fallback to "unknown"
118+ logger.warn("Failed to get npm version:", error);
119+ }
120+
121+ // Diagnostic info
122+ infoLines.push(
123+ "",
124+ chalk.white("Diagnostic Info"),
125+ ` Currently running: npm-global (${chalk.green(npmVersion)})`,
126+ ` Path: ${chalk.blue(nodePath)}`,
127+ ` Invoked: ${chalk.blue(invokedPath)}`,
128+ );
129+
130+ // TODO add global settings like auto update etc.
131+
132+ return {
133+ exit: false,
134+ output: infoLines.join("\n"),
135+ };
136+}
modified extensions/cli/src/slashCommands.test.ts +1 −1
@@ -217,7 +217,7 @@
217217 expect(result).toBeDefined();
218218 expect(result?.output).toContain("Authentication:");
219219 expect(result?.output).toContain("test@example.com");
220- expect(result?.output).toContain("(no org)");
220+ expect(result?.output).toContain("test-org-id");
221221 expect(result?.output).toContain("Configuration:");
222222 expect(result?.output).toContain("/custom/config.yaml");
223223 expect(result?.exit).toBe(false);
modified extensions/cli/src/slashCommands.ts +3 −90
@@ -7,11 +7,11 @@
77 loadAuthConfig,
88 } from "./auth/workos.js";
99 import { getAllSlashCommands } from "./commands/commands.js";
10+import { handleInfoSlashCommand } from "./infoScreen.js";
1011 import { reloadService, SERVICE_NAMES, services } from "./services/index.js";
11-import { getCurrentSession, getSessionFilePath } from "./session.js";
12+import { getCurrentSession } from "./session.js";
1213 import { posthogService } from "./telemetry/posthogService.js";
1314 import { SlashCommandResult } from "./ui/hooks/useChat.types.js";
14-import { getVersion } from "./version.js";
1515
1616 type CommandHandler = (
1717 args: string[],
@@ -115,93 +115,6 @@
115115 }
116116 }
117117
118-async function handleInfo() {
119- posthogService.capture("useSlashCommand", { name: "info" });
120-
121- const infoLines = [];
122-
123- // Version and working directory info
124- const version = getVersion();
125- const cwd = process.cwd();
126-
127- infoLines.push(chalk.white("CLI Information:"));
128- infoLines.push(` Version: ${chalk.green(version)}`);
129- infoLines.push(` Working Directory: ${chalk.blue(cwd)}`);
130-
131- // Auth info
132- if (isAuthenticated()) {
133- const config = loadAuthConfig();
134- if (config && isAuthenticatedConfig(config)) {
135- const email = config.userEmail || config.userId;
136- const org = "(no org)"; // Organization info not available in AuthenticatedConfig
137- infoLines.push("");
138- infoLines.push(chalk.white("Authentication:"));
139- infoLines.push(` Email: ${chalk.green(email)}`);
140- infoLines.push(` Organization: ${chalk.cyan(org)}`);
141- } else {
142- infoLines.push("");
143- infoLines.push(chalk.white("Authentication:"));
144- infoLines.push(
145- ` ${chalk.yellow("Authenticated via environment variable")}`,
146- );
147- }
148- } else {
149- infoLines.push("");
150- infoLines.push(chalk.white("Authentication:"));
151- infoLines.push(` ${chalk.red("Not logged in")}`);
152- }
153-
154- // Config info
155- try {
156- const configState = services.config.getState();
157- infoLines.push("");
158- infoLines.push(chalk.white("Configuration:"));
159- if (configState.config) {
160- infoLines.push(` ${chalk.gray(`Using ${configState.config?.name}`)}`);
161- } else {
162- infoLines.push(` ${chalk.red(`Config not found`)}`);
163- }
164- if (configState.configPath) {
165- infoLines.push(` Path: ${chalk.blue(configState.configPath)}`);
166- }
167-
168- // Add current model info
169- try {
170- const modelInfo = services.model?.getModelInfo();
171- if (modelInfo) {
172- infoLines.push(` Model: ${chalk.cyan(modelInfo.name)}`);
173- } else {
174- infoLines.push(` Model: ${chalk.red("Not available")}`);
175- }
176- } catch {
177- infoLines.push(` Model: ${chalk.red("Error retrieving model info")}`);
178- }
179- } catch {
180- infoLines.push("");
181- infoLines.push(chalk.white("Configuration:"));
182- infoLines.push(` ${chalk.red("Configuration service not available")}`);
183- }
184-
185- // Session info
186- infoLines.push("");
187- infoLines.push(chalk.white("Session:"));
188- try {
189- const currentSession = getCurrentSession();
190- infoLines.push(` Title: ${chalk.green(currentSession.title)}`);
191- infoLines.push(` ID: ${chalk.gray(currentSession.sessionId)}`);
192-
193- const sessionFilePath = getSessionFilePath();
194- infoLines.push(` File: ${chalk.blue(sessionFilePath)}`);
195- } catch {
196- infoLines.push(` ${chalk.red("Session not available")}`);
197- }
198-
199- return {
200- exit: false,
201- output: infoLines.join("\n"),
202- };
203-}
204-
205118 async function handleFork() {
206119 posthogService.capture("useSlashCommand", { name: "fork" });
207120
@@ -247,7 +160,7 @@
247160 login: handleLogin,
248161 logout: handleLogout,
249162 whoami: handleWhoami,
250- info: handleInfo,
163+ info: handleInfoSlashCommand,
251164 model: () => ({ openModelSelector: true }),
252165 compact: () => {
253166 posthogService.capture("useSlashCommand", { name: "compact" });