Skip to content

Commit 17a97a7

Browse files
committed
Merge branch 'main' of github.com:NyxJae/Roo-Code into human-relay
2 parents dd5e65d + 6a700f3 commit 17a97a7

File tree

180 files changed

+12089
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+12089
-788
lines changed

.roomodes

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
{
22
"customModes": [
3-
{
4-
"slug": "translate",
5-
"name": "Translate",
6-
"roleDefinition": "You are Roo, a linguistic specialist focused on translating and managing localization files. Your responsibility is to help maintain and update translation files for the application, ensuring consistency and accuracy across all language resources.",
7-
"groups": [
8-
"read",
9-
["edit", { "fileRegex": "src/i18n/locales/", "description": "Translation files only" }]
10-
],
11-
"customInstructions": "When translating content:\n- Maintain consistent terminology across all translations\n- Respect the JSON structure of translation files\n- Consider context when translating UI strings\n- Watch for placeholders (like {{variable}}) and preserve them in translations\n- Be mindful of text length in UI elements when translating to languages that might require more characters\n- If you need context for a translation, use read_file to examine the components using these strings"
12-
},
133
{
144
"slug": "test",
155
"name": "Test",
@@ -18,12 +8,33 @@
188
"read",
199
"browser",
2010
"command",
21-
["edit", {
22-
"fileRegex": "(__tests__/.*|__mocks__/.*|\\.test\\.(ts|tsx|js|jsx)$|/test/.*|jest\\.config\\.(js|ts)$)",
23-
"description": "Test files, mocks, and Jest configuration"
24-
}]
11+
[
12+
"edit",
13+
{
14+
"fileRegex": "(__tests__/.*|__mocks__/.*|\\.test\\.(ts|tsx|js|jsx)$|/test/.*|jest\\.config\\.(js|ts)$)",
15+
"description": "Test files, mocks, and Jest configuration"
16+
}
17+
]
2518
],
2619
"customInstructions": "When writing tests:\n- Always use describe/it blocks for clear test organization\n- Include meaningful test descriptions\n- Use beforeEach/afterEach for proper test isolation\n- Implement proper error cases\n- Add JSDoc comments for complex test scenarios\n- Ensure mocks are properly typed\n- Verify both positive and negative test cases"
20+
},
21+
{
22+
"slug": "translate",
23+
"name": "Translate",
24+
"roleDefinition": "You are Roo, a linguistic specialist focused on translating and managing localization files. Your responsibility is to help maintain and update translation files for the application, ensuring consistency and accuracy across all language resources.",
25+
"customInstructions": "When internationalizing and translating content:\n\n# Translation Style and Tone\n- Maintain a direct and concise style that mirrors the tone of the original text\n- Carefully account for colloquialisms and idiomatic expressions in both source and target languages\n- Aim for culturally relevant and meaningful translations rather than literal translations\n- Adapt the formality level to match the original content (whether formal or informal)\n- Preserve the personality and voice of the original content\n- Use natural-sounding language that feels native to speakers of the target language\n- Don't translate the word \"token\" as it means something specific in English that all languages will understand\n\n# Technical Implementation\n- Use namespaces to organize translations logically\n- Handle pluralization using i18next's built-in capabilities\n- Implement proper interpolation for variables using {{variable}} syntax\n- Don't include defaultValue. The `en` translations are the fallback.\n- Always use apply_diff instead of write_to_file when editing existing translation files as it's much faster and more reliable\n- When using apply_diff, make sure to carefully identify the exact JSON structure to edit to avoid syntax errors\n- Always use the Trans component for text with embedded components\n\n# Quality Assurance\n- Maintain consistent terminology across all translations\n- Respect the JSON structure of translation files\n- Watch for placeholders and preserve them in translations\n- Be mindful of text length in UI elements when translating to languages that might require more characters\n- Use context-aware translations when the same string has different meanings\n- Always validate your translation work by running the missing translations script:\n ```\n node scripts/find-missing-translations.js\n ```\n- Before completing any translation task, ensure there are no missing translations by running the script with the target locale(s):\n ```\n node scripts/find-missing-translations.js --locale=<locale-code>\n ```\n- Address any missing translations identified by the script to ensure complete coverage across all locales\n\n# Supported Languages\n- Localize all strings into the following locale files: ar, ca, cs, de, en, es, fr, hi, hu, it, ja, ko, pl, pt, pt-BR, ru, tr, zh-CN, zh-TW",
26+
"groups": [
27+
"read",
28+
"command",
29+
[
30+
"edit",
31+
{
32+
"fileRegex": "(.*\\.(md|ts|tsx|js|jsx)$|.*\\.json$)",
33+
"description": "Source code, translation files, and documentation"
34+
}
35+
]
36+
],
37+
"source": "project"
2738
}
2839
]
2940
}

README.md

Lines changed: 15 additions & 15 deletions
Large diffs are not rendered by default.

knip.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"e2e/**",
1717
"src/activate/**",
1818
"src/exports/**",
19-
"src/extension.ts"
19+
"src/extension.ts",
20+
"scripts/**"
2021
],
2122
"workspaces": {
2223
"webview-ui": {
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
/**
2+
* Script to find missing translations in locale files
3+
*
4+
* Usage:
5+
* node scripts/find-missing-translations.js [options]
6+
*
7+
* Options:
8+
* --locale=<locale> Only check a specific locale (e.g. --locale=fr)
9+
* --file=<file> Only check a specific file (e.g. --file=chat.json)
10+
* --help Show this help message
11+
*/
12+
13+
const fs = require("fs")
14+
const path = require("path")
15+
16+
// Process command line arguments
17+
const args = process.argv.slice(2).reduce((acc, arg) => {
18+
if (arg === "--help") {
19+
acc.help = true
20+
} else if (arg.startsWith("--locale=")) {
21+
acc.locale = arg.split("=")[1]
22+
} else if (arg.startsWith("--file=")) {
23+
acc.file = arg.split("=")[1]
24+
}
25+
return acc
26+
}, {})
27+
28+
// Show help if requested
29+
if (args.help) {
30+
console.log(`
31+
Find Missing Translations
32+
33+
A utility script to identify missing translations across locale files.
34+
Compares non-English locale files to the English ones to find any missing keys.
35+
36+
Usage:
37+
node scripts/find-missing-translations.js [options]
38+
39+
Options:
40+
--locale=<locale> Only check a specific locale (e.g. --locale=fr)
41+
--file=<file> Only check a specific file (e.g. --file=chat.json)
42+
--help Show this help message
43+
44+
Output:
45+
- Generates a report of missing translations
46+
`)
47+
process.exit(0)
48+
}
49+
50+
// Path to the locales directory
51+
const LOCALES_DIR = path.join(__dirname, "../webview-ui/src/i18n/locales")
52+
53+
// Recursively find all keys in an object
54+
function findKeys(obj, parentKey = "") {
55+
let keys = []
56+
57+
for (const [key, value] of Object.entries(obj)) {
58+
const currentKey = parentKey ? `${parentKey}.${key}` : key
59+
60+
if (typeof value === "object" && value !== null) {
61+
// If value is an object, recurse
62+
keys = [...keys, ...findKeys(value, currentKey)]
63+
} else {
64+
// If value is a primitive, add the key
65+
keys.push(currentKey)
66+
}
67+
}
68+
69+
return keys
70+
}
71+
72+
// Get value at a dotted path in an object
73+
function getValueAtPath(obj, path) {
74+
const parts = path.split(".")
75+
let current = obj
76+
77+
for (const part of parts) {
78+
if (current === undefined || current === null) {
79+
return undefined
80+
}
81+
current = current[part]
82+
}
83+
84+
return current
85+
}
86+
87+
// Main function to find missing translations
88+
function findMissingTranslations() {
89+
try {
90+
// Get all locale directories (or filter to the specified locale)
91+
const allLocales = fs.readdirSync(LOCALES_DIR).filter((item) => {
92+
const stats = fs.statSync(path.join(LOCALES_DIR, item))
93+
return stats.isDirectory() && item !== "en" // Exclude English as it's our source
94+
})
95+
96+
// Filter to the specified locale if provided
97+
const locales = args.locale ? allLocales.filter((locale) => locale === args.locale) : allLocales
98+
99+
if (args.locale && locales.length === 0) {
100+
console.error(`Error: Locale '${args.locale}' not found in ${LOCALES_DIR}`)
101+
process.exit(1)
102+
}
103+
104+
console.log(`Checking ${locales.length} non-English locale(s): ${locales.join(", ")}`)
105+
106+
// Get all English JSON files
107+
const englishDir = path.join(LOCALES_DIR, "en")
108+
let englishFiles = fs.readdirSync(englishDir).filter((file) => file.endsWith(".json") && !file.startsWith("."))
109+
110+
// Filter to the specified file if provided
111+
if (args.file) {
112+
if (!englishFiles.includes(args.file)) {
113+
console.error(`Error: File '${args.file}' not found in ${englishDir}`)
114+
process.exit(1)
115+
}
116+
englishFiles = englishFiles.filter((file) => file === args.file)
117+
}
118+
119+
// Load file contents
120+
const englishFileContents = englishFiles.map((file) => ({
121+
name: file,
122+
content: JSON.parse(fs.readFileSync(path.join(englishDir, file), "utf8")),
123+
}))
124+
125+
console.log(
126+
`Checking ${englishFileContents.length} translation file(s): ${englishFileContents.map((f) => f.name).join(", ")}`,
127+
)
128+
129+
// Results object to store missing translations
130+
const missingTranslations = {}
131+
132+
// For each locale, check for missing translations
133+
for (const locale of locales) {
134+
missingTranslations[locale] = {}
135+
136+
for (const { name, content: englishContent } of englishFileContents) {
137+
const localeFilePath = path.join(LOCALES_DIR, locale, name)
138+
139+
// Check if the file exists in the locale
140+
if (!fs.existsSync(localeFilePath)) {
141+
missingTranslations[locale][name] = { file: "File is missing entirely" }
142+
continue
143+
}
144+
145+
// Load the locale file
146+
const localeContent = JSON.parse(fs.readFileSync(localeFilePath, "utf8"))
147+
148+
// Find all keys in the English file
149+
const englishKeys = findKeys(englishContent)
150+
151+
// Check for missing keys in the locale file
152+
const missingKeys = []
153+
154+
for (const key of englishKeys) {
155+
const englishValue = getValueAtPath(englishContent, key)
156+
const localeValue = getValueAtPath(localeContent, key)
157+
158+
if (localeValue === undefined) {
159+
missingKeys.push({
160+
key,
161+
englishValue,
162+
})
163+
}
164+
}
165+
166+
if (missingKeys.length > 0) {
167+
missingTranslations[locale][name] = missingKeys
168+
}
169+
}
170+
}
171+
172+
// Output results
173+
let hasMissingTranslations = false
174+
175+
console.log("\nMissing Translations Report:\n")
176+
177+
for (const [locale, files] of Object.entries(missingTranslations)) {
178+
if (Object.keys(files).length === 0) {
179+
console.log(`✅ ${locale}: No missing translations`)
180+
continue
181+
}
182+
183+
hasMissingTranslations = true
184+
console.log(`📝 ${locale}:`)
185+
186+
for (const [fileName, missingItems] of Object.entries(files)) {
187+
if (missingItems.file) {
188+
console.log(` - ${fileName}: ${missingItems.file}`)
189+
continue
190+
}
191+
192+
console.log(` - ${fileName}: ${missingItems.length} missing translations`)
193+
194+
for (const { key, englishValue } of missingItems) {
195+
console.log(` ${key}: "${englishValue}"`)
196+
}
197+
}
198+
199+
console.log("")
200+
}
201+
202+
if (!hasMissingTranslations) {
203+
console.log("\n✅ All translations are complete!")
204+
} else {
205+
console.log("✏️ To add missing translations:")
206+
console.log("1. Add the missing keys to the corresponding locale files")
207+
console.log("2. Translate the English values to the appropriate language")
208+
console.log("3. Run this script again to verify all translations are complete")
209+
}
210+
} catch (error) {
211+
console.error("Error:", error.message)
212+
console.error(error.stack)
213+
process.exit(1)
214+
}
215+
}
216+
217+
// Run the main function
218+
findMissingTranslations()

src/core/mentions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export async function parseMentions(text: string, cwd: string, urlContentFetcher
104104
}
105105
} else if (mention === "problems") {
106106
try {
107-
const problems = getWorkspaceProblems(cwd)
107+
const problems = await getWorkspaceProblems(cwd)
108108
parsedText += `\n\n<workspace_diagnostics>\n${problems}\n</workspace_diagnostics>`
109109
} catch (error) {
110110
parsedText += `\n\n<workspace_diagnostics>\nError fetching diagnostics: ${error.message}\n</workspace_diagnostics>`

src/core/webview/ClineProvider.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15311531
await this.updateGlobalState("browserToolEnabled", message.bool ?? true)
15321532
await this.postStateToWebview()
15331533
break
1534+
case "language":
1535+
await this.updateGlobalState("language", message.text)
1536+
await this.postStateToWebview()
1537+
break
15341538
case "showRooIgnoredFiles":
15351539
await this.updateGlobalState("showRooIgnoredFiles", message.bool ?? true)
15361540
await this.postStateToWebview()
@@ -2510,8 +2514,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
25102514
writeDelayMs: stateValues.writeDelayMs ?? 1000,
25112515
terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500,
25122516
mode: stateValues.mode ?? defaultModeSlug,
2513-
// Pass the VSCode language code directly
2514-
language: formatLanguage(vscode.env.language),
2517+
language: stateValues.language || formatLanguage(vscode.env.language),
25152518
mcpEnabled: stateValues.mcpEnabled ?? true,
25162519
enableMcpServerCreation: stateValues.enableMcpServerCreation ?? true,
25172520
alwaysApproveResubmit: stateValues.alwaysApproveResubmit ?? false,
@@ -2623,7 +2626,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
26232626
* like the current mode, API provider, etc.
26242627
*/
26252628
public async getTelemetryProperties(): Promise<Record<string, any>> {
2626-
const { mode, apiConfiguration } = await this.getState()
2629+
const { mode, apiConfiguration, language } = await this.getState()
26272630
const appVersion = this.context.extension?.packageJSON?.version
26282631
const vscodeVersion = vscode.version
26292632
const platform = process.platform
@@ -2638,6 +2641,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
26382641
properties.appVersion = appVersion
26392642
}
26402643

2644+
// Add language
2645+
if (language) {
2646+
properties.language = language
2647+
}
2648+
26412649
// Add current mode
26422650
if (mode) {
26432651
properties.mode = mode

src/exports/roo-code.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export type GlobalStateKey =
218218
| "telemetrySetting"
219219
| "showRooIgnoredFiles"
220220
| "remoteBrowserEnabled"
221+
| "language"
221222
| "humanRelayMonitorClipboard"
222223
| "humanRelayMonitorInterval"
223224

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export interface WebviewMessage {
110110
| "discoverBrowser"
111111
| "browserConnectionResult"
112112
| "remoteBrowserEnabled"
113+
| "language"
113114
text?: string
114115
disabled?: boolean
115116
askResponse?: ClineAskResponse

src/shared/__tests__/experiments.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ describe("experiments", () => {
55
it("is configured correctly", () => {
66
expect(EXPERIMENT_IDS.POWER_STEERING).toBe("powerSteering")
77
expect(experimentConfigsMap.POWER_STEERING).toMatchObject({
8-
name: 'Use experimental "power steering" mode',
9-
description:
10-
"When enabled, Roo will remind the model about the details of its current mode definition more frequently. This will lead to stronger adherence to role definitions and custom instructions, but will use more tokens per message.",
118
enabled: false,
129
})
1310
})

0 commit comments

Comments
 (0)