|
|
@@ -8,6 +8,7 @@ import pWaitFor from "p-wait-for"
|
|
|
import * as path from "path"
|
|
|
import * as vscode from "vscode"
|
|
|
|
|
|
+import { changeLanguage, t } from "../../i18n"
|
|
|
import { setPanel } from "../../activate/registerCommands"
|
|
|
import { ApiConfiguration, ApiProvider, ModelInfo, API_CONFIG_KEYS } from "../../shared/api"
|
|
|
import { findLast } from "../../shared/array"
|
|
|
@@ -137,7 +138,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
const state = await this.getState()
|
|
|
|
|
|
if (!state || typeof state.mode !== "string") {
|
|
|
- throw new Error("Error failed to retrieve current mode from state.")
|
|
|
+ throw new Error(t("common:errors.retrieve_current_mode"))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -564,9 +565,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
try {
|
|
|
await axios.get(`http://${localServerUrl}`)
|
|
|
} catch (error) {
|
|
|
- vscode.window.showErrorMessage(
|
|
|
- "Local development server is not running, HMR will not work. Please run 'npm run dev' before launching the extension to enable HMR.",
|
|
|
- )
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.hmr_not_running"))
|
|
|
|
|
|
return this.getHtmlContent(webview)
|
|
|
}
|
|
|
@@ -976,7 +975,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
break
|
|
|
case "clearTask":
|
|
|
// clear task resets the current session and allows for a new task to be started, if this session is a subtask - it allows the parent task to be resumed
|
|
|
- await this.finishSubTask(`Task error: It was stopped and canceled by the user.`)
|
|
|
+ await this.finishSubTask(t("common:tasks.canceled"))
|
|
|
await this.postStateToWebview()
|
|
|
break
|
|
|
case "didShowAnnouncement":
|
|
|
@@ -1153,13 +1152,13 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
try {
|
|
|
await pWaitFor(() => this.getCurrentCline()?.isInitialized === true, { timeout: 3_000 })
|
|
|
} catch (error) {
|
|
|
- vscode.window.showErrorMessage("Timed out when attempting to restore checkpoint.")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.checkpoint_timeout"))
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
await this.getCurrentCline()?.checkpointRestore(result.data)
|
|
|
} catch (error) {
|
|
|
- vscode.window.showErrorMessage("Failed to restore checkpoint.")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.checkpoint_failed"))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1184,7 +1183,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
}
|
|
|
case "openProjectMcpSettings": {
|
|
|
if (!vscode.workspace.workspaceFolders?.length) {
|
|
|
- vscode.window.showErrorMessage("Please open a project folder first")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.no_workspace"))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -1200,7 +1199,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
}
|
|
|
await openFile(mcpPath)
|
|
|
} catch (error) {
|
|
|
- vscode.window.showErrorMessage(`Failed to create or open .roo/mcp.json: ${error}`)
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.create_mcp_json", { error }))
|
|
|
}
|
|
|
break
|
|
|
}
|
|
|
@@ -1478,7 +1477,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error update support prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to update support prompt")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.update_support_prompt"))
|
|
|
}
|
|
|
break
|
|
|
case "resetSupportPrompt":
|
|
|
@@ -1502,7 +1501,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error reset support prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to reset support prompt")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.reset_support_prompt"))
|
|
|
}
|
|
|
break
|
|
|
case "updatePrompt":
|
|
|
@@ -1533,13 +1532,14 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
break
|
|
|
case "deleteMessage": {
|
|
|
const answer = await vscode.window.showInformationMessage(
|
|
|
- "What would you like to delete?",
|
|
|
+ t("common:confirmation.delete_message"),
|
|
|
{ modal: true },
|
|
|
- "Just this message",
|
|
|
- "This and all subsequent messages",
|
|
|
+ t("common:confirmation.just_this_message"),
|
|
|
+ t("common:confirmation.this_and_subsequent"),
|
|
|
)
|
|
|
if (
|
|
|
- (answer === "Just this message" || answer === "This and all subsequent messages") &&
|
|
|
+ (answer === t("common:confirmation.just_this_message") ||
|
|
|
+ answer === t("common:confirmation.this_and_subsequent")) &&
|
|
|
this.getCurrentCline() &&
|
|
|
typeof message.value === "number" &&
|
|
|
message.value
|
|
|
@@ -1556,7 +1556,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
if (messageIndex !== -1) {
|
|
|
const { historyItem } = await this.getTaskWithId(this.getCurrentCline()!.taskId)
|
|
|
|
|
|
- if (answer === "Just this message") {
|
|
|
+ if (answer === t("common:confirmation.just_this_message")) {
|
|
|
// Find the next user message first
|
|
|
const nextUserMessage = this.getCurrentCline()!
|
|
|
.clineMessages.slice(messageIndex + 1)
|
|
|
@@ -1603,7 +1603,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
- } else if (answer === "This and all subsequent messages") {
|
|
|
+ } else if (answer === t("common:confirmation.this_and_subsequent")) {
|
|
|
// Delete this message and all that follow
|
|
|
await this.getCurrentCline()!.overwriteClineMessages(
|
|
|
this.getCurrentCline()!.clineMessages.slice(0, messageIndex),
|
|
|
@@ -1642,6 +1642,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
await this.postStateToWebview()
|
|
|
break
|
|
|
case "language":
|
|
|
+ changeLanguage(message.text ?? "en")
|
|
|
await this.updateGlobalState("language", message.text)
|
|
|
await this.postStateToWebview()
|
|
|
break
|
|
|
@@ -1704,7 +1705,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error enhancing prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to enhance prompt")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.enhance_prompt"))
|
|
|
await this.postMessageToWebview({
|
|
|
type: "enhancedPrompt",
|
|
|
})
|
|
|
@@ -1724,7 +1725,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error getting system prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to get system prompt")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.get_system_prompt"))
|
|
|
}
|
|
|
break
|
|
|
case "copySystemPrompt":
|
|
|
@@ -1732,12 +1733,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
const systemPrompt = await generateSystemPrompt(message)
|
|
|
|
|
|
await vscode.env.clipboard.writeText(systemPrompt)
|
|
|
- await vscode.window.showInformationMessage("System prompt successfully copied to clipboard")
|
|
|
+ await vscode.window.showInformationMessage(t("common:info.clipboard_copy"))
|
|
|
} catch (error) {
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error getting system prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to get system prompt")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.get_system_prompt"))
|
|
|
}
|
|
|
break
|
|
|
case "searchCommits": {
|
|
|
@@ -1753,7 +1754,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error searching commits: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to search commits")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.search_commits"))
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
@@ -1768,7 +1769,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error save api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to save api configuration")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.save_api_config"))
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
@@ -1789,7 +1790,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error create new api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to create api configuration")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.create_api_config"))
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
@@ -1818,7 +1819,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error rename api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to rename api configuration")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.rename_api_config"))
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
@@ -1839,19 +1840,19 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error load api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to load api configuration")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.load_api_config"))
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
case "deleteApiConfiguration":
|
|
|
if (message.text) {
|
|
|
const answer = await vscode.window.showInformationMessage(
|
|
|
- "Are you sure you want to delete this configuration profile?",
|
|
|
+ t("common:confirmation.delete_config_profile"),
|
|
|
{ modal: true },
|
|
|
- "Yes",
|
|
|
+ t("common:answers.yes"),
|
|
|
)
|
|
|
|
|
|
- if (answer !== "Yes") {
|
|
|
+ if (answer !== t("common:answers.yes")) {
|
|
|
break
|
|
|
}
|
|
|
|
|
|
@@ -1877,7 +1878,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error delete api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to delete api configuration")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.delete_api_config"))
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
@@ -1890,7 +1891,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Error get list api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to get list api configuration")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.list_api_config"))
|
|
|
}
|
|
|
break
|
|
|
case "updateExperimental": {
|
|
|
@@ -1924,7 +1925,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
this.outputChannel.appendLine(
|
|
|
`Failed to update timeout for ${message.serverName}: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
|
|
)
|
|
|
- vscode.window.showErrorMessage("Failed to update server timeout")
|
|
|
+ vscode.window.showErrorMessage(t("common:errors.update_server_timeout"))
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
@@ -1941,12 +1942,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
case "deleteCustomMode":
|
|
|
if (message.slug) {
|
|
|
const answer = await vscode.window.showInformationMessage(
|
|
|
- "Are you sure you want to delete this custom mode?",
|
|
|
+ t("common:confirmation.delete_custom_mode"),
|
|
|
{ modal: true },
|
|
|
- "Yes",
|
|
|
+ t("common:answers.yes"),
|
|
|
)
|
|
|
|
|
|
- if (answer !== "Yes") {
|
|
|
+ if (answer !== t("common:answers.yes")) {
|
|
|
break
|
|
|
}
|
|
|
|
|
|
@@ -2319,12 +2320,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
} catch (error) {
|
|
|
if (error.message === "TASK_FILES_MISSING") {
|
|
|
const response = await vscode.window.showWarningMessage(
|
|
|
- "This task's files are missing. Would you like to remove it from the task list?",
|
|
|
- "Remove",
|
|
|
- "Keep",
|
|
|
+ t("common:warnings.missing_task_files"),
|
|
|
+ t("common:answers.remove"),
|
|
|
+ t("common:answers.keep"),
|
|
|
)
|
|
|
|
|
|
- if (response === "Remove") {
|
|
|
+ if (response === t("common:answers.remove")) {
|
|
|
await this.deleteTaskFromState(id)
|
|
|
await this.postStateToWebview()
|
|
|
}
|
|
|
@@ -2345,14 +2346,14 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
// this function deletes a task from task hidtory, and deletes it's checkpoints and delete the task folder
|
|
|
async deleteTaskWithId(id: string) {
|
|
|
try {
|
|
|
- // Try to get the task directory full path
|
|
|
+ // get the task directory full path
|
|
|
const { taskDirPath } = await this.getTaskWithId(id)
|
|
|
|
|
|
// remove task from stack if it's the current task
|
|
|
if (id === this.getCurrentCline()?.taskId) {
|
|
|
// if we found the taskid to delete - call finish to abort this task and allow a new task to be started,
|
|
|
// if we are deleting a subtask and parent task is still waiting for subtask to finish - it allows the parent to resume (this case should neve exist)
|
|
|
- await this.finishSubTask(`Task failure: It was stopped and deleted by the user.`)
|
|
|
+ await this.finishSubTask(t("common:tasks.deleted"))
|
|
|
}
|
|
|
|
|
|
// delete task from the task history state
|
|
|
@@ -2725,12 +2726,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
|
|
|
async resetState() {
|
|
|
const answer = await vscode.window.showInformationMessage(
|
|
|
- "Are you sure you want to reset all state and secret storage in the extension? This cannot be undone.",
|
|
|
+ t("common:confirmation.reset_state"),
|
|
|
{ modal: true },
|
|
|
- "Yes",
|
|
|
+ t("common:answers.yes"),
|
|
|
)
|
|
|
|
|
|
- if (answer !== "Yes") {
|
|
|
+ if (answer !== t("common:answers.yes")) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -2835,9 +2836,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
|
|
|
|
|
|
const removedCount = history.length - validTasks.length
|
|
|
if (removedCount > 0) {
|
|
|
- await vscode.window.showInformationMessage(
|
|
|
- `Cleaned up ${removedCount} task(s) with missing files from history.`,
|
|
|
- )
|
|
|
+ await vscode.window.showInformationMessage(t("common:info.history_cleanup", { count: removedCount }))
|
|
|
}
|
|
|
}
|
|
|
}
|