Merge branch 'main' into dallin/enter-to-continue
This commit is contained in:
commit
475ce490ca
4 changed files with 147 additions and 91 deletions
136
extensions/cli/src/infoScreen.ts
Normal file
136
extensions/cli/src/infoScreen.ts
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
import { execSync } from "child_process";
|
||||
|
||||
import chalk from "chalk";
|
||||
|
||||
import {
|
||||
isAuthenticated,
|
||||
isAuthenticatedConfig,
|
||||
loadAuthConfig,
|
||||
} from "./auth/workos.js";
|
||||
import { services } from "./services/index.js";
|
||||
import { getCurrentSession, getSessionFilePath } from "./session.js";
|
||||
import { posthogService } from "./telemetry/posthogService.js";
|
||||
import { logger } from "./util/logger.js";
|
||||
import { getVersion } from "./version.js";
|
||||
|
||||
export async function handleInfoSlashCommand() {
|
||||
posthogService.capture("useSlashCommand", { name: "info" });
|
||||
|
||||
const infoLines = [];
|
||||
|
||||
// Version and working directory info
|
||||
const version = getVersion();
|
||||
const cwd = process.cwd();
|
||||
|
||||
infoLines.push(
|
||||
chalk.white("CLI Information:"),
|
||||
` Version: ${chalk.green(version)}`,
|
||||
` Working Directory: ${chalk.blue(cwd)}`,
|
||||
);
|
||||
|
||||
// Auth info
|
||||
if (isAuthenticated()) {
|
||||
const config = loadAuthConfig();
|
||||
if (config && isAuthenticatedConfig(config)) {
|
||||
const email = config.userEmail || config.userId;
|
||||
const orgId = config.organizationId;
|
||||
infoLines.push(
|
||||
"",
|
||||
chalk.white("Authentication:"),
|
||||
` Email: ${chalk.green(email)}`,
|
||||
` Org ID: ${chalk.cyan(orgId)}`,
|
||||
);
|
||||
} else {
|
||||
infoLines.push(
|
||||
"",
|
||||
chalk.white("Authentication:"),
|
||||
` ${chalk.yellow("Authenticated via environment variable")}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
infoLines.push(
|
||||
"",
|
||||
chalk.white("Authentication:"),
|
||||
` ${chalk.red("Not logged in")}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Config info
|
||||
try {
|
||||
const configState = services.config.getState();
|
||||
infoLines.push("", chalk.white("Configuration:"));
|
||||
if (configState.config) {
|
||||
infoLines.push(` ${chalk.gray(`Using ${configState.config?.name}`)}`);
|
||||
} else {
|
||||
infoLines.push(` ${chalk.red(`Config not found`)}`);
|
||||
}
|
||||
if (configState.configPath) {
|
||||
infoLines.push(` Path: ${chalk.blue(configState.configPath)}`);
|
||||
}
|
||||
|
||||
// Add current model info
|
||||
try {
|
||||
const modelInfo = services.model?.getModelInfo();
|
||||
if (modelInfo) {
|
||||
infoLines.push(` Model: ${chalk.cyan(modelInfo.name)}`);
|
||||
} else {
|
||||
infoLines.push(` Model: ${chalk.red("Not available")}`);
|
||||
}
|
||||
} catch {
|
||||
infoLines.push(` Model: ${chalk.red("Error retrieving model info")}`);
|
||||
}
|
||||
} catch {
|
||||
infoLines.push(
|
||||
"",
|
||||
chalk.white("Configuration:"),
|
||||
` ${chalk.red("Configuration service not available")}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Session info
|
||||
infoLines.push("", chalk.white("Session:"));
|
||||
try {
|
||||
const currentSession = getCurrentSession();
|
||||
const sessionFilePath = getSessionFilePath();
|
||||
infoLines.push(
|
||||
` Title: ${chalk.green(currentSession.title)}`,
|
||||
` ID: ${chalk.gray(currentSession.sessionId)}`,
|
||||
` File: ${chalk.blue(sessionFilePath)}`,
|
||||
);
|
||||
} catch {
|
||||
infoLines.push(` ${chalk.red("Session not available")}`);
|
||||
}
|
||||
|
||||
// Runtime diagnostic info
|
||||
const nodePath = process.execPath;
|
||||
const invokedPath = process.argv[1];
|
||||
|
||||
// Get npm version
|
||||
let npmVersion = "unknown";
|
||||
try {
|
||||
npmVersion = execSync("npm --version", {
|
||||
encoding: "utf8",
|
||||
timeout: 5000,
|
||||
stdio: ["pipe", "pipe", "ignore"],
|
||||
}).trim();
|
||||
} catch (error) {
|
||||
// If npm command fails, fallback to "unknown"
|
||||
logger.warn("Failed to get npm version:", error);
|
||||
}
|
||||
|
||||
// Diagnostic info
|
||||
infoLines.push(
|
||||
"",
|
||||
chalk.white("Diagnostic Info"),
|
||||
` Currently running: npm-global (${chalk.green(npmVersion)})`,
|
||||
` Path: ${chalk.blue(nodePath)}`,
|
||||
` Invoked: ${chalk.blue(invokedPath)}`,
|
||||
);
|
||||
|
||||
// TODO add global settings like auto update etc.
|
||||
|
||||
return {
|
||||
exit: false,
|
||||
output: infoLines.join("\n"),
|
||||
};
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ describe("slashCommands", () => {
|
|||
expect(result).toBeDefined();
|
||||
expect(result?.output).toContain("Authentication:");
|
||||
expect(result?.output).toContain("test@example.com");
|
||||
expect(result?.output).toContain("(no org)");
|
||||
expect(result?.output).toContain("test-org-id");
|
||||
expect(result?.output).toContain("Configuration:");
|
||||
expect(result?.output).toContain("/custom/config.yaml");
|
||||
expect(result?.exit).toBe(false);
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import {
|
|||
loadAuthConfig,
|
||||
} from "./auth/workos.js";
|
||||
import { getAllSlashCommands } from "./commands/commands.js";
|
||||
import { handleInfoSlashCommand } from "./infoScreen.js";
|
||||
import { reloadService, SERVICE_NAMES, services } from "./services/index.js";
|
||||
import { getCurrentSession, getSessionFilePath } from "./session.js";
|
||||
import { getCurrentSession } from "./session.js";
|
||||
import { posthogService } from "./telemetry/posthogService.js";
|
||||
import { SlashCommandResult } from "./ui/hooks/useChat.types.js";
|
||||
import { getVersion } from "./version.js";
|
||||
|
||||
type CommandHandler = (
|
||||
args: string[],
|
||||
|
|
@ -115,93 +115,6 @@ function handleWhoami() {
|
|||
}
|
||||
}
|
||||
|
||||
async function handleInfo() {
|
||||
posthogService.capture("useSlashCommand", { name: "info" });
|
||||
|
||||
const infoLines = [];
|
||||
|
||||
// Version and working directory info
|
||||
const version = getVersion();
|
||||
const cwd = process.cwd();
|
||||
|
||||
infoLines.push(chalk.white("CLI Information:"));
|
||||
infoLines.push(` Version: ${chalk.green(version)}`);
|
||||
infoLines.push(` Working Directory: ${chalk.blue(cwd)}`);
|
||||
|
||||
// Auth info
|
||||
if (isAuthenticated()) {
|
||||
const config = loadAuthConfig();
|
||||
if (config && isAuthenticatedConfig(config)) {
|
||||
const email = config.userEmail || config.userId;
|
||||
const org = "(no org)"; // Organization info not available in AuthenticatedConfig
|
||||
infoLines.push("");
|
||||
infoLines.push(chalk.white("Authentication:"));
|
||||
infoLines.push(` Email: ${chalk.green(email)}`);
|
||||
infoLines.push(` Organization: ${chalk.cyan(org)}`);
|
||||
} else {
|
||||
infoLines.push("");
|
||||
infoLines.push(chalk.white("Authentication:"));
|
||||
infoLines.push(
|
||||
` ${chalk.yellow("Authenticated via environment variable")}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
infoLines.push("");
|
||||
infoLines.push(chalk.white("Authentication:"));
|
||||
infoLines.push(` ${chalk.red("Not logged in")}`);
|
||||
}
|
||||
|
||||
// Config info
|
||||
try {
|
||||
const configState = services.config.getState();
|
||||
infoLines.push("");
|
||||
infoLines.push(chalk.white("Configuration:"));
|
||||
if (configState.config) {
|
||||
infoLines.push(` ${chalk.gray(`Using ${configState.config?.name}`)}`);
|
||||
} else {
|
||||
infoLines.push(` ${chalk.red(`Config not found`)}`);
|
||||
}
|
||||
if (configState.configPath) {
|
||||
infoLines.push(` Path: ${chalk.blue(configState.configPath)}`);
|
||||
}
|
||||
|
||||
// Add current model info
|
||||
try {
|
||||
const modelInfo = services.model?.getModelInfo();
|
||||
if (modelInfo) {
|
||||
infoLines.push(` Model: ${chalk.cyan(modelInfo.name)}`);
|
||||
} else {
|
||||
infoLines.push(` Model: ${chalk.red("Not available")}`);
|
||||
}
|
||||
} catch {
|
||||
infoLines.push(` Model: ${chalk.red("Error retrieving model info")}`);
|
||||
}
|
||||
} catch {
|
||||
infoLines.push("");
|
||||
infoLines.push(chalk.white("Configuration:"));
|
||||
infoLines.push(` ${chalk.red("Configuration service not available")}`);
|
||||
}
|
||||
|
||||
// Session info
|
||||
infoLines.push("");
|
||||
infoLines.push(chalk.white("Session:"));
|
||||
try {
|
||||
const currentSession = getCurrentSession();
|
||||
infoLines.push(` Title: ${chalk.green(currentSession.title)}`);
|
||||
infoLines.push(` ID: ${chalk.gray(currentSession.sessionId)}`);
|
||||
|
||||
const sessionFilePath = getSessionFilePath();
|
||||
infoLines.push(` File: ${chalk.blue(sessionFilePath)}`);
|
||||
} catch {
|
||||
infoLines.push(` ${chalk.red("Session not available")}`);
|
||||
}
|
||||
|
||||
return {
|
||||
exit: false,
|
||||
output: infoLines.join("\n"),
|
||||
};
|
||||
}
|
||||
|
||||
async function handleFork() {
|
||||
posthogService.capture("useSlashCommand", { name: "fork" });
|
||||
|
||||
|
|
@ -247,7 +160,7 @@ const commandHandlers: Record<string, CommandHandler> = {
|
|||
login: handleLogin,
|
||||
logout: handleLogout,
|
||||
whoami: handleWhoami,
|
||||
info: handleInfo,
|
||||
info: handleInfoSlashCommand,
|
||||
model: () => ({ openModelSelector: true }),
|
||||
compact: () => {
|
||||
posthogService.capture("useSlashCommand", { name: "compact" });
|
||||
|
|
|
|||
|
|
@ -176,6 +176,13 @@ export async function constructSystemMessage(
|
|||
if (currentMode === "plan") {
|
||||
systemMessage +=
|
||||
'\n<context name="planMode">You are operating in _Plan Mode_, which means that your goal is to help the user investigate their ideas and develop a plan before taking action. You only have access to read-only tools and should not attempt to circumvent them to write / delete / create files. For example, it is not acceptable to use the Bash tool to write to files.</context>\n';
|
||||
} else {
|
||||
// TODO - make including this coauthor commit configurable
|
||||
systemMessage += `\n<context name="commitSignature">When creating commits using any CLI or tool, include the following in the commit message:
|
||||
Generated with [Continue](https://continue.dev)
|
||||
|
||||
Co-Authored-By: Continue <noreply@continue.dev>
|
||||
</context>\n`;
|
||||
}
|
||||
|
||||
// In headless mode, add instructions to be concise and only provide final answers
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue