-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: Russian localization + dynamic agent language #1990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |
| import type { Tool as AITool } from 'ai'; | ||
|
|
||
| import { resolveAuth, resolveAuthFromQueue, buildDefaultQueueConfig } from '../auth/resolver'; | ||
| import { readSettingsFile } from '../../settings-utils'; | ||
| import { buildLanguageInstruction } from '../prompts/language-utils'; | ||
| import { | ||
| getDefaultThinkingLevel, | ||
| getRequiredMcpServers, | ||
|
|
@@ -192,6 +194,17 @@ export async function createAgentClient( | |
| }; | ||
| } | ||
|
|
||
| // ============================================================================= | ||
| // Language Injection | ||
| // ============================================================================= | ||
|
|
||
| function injectLanguageInstruction(prompt: string): string { | ||
| const settings = readSettingsFile(); | ||
| const lang = (settings?.language as string | undefined) ?? 'en'; | ||
| const instruction = buildLanguageInstruction(lang); | ||
| return instruction ? instruction + prompt : prompt; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Comment on lines
+201
to
+206
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify sync I/O and call-path coupling in current code.
rg -n -C3 '\breadSettingsFile\s*\(' apps/desktop/src/main/ai/client/factory.ts apps/desktop/src/main/settings-utils.ts
rg -n -C3 '\breadFileSync\s*\(' apps/desktop/src/main/settings-utils.ts
rg -n -C3 '\binjectLanguageInstruction\s*\(' apps/desktop/src/main/ai/client/factory.tsRepository: AndyMik90/Aperant Length of output: 2129 🏁 Script executed: #!/bin/bash
# Find all usages of createSimpleClient, injectLanguageInstruction, and readSettingsFile
echo "=== createSimpleClient calls ==="
rg -n 'createSimpleClient\s*\(' apps/desktop/src/main/ai/ --type ts
echo "=== readSettingsFile calls ==="
rg -n 'readSettingsFile\s*\(' apps/desktop/src/main/ --type ts
echo "=== Check TypeScript strict mode ==="
jq '.compilerOptions.strict' apps/desktop/tsconfig.jsonRepository: AndyMik90/Aperant Length of output: 8762 🏁 Script executed: #!/bin/bash
# Check file imports and dependencies to understand context
echo "=== Imports in factory.ts ==="
head -30 apps/desktop/src/main/ai/client/factory.ts | grep -E '^import|^export'
echo "=== Full function signature of createSimpleClient ==="
rg -A 15 'export\s+(?:async\s+)?function\s+createSimpleClient' apps/desktop/src/main/ai/client/factory.tsRepository: AndyMik90/Aperant Length of output: 1378 Consider passing language as a parameter instead of reading settings on each call. Line 202 performs a synchronous disk read via The refactor is straightforward: accept language as a parameter in -function injectLanguageInstruction(prompt: string): string {
- const settings = readSettingsFile();
- const lang = (settings?.language as string | undefined) ?? 'en';
+function injectLanguageInstruction(prompt: string, lang: string): string {
const instruction = buildLanguageInstruction(lang);
return instruction ? instruction + prompt : prompt;
}
const result = await streamText({
model,
tools,
- systemPrompt: injectLanguageInstruction(systemPrompt),
+ systemPrompt: injectLanguageInstruction(systemPrompt, language ?? 'en'),
});Add 🤖 Prompt for AI Agents |
||
|
|
||
| // ============================================================================= | ||
| // createSimpleClient | ||
| // ============================================================================= | ||
|
|
@@ -289,7 +302,7 @@ export async function createSimpleClient( | |
| model, | ||
| resolvedModelId, | ||
| tools, | ||
| systemPrompt, | ||
| systemPrompt: injectLanguageInstruction(systemPrompt), | ||
| maxSteps, | ||
| thinkingLevel: resolvedThinkingLevel, | ||
| ...(queueAuth ? { queueAuth } : {}), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { AVAILABLE_LANGUAGES } from '../../../shared/constants/i18n'; | ||
|
|
||
| export function buildLanguageInstruction(language: string): string | null { | ||
| if (!language || language === 'en') return null; | ||
| const entry = AVAILABLE_LANGUAGES.find((l) => l.value === language); | ||
| const langName = entry?.label ?? language; | ||
| return ( | ||
| `**LANGUAGE**: Always respond in ${langName}. All code comments, ` + | ||
| `documentation, commit messages, and explanations must be in ${langName}.\n\n` | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { join } from 'node:path'; | |
| import { execSync } from 'node:child_process'; | ||
|
|
||
| import type { ProjectCapabilities, PromptContext, PromptValidationResult } from './types'; | ||
| import { buildLanguageInstruction } from './language-utils'; | ||
|
|
||
| // ============================================================================= | ||
| // Expected prompt files (used for startup validation) | ||
|
|
@@ -223,7 +224,13 @@ export function injectContext(promptTemplate: string, context: PromptContext): s | |
| sections.push(context.recoveryContext); | ||
| } | ||
|
|
||
| // 3. Human input | ||
| // 3. Language instruction (non-English only) | ||
| if (context.language) { | ||
| const instruction = buildLanguageInstruction(context.language); | ||
| if (instruction) sections.push(instruction); | ||
| } | ||
|
|
||
| // 4. Human input | ||
| if (context.humanInput) { | ||
| sections.push( | ||
| `## HUMAN INPUT (READ THIS FIRST!)\n\n` + | ||
|
Comment on lines
226
to
236
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The QA status check in Suggested FixUpdate the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
@@ -234,7 +241,7 @@ export function injectContext(promptTemplate: string, context: PromptContext): s | |
| ); | ||
| } | ||
|
|
||
| // 4. Project instructions (AGENTS.md or CLAUDE.md fallback) | ||
| // 5. Project instructions (AGENTS.md or CLAUDE.md fallback) | ||
| if (context.projectInstructions) { | ||
| sections.push( | ||
| `## PROJECT INSTRUCTIONS\n\n` + | ||
|
|
@@ -243,7 +250,7 @@ export function injectContext(promptTemplate: string, context: PromptContext): s | |
| ); | ||
| } | ||
|
|
||
| // 5. Base prompt | ||
| // 6. Base prompt | ||
| sections.push(promptTemplate); | ||
|
|
||
| return sections.join(''); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.