Merge branch 'main' into clear
This commit is contained in:
commit
ee14cabb04
8 changed files with 73 additions and 57 deletions
|
|
@ -39,7 +39,6 @@ export function introMessage(assistant: Assistant, mcpService: MCPService) {
|
|||
console.info(`- ${chalk.green("/exit")}: Exit the chat`);
|
||||
console.info(`- ${chalk.green("/clear")}: Clear the chat history`);
|
||||
console.info(`- ${chalk.green("/help")}: Show help message`);
|
||||
console.info(`- ${chalk.green("/models")}: Show available models`);
|
||||
console.info(`- ${chalk.green("/login")}: Authenticate with your account`);
|
||||
console.info(`- ${chalk.green("/logout")}: Sign out of your current session`);
|
||||
console.info(
|
||||
|
|
|
|||
|
|
@ -28,21 +28,11 @@ export function handleSlashCommands(
|
|||
"/login - Authenticate with your account",
|
||||
"/logout - Sign out of your current session",
|
||||
"/whoami - Check who you're currently logged in as",
|
||||
"/models - List available AI models",
|
||||
...(assistant.prompts?.map(
|
||||
(prompt) => `/${prompt?.name} - ${prompt?.description}`
|
||||
) ?? []),
|
||||
].join("\n");
|
||||
return { output: helpMessage };
|
||||
case "models":
|
||||
return {
|
||||
output: `Available models:\n• ${
|
||||
assistant.models?.map((model) => model?.name)?.join("\n• ") ||
|
||||
"None"
|
||||
}`,
|
||||
};
|
||||
case "clear":
|
||||
return { clear: true, output: "Chat history cleared." };
|
||||
case "exit":
|
||||
return { exit: true, output: "Goodbye!" };
|
||||
case "login":
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ function getGitStatus(): string {
|
|||
const baseSystemMessage = `You are an agent in the Continue CLI. Given the user's prompt, you should use the tools available to you to answer the user's question.
|
||||
|
||||
Notes:
|
||||
1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...".
|
||||
1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface.
|
||||
2. When relevant, share file names and code snippets relevant to the query
|
||||
3. Any file paths you return in your final response MUST be absolute. DO NOT use relative paths.
|
||||
Here is useful information about the environment you are running in:
|
||||
|
|
@ -136,4 +136,4 @@ export function constructSystemMessage(rulesSystemMessage: string): string {
|
|||
}
|
||||
|
||||
return systemMessage;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@ const SlashCommandUI: React.FC<SlashCommandUIProps> = ({
|
|||
description: "Check who you're currently logged in as",
|
||||
category: "system",
|
||||
},
|
||||
{
|
||||
name: "models",
|
||||
description: "List available AI models",
|
||||
category: "system",
|
||||
},
|
||||
];
|
||||
|
||||
const assistantCommands: SlashCommand[] =
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { ContinueClient } from "@continuedev/sdk";
|
||||
import { Box, Text, useApp } from "ink";
|
||||
import { ChatCompletionMessageParam } from "openai/resources.mjs";
|
||||
import path from "path";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { handleSlashCommands } from "../slashCommands.js";
|
||||
import { StreamCallbacks, streamChatResponse } from "../streamChatResponse.js";
|
||||
|
|
@ -123,36 +124,19 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
// Create callbacks to handle streaming updates
|
||||
const streamCallbacks: StreamCallbacks = {
|
||||
onContent: (content: string) => {
|
||||
setMessages((prev) => {
|
||||
const newMessages = [...prev];
|
||||
|
||||
// Find or create current streaming message
|
||||
if (!currentStreamingMessage) {
|
||||
currentStreamingMessage = { role: "assistant", content: "", isStreaming: true };
|
||||
newMessages.push(currentStreamingMessage);
|
||||
}
|
||||
|
||||
// Update the streaming message
|
||||
const streamingIndex = newMessages.indexOf(currentStreamingMessage);
|
||||
if (streamingIndex >= 0) {
|
||||
newMessages[streamingIndex].content += content;
|
||||
}
|
||||
|
||||
return newMessages;
|
||||
});
|
||||
// Buffer content but don't update UI until complete or tool call
|
||||
if (!currentStreamingMessage) {
|
||||
currentStreamingMessage = { role: "assistant", content: "", isStreaming: true };
|
||||
}
|
||||
currentStreamingMessage.content += content;
|
||||
},
|
||||
onContentComplete: (content: string) => {
|
||||
// Finalize the current streaming message
|
||||
// Display the complete message
|
||||
if (currentStreamingMessage) {
|
||||
setMessages((prev) => {
|
||||
const newMessages = [...prev];
|
||||
const streamingIndex = newMessages.indexOf(currentStreamingMessage!);
|
||||
if (streamingIndex >= 0) {
|
||||
newMessages[streamingIndex].isStreaming = false;
|
||||
newMessages[streamingIndex].content = content;
|
||||
}
|
||||
return newMessages;
|
||||
});
|
||||
setMessages((prev) => [
|
||||
...prev,
|
||||
{ role: "assistant", content: content, isStreaming: false }
|
||||
]);
|
||||
currentStreamingMessage = null;
|
||||
}
|
||||
},
|
||||
|
|
@ -163,9 +147,30 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
|
||||
// Get the first parameter value for display
|
||||
const firstValue = Object.values(args)[0];
|
||||
return `${displayName}(${firstValue || ""})`;
|
||||
|
||||
// Convert absolute paths to relative paths from workspace root
|
||||
const formatPath = (value: any) => {
|
||||
if (typeof value === "string" && path.isAbsolute(value)) {
|
||||
const workspaceRoot = process.cwd();
|
||||
const relativePath = path.relative(workspaceRoot, value);
|
||||
return relativePath || value;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
return `${displayName}(${formatPath(firstValue) || ""})`;
|
||||
};
|
||||
|
||||
// Display buffered content when tool starts
|
||||
if (currentStreamingMessage && currentStreamingMessage.content) {
|
||||
const messageContent = currentStreamingMessage.content;
|
||||
setMessages((prev) => [
|
||||
...prev,
|
||||
{ role: "assistant", content: messageContent, isStreaming: false }
|
||||
]);
|
||||
currentStreamingMessage = null;
|
||||
}
|
||||
|
||||
setMessages((prev) => [
|
||||
...prev,
|
||||
{
|
||||
|
|
@ -218,15 +223,12 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
);
|
||||
|
||||
// Finalize any remaining streaming message
|
||||
if (currentStreamingMessage) {
|
||||
setMessages((prev) => {
|
||||
const newMessages = [...prev];
|
||||
const streamingIndex = newMessages.indexOf(currentStreamingMessage!);
|
||||
if (streamingIndex >= 0) {
|
||||
newMessages[streamingIndex].isStreaming = false;
|
||||
}
|
||||
return newMessages;
|
||||
});
|
||||
if (currentStreamingMessage && (currentStreamingMessage as any).content) {
|
||||
const messageContent = (currentStreamingMessage as any).content;
|
||||
setMessages((prev) => [
|
||||
...prev,
|
||||
{ role: "assistant", content: messageContent, isStreaming: false }
|
||||
]);
|
||||
}
|
||||
} catch (error: any) {
|
||||
const errorMessage = `Error: ${error.message}`;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Box, Text } from "ink";
|
||||
import path from "path";
|
||||
import React from "react";
|
||||
import { getToolDisplayName } from "../tools.js";
|
||||
|
||||
|
|
@ -18,6 +19,16 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
|||
const chars = content.length;
|
||||
const displayName = toolName ? getToolDisplayName(toolName) : "Tool";
|
||||
|
||||
// Convert absolute paths to relative paths from workspace root
|
||||
const formatPath = (filePath: string) => {
|
||||
if (path.isAbsolute(filePath)) {
|
||||
const workspaceRoot = process.cwd();
|
||||
const relativePath = path.relative(workspaceRoot, filePath);
|
||||
return relativePath || filePath;
|
||||
}
|
||||
return filePath;
|
||||
};
|
||||
|
||||
// Handle specific tool output formatting
|
||||
switch (toolName) {
|
||||
case "read_file":
|
||||
|
|
@ -25,7 +36,7 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
|||
if (content.includes("→")) {
|
||||
const pathMatch = content.match(/^(.+?):/);
|
||||
const filePath = pathMatch ? pathMatch[1] : "file";
|
||||
return `${displayName} ${filePath} (${lines} lines)`;
|
||||
return `${displayName} ${formatPath(filePath)} (${lines} lines)`;
|
||||
}
|
||||
return `${displayName} tool output (${lines} lines)`;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
name: "whoami",
|
||||
description: "Check who you're currently logged in as",
|
||||
},
|
||||
{ name: "models", description: "List available AI models" },
|
||||
];
|
||||
|
||||
const assistantCommands =
|
||||
|
|
|
|||
20
test-relative-path.js
Normal file
20
test-relative-path.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import path from "path";
|
||||
|
||||
// Test the relative path conversion logic
|
||||
const formatPath = (value) => {
|
||||
if (typeof value === "string" && path.isAbsolute(value)) {
|
||||
const workspaceRoot = process.cwd();
|
||||
const relativePath = path.relative(workspaceRoot, value);
|
||||
return relativePath || value;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
// Test cases
|
||||
console.log("Current working directory:", process.cwd());
|
||||
console.log("Test absolute path:", `/Users/nate/gh/continuedev/wt-no-abs/src/continueSDK.ts`);
|
||||
console.log("Converted to relative:", formatPath(`/Users/nate/gh/continuedev/wt-no-abs/src/continueSDK.ts`));
|
||||
console.log("Test relative path:", `src/continueSDK.ts`);
|
||||
console.log("Remains relative:", formatPath(`src/continueSDK.ts`));
|
||||
console.log("Test root file:", `/Users/nate/gh/continuedev/wt-no-abs/package.json`);
|
||||
console.log("Converted to relative:", formatPath(`/Users/nate/gh/continuedev/wt-no-abs/package.json`));
|
||||
Loading…
Add table
Reference in a new issue